/* Тёмная тема — база. Светлая переопределяет те же токены ниже. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c10;
  --bg-soft: #111319;
  --surface: #15171f;
  --surface-2: #1b1e28;
  --line: #262a36;
  --line-soft: #1e2129;
  --text: #e8eaf0;
  --muted: #8b90a0;
  --faint: #5d6270;
  --accent: #7c5cff;
  --good: #2fbf7a;
  --warn: #e8b13a;
  --bad: #e8545b;
  --page-glow: radial-gradient(1100px 620px at 78% -12%, #1a1630 0%, transparent 62%);
  --sidebar-bg: rgba(12, 13, 18, .7);
  --hover: rgba(255, 255, 255, .015);
  --scrim: rgba(6, 7, 10, .7);
  --shadow: 0 18px 48px rgba(0, 0, 0, .45);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-soft: #fbfcfd;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --line: #d8dde6;
  --line-soft: #e6eaf0;
  --text: #171a21;
  --muted: #5b6273;
  --faint: #8a91a1;
  --accent: #5b3ce0;
  --good: #12925a;
  --warn: #a8760c;
  --bad: #cf3840;
  --page-glow: radial-gradient(1100px 620px at 78% -12%, #e9e4ff 0%, transparent 62%);
  --sidebar-bg: rgba(255, 255, 255, .78);
  --hover: rgba(18, 22, 32, .025);
  --scrim: rgba(28, 32, 44, .42);
  --shadow: 0 16px 40px rgba(20, 26, 40, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page-glow), var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(124, 92, 255, .35); }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.auth-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.auth-mark {
  width: 64px; height: 64px; margin-bottom: 16px; object-fit: contain; display: block;
}

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line-soft); padding: 22px 16px; background: var(--sidebar-bg);
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; object-fit: contain; flex: none;
}
.nav-icon { width: 19px; flex: none; text-align: center; font-size: 13px; opacity: .85; }
.nav-emoji { width: 19px; flex: none; text-align: center; font-size: 14px; line-height: 1; }
.nav-logo { width: 19px; height: 19px; object-fit: contain; border-radius: 5px; flex: none; margin: 0 -2px 0 -3px; }
.brand b { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.brand span { display: block; font-size: 11px; color: var(--faint); }
.nav-label { padding: 14px 10px 6px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  color: var(--muted); text-decoration: none; cursor: pointer; border: 0; background: none; width: 100%;
  text-align: left; font-size: 13.5px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { box-shadow: inset 0 0 0 1px var(--line-soft); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.nav-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-soft); }

.main { padding: 26px 34px 80px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 25px; letter-spacing: -.025em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- элементы ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 13px; border-radius: 10px; cursor: pointer; font-size: 13px;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--line); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:hover { background: #8d71ff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(232, 84, 91, .3); }
.btn.danger:hover { background: rgba(232, 84, 91, .1); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .16); }
textarea.input { resize: vertical; min-height: 72px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kpi .label { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.kpi .value { font-size: 27px; font-weight: 650; letter-spacing: -.03em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--faint); }

.bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.bar.good > i { background: var(--good); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px;
  font-size: 11.5px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-soft);
}
.pill.good { color: var(--good); border-color: rgba(47, 191, 122, .28); background: rgba(47, 191, 122, .1); }
.pill.warn { color: var(--warn); border-color: rgba(232, 177, 58, .28); background: rgba(232, 177, 58, .1); }
.pill.bad { color: var(--bad); border-color: rgba(232, 84, 91, .28); background: rgba(232, 84, 91, .1); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.empty { padding: 40px; text-align: center; color: var(--faint); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- таблица ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
  font-weight: 500; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
tr.group-row td { background: var(--bg-soft); font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
tr.total-row td { background: var(--bg-soft); font-weight: 600; }
.cell-input {
  width: 78px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; text-align: right; font-variant-numeric: tabular-nums; outline: none;
}
.cell-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .16); }
.cell-input.wide { width: 100%; text-align: left; }
.cell-input.ok { border-color: rgba(47, 191, 122, .5); }

/* ---------- обложка направления ---------- */
.hero {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line-soft); margin-bottom: 18px; background: #0c0e13;
  min-height: 150px; display: flex; align-items: flex-end;
}
.hero-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 14%; opacity: .5;
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(10, 11, 15, .95) 0%, rgba(10, 11, 15, .78) 38%, rgba(10, 11, 15, .42) 100%);
}
.hero-body { position: relative; z-index: 1; padding: 20px 22px; display: flex; align-items: center; gap: 16px; width: 100%; }
.hero-logo {
  height: 74px; width: auto; max-width: 230px; object-fit: contain; flex: none;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, .7));
}
.hero h1 { margin: 0; font-size: 26px; letter-spacing: -.025em; color: #f4f5f8; }
.hero .sub { color: rgba(244, 245, 248, .62); font-size: 13px; margin-top: 4px; }
.card-logo { width: 24px; height: 24px; object-fit: contain; border-radius: 6px; flex: none; }

/* ---------- карта желаний ---------- */
.wish-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.wish {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  transition: border-color .15s, transform .12s; position: relative; overflow: hidden;
}
.wish:hover { border-color: var(--line); transform: translateY(-2px); }
.wish.done { opacity: .58; }
.wish.done .wish-title { text-decoration: line-through; }
.wish-cover { height: 108px; margin: -14px -14px 2px; background: var(--surface-2) center/cover no-repeat; }
.wish-title { font-size: 14px; font-weight: 550; letter-spacing: -.01em; }
.wish-price { font-size: 18px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.wish-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.cat-head { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 12px; }
.cat-head h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); cursor: pointer; font-size: 12.5px; white-space: nowrap;
}
.chip.active { background: var(--surface-2); color: var(--text); border-color: var(--line); }

