/* «График» — пресет «Мини-апп Telegram»: фирменная база xxlmp (indigo, slate, радиусы 10/14,
   Inter + JetBrains Mono, bi-иконки), фон и текст — из темы Telegram, тач-цели от 44px. */

@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap;
  src: url("vendor/inter-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap;
  src: url("vendor/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-weight: 100 800; font-display: swap;
  src: url("vendor/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); }

:root {
  --page: var(--tg-theme-secondary-bg-color, #f1f5f9);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0f172a);
  --muted: var(--tg-theme-hint-color, #64748b);
  --line: color-mix(in srgb, var(--muted) 20%, transparent);
  --primary: #4f46e5;
  --on-primary: #ffffff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --chat: #0891b2;        /* из переписки (секретарь) */
  --portal: #d97706;      /* с портала xxlmp */
  --meet: #7c3aed;        /* встречи (Zoom) с портала */
  --soft: color-mix(in srgb, var(--primary) 10%, var(--card));
  --hour: 60px;
  --r: 10px;
  --R: 14px;
  --tabbar: calc(60px + env(safe-area-inset-bottom));
  color-scheme: light;
}
:root[data-theme="dark"] {
  --primary: #818cf8;
  --on-primary: #0f172a;
  --chat: #22d3ee;
  --portal: #fbbf24;
  --meet: #a78bfa;
  --line: color-mix(in srgb, var(--muted) 26%, transparent);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--page); color: var(--text);
  font: 15px/1.4 "Inter", -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 12px; width: 100%; outline: none; }
input:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 120px; resize: vertical; }
textarea.desc { min-height: 0; margin-top: 12px; font-size: 15px; }
.tag-desc { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* Полоска «идёт запрос» */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 30; overflow: hidden; }
.progress::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--primary);
  animation: slide 1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Шапка */
header { position: sticky; top: 0; z-index: 5; background: var(--page); padding: 12px 16px 8px; }
.hrow { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.htitle { flex: 1; min-width: 0; }
.htitle b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.htitle span { color: var(--muted); font-size: 13px; }
.ibtn { width: 40px; height: 40px; border-radius: var(--r); display: grid; place-items: center; color: var(--primary);
  font-size: 18px; background: var(--card); }
.pill { height: 32px; padding: 0 12px; border-radius: 999px; background: var(--soft); color: var(--primary);
  font-size: 13px; font-weight: 600; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 8px; border-radius: var(--r);
  min-height: 56px; }
.wd .n { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.wd .d { font-size: 16px; font-weight: 600; }
.wd .ld { width: 22px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 2px; }
.wd .ld i { display: block; height: 100%; background: var(--primary); }
.wd.today .d { color: var(--primary); }
.wd.on { background: var(--primary); }
.wd.on .n, .wd.on .d { color: var(--on-primary); }
.wd.on .ld { background: color-mix(in srgb, var(--on-primary) 35%, transparent); }
.wd.on .ld i { background: var(--on-primary); }
.search { margin-top: 10px; }
.seg { display: inline-flex; background: var(--card); border-radius: var(--r); padding: 3px; }
.seg button { padding: 7px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--primary); color: var(--on-primary); }

main { padding: 4px 16px calc(var(--tabbar) + 88px); }

/* Карточки и секции */
.card { background: var(--card); border-radius: var(--R); padding: 14px; margin-bottom: 12px; }
.sec { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 4px 8px; }
.sec h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sec .cnt { font-size: 12px; color: var(--muted); }
.list { background: var(--card); border-radius: var(--R); overflow: hidden; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; font-size: 14px; }

/* Строка задачи */
.task { display: flex; align-items: center; gap: 2px; min-height: 56px; padding: 4px 4px 4px 0;
  border-bottom: 1px solid var(--line); transition: opacity .2s ease; }
.task:last-child { border-bottom: 0; }
.tick { width: 48px; height: 48px; flex: none; display: grid; place-items: center; }
.tick i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center;
  font-size: 13px; color: transparent; transition: .15s ease; }
.tick.ext i { border: 0; color: var(--portal); font-size: 17px; }
.task.done { opacity: .45; }
.task.done .tick i { background: var(--success); border-color: var(--success); color: #fff; }
.task.done .t-title { text-decoration: line-through; }
.t-main { flex: 1; min-width: 0; padding: 6px 0; }
.t-title { font-weight: 500; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.tags span { display: inline-flex; align-items: center; gap: 4px; }
.tag-late { color: var(--danger); font-weight: 500; }
.tag-chat { color: var(--chat); font-weight: 500; }
.tag-portal { color: var(--portal); font-weight: 500; }
.tag-meet { color: var(--meet); font-weight: 500; }
.tag-star { color: var(--warning); }
.t-act { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: var(--r);
  color: var(--primary); font-size: 18px; }
.more { width: 100%; padding: 12px; color: var(--primary); font-size: 14px; font-weight: 500; }

/* «Сейчас» */
.focus { display: flex; gap: 12px; align-items: center; background: var(--soft); border-radius: var(--R);
  padding: 14px; margin: 4px 0 4px; }
.focus .fi { width: 40px; height: 40px; flex: none; border-radius: var(--r); background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-size: 18px; }
.focus small { display: block; font-size: 12px; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.focus b { display: block; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.focus span { color: var(--muted); font-size: 13px; }

/* Лента времени */
.tl-wrap { background: var(--card); border-radius: var(--R); padding: 10px 10px 10px 0; }
.timeline { position: relative; margin-left: 52px; }
.hour { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.hour span { position: absolute; left: -48px; top: -8px; width: 40px; text-align: right; font-size: 11px; color: var(--muted); }
.off { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--muted) 6%, transparent); }
.free { position: absolute; left: 4px; right: 4px; border: 1.5px dashed color-mix(in srgb, var(--success) 55%, transparent);
  border-radius: var(--r); color: var(--success); font-size: 12px; font-weight: 500; padding: 4px 10px;
  display: flex; align-items: flex-start; gap: 4px; background: color-mix(in srgb, var(--success) 6%, transparent); }
.block { position: absolute; border-radius: var(--r); padding: 5px 9px; overflow: hidden; font-size: 13px;
  background: color-mix(in srgb, var(--c, var(--primary)) 14%, var(--card));
  border-left: 3px solid var(--c, var(--primary)); text-align: left; transition: opacity .2s ease; }
.block { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.block.dragging { z-index: 6; box-shadow: 0 8px 24px rgba(15, 23, 42, .25); transform: scale(1.02); transition: none; }
.block.dragging::after { content: attr(data-time); position: absolute; right: 6px; top: 4px; padding: 3px 6px;
  border-radius: 6px; background: var(--primary); color: #fff; font: 600 12px/1 "JetBrains Mono", monospace; }
.block b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block small { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 11px; }
.block.chat { --c: var(--chat); }
.block.portal { --c: var(--portal); }
.block.meeting { --c: var(--meet); }
.block.imp b::after { content: " ★"; color: var(--warning); }
.block.done { opacity: .4; text-decoration: line-through; }
.now { position: absolute; left: -6px; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* Неделя */
.big { display: flex; align-items: baseline; gap: 8px; }
.big b { font-size: 36px; font-weight: 700; letter-spacing: -.02em; }
.meter { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 10px 0 14px; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.meter i.low { background: var(--success); }
.meter i.high { background: var(--warning); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--page); border-radius: var(--r); padding: 10px; }
.tile b { display: block; font-size: 20px; font-weight: 700; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.late b { color: var(--danger); }
.tile.ok b { color: var(--success); }
.insight { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 14px; }
.insight i { color: var(--primary); font-size: 16px; margin-top: 1px; }
.dayrow { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; width: 100%;
  min-height: 52px; padding: 6px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.dayrow:last-child { border-bottom: 0; }
.dayrow .dn { font-weight: 600; white-space: nowrap; }
.dayrow .dn small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.dayrow.today .dn { color: var(--primary); }
.dbar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.dbar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.dmeta { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.dmeta .ok { color: var(--success); font-weight: 600; }

/* Деньги */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.total { background: var(--card); border-radius: var(--R); padding: 14px; }
.total span { color: var(--muted); font-size: 12px; }
.total b { display: block; font-size: 22px; font-weight: 700; margin-top: 2px; }
.total.in b { color: var(--success); }
.cat { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat:last-child { border-bottom: 0; }
.cat .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.cat .top span { color: var(--muted); white-space: nowrap; }
.bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); }
.bar i.over { background: var(--danger); }
.entry { display: flex; justify-content: space-between; gap: 10px; align-items: center; min-height: 56px; padding: 8px 14px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.entry:last-child { border-bottom: 0; }
.entry .d b { display: block; font-weight: 500; overflow-wrap: anywhere; }
.entry .d small { color: var(--muted); }
.entry .a { font-weight: 600; white-space: nowrap; }
.entry .a.in { color: var(--success); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; background: var(--page);
  border-radius: var(--r); padding: 12px; max-height: 40vh; overflow-y: auto; }
.points { margin: 6px 0 0; padding-left: 20px; }
.link { color: var(--primary); overflow-wrap: anywhere; }

/* Нижняя панель и «+» */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; display: grid; grid-template-columns: repeat(5, 1fr);
  height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom); background: var(--card);
  border-top: 1px solid var(--line); }
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 500; }
.tabbar button i { font-size: 20px; }
.tabbar button.on { color: var(--primary); }
.tabbar button { position: relative; }
.tabbar .badge { position: absolute; top: 5px; left: calc(50% + 5px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px;
  text-align: center; font-variant-numeric: tabular-nums; }
.tabbar .badge[hidden] { display: none; }
.fab { position: fixed; right: 16px; bottom: calc(var(--tabbar) + 16px); z-index: 8; width: 56px; height: 56px;
  border-radius: 18px; background: var(--primary); color: var(--on-primary); font-size: 24px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 35%, transparent); display: grid; place-items: center; }

/* Лист снизу */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(15, 23, 42, .4); animation: fade .18s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--card); border-radius: 18px 18px 0 0;
  max-height: calc(var(--tg-viewport-height, 100vh) * .9); overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .2s ease; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.shead { display: flex; gap: 8px; align-items: flex-start; }
.shead .title { flex: 1; font-size: 18px; font-weight: 600; border: 0; background: transparent; padding: 6px 0; }
.shead .ibtn { background: var(--page); color: var(--muted); }
.lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  margin: 16px 0 8px; display: flex; justify-content: space-between; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { flex: none; min-height: 38px; padding: 0 14px; border-radius: var(--r); background: var(--page);
  font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; position: relative; }
.chip.on { background: var(--primary); color: var(--on-primary); }
.chip.slot { color: var(--success); }
.chip.slot.on { background: var(--success); color: #fff; }
.chip input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; padding: 0; }
header .chip:not(.on) { background: var(--card); }   /* шапка того же цвета, что страница */
.doc-ic { width: 48px; height: 48px; flex: none; display: grid; place-items: center; font-size: 20px; color: var(--primary); }
.doc-ic.warn { color: var(--chat); }
.doc-ic.portal { color: var(--portal); }

/* Быстрый ввод «что и когда» */
.quick { display: flex; gap: 8px; align-items: center; background: var(--card); border-radius: var(--R); padding: 6px 6px 6px 4px;
  margin-bottom: 12px; }
.quick input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 10px; font-size: 16px; }
.quick input:focus { outline: none; }
.quick:focus-within { box-shadow: 0 0 0 2px var(--primary); }
.qsend { width: 40px; height: 40px; flex: none; border-radius: var(--r); background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-size: 18px; }
.qsend:disabled { opacity: .5; }

/* Перенос незакрытого на завтра */
.carry { width: 100%; min-height: 48px; margin-top: 12px; border-radius: var(--R); background: var(--card); color: var(--primary);
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 500; }
.carry .cnt { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--soft); font-size: 12px;
  display: grid; place-items: center; }
.days7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.days7 .chip { padding: 0; justify-content: center; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.srcline { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.srcline .chip { min-height: 32px; font-size: 13px; }
.srcline .chat { color: var(--chat); }
.srcline .portal { color: var(--portal); }
.srcline .meet { color: var(--meet); }
.btns { display: flex; gap: 8px; margin-top: 20px; }
.btn { flex: 1; min-height: 50px; border-radius: var(--R); font-weight: 600; background: var(--page);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.main { background: var(--primary); color: var(--on-primary); }
.btn.ok { background: var(--success); color: #fff; }
.btn.del { color: var(--danger); flex: 0 0 auto; padding: 0 18px; }
.btn:disabled { opacity: .5; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 88px); transform: translateX(-50%); z-index: 40;
  background: rgba(15, 23, 42, .92); color: #fff; padding: 10px 14px; border-radius: var(--r); font-size: 14px;
  max-width: calc(100vw - 32px); text-align: center; animation: fade .15s ease; }
.toast:has(.toast-act) { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left;
  min-width: min(320px, calc(100vw - 32px)); }
.toast-act { color: #a5b4fc; font-weight: 600; font-size: 14px; padding: 6px 4px; flex: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
