/* Layout: один тёмный лист. Сверху «Сегодня» — режим дня, быстрый ввод, приоритеты и сроки; ниже канбан по пяти статусам. */
:root {
  color-scheme: dark;
  --bg: #12181f;
  --panel: #19212b;
  --raised: #212c38;
  --line: #2e3b4a;
  --ink: #e7ecf1;
  --muted: #9dabb9;
  --accent: #8fc4d3;
  --accent-ink: #0e1a20;
  --accent-bg: #1c3640;
  --night: #8a96e6;
  --night-bg: #23294a;
  --warn: #e6b866;
  --warn-bg: #3a2f17;
  --crit: #f2978a;
  --crit-bg: #41231f;
  --ok: #8fd0a6;
  --ok-bg: #1b3526;
  --backdrop: rgba(4, 8, 12, .66);
  --display: "Geologica", "Golos Text", system-ui, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15.5px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app {
  max-width: 1360px; margin: 0 auto;
  padding-block: 18px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 18px;
}
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.brand { font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: .04em; }
.brand span { color: var(--muted); font-weight: 500; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--ink); background: var(--panel); }
.nav a.on { color: var(--ink); background: var(--raised); }

.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 9px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14.5px; }
.banner.info { background: var(--accent-bg); color: var(--accent); }
#banners { display: flex; flex-direction: column; gap: 8px; }
#banners:empty { display: none; }

/* Кнопки и поля */
.btn { padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); color: var(--ink); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--crit); }
.btn.armed { background: var(--crit-bg); border-color: var(--crit); color: var(--crit); }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], textarea, select {
  padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; max-width: 100%; min-width: 0;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { resize: vertical; width: 100%; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 14.5px; }
.seg button.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 600; }

