/* FollowUp Desk */
:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #f0f3ef;
  --border: #e1e6e0;
  --text: #17201c;
  --muted: #66736c;
  --accent: #0e9f6e;
  --accent-ink: #ffffff;
  --accent-soft: #dff5ea;
  --wa: #1fa855;
  --danger: #d0372f;
  --warn: #c26a00;
  --good: #0e8a5f;
  --side: #0f2a24;
  --side-text: #c9d8d1;
  --side-active: #1b4036;
  --shadow: 0 1px 2px rgba(16, 32, 26, .06), 0 4px 14px rgba(16, 32, 26, .05);
  --radius: 12px;
  --s1: #0e9f6e; --s2: #f2a516; --s3: #7c8cf0;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1412;
  --surface: #171e1b;
  --surface-2: #1e2723;
  --border: #2a3530;
  --text: #e4ebe7;
  --muted: #93a29a;
  --accent: #22c08a;
  --accent-ink: #062018;
  --accent-soft: #163a2e;
  --wa: #25c264;
  --danger: #ff6b61;
  --warn: #f0a640;
  --good: #3fd49b;
  --side: #0a110f;
  --side-text: #b5c4bd;
  --side-active: #18302a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --s1: #22c08a; --s2: #f2b440; --s3: #8f9dff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.danger { color: var(--danger); }
