:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e5eaf2;
  --border: #dde3ec;
  --ink: #152033;
  --ink-2: #4a5568;
  --ink-3: #8a94a6;
  --accent: #0b6bcb;
  --accent-soft: #e3effc;
  --bad: #dc2626;
  --warn: #c2620a;
  --good: #16a34a;
  --topbar: #0f3d63;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 3px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .22);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151d; --surface: #19202b; --surface-2: #212937; --surface-3: #2a3344; --border: #2e3747;
    --ink: #e7eaf1; --ink-2: #aab2c3; --ink-3: #7a8396; --accent: #5aa6ff; --accent-soft: #1d3150; --topbar: #12273d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10151d; --surface: #19202b; --surface-2: #212937; --surface-3: #2a3344; --border: #2e3747;
  --ink: #e7eaf1; --ink-2: #aab2c3; --ink-3: #7a8396; --accent: #5aa6ff; --accent-soft: #1d3150; --topbar: #12273d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
h2 { font-size: 1.3rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
h3 a { margin-left: auto; font-weight: 400; font-size: 13px; }
h4 { font-size: .8rem; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; flex: none; }
input[type=color] { padding: 1px; height: 26px; width: 34px; border-radius: 6px; }
textarea { resize: vertical; width: 100%; }
.invalid { outline: 2px solid var(--bad) !important; outline-offset: 1px; border-radius: 8px; }
kbd { font-size: 11px; background: var(--surface-3); border-radius: 4px; padding: 0 4px; border: 1px solid var(--border); }
.muted { color: var(--ink-3); }
.small { font-size: .85em; }
.grow { flex: 1; }
.pad { padding: 12px 4px; }
.hint { color: var(--ink-3); font-size: .85rem; margin: 4px 0; }
.bad { color: var(--bad); }
.req { color: var(--bad); }
.empty { color: var(--ink-3); text-align: center; padding: 56px 12px; }
.empty .btn { margin-top: 14px; }
.loading { padding: 80px 20px; text-align: center; color: var(--ink-3); }
[hidden] { display: none !important; }
.note { font-size: 13px; background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.warn-note { background: color-mix(in srgb, #f59e0b 16%, var(--surface)); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

/* Every button gives tactile feedback (owner's rule: no "dead" buttons). */
button { cursor: pointer; transition: transform .08s ease, background .15s, border-color .15s; }
button:active { transform: scale(.95); }
button:disabled { opacity: .5; cursor: default; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 14px; font-weight: 500; white-space: nowrap; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-good:hover { background: var(--good); filter: brightness(1.07); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 5px 10px; font-size: .86rem; }
.btn-wide { width: 100%; padding: 12px; font-size: 1rem; }
.btn.flashed, .link-btn.flashed { background: var(--good); border-color: var(--good); color: #fff; }
.icon-btn { border: 0; background: transparent; border-radius: 7px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); font-size: 15px; flex: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.small { width: 26px; height: 26px; font-size: 12px; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }

/* ---------- Header & tabs ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--topbar); color: #fff; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; min-width: 0; }
.logo { background: rgba(255,255,255,.16); border-radius: 8px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; font-weight: 700; white-space: nowrap; }
.brand-text small { font-weight: 400; opacity: .75; font-size: 11.5px; }
.project-btn { display: flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; border-radius: 9px; padding: 6px 12px; font-weight: 700; max-width: 40vw; margin-left: 6px; }
.project-btn:hover { background: rgba(255,255,255,.2); }
.pj-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-pin { font-size: 11px; }
.caret-down { font-size: 10px; opacity: .7; }
.add-btn { border: 0; background: #22c55e; color: #fff; border-radius: 999px; padding: 7px 14px; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.add-btn:hover { filter: brightness(1.06); }
.me-btn { position: relative; display: flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; border-radius: 999px; padding: 3px 12px 3px 3px; max-width: 34vw; }
.me-btn:not(.set) { padding: 5px 12px; }
.me-btn.set { background: #fff; color: var(--topbar); border-color: #fff; font-weight: 600; }
:root[data-theme="dark"] .me-btn.set { background: #e7eaf1; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.red-dot { position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: #ef4444; border: 2px solid var(--topbar); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .6); } 50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); } }
.theme-btn, .admin-btn { border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; border-radius: 999px; width: 34px; height: 32px; display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: 14px; }
.theme-btn:hover, .admin-btn:hover { background: rgba(255,255,255,.12); }
.admin-btn.on { background: #fbbf24; border-color: #fbbf24; }
.gap-bar { background: color-mix(in srgb, #ef4444 12%, var(--surface)); color: var(--ink); font-size: 13px; padding: 7px 16px; cursor: pointer; border-bottom: 1px solid color-mix(in srgb, #ef4444 30%, var(--border)); }
.gap-bar u { color: var(--bad); font-weight: 600; }
.tabs { position: sticky; top: 52px; z-index: 29; display: flex; gap: 2px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 11px 12px 9px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; display: flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 13px; opacity: .7; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; flex: none; vertical-align: middle; }
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }
.me-btn .avatar { width: 26px; height: 26px; }

.main { padding: 14px 20px 70px; overflow-x: clip; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }

/* ---------- Presets & toolbar ---------- */
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.preset { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 13px; font-weight: 500; color: var(--ink-2); }
.preset:hover { border-color: var(--accent); }
.preset.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.preset.attn { border-color: #f59e0b; }
.preset.attn b { background: #f59e0b; color: #fff; border-radius: 999px; padding: 0 6px; font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.search { width: 260px; }
.search.wide { width: 100%; max-width: 560px; margin-bottom: 12px; }
.filters { display: contents; }
.filters-toggle { display: none; }
.filters-toggle.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filter-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; padding: 3px 0; }
.check.strong { font-weight: 600; }
.list-meta { display: flex; gap: 10px; align-items: center; margin: 2px 0 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 500; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg-wide { display: flex; }
.seg-wide button { flex: 1; }
.seg-type button.on { background: var(--c); color: #fff; }
.seg-tabs { margin: 0 16px 4px; display: flex; }
.seg-tabs button { flex: 1; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; color: var(--ink-2); }

/* ---------- Atoms ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); white-space: nowrap; }
.pill-big { font-size: 14px; padding: 4px 12px; }
.tchip { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 11%, transparent); white-space: nowrap; }
.prio { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; color: #fff; background: var(--c); }
.target { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 5px; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); margin-right: 4px; white-space: nowrap; }
.dchip { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 5px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap; }
.month { font-size: 12px; white-space: nowrap; color: var(--ink-2); }
.month.late { color: var(--bad); font-weight: 600; }
.assignee { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.num.big { font-size: 1.15rem; color: var(--ink); }
.crumbs { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.tag { font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 1px 6px; }

/* ---------- Thumbnails, hover preview, lightbox ---------- */
.thumbs { display: flex; gap: 5px; flex-wrap: wrap; }
.thumb { position: relative; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); padding: 0; flex: none; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.thumb:hover img { transform: scale(1.08); }
.thumbs.sm .thumb { width: 40px; height: 40px; }
.thumb.more { font-weight: 700; color: var(--ink-2); font-size: 13px; }
.thumb-ph { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 20px; }
.play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; text-shadow: 0 1px 4px rgba(0,0,0,.7); pointer-events: none; }
.play.big { font-size: 46px; }
.hover-preview { position: fixed; z-index: 95; pointer-events: none; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 4px; animation: pop .12s ease-out; }
.hover-preview img { display: block; max-width: inherit; max-height: inherit; width: auto; height: auto; border-radius: 9px; object-fit: contain; }
@keyframes pop { from { transform: scale(.92); opacity: .4; } }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 14, .94); display: flex; flex-direction: column; animation: fade .15s; }
.lb-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #fff; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { opacity: .6; margin-left: 6px; }
.lb-btn { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 56px 20px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #000; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); border: 0; background: rgba(255,255,255,.14); color: #fff; width: 46px; height: 64px; border-radius: 12px; font-size: 34px; line-height: 1; }
.lb-nav:active { transform: translateY(-50%) scale(.94); }
.lb-nav.prev { left: 6px; }
.lb-nav.next { right: 6px; }

/* ---------- List ---------- */
.ilist { display: flex; flex-direction: column; gap: 8px; }
.irow { display: flex; gap: 0; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--c); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.irow:hover { border-color: color-mix(in srgb, var(--c) 60%, var(--border)); box-shadow: 0 4px 16px rgba(16,24,40,.09); }
.irow.closed { opacity: .72; }
.irow-q { width: 34px; flex: none; display: flex; justify-content: center; padding-top: 12px; font-weight: 800; color: var(--ink-3); font-size: 13px; }
.irow-main { flex: 1; min-width: 0; padding: 9px 12px 10px 0; }
.irow-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.irow-text { margin: 5px 0 7px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: 14.5px; }
.irow-bottom { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta { font-size: 12px; color: var(--ink-3); display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.igroup { margin-bottom: 18px; }
.igroup-head { font-weight: 700; margin: 6px 0 8px; display: flex; gap: 8px; align-items: center; font-size: 15px; }

/* ---------- Board & months ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
@media (min-width: 641px) {
  .board { height: calc(100vh - var(--board-top, 230px)); align-items: stretch; }
  .bcol, .mcol { display: flex; flex-direction: column; min-height: 0; }
  .bcol-body, .mcol-body { overflow-y: auto; flex: 1; min-height: 0; }
}
.bcol { background: var(--surface-2); border-radius: var(--radius); border-top: 4px solid var(--c); }
.bcol-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; }
.bcol-head i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.bcol-head b { margin-left: auto; color: var(--ink-3); }
.bcol-body, .mcol-body { padding: 0 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.bcard { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 9px; padding: 8px 10px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 5px; }
.bcard:hover { border-color: var(--c); }
.bcard-top { display: flex; align-items: center; gap: 6px; }
.bcard-crumbs { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard-title { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bcard-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.mcol { background: var(--surface-2); border-radius: var(--radius); border-top: 4px solid var(--ink-3); }
.mcol.cur { border-top-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface-2)); }
.mcol.late-col { border-top-color: var(--bad); background: color-mix(in srgb, var(--bad) 6%, var(--surface-2)); }
.mcol-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px 4px; text-transform: capitalize; }
.mcol > .muted { padding: 0 12px 6px; }
.mprogress { height: 6px; border-radius: 3px; background: var(--surface-3); margin: 4px 12px 2px; overflow: hidden; }
.mprogress i { display: block; height: 100%; background: var(--good); }

/* ---------- Summary ---------- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.summary > * { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.span-2 { grid-column: span 2; }
.hero-title { font-size: 1.3rem; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 14px; }
.tile { text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; border-top: 4px solid var(--c); }
.tile:hover { background: var(--surface-2); }
.tile-v { font-size: 1.9rem; font-weight: 700; color: var(--c); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { color: var(--ink-2); font-size: 13px; }
.mini { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-left: 3px solid var(--c); border-radius: 4px; cursor: pointer; margin-bottom: 4px; background: var(--surface-2); }
.mini:hover { background: var(--surface-3); }
.mini-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-note { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.dtable td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.dtable tr[data-go-filter] { cursor: pointer; }
.dtable tr[data-go-filter]:hover { background: var(--surface-2); }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.mrow { display: grid; grid-template-columns: 150px 1fr 50px; gap: 10px; align-items: center; padding: 5px 4px; cursor: pointer; border-radius: 6px; }
.mrow:hover { background: var(--surface-2); }
.mrow.cur .mrow-l { font-weight: 700; color: var(--accent); }
.mrow-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.mbar { display: flex; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.mbar i { display: block; height: 100%; background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.mbar i.done { background: var(--good); }
.feed-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed-row.clickable { cursor: pointer; }
.feed-row.clickable:hover { background: var(--surface-2); }
.feed-time { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-by { color: var(--ink-2); white-space: nowrap; }

/* ---------- Drawer (item card) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .3); z-index: 40; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { padding: 10px 14px; border-bottom: 1px solid var(--border); border-top: 5px solid var(--c); }
.drawer-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.status-box { border: 1px solid color-mix(in srgb, var(--c) 35%, var(--border)); background: color-mix(in srgb, var(--c) 7%, var(--surface)); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-reason { margin-top: 8px; font-size: 13.5px; overflow-wrap: anywhere; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.card-text { font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; margin-bottom: 12px; }
.card-media { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.card-media .thumb { width: 96px; height: 96px; }
.thumb-del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; display: none; align-items: center; justify-content: center; cursor: pointer; }
.thumb:hover .thumb-del { display: flex; }
@media (hover: none) { .thumb-del { display: flex; } }
.card-addmedia { margin-bottom: 14px; }
.addmedia-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--surface-2); }
.facts { display: grid; gap: 9px; margin-bottom: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.fact { display: grid; grid-template-columns: 140px 1fr; gap: 10px; align-items: center; }
.fact > span:first-child { color: var(--ink-3); font-size: 13px; }
.inline-select { padding: 4px 8px; max-width: 100%; }
.inline-select.late { border-color: var(--bad); color: var(--bad); }
.vote.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.card-section { margin: 18px 0; }
.comment { padding: 9px 11px; background: var(--surface-2); border-radius: 10px; margin-bottom: 8px; }
.comment.status-entry { background: transparent; border: 1px dashed color-mix(in srgb, var(--c) 45%, var(--border)); font-size: 13px; }
.comment-head { display: flex; gap: 8px; align-items: center; margin-bottom: 3px; }
.comment-head .icon-btn { margin-left: auto; }
.comment-text { overflow-wrap: anywhere; margin-top: 3px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-top: 8px; }
.history summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
.hist { padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field > select, .field > input:not([type=checkbox]):not([type=radio]) { width: 100%; }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.field.inline > input { width: 90px; }
.field.miss input, .field.miss .seg { outline: 2px solid #ef4444; outline-offset: 1px; border-radius: 8px; }
.field.miss > span::after { content: ' ● не заполнено'; color: #ef4444; font-weight: 600; }
.field-warn { color: var(--bad); font-size: 12.5px; background: color-mix(in srgb, var(--bad) 8%, var(--surface)); padding: 6px 8px; border-radius: 7px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.inline-new { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.inline-new input { flex: 1; }
.form-group { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.form-group-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.form-group-head .link-btn { margin-left: auto; }
.form-sub { margin-top: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.chip-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid color-mix(in srgb, var(--c, var(--ink-3)) 40%, var(--border)); border-radius: 8px; padding: 4px 9px; cursor: pointer; font-size: 13px; }
.ev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.sub-depts, .sub-projects { margin-left: 26px; }
.target-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.target-pick button { border: 2px solid color-mix(in srgb, var(--c, var(--ink-3)) 45%, var(--border)); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 600; color: var(--ink-2); }
.target-pick button.on { background: var(--c); border-color: var(--c); color: #fff; }
.target-pick .all-btn { --c: var(--ink-2); border-style: dashed; }
.target-pick .all-btn.on { background: var(--ink-2); color: var(--surface); }
.prio-pick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.prio-pick button { border: 2px solid color-mix(in srgb, var(--c) 40%, var(--border)); background: var(--surface); border-radius: 10px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; color: var(--c); }
.prio-pick button b { font-size: 17px; }
.prio-pick button small { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.prio-pick button.on { background: var(--c); color: #fff; }
.prio-pick button.on small { color: rgba(255,255,255,.85); }
.up-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 10px; transition: border-color .15s, background .15s; }
.up-zone.drag { border-color: var(--accent); background: var(--accent-soft); }
.up-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.up-grid:not(:empty) { margin-bottom: 10px; }
.up-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.up-tile { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); }
.up-tile img { width: 100%; height: 100%; object-fit: cover; }
.up-tile.ok { border-color: var(--good); }
.up-tile.err { border-color: var(--bad); }
.up-progress { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.35); overflow: hidden; }
.up-progress i { display: block; height: 100%; background: #fff; transition: width .2s; }
.up-err { position: absolute; inset: auto 0 0 0; background: var(--bad); color: #fff; font-size: 10px; padding: 2px 4px; }
.up-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; }
.status-pick { display: grid; gap: 6px; }
.status-pick button { display: flex; align-items: center; gap: 12px; text-align: left; border: 2px solid var(--border); background: var(--surface); border-radius: 10px; padding: 9px 12px; }
.status-pick button:hover { border-color: color-mix(in srgb, var(--c) 50%, var(--border)); }
.status-pick button.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.status-pick span:last-child { display: flex; flex-direction: column; }
.status-pick small { color: var(--ink-3); font-size: 12px; }
.sp-icon { width: 30px; height: 30px; border-radius: 8px; background: color-mix(in srgb, var(--c) 15%, transparent); display: flex; align-items: center; justify-content: center; flex: none; }
.pending-box { display: flex; flex-direction: column; gap: 8px; background: color-mix(in srgb, #f59e0b 14%, var(--surface)); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.code-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.code-input { width: 130px; font-size: 20px; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.tg-box { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; flex-wrap: wrap; font-size: 13.5px; }
.test-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Identity ---------- */
.id-search { width: 100%; padding: 11px 12px; font-size: 15px; border-radius: 10px; }
.id-list { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.id-group-head { font-size: 12px; font-weight: 700; color: var(--c); text-transform: uppercase; letter-spacing: .03em; padding: 2px 4px; border-bottom: 2px solid color-mix(in srgb, var(--c) 30%, transparent); margin-bottom: 4px; }
.id-person { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px; border-radius: 9px; }
.id-person:hover, .id-person.on { background: var(--accent-soft); }
.id-name { flex: 1; display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.id-name small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.id-go { color: var(--accent); font-size: 12.5px; opacity: 0; white-space: nowrap; }
.id-person:hover .id-go { opacity: 1; }

/* ---------- People ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.people-grid > * { min-width: 0; }
.dept-card { border-top: 4px solid var(--c); padding: 12px; }
.dept-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dept-title { color: var(--c); font-size: 14.5px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; }
.prow.me { background: var(--accent-soft); cursor: pointer; }
.prow-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.prow-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow-stats { display: flex; gap: 8px; font-size: 12px; color: var(--ink-2); }
.ch { font-size: 10.5px; font-weight: 700; color: var(--ink-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; opacity: .5; }
.ch.on { color: var(--good); border-color: var(--good); opacity: 1; }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings > * { min-width: 0; }
.sform { display: flex; flex-direction: column; gap: 10px; }
.sform > .btn { align-self: flex-start; }
.proj-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; flex-wrap: wrap; }
.proj-row.on { background: var(--accent-soft); }
.sec-tree { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.sec-node { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.sec-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; min-height: 30px; }
.sec-row.sub { padding-left: 10px; font-size: 13.5px; }
.sub-list .inline-new { padding-left: 10px; }
.sub-list .inline-new input { padding: 5px 8px; font-size: 13px; }
.bot-status { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); margin-bottom: 8px; font-size: 13.5px; }
.bot-status.on { background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.bot-status.error { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.steps { padding-left: 20px; color: var(--ink-2); font-size: 13px; margin: 0; }

/* ---------- Modal, menu, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .12s; }
.modal-backdrop.show { opacity: 1; }
.confirm-layer { z-index: 80; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(480px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal > form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 32px); }
.modal-wide { width: min(700px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; gap: 10px; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 8px 16px; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px 14px; border-top: 1px solid var(--border); margin-top: 6px; flex-wrap: wrap; align-items: center; }
.confirm-text { margin: 12px 0 6px; font-size: 15px; }
.popmenu { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; min-width: 220px; max-width: calc(100vw - 16px); max-height: 70vh; overflow-y: auto; }
.popmenu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; white-space: pre; }
.popmenu button:hover:not(:disabled) { background: var(--surface-2); }
.popmenu button.danger { color: var(--bad); }
.popmenu button.checked { font-weight: 600; }
.popmenu-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 6px 10px 4px; }
.popmenu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.pm-box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-style: normal; font-weight: 800; color: #fff; flex: none; }
.checked .pm-box { background: var(--accent); }
.project-pop { min-width: 300px; }
.project-pop button { white-space: normal; }
.pm-proj { display: flex; flex-direction: column; flex: 1; }
.pm-proj small { color: var(--ink-3); font-weight: 400; }
.pm-check { color: var(--accent); font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 110; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); display: flex; gap: 14px; align-items: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-error { background: #b91c1c; }
.toast-success { background: #15803d; }
.toast-action { border: 1px solid rgba(255,255,255,.6); background: transparent; color: #fff; border-radius: 6px; padding: 3px 10px; font-weight: 600; white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .settings { grid-template-columns: 1fr; }
  .settings .span-2 { grid-column: auto; }
}
@media (max-width: 900px) {
  .summary { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
  .hide-mobile { display: none !important; }
  .main { padding: 10px 10px 80px; }
  .topbar { padding: 6px 8px; gap: 6px; }
  .brand-text, .theme-btn { display: none; }
  .logo { width: 30px; height: 30px; }
  .project-btn { max-width: 38vw; padding: 6px 9px; margin-left: 0; }
  .add-text { display: none; }
  .add-btn { width: 38px; height: 38px; padding: 0; font-size: 20px; }
  .me-btn { max-width: none; padding: 3px; }
  .me-btn .me-name { display: none; }
  .tabs { top: 50px; padding: 0 4px; }
  .tabs a { padding: 10px 9px 8px; }
  .tab-icon { display: none; }
  .search { width: 100%; }
  .toolbar .grow { display: none; }
  .filters-toggle { display: inline-flex; }
  .filters { display: none; }
  .filters.open { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px 10px; padding: 0 10px; }
  .preset { white-space: nowrap; }
  .irow-q { display: none; }
  .irow-main { padding-left: 10px; }
  .irow-top .crumbs { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .fact { grid-template-columns: 1fr; gap: 2px; }
  .row2, .ev-grid { grid-template-columns: 1fr; }
  .feed-row { grid-template-columns: 1fr; gap: 2px; }
  .people-grid { grid-template-columns: 1fr; }
  .mrow { grid-template-columns: 110px 1fr 40px; }
  .prio-pick small { display: none; }
  /* Forms take the whole phone screen. */
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal, .modal-wide { width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
  .modal > form { max-height: 100%; height: 100%; }
  .modal-body { flex: 1; }
  .confirm-layer { padding: 16px; align-items: center; }
  .confirm-layer .modal { height: auto; border-radius: 14px; }
  .lb-stage { padding: 0 0 20px; }
  .lb-nav { display: none; }
  .card-media .thumb { width: 80px; height: 80px; }
}