#view { display: flex; flex-direction: column; gap: 16px; }
/* Сегодня */
.hero { display: flex; flex-direction: column; gap: 14px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.mode-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; }
.eyebrow { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1.15; text-wrap: balance; }
.sub { color: var(--muted); max-width: 62ch; }
.strip { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.strip div { padding: 6px 4px; border-radius: 8px; background: var(--raised); text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.25; min-width: 0; overflow: hidden; }
.strip div b { display: block; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.strip .shift { background: var(--night-bg); color: var(--night); }
.strip .now { outline: 2px solid var(--accent); outline-offset: -2px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick input { flex: 1 1 220px; padding: 11px 12px; font-size: 16px; }
.quick select { flex: 0 1 190px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid { grid-template-columns: minmax(0, 1fr); } h1 { font-size: 25px; } }
.panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.panel.urgent { border-color: var(--crit); }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; }
h2 { font-family: var(--display); font-weight: 600; font-size: 18px; }
h3 { font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.note { color: var(--muted); font-size: 14.5px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; font-size: 14.5px; color: var(--muted); }
.controls label { display: flex; align-items: center; gap: 8px; }
.controls input[type="number"] { width: 84px; }

.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 10px 12px; background: var(--raised); border-radius: 10px; min-width: 0; }
.row-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { background: none; border: 0; padding: 0; text-align: left; font-weight: 600; overflow-wrap: anywhere; }
.row-title:hover { color: var(--accent); }
.row-sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.row-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row.picked { outline: 1px solid var(--accent); }
.slot { padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 14.5px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tag.late { background: var(--crit-bg); color: var(--crit); }
.tag.soon { background: var(--warn-bg); color: var(--warn); }
.tag.plain { background: var(--bg); color: var(--muted); font-weight: 500; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.ex { background: var(--accent-bg); color: var(--accent); }
.conflict { padding: 9px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14.5px; }
.conflict.crit { background: var(--crit-bg); color: var(--crit); }
.conflict.calm { background: var(--ok-bg); color: var(--ok); }
.totals { display: flex; flex-wrap: wrap; gap: 6px 18px; font-variant-numeric: tabular-nums; }
.totals b { font-weight: 600; }

/* Сферы и доска */
.board-head { display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 14.5px; }
.chip.on { background: var(--raised); color: var(--ink); border-color: var(--muted); font-weight: 600; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.s-money { background: #dcb863; } .s-work { background: #86aee6; } .s-family { background: #e89a86; }
.s-health { background: #84d0a3; } .s-projects { background: #b9a0ea; } .s-faith { background: #dfa8cb; }
.sphere { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }

.tabs { display: none; flex-wrap: wrap; gap: 6px; }
.tabs button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.tabs button.on { background: var(--raised); color: var(--ink); border-color: var(--muted); font-weight: 600; }
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; min-height: 120px; }
.col.over { border-color: var(--accent); background: var(--accent-bg); }
.col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col-head .count { padding: 1px 9px; border-radius: 999px; background: var(--raised); color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { padding: 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 14px; text-align: center; }
@media (max-width: 980px) {
  .tabs { display: flex; }
  .board { grid-template-columns: minmax(0, 1fr); }
  .col { display: none; }
  .col.active { display: flex; }
}
.card { display: flex; flex-direction: column; gap: 7px; padding: 10px 11px; background: var(--raised); border: 1px solid transparent; border-radius: 11px; min-width: 0; }
.card[draggable="true"] { cursor: grab; }
.card:hover { border-color: var(--line); }
.card.dim { opacity: .45; }
.card.dragging { opacity: .3; }
.card-top { display: flex; align-items: flex-start; gap: 6px; }
.card-title { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; font-weight: 600; overflow-wrap: anywhere; }
.card-title:hover { color: var(--accent); }
.star { flex: none; width: 30px; height: 30px; margin: -4px -5px 0 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 17px; line-height: 1; }
.star.on { color: var(--warn); }
.star:hover { background: var(--bg); }
.next-step, .wait-line { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.wait-line { color: var(--night); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; }
.status-pick select { width: 100%; padding: 6px 8px; font-size: 14px; background: var(--bg); }

/* Прочие разделы */
.page { display: flex; flex-direction: column; gap: 16px; max-width: 860px; }
.page h1 { font-size: 26px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal button { padding: 8px 2px; border: 1px solid transparent; border-radius: 10px; background: var(--raised); color: var(--muted); font-size: 12.5px; line-height: 1.3; min-width: 0; overflow: hidden; }
.cal button b { display: block; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.cal button.shift { background: var(--night-bg); color: var(--night); }
.cal button.now { border-color: var(--accent); }
.cal button.changed { border-style: dashed; border-color: var(--warn); }
.formrow { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 160px; }
.field > span, fieldset.field > legend { font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0; }
.field input, .field select, .field textarea { width: 100%; }
fieldset.field { border: 0; margin: 0; padding: 0; }
.scale { display: flex; flex-wrap: wrap; gap: 5px; }
.scale label { cursor: pointer; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; }
.scale span { display: block; min-width: 38px; padding: 6px 0; text-align: center; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scale input:checked + span { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.scale input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.backup { min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100% - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: var(--backdrop); }
.dlg { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.box { display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.rv-item { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--raised); border-radius: 12px; }
.rv-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 500; z-index: 50; }
/* Долги */
.tag.night { background: var(--night-bg); color: var(--night); }
.tag.acc { background: var(--accent-bg); color: var(--accent); }
dl.kv { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.kv .tag, .row-sub .tag { white-space: normal; }
@media (max-width: 560px) { dl.kv { grid-template-columns: minmax(0, 1fr); gap: 1px; } .kv dd { margin-bottom: 8px; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 3px; padding: 12px; background: var(--raised); border-radius: 12px; min-width: 0; }
.stat b { font-family: var(--display); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat span { color: var(--muted); font-size: 13.5px; }
.debt { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--raised); border-radius: 12px; min-width: 0; }
.debt.focus { outline: 2px solid var(--accent); }
.debt-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 10px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; }
.bulk-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; align-items: center; }
.bulk-row input, .bulk-row select { width: 100%; }
.bulk-row .check input { width: 18px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Вход и состояние синхронизации */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); }
.auth-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.auth-box .link { align-self: flex-start; color: var(--muted); font-size: 14.5px; }
.sync { margin-left: 8px; font-family: var(--body); font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--muted); white-space: nowrap; }
.sync.offline, .sync.conflict, .sync.setup { color: var(--warn); }
.banner .link + .link { margin-left: 4px; }
.auth-box .field { flex: none; }