.warn { color: var(--warn); }
.good { color: var(--good); }
.danger-text { color: var(--danger) !important; }
.pre { white-space: pre-wrap; word-break: break-word; }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.push { margin-left: auto; }
.grow { flex: 1; min-width: 0; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 228px 1fr; height: 100vh; }
.side {
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; font-size: 17px; padding: 0 8px; }
.brand b { color: #5ee0ab; font-weight: 700; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #10b981, #0b7a55); color: #fff;
}
.brand-mark.big { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px;
  text-decoration: none; color: var(--side-text); font-weight: 500;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #34d399; }
.badge {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: #f97316; color: #fff; font-size: 11px; text-align: center; font-weight: 700;
}
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.side-note { font-size: 12px; opacity: .75; }
.install-btn { align-self: flex-start; border: 1px solid rgba(255, 255, 255, .25); background: rgba(52, 211, 153, .15); color: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.install-btn:hover { background: rgba(52, 211, 153, .3); }
.seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.seg.mini { background: rgba(255, 255, 255, .06); border-radius: 9px; padding: 3px; align-self: flex-start; }
.seg.mini button { border: 0; background: none; color: var(--side-text); width: 32px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 15px; }
.seg.mini button.active { background: rgba(255, 255, 255, .14); color: #fff; }

main { overflow-y: auto; padding: 28px 32px 60px; outline: none; }
main > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
main > .board, main > .tabs, main > .board-search { max-width: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; cursor: pointer; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 550;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { filter: brightness(1.07); }
.btn.success { background: var(--accent-soft); border-color: transparent; color: var(--good); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn-row.center { justify-content: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  border: 1px solid var(--border); background: var(--surface); border-radius: 9px;
  padding: 8px 10px; min-height: 36px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field > input, .field > select, .field > textarea { color: var(--text); font-weight: 400; font-size: 14px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline select { width: auto; min-width: 160px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 .wide { grid-column: 1 / -1; }
.label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.hint { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 220px; }
.search .ic { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 150px; }

/* ---------- Cards, stats, lists ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 1px 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col > .card { margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stats.six { grid-template-columns: repeat(6, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-num { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }

.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 8px; border-radius: 10px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.list > .row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.list.compact .row { padding: 8px 6px; }
.row-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; font-weight: 600; white-space: nowrap; }
.snooze { width: auto; min-height: 30px; height: 30px; padding: 0 8px; font-size: 13px; }
.group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 4px 4px; }
.group-label:first-child { margin-top: 2px; }
.group-label.danger { color: var(--danger); }

.empty { text-align: center; padding: 28px 12px; }
.empty-title { font-weight: 650; margin-bottom: 4px; }

.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--c-bg); color: var(--c-fg);
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.pill { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--c-bg); color: var(--c-fg); white-space: nowrap; }
.tag { display: inline-flex; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.chip { display: inline-flex; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--good); border: 0; cursor: pointer; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-fg); flex: none; }

/* colour tokens */
.c-blue { --c-bg: #e3edff; --c-fg: #2559c7; }
.c-slate { --c-bg: #e8ecef; --c-fg: #4b5a66; }
.c-violet { --c-bg: #eee7ff; --c-fg: #6b3fd4; }
.c-amber { --c-bg: #fff2d6; --c-fg: #9a6200; }
.c-orange { --c-bg: #ffe8da; --c-fg: #c2510c; }
.c-green { --c-bg: #dcf6e8; --c-fg: #0d7f52; }
.c-red { --c-bg: #fde4e2; --c-fg: #c3342b; }
.c-teal { --c-bg: #d9f4f4; --c-fg: #0f7c80; }
.c-pink { --c-bg: #fde4f1; --c-fg: #b5306f; }
[data-theme="dark"] .c-blue { --c-bg: #1b2a45; --c-fg: #8db4ff; }
[data-theme="dark"] .c-slate { --c-bg: #262f35; --c-fg: #aebbc5; }
[data-theme="dark"] .c-violet { --c-bg: #2a2243; --c-fg: #b9a0ff; }
[data-theme="dark"] .c-amber { --c-bg: #3a2e12; --c-fg: #f4c25b; }
[data-theme="dark"] .c-orange { --c-bg: #3d2416; --c-fg: #ffa36b; }
[data-theme="dark"] .c-green { --c-bg: #15352a; --c-fg: #5fdca6; }
[data-theme="dark"] .c-red { --c-bg: #3d1d1b; --c-fg: #ff8a80; }
[data-theme="dark"] .c-teal { --c-bg: #123536; --c-fg: #6fe0e3; }
[data-theme="dark"] .c-pink { --c-bg: #3b1a2b; --c-fg: #ff8cc2; }

/* ---------- Table ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-lead { display: flex; align-items: center; gap: 10px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 12px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab.add { margin-left: auto; color: var(--accent); }

/* ---------- Kanban ---------- */
.board-search { max-width: 360px !important; margin: 0 0 14px !important; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.kcol { flex: 0 0 264px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); transition: box-shadow .12s, border-color .12s; }
.kcol.over { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kcol-head { padding: 12px 12px 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 3px solid var(--c-fg); border-radius: var(--radius) var(--radius) 0 0; }
.kcol-head b { font-size: 13.5px; }
.kcol-head .count { margin-left: auto; background: var(--surface); }
.kcol-total { width: 100%; font-size: 12px; color: var(--muted); font-weight: 600; }
.kcol-body { padding: 4px 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kcol-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 18px 0; border: 1.5px dashed var(--border); border-radius: 10px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; cursor: grab; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 5px; }
.kcard:hover { border-color: var(--accent); }
.kcard.dragging { opacity: .45; }
.kc-top { display: flex; align-items: center; gap: 8px; }
.kc-top b { font-size: 13.5px; }
.kc-line { font-size: 12.5px; color: var(--muted); }
.kc-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12.5px; }
.kc-foot .small { display: inline-flex; gap: 3px; align-items: center; }
.kc-val { font-weight: 700; }

/* ---------- Tasks ---------- */
.quick-add { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.quick-add > .ic { color: var(--muted); }
.quick-add input[name=title] { border: 0; box-shadow: none; flex: 1; padding-left: 0; }
.quick-add select { width: auto; }
.check {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); background: transparent;
  display: grid; place-items: center; cursor: pointer; color: #fff; padding: 0;
}
.check.p-high { border-color: var(--danger); }
.check.p-medium { border-color: var(--warn); }
.check.p-low { border-color: var(--muted); }
.check:hover { background: var(--accent-soft); }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .row-title { text-decoration: line-through; color: var(--muted); }
.subtasks { display: flex; flex-direction: column; gap: 4px; }
.subtask { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); font-size: 14px; }
.subtask input { width: 16px; min-height: 16px; height: 16px; flex: none; }
.subtask span { flex: 1; }

/* ---------- Templates ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.tpl { cursor: pointer; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.tpl:hover { border-color: var(--accent); }
.tpl-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.bubble { background: #dcf8c6; color: #10201a; padding: 10px 12px; border-radius: 4px 12px 12px 12px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; }
[data-theme="dark"] .bubble { background: #134d37; color: #e6f5ec; }
.vars summary { cursor: pointer; font-weight: 600; }
.var-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin-top: 12px; font-size: 13px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.var-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Dashboard ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .s1, .legend .s1 { fill: var(--s1); background: var(--s1); }
.chart .s2, .legend .s2 { fill: var(--s2); background: var(--s2); }
.chart .s3, .legend .s3 { fill: var(--s3); background: var(--s3); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { background: var(--surface-2); border-radius: 99px; height: 10px; overflow: hidden; }
.hb-fill { background: var(--accent); height: 100%; border-radius: 99px; min-width: 3px; }
.hb-val { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Settings ---------- */
.form-card h2 { margin-bottom: 4px; }
.form-card .grid2 { margin-top: 12px; }
.theme-seg { margin-top: 10px; }
.data-counts { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0 10px; }
.data-counts div { display: flex; flex-direction: column; }
.data-counts b { font-size: 20px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone .btn-row { margin-top: 10px; }

/* ---------- Modals ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(8, 18, 14, .45); display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50; opacity: 0; transition: opacity .15s;
}
.overlay.show { opacity: 1; }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  width: 100%; max-width: 460px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden;
}
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal.md { max-width: 620px; }
.modal.sm { max-width: 420px; }
.m-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.m-head h2 { flex: 1; }
.m-head .grow h2 { flex: none; }
.m-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.m-body.grid2 { display: grid; }
.m-body > * { flex-shrink: 0; }
input::placeholder { text-transform: none; }
.m-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.welcome { padding: 30px 28px 26px; text-align: center; }
.welcome h2 { font-size: 22px; margin-bottom: 6px; }
.welcome .grid2 { text-align: left; margin-top: 20px; }
.welcome .btn-row { margin-top: 20px; }

.overlay:has(.drawer) { justify-content: flex-end; padding: 0; }
.modal.drawer { max-width: 520px; height: 100vh; max-height: 100vh; border-radius: 0; transform: translateX(30px); transition: transform .18s; }
.overlay.show .modal.drawer { transform: none; }
.dr-head { display: flex; gap: 14px; align-items: center; padding: 20px 20px 12px; }
.dr-head h2 { font-size: 19px; }
.dr-actions { display: flex; gap: 8px; padding: 0 20px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.dr-body { overflow-y: auto; padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 16px; }
.dr-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dr-follow { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.dr-follow .big { font-size: 16px; font-weight: 700; margin: 2px 0; }
.dr-follow .big.muted { color: var(--text); }
.follow-ctl { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.follow-ctl input { width: 160px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.facts dd { margin: 2px 0 0; }
.dr-sec h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; }
.inline-form input[name=due] { width: 150px; flex: none; }
.note-form { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; margin-bottom: 14px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { display: flex; gap: 10px; font-size: 13.5px; }
.tl-ic { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.tl-ic.t-whatsapp { background: #dcf8c6; color: #128c4b; }
.tl-ic.t-call { background: #e3edff; color: #2559c7; }
.tl-ic.t-stage { background: #fff2d6; color: #9a6200; }
.tl-ic.t-task { background: var(--accent-soft); color: var(--good); }
[data-theme="dark"] .tl-ic.t-whatsapp { background: #134d37; color: #7ee2a8; }
[data-theme="dark"] .tl-ic.t-call { background: #1b2a45; color: #8db4ff; }
[data-theme="dark"] .tl-ic.t-stage { background: #3a2e12; color: #f4c25b; }

/* ---------- Billing ---------- */
.modal.xl { max-width: 1120px; }
.notice { display: flex; align-items: center; gap: 12px; border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.billing-stats { cursor: pointer; }
.billing-stats .stat:hover { border-color: var(--accent); }
.doc-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.doc-grid.bottom { grid-template-columns: 1fr 340px; align-items: start; }
.grid2.one { grid-template-columns: 1fr; }
.doc-box { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.box-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.items-wrap { overflow-x: auto; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.items-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.items-table th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.items-table td { padding: 6px 4px; vertical-align: top; border-bottom: 1px solid var(--border); }
.items-table input, .items-table select { min-height: 32px; padding: 5px 7px; }
.it-name { min-width: 240px; }
.it-desc { margin-top: 4px; font-size: 12.5px; }
.w-hsn { width: 84px; } .w-num { width: 66px; } .w-unit { width: 64px; } .w-rate { width: 104px; }
.it-amt { padding-top: 12px !important; font-weight: 600; white-space: nowrap; }
.totals { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums; }
.totals > div:not(.words):not(.small) { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand { font-size: 18px; font-weight: 750; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
.totals .words { font-size: 12px; font-style: italic; color: var(--muted); }
.push-right { margin-right: auto; }
.doc-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.doc-view { display: grid; grid-template-columns: 1fr 260px; min-height: 0; flex: 1; overflow: hidden; }
.doc-view:not(:has(.pay-side)) { grid-template-columns: 1fr; }
.doc-frame { width: 100%; height: 72vh; border: 0; background: #e9eeeb; }
.pay-side { border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.pay-sum { display: flex; flex-direction: column; gap: 8px; }
.pay-sum div { display: flex; justify-content: space-between; align-items: baseline; }
.pay-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pay-list li { display: flex; justify-content: space-between; align-items: center; background: var(--surface-2); border-radius: 9px; padding: 8px 10px; }
.wide-btn { width: 100%; }
.pay-list li.clickable { cursor: pointer; }
.pay-list li.clickable:hover { background: var(--accent-soft); }
.pay-side h3 { margin-top: 4px; }
.dr-sec h3 .btn { font-weight: 550; }

/* ---------- Calendar ---------- */
.cal-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-bar h2 { font-size: 18px; }
.cal-bar .seg .btn.sm { min-width: 34px; }
.ev {
  display: flex; align-items: center; gap: 5px; width: 100%; border: 0; text-align: left; cursor: pointer;
  background: var(--c-bg); color: var(--c-fg); border-left: 3px solid var(--c-fg); border-radius: 5px;
  padding: 2px 6px; font-size: 12px; line-height: 1.35; overflow: hidden; white-space: nowrap;
}
.ev:hover { filter: brightness(.97); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.ev.done { opacity: .55; text-decoration: line-through; }
.ev.more { background: none; border: 0; color: var(--muted); padding-left: 4px; }
.ev-time { font-weight: 700; flex: none; }
.ev-title { overflow: hidden; text-overflow: ellipsis; }
.ev-rep { margin-left: auto; opacity: .7; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(var(--weeks), minmax(112px, 1fr));
  background: var(--border); gap: 1px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.mhead { background: var(--surface-2); padding: 8px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mcell { background: var(--surface); padding: 4px 5px 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; }
.mcell:hover { background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.mcell.other { background: var(--surface-2); }
.mcell.other .mnum { color: var(--muted); }
.mnum { align-self: flex-start; border: 0; background: none; font-weight: 650; font-size: 13px; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; padding: 0; }
.mnum:hover { background: var(--surface-2); }
.mcell.today .mnum { background: var(--accent); color: var(--accent-ink); }
.mevs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mextra { font-size: 11px; color: var(--muted); margin-top: auto; }
.week { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.whead, .wallday { display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.wday { border: 0; background: none; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; cursor: pointer; color: var(--muted); }
.wday b { font-size: 18px; color: var(--text); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.wday.today b { background: var(--accent); color: var(--accent-ink); }
.wlabel { font-size: 11px; color: var(--muted); padding: 6px; text-align: right; }
.wad { border-left: 1px solid var(--border); padding: 3px; min-height: 30px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.wbody { display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); max-height: calc(100vh - 300px); min-height: 320px; overflow-y: auto; }
.wtimes div { font-size: 11px; color: var(--muted); text-align: right; padding: 0 8px; transform: translateY(-7px); }
.wtimes div:first-child { transform: none; }
.wcol { position: relative; border-left: 1px solid var(--border); }
.wcol.today { background: color-mix(in srgb, var(--accent-soft) 30%, transparent); }
.wslot { border-top: 1px solid var(--border); cursor: pointer; }
.wslot:hover { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.wev-pos { position: absolute; display: flex; z-index: 1; }
.wev-pos .ev { height: 100%; align-items: flex-start; flex-wrap: wrap; white-space: normal; padding-top: 3px; }
.wev-pos.short .ev { flex-wrap: nowrap; white-space: nowrap; align-items: center; padding-top: 0; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.appt-row .appt-time { width: 64px; display: flex; flex-direction: column; font-size: 13px; flex: none; }
.appt-row.done .row-title, .appt-row.past .row-title { color: var(--muted); }
.appt-row.done .row-title { text-decoration: line-through; }
.bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c-fg); flex: none; min-height: 28px; }
.bar.tall { min-height: 40px; }
.muted-row { opacity: .7; }
.appt-facts { display: flex; flex-direction: column; gap: 10px; }
.appt-facts > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.appt-facts .ic { color: var(--muted); }
.m-foot.wrap { flex-wrap: wrap; }
.inline-check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14px; min-height: 36px; }
.inline-check input { width: 16px; min-height: 16px; height: 16px; }
.group-label.good { color: var(--good); }
#reminders { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; width: min(380px, calc(100vw - 36px)); }
.reminder { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); animation: pop .2s ease-out; }
.rem-ic { color: var(--accent); }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Import ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 38px 20px; border: 2px dashed var(--border); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.dz-ic { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--good); margin-bottom: 6px; }
details.card summary { cursor: pointer; }
details.card textarea { margin-top: 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.tips { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.imp-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.imp-grid > .card { margin-bottom: 16px; }
.map-table td { vertical-align: middle; }
.map-table select { min-width: 170px; }
.map-table tbody tr { cursor: default; }
.map-table .unmapped td:not(:last-child) { opacity: .55; }
.sample { color: var(--muted); max-width: 240px; line-height: 1.5; }
.imp-counts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
button.pill { border: 0; cursor: pointer; font-family: inherit; }
.pill.sel { outline: 2px solid var(--c-fg); outline-offset: 1px; }
.imp-preview { max-height: 460px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.imp-preview thead th { position: sticky; top: 0; z-index: 1; }
.imp-preview tbody tr { cursor: default; }
.row-err td { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.imp-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.done-card { text-align: center; padding: 36px 20px; }
.done-ic { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); margin: 0 auto 14px; }
.done-card p { margin-top: 6px; }

/* ---------- Reports ---------- */
.page-head .actions input[type=date] { width: auto; }
.page-head .actions select { width: auto; }
.rep-table tbody tr { cursor: default; }
.rep-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface-2); padding: 10px 14px; }
.rep-card .table-wrap { border: 1px solid var(--border); border-radius: 10px; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.fn-row { display: grid; grid-template-columns: minmax(120px, 40%) 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.fn-track { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.fn-bar { height: 100%; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #7c8cf0)); border-radius: 6px; }
.fn-val { text-align: right; white-space: nowrap; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.print-only { display: none; }
@media print {
  .side, .no-print, #toast, #reminders, #modal-root { display: none !important; }
  .app { display: block; height: auto; }
  main { overflow: visible; padding: 0; }
  body { background: #fff; }
  .card, .stat { box-shadow: none; break-inside: avoid; }
  .print-only { display: block; margin-bottom: 12px; }
  .stats.six { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
}

/* ---------- Medisfera: sign-in, roles, hospital admin ---------- */
#auth-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% 0%, #1b4036, var(--side)); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; padding: 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand h1 { font-size: 21px; margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .btn { height: 42px; }
.auth-msg { font-size: 13px; min-height: 1em; margin: 0; }
.auth-form .link { align-self: center; }
.whoami { display: flex; flex-direction: column; font-size: 12.5px; line-height: 1.3; color: #fff; }
.whoami span { color: var(--side-text); opacity: .8; font-size: 11.5px; }
.seg.mini .signout-btn { margin-left: 4px; }
.modal.lg { max-width: 820px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.grid3 .span2 { grid-column: span 2; }
.grid3 .wide, .grid2 .wide { grid-column: 1 / -1; }
.m-body.grid3 { display: grid; }
.consent-box { display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.consent-box .inline-check { min-height: 0; font-size: 13.5px; }
.notice-line { font-size: 13px; padding: 8px 12px; border-radius: 9px; background: color-mix(in srgb, var(--warn) 12%, transparent); }
details.attr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
details.attr summary { cursor: pointer; font-weight: 600; font-size: 13px; }
details.attr .facts { margin-top: 10px; }
.cal-doc { width: auto; min-width: 180px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.role-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.role-card p { margin-top: 4px; }
.team-table select { width: auto; min-width: 160px; }
.url-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.url-list dt { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.url-list dd { margin: 3px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.url-list code { word-break: break-all; }
.conv-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin: 12px 0; }
.conv-map .field.inline { justify-content: space-between; }
.conv-map .field.inline span { color: var(--text); font-weight: 500; }
.conv-map select { width: 170px; }
.privacy-note { display: flex; gap: 10px; background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.privacy-note .ic { flex: none; margin-top: 2px; color: var(--good); }
.sub-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.tpl-map { display: grid; grid-template-columns: 160px 1fr 1.4fr; gap: 8px; align-items: center; margin-top: 8px; font-size: 13.5px; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font: 12.5px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; margin: 10px 0; }
@media (max-width: 860px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .tpl-map { grid-template-columns: 1fr; }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #13241e; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-weight: 550; opacity: 0; pointer-events: none; transition: .2s; z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats.six { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; padding: 8px 10px; gap: 10px; overflow-x: auto; }
  .brand > span:last-child, .side-foot { display: none; }
  #nav { flex-direction: row; gap: 2px; }
  .nav-item { padding: 8px 10px; gap: 6px; font-size: 13px; }
  .nav-item.active { box-shadow: inset 0 -3px 0 #34d399; }
  main { padding: 18px 14px 60px; }
  .two-col, .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats.six { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
  .snooze { display: none; }
  .row-meta { display: none; }
  .modal.drawer { max-width: 100%; }
  .doc-grid, .doc-grid.bottom, .doc-view { grid-template-columns: 1fr; }
  .pay-side { border-left: 0; border-top: 1px solid var(--border); }
  .doc-frame { height: 60vh; }
  .month { grid-template-rows: auto repeat(var(--weeks), minmax(72px, 1fr)); }
  .imp-grid { grid-template-columns: 1fr; }
  .mevs .ev-time, .mextra { display: none; }
  .whead, .wallday, .wbody { grid-template-columns: 44px repeat(7, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .nav-item span { display: none; }
  .nav-item .badge { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
