/* Штаб: токены цвета. В Telegram их переопределяет тема Telegram (app.js → applyTgTheme). */
:root {
  --bg: #f6f7f9; --bg2: #ffffff; --fg: #1d2330; --muted: #6b7385; --line: #e3e6ec; --accent: #3b6fd8; --link: #3b6fd8;
  --good: #2e9d63; --bad: #d64545; --warn: #d98a1c; --c1: #3b6fd8; --c2: #9aa9c7; --c3: #d98a1c;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  --r: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --bg2: #1b1f27; --fg: #e7eaf0; --muted: #98a0b0; --line: #2a303b; --accent: #6b97f0; --link: #8ab0ff;
    --good: #3fbf7f; --bad: #ef6464; --warn: #f0a640; --c1: #6b97f0; --c2: #56607a; --c3: #f0a640; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --bg2: #1b1f27; --fg: #e7eaf0; --muted: #98a0b0; --line: #2a303b; --accent: #6b97f0; --link: #8ab0ff;
  --good: #3fbf7f; --bad: #ef6464; --warn: #f0a640; --c1: #6b97f0; --c2: #56607a; --c3: #f0a640; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2.day { font-size: 22px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
h4 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); }
a { color: var(--link); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap; }
button:disabled { opacity: .45; cursor: default; }
button.link { background: none; color: var(--link); padding: 0; font-weight: 500; }
code { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: 13px; }
.muted { color: var(--muted); }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; text-align: center; }
.login-box { max-width: 420px; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 28px; margin: 0 auto 12px; }
.logo.sm { width: 28px; height: 28px; font-size: 15px; border-radius: 8px; margin: 0; }

/* каркас */
.app { max-width: 1200px; margin: 0 auto; padding: 0 16px 90px; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 6px; }
.top-row { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; }
.is-tg .brand { display: none; }
.sphere { margin-left: auto; display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.sphere button { background: none; color: var(--muted); padding: 5px 10px; font-weight: 600; border-radius: 8px; }
.sphere button.on { background: var(--accent); color: #fff; }
.quick { display: flex; gap: 8px; margin-top: 10px; }
.quick button { font-size: 20px; padding: 0 16px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 2px 0; overflow-x: auto; white-space: nowrap; }
.tabs.desktop { display: none; gap: 4px; }
.tabs button { background: none; color: var(--muted); font-weight: 600; }
.tabs button.on { color: var(--accent); }
.tabs.desktop button.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tabs.mobile { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg2); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 6; }
.tabs.mobile button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; padding: 4px; }
.tabs.mobile .ti { font-size: 20px; }
@media (min-width: 860px) { .tabs.desktop { display: flex; } .tabs.mobile { display: none; } .app { padding-bottom: 40px; } }
.content { padding-top: 8px; }

/* плитки */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); border-left: 4px solid var(--line); }
.tile.good { border-left-color: var(--good); } .tile.bad { border-left-color: var(--bad); } .tile.warn { border-left-color: var(--warn); }
.tile-k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tile-v { font-size: 20px; font-weight: 700; margin: 2px 0; }
.tile-s { font-size: 12px; color: var(--muted); }
.dots { letter-spacing: 2px; font-size: 16px; }
.vpn-detail { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin-top: 10px; font-size: 14px; }
.vpn-g { margin: 4px 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.good { background: var(--good); } .dot.bad { background: var(--bad); }

/* таймлайн дня */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.timeline li.meeting { border-left: 4px solid var(--c3); } .timeline li.task { border-left: 4px solid var(--accent); }
.timeline li.done { opacity: .55; } .timeline li.done a { text-decoration: line-through; }
.timeline time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; padding-top: 2px; }
.tl-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.tl-body small { flex-basis: 100%; }
.check { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--accent); font-size: 13px; line-height: 1; flex: none; }
.empty { color: var(--muted); background: var(--bg2); border: 1px dashed var(--line); border-radius: var(--r); padding: 16px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.due { font-size: 12px; color: var(--muted); white-space: nowrap; }
.due.over { color: var(--bad); font-weight: 600; } .due.now { color: var(--warn); font-weight: 600; }

/* доска */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x mandatory; }
.col { background: color-mix(in srgb, var(--bg2) 55%, var(--bg)); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; scroll-snap-align: start; display: flex; flex-direction: column; }
.col-h { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px; padding: 0 2px; }
.count { color: var(--muted); font-weight: 600; }
.col-list { min-height: 60px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.chip { background: var(--bg2); border: 1px solid var(--line); border-left: 4px solid var(--c2); border-radius: 10px; padding: 9px 11px; cursor: grab; box-shadow: var(--shadow); }
.chip.p1 { border-left-color: var(--bad); } .chip.p2 { border-left-color: var(--accent); }
.chip.project { background: color-mix(in srgb, var(--accent) 5%, var(--bg2)); }
.chip-t { font-weight: 600; }
.chip-m { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chip-n { font-size: 13px; color: var(--muted); margin-top: 4px; }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); border: 1px solid currentColor; border-radius: 5px; padding: 0 4px; vertical-align: 2px; }
.ghost { opacity: .35; }
.add-in-col { margin-top: 8px; background: none; color: var(--muted); border: 1px dashed var(--line); }

