/* Палитра и базовые токены */
:root {
  --bg: #faf3ec;
  --bg-elev: #ffffff;
  --bg-soft: #f3e9dd;
  --ink: #2b1d2a;
  --ink-soft: #5a4a55;
  --rose: #a64a6a;
  --rose-soft: #d59aae;
  --rose-ink: #6b2542;
  --sand: #d8b48a;
  --sand-soft: #ead4b3;
  --green: #5a8a5f;
  --green-soft: #c2d8c2;
  --green-ink: #2f4a32;
  --amber: #b97c1d;
  --amber-soft: #f4dca8;
  --amber-ink: #6e4811;
  --line: #e6d6c5;
  --line-strong: #c8b29c;
  --shadow: 0 6px 18px rgba(74, 35, 60, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
}
body[data-theme="night"] {
  --bg: #1c1320;
  --bg-elev: #271a2c;
  --bg-soft: #2e1f33;
  --ink: #f1dfe5;
  --ink-soft: #b6a0ad;
  --rose: #c97c95;
  --rose-soft: #6b3a4d;
  --rose-ink: #f1c5d4;
  --sand: #c39c75;
  --sand-soft: #4f3b2a;
  --green: #8aae8a;
  --green-soft: #3a4d3d;
  --green-ink: #c6dcc7;
  --amber: #d39a3d;
  --amber-soft: #4f3a1e;
  --amber-ink: #f4dca8;
  --line: #3a2a3f;
  --line-strong: #523b58;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; padding-bottom: 96px; }
button { font: inherit; color: inherit; }
a { color: var(--rose-ink); }
body[data-theme="night"] a { color: var(--rose-ink); }
#app { max-width: 720px; margin: 0 auto; padding: 16px 16px 24px; }

.top { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.top h1 { font-size: 18px; margin: 0; font-weight: 600; flex: 1; line-height: 1.2; min-width: 0; }
.top .sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.top .seg { display: inline-flex; background: var(--bg-soft); border-radius: 999px; padding: 3px; }
.top .seg button { background: transparent; border: 0; padding: 8px 12px; border-radius: 999px; min-height: var(--tap); color: var(--ink-soft); cursor: pointer; }
.top .seg button.on { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow); }
.top .icon-btn { background: var(--bg-soft); border: 0; border-radius: 999px; min-width: var(--tap); min-height: var(--tap); padding: 0 12px; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.top .icon-btn:active { transform: scale(0.97); }
.profile-switch { background: var(--bg-soft); border: 0; border-radius: 999px; min-height: var(--tap); padding: 0 12px; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg-elev); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 8px env(safe-area-inset-bottom, 8px); z-index: 50; }
.tabbar button { background: transparent; border: 0; flex: 1; padding: 8px 4px; min-height: var(--tap); color: var(--ink-soft); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; cursor: pointer; }
.tabbar button.on { color: var(--rose-ink); }
.tabbar svg { width: 22px; height: 22px; }

.card { background: var(--bg-elev); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.card .hint { color: var(--ink-soft); font-size: 13px; }

.onb { padding: 6vh 16px 24px; max-width: 560px; margin: 0 auto; }
.onb h1 { font-size: 28px; margin: 0 0 8px; line-height: 1.15; }
.onb .lead { color: var(--ink-soft); margin: 0 0 24px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-soft); }
.input, select.input { width: 100%; padding: 12px 14px; min-height: var(--tap); border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); font-size: 16px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; min-height: var(--tap); border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink); cursor: pointer; font-size: 14px; }
.chip.on { background: var(--rose); color: #fff; border-color: var(--rose); }
body[data-theme="night"] .chip.on { background: var(--rose); color: #fff; }

.hero-btn { width: 100%; min-height: 88px; border-radius: 22px; border: 0; background: var(--rose); color: #fff; font-size: 22px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.hero-btn.alt { background: var(--green); }
.hero-btn:active { transform: scale(0.98); }
.timer { text-align: center; color: var(--ink-soft); margin-top: 8px; font-variant-numeric: tabular-nums; }
.timer.big { font-size: 28px; color: var(--ink); font-weight: 600; }

.window-bar { position: relative; height: 14px; background: var(--bg-soft); border-radius: 999px; margin: 16px 0 6px; overflow: hidden; }
.window-bar .zone { position: absolute; top: 0; bottom: 0; }
.window-bar .early { background: var(--amber-soft); }
.window-bar .norm { background: var(--green-soft); }
.window-bar .late { background: var(--rose-soft); }
.window-bar .runner { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--ink); border-radius: 2px; }
.window-legend { display: flex; gap: 10px; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; }
.window-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 4px; }
.window-hint { color: var(--ink-soft); font-size: 13px; margin-top: 6px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--bg-elev); border-radius: var(--radius-sm); padding: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; border: 1px solid var(--line); }
.row .time { font-variant-numeric: tabular-nums; font-weight: 600; }
.row .meta { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.row .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.row .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--ink-soft); }
.row button.link { background: transparent; border: 0; color: var(--rose-ink); padding: 8px 10px; min-height: var(--tap); cursor: pointer; }
.row .paperclip { color: var(--rose-ink); font-size: 14px; margin-left: 4px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--bg-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.metric .k { color: var(--ink-soft); font-size: 12px; }
.metric .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metric .n { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.metric.ok { border-left: 3px solid var(--green); }
.metric.warn { border-left: 3px solid var(--amber); }
.metric.over { border-left: 3px solid var(--rose); }
.metric .arrow { font-size: 12px; margin-left: 6px; color: var(--ink-soft); }
.metric .arrow.up { color: var(--green); }
.metric .arrow.down { color: var(--rose); }

.rec { display: flex; gap: 10px; padding: 12px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.rec .ic { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.rec.amber { background: var(--amber-soft); }
.rec.amber .ic { background: var(--amber); color: #fff; }
.rec.info { background: var(--bg-soft); }
.rec.info .ic { background: var(--rose-soft); color: var(--rose-ink); }
.rec.ok { background: var(--green-soft); }
.rec.ok .ic { background: var(--green); color: #fff; }
.rec .title { font-weight: 600; }
.rec .short { margin-top: 2px; }
.rec .why { display: none; margin-top: 8px; color: var(--ink-soft); font-size: 13px; }
.rec.open .why { display: block; }
.rec .more { background: transparent; border: 0; color: var(--rose-ink); font-size: 12px; padding: 6px 0; cursor: pointer; }
.disclaimer { font-size: 11px; color: var(--ink-soft); margin-top: 12px; line-height: 1.5; }

.dash { display: flex; flex-direction: column; gap: 12px; }
.gantt { background: var(--bg-elev); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; }
.gantt .day-row { display: grid; grid-template-columns: 36px 1fr; gap: 6px; align-items: center; margin: 4px 0; }
.gantt .day-row .lbl { font-size: 12px; color: var(--ink-soft); }
.gantt .track { position: relative; height: 22px; background: var(--bg-soft); border-radius: 6px; min-width: 480px; }
.gantt .bar { position: absolute; top: 3px; bottom: 3px; background: var(--sand-soft); border-radius: 4px; }
.gantt .bar.night { background: #6b3a4d; }
body[data-theme="night"] .gantt .bar.night { background: #8a556a; }
.gantt .bar.day { background: var(--sand-soft); }
.gantt .ideal { position: absolute; top: 0; bottom: 0; background: rgba(90, 138, 95, 0.16); border-left: 1px dashed var(--green); border-right: 1px dashed var(--green); }
.gantt .scale { display: flex; font-size: 10px; color: var(--ink-soft); padding-left: 42px; min-width: 480px; }
.gantt .scale span { flex: 1; text-align: left; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 4px; }

.bar-chart-wrap { position: relative; padding-top: 8px; }
.bar-chart { position: relative; display: flex; gap: 6px; align-items: flex-end; height: 140px; padding: 12px 4px 0; }
.bar-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; justify-content: flex-end; }
.bar-chart .col .b { width: 70%; background: var(--rose-soft); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-chart .col .b.over { background: var(--rose); }
.bar-chart .col .b.under { background: var(--amber-soft); }
.bar-chart .col .b.ok { background: var(--green-soft); }
.bar-chart .lbl { font-size: 10px; color: var(--ink-soft); }
.norm-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--green); pointer-events: none; font-size: 10px; color: var(--green); height: 0; }
.norm-line .lab { background: var(--bg-elev); padding: 0 4px; position: absolute; right: 4px; top: -8px; }
.norm-line.upper { border-top: 1px dashed var(--green); }
.norm-line.lower { border-top: 1px dashed var(--amber); }

.heat { display: grid; grid-template-columns: 36px repeat(24, 1fr); gap: 2px; font-size: 10px; color: var(--ink-soft); }
.heat .h { text-align: center; }
.heat .day { text-align: right; padding-right: 4px; }
.heat .cell { aspect-ratio: 1 / 1; background: var(--bg-soft); border-radius: 2px; }
.heat .cell.l1 { background: #f4dca8; }
.heat .cell.l2 { background: #e8b878; }
.heat .cell.l3 { background: #b97c1d; }
body[data-theme="night"] .heat .cell.l1 { background: #4a3618; }
body[data-theme="night"] .heat .cell.l2 { background: #6e4a1f; }
body[data-theme="night"] .heat .cell.l3 { background: #a6722b; }

.btn { background: var(--rose); color: #fff; border: 0; border-radius: var(--radius-sm); padding: 0 16px; min-height: var(--tap); cursor: pointer; }
.btn.alt { background: var(--green); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.btn.danger { background: transparent; color: var(--rose); border: 1px solid var(--rose); }
.btn:active { transform: scale(0.98); }

.modal-bg { position: fixed; inset: 0; background: rgba(20, 10, 20, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 100; }
.modal { background: var(--bg-elev); width: 100%; max-width: 720px; border-radius: 20px 20px 0 0; padding: 18px 16px 24px; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal .row-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal .row-actions .btn { flex: 1; }
.kbd { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

.toast { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 999px; z-index: 200; font-size: 14px; box-shadow: var(--shadow); }
.toast[hidden] { display: none; }

@media (min-width: 720px) { .metrics { grid-template-columns: 1fr 1fr 1fr; } .bar-chart { height: 160px; } }
@media (min-width: 900px) { #app { padding: 24px 24px 32px; } }
@media (max-width: 360px) { .hero-btn { font-size: 18px; } .row-2 { grid-template-columns: 1fr; } }

.svg-icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }
.rec .ic .svg-icon { width: 20px; height: 20px; color: #fff; }
.search { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.empty { color: var(--ink-soft); font-size: 14px; padding: 24px; text-align: center; }
.h-spacer { flex: 1; }
.kbd-tip { font-size: 11px; color: var(--ink-soft); }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
small.muted { color: var(--ink-soft); }
.section-title { font-size: 12px; color: var(--ink-soft); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.tablist { display: flex; gap: 6px; background: var(--bg-soft); padding: 4px; border-radius: 999px; margin-bottom: 12px; }
.tablist button { flex: 1; background: transparent; border: 0; padding: 8px 10px; min-height: var(--tap); border-radius: 999px; color: var(--ink-soft); cursor: pointer; }
.tablist button.on { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow); }
.scale-h { display: flex; gap: 8px; align-items: center; }
.scale-h input { flex: 1; }
.summary { font-size: 14px; }
.summary li { margin-bottom: 4px; }
.note-line { font-size: 12px; color: var(--ink-soft); }
.center { text-align: center; }
.muted { color: var(--ink-soft); }
.iconbtn-32 { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-soft); border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.iconbtn-32:active { transform: scale(0.95); }
.iconbtn-32 .svg-icon { width: 18px; height: 18px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--rose-soft); color: var(--rose-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