/* ---------- модалка ---------- */
.modal-back {
  position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 22px; z-index: 50;
}
.modal {
  width: min(540px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 18px; font-size: 18px; letter-spacing: -.02em; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert.error { background: rgba(232, 84, 91, .12); color: #ff9aa0; border: 1px solid rgba(232, 84, 91, .25); }
.alert.info { background: rgba(124, 92, 255, .1); color: #c3b4ff; border: 1px solid rgba(124, 92, 255, .25); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 11px;
  box-shadow: var(--shadow); z-index: 90; font-size: 13px; animation: rise .22s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .brand { padding: 4px 8px; width: 100%; }
  .nav-label { display: none; }
  .nav-item { width: auto; }
  .nav-foot { margin: 0; padding-top: 0; border: 0; }
  .main { padding: 20px 16px 60px; }
}

/* ---------- контент-доска ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(212px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.board-col { background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 10px; }
.board-head b { font-size: 12.5px; font-weight: 600; letter-spacing: -.01em; }
.board-head .count { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.board-col > .cards { display: grid; gap: 9px; }
.post {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 11px; padding: 11px;
  display: grid; gap: 7px; cursor: pointer; transition: border-color .15s, transform .12s;
}
.post:hover { border-color: var(--line); transform: translateY(-1px); }
.post-title { font-size: 13px; line-height: 1.35; font-weight: 550; }
.post-meta { font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dots { display: flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.owner {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-2); border: 1px solid var(--line-soft); font-size: 10px; font-weight: 600; color: var(--muted);
}
.move { display: flex; gap: 2px; }
.move button {
  border: 1px solid var(--line-soft); background: var(--bg-soft); color: var(--muted); cursor: pointer;
  width: 22px; height: 22px; border-radius: 7px; font-size: 11px; line-height: 1; padding: 0;
}
.move button:hover:not([disabled]) { color: var(--text); border-color: var(--line); }
.move button[disabled] { opacity: .3; cursor: default; }
.channel-mark { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.nav-sub { display: grid; gap: 2px; margin: 2px 0 6px 12px; padding-left: 10px; border-left: 1px solid var(--line-soft); }
.nav-sub .nav-item { padding: 6px 9px; font-size: 12.5px; }

/* ---------- контент списком ---------- */
.list-input {
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 5px 7px; outline: none; font-size: 13px; transition: border-color .12s, background .12s;
}
.list-input:hover { border-color: var(--line-soft); }
.list-input:focus { border-color: var(--accent); background: var(--bg-soft); box-shadow: 0 0 0 3px rgba(124, 92, 255, .14); }
.list-input.ok { border-color: rgba(47, 191, 122, .5); }
select.list-input { appearance: none; cursor: pointer; }
input[type="date"].list-input { font-variant-numeric: tabular-nums; }
input[type="date"].list-input::-webkit-calendar-picker-indicator { opacity: .4; cursor: pointer; }
input[type="date"].list-input:hover::-webkit-calendar-picker-indicator { opacity: .75; }
.list-table td { padding: 5px 8px; }
.list-table th { padding: 11px 8px; }
.list-table .list-input { font-size: 12.5px; }
.plat-toggle { display: flex; gap: 4px; }
.plat-toggle button {
  width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  cursor: pointer; padding: 0; transition: opacity .12s, transform .12s;
}
.plat-toggle button[aria-pressed="false"] { opacity: .22; }
.plat-toggle button:hover { transform: scale(1.15); }
.view-switch { display: flex; gap: 2px; background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 10px; padding: 2px; }
.view-switch button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 5px 11px; border-radius: 8px; font-size: 12.5px;
}
.view-switch button.active { background: var(--surface-2); color: var(--text); }
.dict-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.dict-row .count { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