/* OKR */
.okr { display: grid; gap: 14px; }
.obj { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.obj-h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.obj-h h3 { margin: 2px 0 0; color: var(--fg); text-transform: none; letter-spacing: 0; font-size: 17px; }
.big { font-size: 26px; font-weight: 800; color: var(--accent); }
.bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 10px 0 6px; }
.bar.sm { height: 6px; margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s; }
.kr { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.kr-h { display: flex; justify-content: space-between; gap: 10px; }
.kr-v { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.kr-a { display: grid; grid-template-columns: 1fr 140px; gap: 10px; align-items: center; }
.spark { width: 140px !important; height: 36px !important; }
.kr-cards { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; margin-top: 4px; }
.kr-cards a.done { text-decoration: line-through; color: var(--muted); }
.inline { display: flex; gap: 6px; flex-wrap: wrap; }
.inline input { flex: 1 1 120px; }
.inline input.xs { flex: 0 1 70px; }
.add-kr { margin-top: 10px; }
.obj.new input { margin: 8px 0; }
@media (max-width: 560px) { .kr-a { grid-template-columns: 1fr; } }

/* отчёты */
.reports .chart-box { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-top: 14px; height: 270px; display: flex; flex-direction: column; }
.reports .chart-box h3 { margin: 0 0 8px; }
.reports .chart-box canvas { flex: 1; min-height: 0; }

/* карточка */
.drawer-bg { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); z-index: 20; display: flex; justify-content: flex-end; }
.drawer { width: min(560px, 100%); height: 100%; overflow-y: auto; background: var(--bg); padding: 14px 16px 40px; box-shadow: -8px 0 30px rgba(0, 0, 0, .15); }
.dr-h { display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
.x { background: none; color: var(--muted); font-size: 18px; padding: 4px 8px; margin-left: auto; }
.title-in { font-size: 20px; font-weight: 700; border-color: transparent; background: transparent; padding: 6px 2px; margin: 4px 0 10px; }
.title-in:hover { border-color: var(--line); }
.props { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.full { margin-top: 12px; }
label > input, label > select, label > textarea { color: var(--fg); font-size: 15px; }
.subs .sub { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.subs .sub a { flex: 1; } .subs .sub.done a { text-decoration: line-through; color: var(--muted); }
.subs form { margin-top: 8px; }
.note { display: flex; gap: 8px; align-items: flex-end; }
.events { list-style: none; padding: 0; margin: 12px 0 0; }
.events li { display: grid; grid-template-columns: 24px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.events time { font-size: 12px; color: var(--muted); }
.events p { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
.events li.status p, .events li.created p { color: var(--muted); }
.events li.summary { background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 8px; padding: 8px; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 20px;
  font-size: 14px; z-index: 30; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); }
@media (min-width: 860px) { .toast { bottom: 24px; } }

/* узкие экраны (Mini App на телефоне): три плитки в ряд, название в таймлайне рядом с иконкой */
@media (max-width: 520px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px; }
  .tile-v { font-size: 16px; }
  .tile-k, .tile-s { font-size: 11px; }
  .timeline li { grid-template-columns: 78px 1fr; padding: 9px 10px; }
  .reports .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.tl-body > a, .tl-body > span:not(.tl-icon) { flex: 1 1 0; min-width: 0; }
