/* Controlis Hub — the ControlisOS visual language, right to left.
   Flat opaque cards, 1px hairlines, 6px radius, one teal accent, Assistant. */
* { box-sizing: border-box; font-family: 'Assistant', Arial, sans-serif; }
html, body { margin: 0; height: 100%; }
body { background: rgb(var(--c-canvas)); color: rgb(var(--c-ink)); font-size: 14px; line-height: 1.45; }
a { color: rgb(var(--c-accent-400)); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
select option { background: rgb(var(--c-surface)); color: rgb(var(--c-ink)); }
::selection { background: rgb(var(--c-accent-500) / .25); }
h1, h2, h3, h4 { margin: 0; color: rgb(var(--c-ink-strong)); }
h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: rgb(var(--c-ink-500)); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.bold { font-weight: 700; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

/* ── Shell ───────────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: 240px; z-index: 40;
  background: rgb(var(--c-surface)); border-inline-end: 1px solid rgb(var(--c-line));
  display: flex; flex-direction: column; transition: transform .2s;
}
.brand { height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid rgb(var(--c-line)); }
.brand svg { width: 22px; height: 22px; fill: rgb(var(--c-ink-strong)); }
.brand svg circle { fill: rgb(var(--c-brand-dot)); }
.brand b { font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: rgb(var(--c-ink-strong)); }
.brand span { font-size: 12px; color: rgb(var(--c-accent-400)); font-weight: 700; }
.nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-h { padding: 0 8px; height: 24px; display: flex; align-items: center; font-size: 12px; color: rgb(var(--c-ink-500)); margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px; border-radius: 4px;
  border-inline-start: 2px solid transparent; color: rgb(var(--c-ink-400)); font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgb(var(--c-ink-strong) / .06); color: rgb(var(--c-ink-200)); }
.nav-item.active { background: rgb(var(--c-accent-500) / .12); color: rgb(var(--c-ink-strong));
  border-inline-start-color: rgb(var(--c-accent-500)); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav-item .count { margin-inline-start: auto; }
.nav-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.side-foot { border-top: 1px solid rgb(var(--c-line)); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
main { flex: 1; margin-inline-start: 240px; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; border-bottom: 1px solid rgb(var(--c-line)); background: rgb(var(--c-surface));
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.page { padding: 20px 24px 40px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: rgb(var(--c-ink-500)); }
#menu-btn, #scrim { display: none; }
@media (max-width: 860px) {
  .sidebar { transform: translateX(100%); }
  body.side-open .sidebar { transform: none; }
  body.side-open #scrim { display: block; }
  #menu-btn { display: inline-flex; }
  main { margin-inline-start: 0; }
  .page { padding: 16px; }
  .topbar { padding: 0 12px; }
}
#scrim { position: fixed; inset: 0; background: rgb(var(--c-scrim) / .5); z-index: 35; }

/* ── Controls ────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 6px; border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-surface));
  color: rgb(var(--c-ink-200)); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: rgb(var(--c-surface-2)); }
.btn.primary { background: rgb(var(--c-accent-500)); border-color: rgb(var(--c-accent-500)); color: rgb(var(--c-surface)); }
:root[data-theme="dark"] .btn.primary { color: rgb(var(--c-canvas)); }
.btn.primary:hover { background: rgb(var(--c-accent-600)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgb(var(--c-ink-strong) / .06); }
.btn.outline-accent { border-color: rgb(var(--c-accent-500) / .4); color: rgb(var(--c-accent-400)); }
.btn.outline-accent:hover { background: rgb(var(--c-accent-500) / .1); }
.btn.danger { color: rgb(var(--c-bad-400)); border-color: rgb(var(--c-bad-line)); }
.btn.danger:hover { background: rgb(var(--c-bad-bg)); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn.sm.icon { width: 28px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, .select, .textarea { height: 34px; padding: 0 10px; border-radius: 6px; border: 1px solid rgb(var(--c-line));
  background: rgb(var(--c-surface)); width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: rgb(var(--c-accent-500)); box-shadow: 0 0 0 3px rgb(var(--c-accent-500) / .15); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: rgb(var(--c-ink-500)); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.search { position: relative; width: 320px; max-width: 100%; }
.search input { padding-inline-start: 32px; background: rgb(var(--c-canvas)); }
.search svg { position: absolute; inset-inline-start: 10px; top: 9px; width: 16px; height: 16px; stroke: rgb(var(--c-ink-500)); fill: none; stroke-width: 1.8; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid rgb(var(--c-line)); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 0 14px; height: 38px; display: inline-flex; align-items: center; gap: 6px; border: 0; background: none;
  border-bottom: 2px solid transparent; color: rgb(var(--c-ink-500)); font-weight: 600; white-space: nowrap; }
.tab:hover { color: rgb(var(--c-ink-200)); }
.tab.active { color: rgb(var(--c-ink-strong)); border-bottom-color: rgb(var(--c-accent-500)); }
.seg { display: inline-flex; border: 1px solid rgb(var(--c-line)); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: rgb(var(--c-surface)); height: 30px; padding: 0 12px; font-size: 13px; color: rgb(var(--c-ink-400)); }
.seg button + button { border-inline-start: 1px solid rgb(var(--c-line)); }
.seg button.active { background: rgb(var(--c-accent-500) / .12); color: rgb(var(--c-ink-strong)); font-weight: 700; }

/* ── Surfaces ────────────────────────────────────────────────────────── */
.card { background: rgb(var(--c-surface)); border: 1px solid rgb(var(--c-line)); border-radius: 6px; }
.card-h { padding: 12px 16px; border-bottom: 1px solid rgb(var(--c-line-soft)); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-b { padding: 14px 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 800; color: rgb(var(--c-ink-strong)); line-height: 1.1; }
.stat .l { font-size: 12px; color: rgb(var(--c-ink-500)); margin-top: 2px; }
.stat.bad .v { color: rgb(var(--c-bad-400)); }
.stat.accent .v { color: rgb(var(--c-accent-400)); }
.dash { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }
.empty { padding: 28px 16px; text-align: center; color: rgb(var(--c-ink-500)); }
.empty svg { width: 40px; height: 40px; stroke: rgb(var(--c-ink-700)); fill: none; stroke-width: 1.4; display: block; margin: 0 auto 8px; }

/* ── Tables / lists ──────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; color: rgb(var(--c-ink-500)); font-weight: 600; padding: 8px 12px;
  border-bottom: 1px solid rgb(var(--c-line)); background: rgb(var(--c-well)); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 8px 12px; border-bottom: 1px solid rgb(var(--c-line-soft)); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: rgb(var(--c-ink-strong) / .03); }
.table-wrap { overflow-x: auto; }
.li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid rgb(var(--c-line-soft)); cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li:hover { background: rgb(var(--c-ink-strong) / .03); }

/* ── Chips, badges, people ───────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
  background: rgb(var(--c-surface-2)); color: rgb(var(--c-ink-400)); white-space: nowrap; }
.chip.accent { background: rgb(var(--c-accent-bg)); color: rgb(var(--c-accent-400)); }
.chip.ok { background: rgb(var(--c-ok-bg)); color: rgb(var(--c-ok-400)); }
.chip.bad { background: rgb(var(--c-bad-bg)); color: rgb(var(--c-bad-400)); }
.chip.warn { background: rgb(var(--c-warn-bg)); color: rgb(var(--c-warn-400)); }
.chip.info { background: rgb(var(--c-info-bg)); color: rgb(var(--c-info-400)); }
.chip.na { background: rgb(var(--c-na-bg)); color: rgb(var(--c-na)); }
.key { font-size: 12px; color: rgb(var(--c-ink-500)); font-weight: 600; direction: ltr; unicode-bidi: isolate; }
.prio { display: inline-flex; width: 16px; justify-content: center; }
.prio i { display: block; width: 3px; border-radius: 1px; margin: 0 1px; background: rgb(var(--c-ink-700)); }
.prio.low i:nth-child(1), .prio.medium i:nth-child(-n+2), .prio.high i, .prio.urgent i { background: currentColor; }
.prio.low { color: rgb(var(--c-ink-500)); } .prio.medium { color: rgb(var(--c-info-500)); }
.prio.high { color: rgb(var(--c-warn-500)); } .prio.urgent { color: rgb(var(--c-bad-500)); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0; position: relative; color: rgb(var(--c-surface)); }
:root[data-theme="dark"] .avatar { color: rgb(var(--c-canvas)); }
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.avatar.empty { background: transparent !important; border: 1px dashed rgb(var(--c-line-strong)); color: rgb(var(--c-ink-500)); }
.avatar .on { position: absolute; bottom: -1px; inset-inline-end: -1px; width: 9px; height: 9px; border-radius: 50%;
  background: rgb(var(--c-ok-500)); border: 2px solid rgb(var(--c-surface)); }
.bar { height: 6px; background: rgb(var(--c-ink-strong) / .08); border-radius: 9999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: rgb(var(--c-accent-500)); border-radius: 9999px; transition: width .3s; }
.bar.bad > i { background: rgb(var(--c-bad-500)); } .bar.warn > i { background: rgb(var(--c-warn-500)); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: rgb(var(--c-accent-500)); color: rgb(var(--c-surface));
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
:root[data-theme="dark"] .badge { color: rgb(var(--c-canvas)); }
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.health::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.health.on_track { color: rgb(var(--c-ok-400)); } .health.at_risk { color: rgb(var(--c-attn-fill)); }
.health.late { color: rgb(var(--c-bad-400)); } .health.done { color: rgb(var(--c-na)); }

/* ── Kanban ──────────────────────────────────────────────────────────── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.column { background: rgb(var(--c-inset)); border: 1px solid rgb(var(--c-line)); border-radius: 6px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.column-h { padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-weight: 700; color: rgb(var(--c-ink-200)); }
.column-h .dot { width: 8px; height: 8px; border-radius: 50%; }
.column-b { padding: 4px 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.column.drop .column-b { background: rgb(var(--c-accent-500) / .06); }
.kcard { background: rgb(var(--c-surface)); border: 1px solid rgb(var(--c-line)); border-radius: 6px; padding: 10px 12px; cursor: grab; user-select: none; }
.kcard:hover { border-color: rgb(var(--c-line-strong)); }
.kcard.dragging { opacity: .4; }
.kcard.late { border-inline-start: 3px solid rgb(var(--c-bad-500)); }
.kcard.at_risk { border-inline-start: 3px solid rgb(var(--c-attn-fill)); }
.kcard .t { font-weight: 600; color: rgb(var(--c-ink-strong)); margin: 4px 0 8px; word-break: break-word; }
.kcard .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgb(var(--c-ink-500)); }
.kcard .meta svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.add-card { border: 1px dashed rgb(var(--c-line-strong)); background: none; border-radius: 6px; height: 32px; color: rgb(var(--c-ink-500)); }
.add-card:hover { color: rgb(var(--c-accent-400)); border-color: rgb(var(--c-accent-500)); }
.date-late { color: rgb(var(--c-bad-400)); font-weight: 700; }

/* ── Gantt (time runs left to right inside an RTL page) ──────────────── */
.gantt { display: flex; border: 1px solid rgb(var(--c-line)); border-radius: 6px; background: rgb(var(--c-surface)); overflow: hidden; height: calc(100vh - 250px); min-height: 420px; }
.g-left { width: 320px; flex-shrink: 0; border-inline-end: 1px solid rgb(var(--c-line)); display: flex; flex-direction: column; }
.g-left-h, .g-head { height: 52px; border-bottom: 1px solid rgb(var(--c-line)); background: rgb(var(--c-well)); flex-shrink: 0; }
.g-left-h { display: flex; align-items: center; padding: 0 12px; font-size: 12px; font-weight: 600; color: rgb(var(--c-ink-500)); }
.g-rows { overflow: hidden; flex: 1; }
.g-row { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid rgb(var(--c-line-soft)); cursor: pointer; }
.g-row:hover, .g-row.hl { background: rgb(var(--c-accent-500) / .06); }
.g-row.sub { padding-inline-start: 30px; }
.g-right { flex: 1; overflow: auto; direction: ltr; position: relative; }
.g-head { position: sticky; top: 0; z-index: 3; display: flex; flex-direction: column; }
.g-head .months, .g-head .days { display: flex; height: 26px; }
.g-head .months div { border-right: 1px solid rgb(var(--c-line)); font-size: 12px; font-weight: 700; padding: 5px 8px; color: rgb(var(--c-ink-300)); white-space: nowrap; overflow: hidden; }
.g-head .days div { border-right: 1px solid rgb(var(--c-line-soft)); font-size: 11px; text-align: center; padding-top: 5px; color: rgb(var(--c-ink-500)); flex-shrink: 0; }
.g-head .days div.we { background: rgb(var(--c-ink-strong) / .03); }
.g-head .days div.today { color: rgb(var(--c-accent-400)); font-weight: 800; }
.g-body { position: relative; }
.g-grid { position: absolute; inset: 0; display: flex; pointer-events: none; }
.g-grid div { border-right: 1px solid rgb(var(--c-line-soft)); flex-shrink: 0; height: 100%; }
.g-grid div.we { background: rgb(var(--c-ink-strong) / .025); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: rgb(var(--c-accent-500)); z-index: 2; pointer-events: none; }
.g-line { height: 36px; border-bottom: 1px solid rgb(var(--c-line-soft)); position: relative; }
.g-line.hl { background: rgb(var(--c-accent-500) / .06); }
.g-bar { position: absolute; top: 9px; height: 18px; border-radius: 4px; background: rgb(var(--c-accent-500) / .28);
  border: 1px solid rgb(var(--c-accent-500)); cursor: grab; z-index: 2; overflow: hidden; }
.g-bar > i { position: absolute; inset-block: 0; left: 0; background: rgb(var(--c-accent-500)); pointer-events: none; }
.g-bar > span { position: absolute; left: 6px; top: 0; font-size: 11px; line-height: 16px; font-weight: 700; color: rgb(var(--c-ink-strong)); white-space: nowrap; pointer-events: none; }
.g-bar.late { background: rgb(var(--c-bad-500) / .22); border-color: rgb(var(--c-bad-500)); }
.g-bar.late > i { background: rgb(var(--c-bad-500)); }
.g-bar.at_risk { background: rgb(var(--c-attn-fill) / .22); border-color: rgb(var(--c-attn-fill)); }
.g-bar.at_risk > i { background: rgb(var(--c-attn-fill)); }
.g-bar.done { background: rgb(var(--c-na) / .2); border-color: rgb(var(--c-na)); }
.g-bar.done > i { background: rgb(var(--c-na)); }
.g-bar .h { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; z-index: 3; }
.g-bar .h.l { left: 0; } .g-bar .h.r { right: 0; }
.g-bar .lk { position: absolute; right: -14px; top: 3px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgb(var(--c-accent-500)); background: rgb(var(--c-surface)); cursor: crosshair; display: none; }
.g-line:hover .g-bar .lk { display: block; }
.g-bar.ms { width: 16px !important; height: 16px; top: 10px; transform: rotate(45deg); border-radius: 2px; background: rgb(var(--c-info-500)); border-color: rgb(var(--c-info-500)); overflow: visible; }
.g-bar.ms.late { background: rgb(var(--c-bad-500)); border-color: rgb(var(--c-bad-500)); }
.g-bar.ms.done { background: rgb(var(--c-na)); }
.g-bar.ms > i, .g-bar.ms > span, .g-bar.ms .h { display: none; }
.g-base { position: absolute; top: 29px; height: 3px; background: rgb(var(--c-ink-600) / .55); border-radius: 2px; z-index: 1; pointer-events: none; }
.g-slip { position: absolute; top: 29px; height: 3px; background: rgb(var(--c-bad-500)); z-index: 1; pointer-events: none; }
.g-label { position: absolute; top: 10px; font-size: 11px; color: rgb(var(--c-ink-500)); white-space: nowrap; pointer-events: none; z-index: 1; }
.g-arrows { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: visible; }
.g-arrows path { fill: none; stroke: rgb(var(--c-ink-600)); stroke-width: 1.3; }
.g-arrows path.hot { stroke: rgb(var(--c-bad-500)); }
.g-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: rgb(var(--c-ink-500)); align-items: center; }
.g-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-inline-end: 4px; vertical-align: middle; }
.g-empty-bar { position: absolute; top: 9px; height: 18px; border: 1px dashed rgb(var(--c-line-strong)); border-radius: 4px; font-size: 11px; color: rgb(var(--c-ink-500)); padding: 0 6px; display: none; }

/* ── Drawer & modal ──────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgb(var(--c-scrim) / .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: rgb(var(--c-surface)); border: 1px solid rgb(var(--c-line)); border-radius: 8px; width: 520px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: 760px; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid rgb(var(--c-line)); display: flex; align-items: center; justify-content: space-between; }
.modal-b { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-f { padding: 12px 18px; border-top: 1px solid rgb(var(--c-line)); display: flex; gap: 8px; justify-content: flex-start; }
.drawer-wrap { position: fixed; inset: 0; z-index: 55; background: rgb(var(--c-scrim) / .3); }
.drawer { position: fixed; inset-block: 0; inset-inline-end: 0; width: 720px; max-width: 100%; background: rgb(var(--c-surface));
  border-inline-start: 1px solid rgb(var(--c-line)); display: flex; flex-direction: column; z-index: 56; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(-30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-h { padding: 12px 18px; border-bottom: 1px solid rgb(var(--c-line)); display: flex; align-items: center; gap: 8px; }
.drawer-b { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 230px; }
@media (max-width: 720px) { .drawer-b { grid-template-columns: 1fr; } }
.drawer-main { padding: 16px 18px; border-inline-end: 1px solid rgb(var(--c-line-soft)); min-width: 0; }
.drawer-side { padding: 16px; display: flex; flex-direction: column; gap: 12px; background: rgb(var(--c-well)); }
.title-edit { font-size: 20px; font-weight: 800; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; width: 100%; background: none; color: rgb(var(--c-ink-strong)); }
.title-edit:hover { border-color: rgb(var(--c-line)); } .title-edit:focus { border-color: rgb(var(--c-accent-500)); outline: none; }
.section-t { font-size: 12px; font-weight: 700; color: rgb(var(--c-ink-500)); margin: 18px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment .b { background: rgb(var(--c-surface-2)); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.hist { font-size: 12px; color: rgb(var(--c-ink-500)); padding: 4px 0; display: flex; gap: 6px; }
.range { width: 100%; accent-color: rgb(var(--c-accent-500)); }

/* ── Chat ────────────────────────────────────────────────────────────── */
.chat { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 56px); }
.chat-list { border-inline-end: 1px solid rgb(var(--c-line)); background: rgb(var(--c-surface)); overflow-y: auto; }
.chat-item { display: flex; gap: 10px; align-items: center; padding: 9px 14px; cursor: pointer; border-inline-start: 2px solid transparent; }
.chat-item:hover { background: rgb(var(--c-ink-strong) / .04); }
.chat-item.active { background: rgb(var(--c-accent-500) / .1); border-inline-start-color: rgb(var(--c-accent-500)); }
.chat-item .hash { width: 26px; text-align: center; color: rgb(var(--c-ink-500)); font-weight: 700; }
.chat-item.unread .n { font-weight: 800; color: rgb(var(--c-ink-strong)); }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-h { height: 56px; padding: 0 18px; border-bottom: 1px solid rgb(var(--c-line)); display: flex; align-items: center; gap: 10px; background: rgb(var(--c-surface)); }
.msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; }
.msg { display: flex; gap: 10px; padding: 4px 6px; border-radius: 6px; }
.msg:hover { background: rgb(var(--c-ink-strong) / .03); }
.msg.cont { padding-top: 0; } .msg.cont .avatar { visibility: hidden; height: 0; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg .acts { margin-inline-start: auto; display: none; gap: 2px; }
.msg:hover .acts { display: flex; }
.day-sep { text-align: center; font-size: 12px; color: rgb(var(--c-ink-500)); margin: 14px 0 6px; display: flex; align-items: center; gap: 10px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: rgb(var(--c-line)); }
.fileblob { display: inline-flex; align-items: center; gap: 10px; border: 1px solid rgb(var(--c-line)); border-radius: 6px; padding: 8px 12px; margin-top: 4px; background: rgb(var(--c-surface)); max-width: 360px; }
.fileblob img { max-width: 320px; max-height: 220px; border-radius: 4px; display: block; }
.composer { border-top: 1px solid rgb(var(--c-line)); padding: 12px 18px; background: rgb(var(--c-surface)); }
.composer .box { display: flex; gap: 8px; align-items: flex-end; border: 1px solid rgb(var(--c-line)); border-radius: 8px; padding: 6px; background: rgb(var(--c-canvas)); }
.composer textarea { flex: 1; border: 0; background: none; resize: none; outline: none; min-height: 24px; max-height: 160px; padding: 6px; }
.typing { font-size: 12px; color: rgb(var(--c-ink-500)); height: 16px; padding: 0 18px; }
@media (max-width: 760px) { .chat { grid-template-columns: 1fr; } .chat.has-active .chat-list { display: none; } .chat:not(.has-active) .chat-main { display: none; } }

/* ── Drive ───────────────────────────────────────────────────────────── */
.drive { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
@media (max-width: 860px) { .drive { grid-template-columns: 1fr; } .drive .tree { display: none; } }
.tree { padding: 8px; max-height: calc(100vh - 180px); overflow-y: auto; }
.tree-item { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px; border-radius: 4px; cursor: pointer; color: rgb(var(--c-ink-400)); font-size: 13px; }
.tree-item:hover { background: rgb(var(--c-ink-strong) / .05); }
.tree-item.active { background: rgb(var(--c-accent-500) / .12); color: rgb(var(--c-ink-strong)); font-weight: 600; }
.tree-item svg, .ficon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; flex-shrink: 0; }
.ficon.folder { stroke: rgb(var(--c-accent-400)); }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 14px; }
.crumbs a { color: rgb(var(--c-ink-400)); } .crumbs a:last-child { color: rgb(var(--c-ink-strong)); font-weight: 700; }
.dropzone.over { outline: 2px dashed rgb(var(--c-accent-500)); outline-offset: -6px; background: rgb(var(--c-accent-500) / .04); }

