:root {
  --ink: #15110f;
  --ink-soft: #4a433f;
  --paper: #f7f4ef;
  --paper-raised: #ffffff;
  --line: #e4ddd3;
  --burgundy: #8b1a1a;
  --burgundy-soft: #fbeaea;
  --gold: #a9792f;
  --sidebar-bg: #15110f;
  --sidebar-line: #2b2522;
  --font-head: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-head); margin: 0 0 6px; color: var(--ink); font-weight: 600; }
h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin-bottom: 14px; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin-bottom: 10px; }

a { color: var(--burgundy); text-decoration: none; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #eee8e0;
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand { display: flex; align-items: baseline; gap: 6px; padding: 0 6px 28px; }
.brand-mark { font-family: var(--font-head); font-size: 20px; font-weight: 600; color: #fff; letter-spacing: 0.02em; }
.brand-sub { font-size: 11px; letter-spacing: 0.14em; color: var(--burgundy); text-transform: uppercase; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  color: #c9c1b8; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--sidebar-line); color: #fff; }
.sidebar-nav a.active { background: var(--burgundy); color: #fff; }
.nav-ico { font-size: 11px; opacity: 0.8; width: 14px; }

.sidebar-cta {
  display: block; text-align: center; margin: 16px 6px 0;
  background: transparent; border: 1px solid var(--sidebar-line);
  color: #eee8e0; padding: 10px; border-radius: 8px; font-size: 13px; font-weight: 500;
  transition: border-color .15s;
}
.sidebar-cta:hover { border-color: var(--burgundy); color: #fff; }

.sidebar-user { margin-top: 18px; padding: 14px 6px 0; border-top: 1px solid var(--sidebar-line); }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: #9a9188; margin-top: 2px; }
.user-logout { display: inline-block; margin-top: 8px; font-size: 12px; color: #9a9188; }
.user-logout:hover { color: var(--burgundy); }

.main { flex: 1; min-width: 0; }
.main-inner { max-width: 1120px; margin: 0 auto; padding: 36px 40px 60px; }

.container { max-width: 420px; margin: 0 auto; padding: 60px 20px; }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 14px;
  padding: 40px 36px; width: 320px; box-shadow: 0 20px 60px -24px rgba(0,0,0,0.25);
}
.login-brand { display: flex; align-items: baseline; gap: 6px; justify-content: center; margin-bottom: 28px; }
.login-box form { display: flex; flex-direction: column; gap: 14px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }

/* ---------- forms ---------- */
input[type=text], input[type=password], input[type=email], input[type=number], textarea, select {
  font-family: var(--font-body);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--burgundy); }

button, .btn-primary, .btn-secondary, .btn-danger {
  font-family: var(--font-body);
  border: none; border-radius: 7px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-block; text-align: center;
}
button[type=submit], .btn-primary { background: var(--burgundy); color: #fff; }
button[type=submit]:hover, .btn-primary:hover { background: #701414; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--ink); }
.btn-danger { background: #fff; color: var(--burgundy); border: 1px solid var(--burgundy-soft); }
.btn-danger:hover { background: var(--burgundy-soft); }
.link-btn { background: none; border: none; color: var(--ink-soft); font-size: 12px; text-decoration: underline; padding: 0; cursor: pointer; }

/* ---------- page structure ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; gap: 12px; }
.page-actions { display: flex; gap: 8px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 20px; }
.toolbar input[type=text] { flex: 1; }

.panel {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 24px;
}

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.flash-success { background: #eef6ea; color: #3a6b2a; }
.flash-error { background: var(--burgundy-soft); color: var(--burgundy); }

/* ---------- dashboard ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi-tile {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-tile.accent { background: var(--ink); border-color: var(--ink); }
.kpi-tile.accent .kpi-label { color: #c9c1b8; }
.kpi-tile.accent .kpi-value { color: #fff; }
.kpi-label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-family: var(--font-head); font-size: 28px; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 0; }
.grid-2 .panel { margin-bottom: 20px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 100px 1fr 32px; align-items: center; gap: 10px; }
.funnel-label { font-size: 12px; color: var(--ink-soft); }
.funnel-bar-track { background: var(--line); border-radius: 5px; height: 10px; overflow: hidden; }
.funnel-bar { background: var(--burgundy); height: 100%; border-radius: 5px; }
.funnel-count { font-size: 13px; font-weight: 600; text-align: right; }

.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list-plain li {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-bottom: 1px solid var(--line); font-size: 13px; cursor: default;
}
.list-plain li:last-child { border-bottom: none; }
.list-plain li[onclick] { cursor: pointer; }
.list-plain li[onclick]:hover { background: var(--paper); }
.li-date { font-size: 12px; color: var(--burgundy); font-weight: 600; width: 46px; flex-shrink: 0; }
.li-main { font-weight: 600; flex-shrink: 0; }
.li-sub { color: var(--ink-soft); font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-note { color: var(--ink-soft); font-size: 13px; padding: 6px 0; }

/* ---------- tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-soft); font-weight: 600; padding: 0 10px 10px; border-bottom: 1px solid var(--line);
}
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: none; }
.row-click { cursor: pointer; }
.row-click:hover { background: var(--paper); }
.cell-main { font-weight: 600; }

/* ---------- status pills ---------- */
.status-pill {
  display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11px;
  font-weight: 600; margin-right: 4px; white-space: nowrap;
}
.status-предзаказ { background: #eef1f4; color: #41607a; }
.status-в-работе { background: #fdf3e3; color: #a9792f; }
.status-на-примерке { background: #f1ecf7; color: #6a4a9e; }
.status-готово { background: #eaf5ee; color: #2f7d4f; }
.status-оплачено { background: #e7f4f2; color: #1f7a6c; }
.status-отправлено { background: #e9e9e9; color: #555; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card p { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin: 0 0 8px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.card p:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.card p span { color: var(--ink-soft); flex-shrink: 0; }
.card-text { display: block !important; border-bottom: none !important; color: var(--ink); white-space: pre-wrap; }

/* ---------- form grid ---------- */
.form-grid { display: flex; flex-direction: column; gap: 18px; }
.form-grid fieldset { border: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid legend { font-family: var(--font-head); font-size: 15px; font-weight: 600; margin-bottom: 10px; grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-soft); }
.form-grid fieldset label:has(textarea) { grid-column: 1 / -1; }

.inline-form { margin-top: 16px; }
.inline-form summary { cursor: pointer; font-size: 13px; color: var(--burgundy); font-weight: 600; }
.inline-form form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.inline-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-soft); grid-column: span 1; }
.inline-form label:has(textarea) { grid-column: 1 / -1; }
.inline-form button { grid-column: 1 / -1; width: fit-content; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: relative; height: auto; width: 100%; flex-direction: row; align-items: center; padding: 14px 18px; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-cta, .sidebar-user { display: none; }
  .main-inner { padding: 24px 18px; }
  .kpi-row, .grid-2, .cards { grid-template-columns: 1fr; }
  .form-grid fieldset { grid-template-columns: 1fr; }
}
