:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface:        #fcfcfb;
  --surface-2:      #f2f1ed;
  --text:           #0b0b0b;
  --text-2:         #52514e;
  --muted:          #898781;
  --line:           #e1e0d9;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;  /* план */
  --series-2:       #eb6834;  /* факт */
  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;
  --success-text:   #006300;
  --accent:         #2a78d6;
  --radius:         10px;
  --shadow:         0 1px 2px rgba(11, 11, 11, .05), 0 4px 16px rgba(11, 11, 11, .04);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface:        #1a1a19;
  --surface-2:      #232322;
  --text:           #ffffff;
  --text-2:         #c3c2b7;
  --muted:          #898781;
  --line:           #2c2c2a;
  --border:         rgba(255, 255, 255, 0.10);
  --series-1:       #3987e5;
  --series-2:       #d95926;
  --success-text:   #0ca30c;
  --accent:         #3987e5;
  --shadow:         0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------------------------------- шапка --------------------------------- */

header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 650; letter-spacing: -.01em; font-size: 15px; margin-right: 4px; }

nav.tabs { display: flex; gap: 4px; }

nav.tabs button {
  background: none;
  border: 0;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
}
nav.tabs button:hover { background: var(--surface-2); color: var(--text); }
nav.tabs button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.spacer { flex: 1; }
.whoami { color: var(--text-2); font-size: 13px; }
.whoami b { color: var(--text); font-weight: 600; }

/* --------------------------------- элементы -------------------------------- */

main { max-width: 1180px; margin: 0 auto; padding: 20px; }

button, select, input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 72px; }
button { cursor: pointer; }
button:hover { border-color: var(--muted); }

button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.07); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); padding: 6px 8px; }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger { color: var(--critical); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar .grow { flex: 1; min-width: 160px; }

/* --------------------------------- задачи ---------------------------------- */

table.tasks { width: 100%; border-collapse: collapse; }
table.tasks th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tasks td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tasks tbody tr:hover { background: var(--surface-2); }
table.tasks tbody tr { cursor: pointer; }
table.tasks tr:last-child td { border-bottom: 0; }
.t-title { font-weight: 550; }
.t-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.new         { background: var(--muted); }
.dot.accepted    { background: var(--series-1); }
.dot.in_progress { background: var(--warning); }
.dot.done        { background: var(--good); }
.dot.cancelled   { background: var(--muted); opacity: .5; }

.prio { font-size: 12.5px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.prio .bar { width: 3px; height: 13px; border-radius: 2px; background: var(--muted); }
.prio.critical .bar { background: var(--critical); }
.prio.high .bar     { background: var(--serious); }
.prio.medium .bar   { background: var(--series-1); }
.prio.low .bar      { background: var(--muted); }

.overdue { color: var(--critical); font-weight: 600; }
.dim { color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* -------------------------------- статистика ------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; }
.kpi .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.legend { display: flex; gap: 16px; align-items: center; font-size: 12.5px; color: var(--text-2); margin: 4px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch.plan { background: var(--series-1); }
.swatch.fact { background: var(--series-2); }

.bars { display: grid; gap: 4px; min-width: 190px; }
.bar-row { display: grid; grid-template-columns: 34px 1fr 88px; gap: 8px; align-items: center; font-size: 12px; }
.bar-row .cap { color: var(--muted); }
.bar-track { display: block; height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; min-width: 2px; }
.bar-row:hover .bar-fill { filter: brightness(1.08); }
.bar-fill.plan { background: var(--series-1); }
.bar-fill.fact { background: var(--series-2); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }

.mini { display: flex; gap: 4px 12px; align-items: center; flex-wrap: wrap; }

.mini .chip { font-size: 11.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }

/* ---------------------------------- модалка -------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  z-index: 50;
}
.modal { width: 100%; max-width: 620px; padding: 20px; }
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-2); }
label.field input, label.field select, label.field textarea { width: 100%; }
label.field.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
label.field.inline input { width: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; align-items: center; }

.log { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; max-height: 210px; overflow: auto; }
.log h3 { font-size: 12px; color: var(--muted); margin: 0 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.log-item { font-size: 12.5px; color: var(--text-2); padding: 3px 0; }
.log-item time { color: var(--muted); }

/* ----------------------------------- вход ---------------------------------- */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth { width: 100%; max-width: 380px; padding: 28px; }
.auth h1 { font-size: 20px; margin: 0 0 4px; }
.auth p.hint { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.auth label.field { margin-bottom: 12px; }
.auth button.primary { width: 100%; margin-top: 6px; padding: 9px; }
.auth .switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--text-2); }

.error {
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  color: var(--critical);
  border: 1px solid color-mix(in srgb, var(--critical) 35%, transparent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--page);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  main { padding: 12px; }
  .hide-sm { display: none; }
}