/* ── Popover / menus / toasts ───────────────────────────────────────── */
.pop { position: absolute; z-index: 80; background: rgb(var(--c-surface)); border: 1px solid rgb(var(--c-line)); border-radius: 6px;
  box-shadow: 0 8px 24px rgb(var(--c-scrim) / .14); min-width: 220px; max-height: 380px; overflow-y: auto; padding: 4px; }
.pop .opt { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.pop .opt:hover, .pop .opt.sel { background: rgb(var(--c-accent-500) / .1); }
.notif { padding: 10px 12px; border-bottom: 1px solid rgb(var(--c-line-soft)); cursor: pointer; font-size: 13px; }
.notif.unread { background: rgb(var(--c-accent-500) / .06); }
#toasts { position: fixed; bottom: 16px; left: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: rgb(var(--c-surface)); border: 1px solid rgb(var(--c-line)); border-inline-start: 3px solid rgb(var(--c-accent-500));
  border-radius: 6px; padding: 10px 14px; min-width: 260px; max-width: 380px; box-shadow: 0 6px 20px rgb(var(--c-scrim) / .14); animation: pop .15s; }
.toast.bad { border-inline-start-color: rgb(var(--c-bad-500)); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Login ───────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; width: 100%; }
.login .card { width: 380px; max-width: 100%; padding: 28px; }
.login .brand { border: 0; padding: 0; height: auto; margin-bottom: 18px; }
.err { color: rgb(var(--c-bad-400)); font-size: 13px; min-height: 18px; }

