:root {
  --bordeaux: #6b2737;
  --bordeaux-dark: #4f1c28;
  --charcoal: #1f2933;
  --cream: #f5efe6;
  --cream-card: #fffdf9;
  --gold: #c9a227;
  --ink: #2a2420;
  --muted: #8a7f73;
  --line: #e7ddcf;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  --radius: 14px;

  /* --- аналитика: валидированная категориальная палитра (dataviz skill), проверена на --cream-card --- */
  --cat-1: #2a78d6; /* blue */
  --cat-2: #eb6834; /* orange */
  --cat-3: #1baf7a; /* aqua */
  --cat-4: #eda100; /* yellow */
  --cat-5: #e87ba4; /* magenta */
  --cat-6: #008300; /* green */
  --cat-7: #6250d6; /* violet */
  --cat-8: #e34948; /* red */
  --seq-300: #6da7ec;
  --seq-450: #2a78d6;
  --seq-600: #184f95;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand {
  font-family: "Playfair Display", serif;
  font-weight: 600;
  color: var(--charcoal);
}

#app { min-height: 100vh; display: flex; }

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

.sidebar {
  width: 240px;
  flex: none;
  background: linear-gradient(180deg, var(--charcoal), #141b22);
  color: #e9e4db;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand {
  color: #fff;
  font-size: 20px;
  letter-spacing: 0.02em;
}
.sidebar .brand small { display: block; font-family: "Inter"; font-size: 11px; color: var(--gold); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font-family: inherit;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 10px;
  color: #cfc9c0;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav button:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav button.active { background: var(--gold); color: var(--charcoal); font-weight: 600; }

.sidebar .foot { margin-top: auto; font-size: 12px; color: #9a9289; }
.sidebar .foot b { color: #e9e4db; }

.main { flex: 1; padding: 32px 40px; max-width: 1200px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.topbar h1 { margin: 0; font-size: 26px; }
.topbar .who { font-size: 13px; color: var(--muted); }
.topbar .who button { margin-left: 10px; border: none; background: none; color: var(--bordeaux); cursor: pointer; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat {
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.stat .value { font-family: "Playfair Display", serif; font-size: 26px; color: var(--charcoal); }
.stat .value.pos { color: #2f6b45; }
.stat .value.neg { color: var(--bordeaux); }

.card {
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 18px; margin: 0 0 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #efe3c8;
  color: #6b4f0f;
}
.badge.done, .badge.closed { background: #dcecdf; color: #2f6b45; }
.badge.lead { background: #efe0e0; color: var(--bordeaux); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--bordeaux);
  color: #fff;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--bordeaux-dark); }
.btn.ghost { background: transparent; color: var(--bordeaux); border: 1px solid var(--bordeaux); }
.btn.gold { background: var(--gold); color: var(--charcoal); }

form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  min-width: 160px;
}
.field textarea { min-width: 260px; }

/* --- аналитика --- */
.bars { display: flex; flex-direction: column; gap: 10px; margin: 6px 0; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 90px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .bar-label { color: var(--ink); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--line); border-radius: 4px; height: 16px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .2s; }
.bar-row .bar-value { font-variant-numeric: tabular-nums; color: var(--charcoal); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 0 14px; font-size: 12px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pill.good { background: rgba(12,163,12,0.12); color: #0a6b0a; }
.status-pill.warning { background: rgba(250,178,25,0.18); color: #8a5a00; }
.status-pill.critical { background: rgba(208,59,59,0.12); color: var(--status-critical); }
.kpi-note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } .bar-row { grid-template-columns: 110px 1fr 70px; } }

.comments { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.comments h3 { font-size: 14px; margin: 0 0 10px; color: var(--charcoal); }
.comment-row { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.comment-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.comment-text { font-size: 14px; white-space: pre-wrap; }
.muted { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.topbar.card-head { margin-bottom: 0; }
.card .topbar { margin-bottom: 16px; }
.card .topbar h2 { margin: 0; }

.login-screen {
  margin: auto;
  width: 100%;
  max-width: 360px;
  background: var(--cream-card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  text-align: center;
}
.login-screen h1 { font-size: 24px; margin-bottom: 4px; }
.login-screen .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-screen form { display: flex; flex-direction: column; gap: 12px; }
.login-screen input { border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font-size: 14px; }
.login-screen .err { color: var(--bordeaux); font-size: 13px; min-height: 18px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 14px; align-items: center; }
  .sidebar .brand { display: none; }
  .nav { flex-direction: row; }
  .sidebar .foot { display: none; }
  .main { padding: 20px; }
}