/* bar chart */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.chart .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .bars i { width: 40%; max-width: 16px; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .bars i.a { background: rgb(var(--c-line-strong)); } .chart .bars i.b { background: rgb(var(--c-accent-500)); }
.legend-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: middle; }
.row > .bar { flex: 1; min-width: 40px; }
/* Phone widths: nothing may push the page wider than the screen. */
.dash > *, .drive > *, .grid2 > *, .grid3 > * { min-width: 0; }
@media (max-width: 1100px) { .dash { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .topbar .search { display: none; }
  #quick-add { width: 34px; padding: 0; font-size: 0; gap: 0; }
  .page-head { align-items: flex-start; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-auto-columns: minmax(260px, 85vw); }
  .g-left { width: 150px; }
  .g-left .g-row .avatar, .g-left .g-row .key { display: none; }
  .li { padding: 9px 12px; flex-wrap: wrap; }
  .modal-f { flex-wrap: wrap; }
}
.card-h { flex-wrap: wrap; } .card-h > * { min-width: 0; }

/* Google's sign-in button keeps Google's branding (white, dark text) in both themes, as in ControlisOS. */
.gsi-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 38px; width: 100%;
  border-radius: 6px; border: 1px solid #dadce0; background: #fff; color: #1f1f1f; font-weight: 600; font-size: 14px; }
.gsi-btn:hover { background: #f1f3f4; }
.gsi-btn:disabled { opacity: .6; cursor: wait; }
.switch { position: relative; width: 36px; height: 20px; border-radius: 10px; border: 0; background: rgb(var(--c-ink-700)); flex-shrink: 0; transition: background .15s; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%; background: rgb(var(--c-surface)); transition: right .15s; }
.switch.on { background: rgb(var(--c-accent-500)); }
.switch.on::after { right: 18px; }
.switch:disabled { opacity: .5; cursor: wait; }
