/* TL Media Agency — Business Hub. Brand tokens taken from tlmediallc.net:
   black #0c0c0c, gold #c9a84c / #d4b96a, ivory #f0ece4, Cormorant Garamond + Outfit. */
:root {
  /* Dark (brand default) */
  --bg: #0c0c0c;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --ink: #f0ece4;
  --ink-2: #d9d3c7;
  --muted: #9a9488;
  --line: rgb(201 168 76 / 0.16);
  --line-strong: rgb(201 168 76 / 0.34);
  --accent: #c9a84c;
  --accent-hi: #d4b96a;
  --accent-ink: #0c0c0c;
  --accent-soft: rgb(201 168 76 / 0.12);
  --btn-bg: #c9a84c;
  --btn-bg-hi: #d4b96a;
  --btn-ink: #0c0c0c;
  --warn: #e3934a;
  --warn-soft: rgb(227 147 74 / 0.14);
  --danger: #e5675c;
  --danger-soft: rgb(229 103 92 / 0.14);
  --danger-ink: #0c0c0c;
  --ok: #8cc79c;
  --ok-soft: rgb(140 199 156 / 0.13);
  --overlay: rgba(0, 0, 0, .7);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.45);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 240px;
  --font: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Cormorant Garamond", Georgia, serif;
  color-scheme: dark;
}
/* Light: ivory paper, black ink, deep gold for text-level accents (gold #c9a84c stays on buttons). */
:root[data-theme="light"] {
  --bg: #f0ece4;
  --surface: #faf8f3;
  --surface-2: #f4f0e7;
  --ink: #0c0c0c;
  --ink-2: #2e2b26;
  --muted: #66604f;
  --line: rgb(122 92 18 / 0.16);
  --line-strong: rgb(122 92 18 / 0.32);
  --accent: #7a5c12;
  --accent-hi: #6a4f0e;
  --accent-ink: #ffffff;
  --accent-soft: rgb(201 168 76 / 0.18);
  --warn: #9a520c;
  --warn-soft: rgb(227 147 74 / 0.18);
  --danger: #b42318;
  --danger-soft: rgb(229 103 92 / 0.15);
  --danger-ink: #ffffff;
  --ok: #1f6b44;
  --ok-soft: rgb(31 107 68 / 0.12);
  --overlay: rgba(12, 12, 12, .45);
  --shadow: 0 1px 2px rgba(60,45,10,.06), 0 12px 32px rgba(60,45,10,.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-family: var(--font-display); font-size: 32px; font-weight: 600; letter-spacing: 0.01em; }
h2 { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: 0.01em; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 10px; }
svg[aria-hidden="true"] { width: 1.1em; height: 1.1em; vertical-align: -0.18em; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgb(201 168 76 / .35); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 600; font-size: 21px; color: var(--accent-hi); padding: 4px 8px 20px; letter-spacing: 0.01em; line-height: 1.1; }
.brand img { width: 34px; height: 34px; object-fit: contain; flex: none; }
.brand .name { display: block; min-width: 0; }
.brand small { display: block; font-family: var(--font); font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: 0.08em; margin-top: 3px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 550; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-hi); box-shadow: inset 2px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; background: var(--warn-soft); color: var(--warn); border-radius: 99px; padding: 0 7px; font-weight: 650; }
.sidebar .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); margin-top: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-hi); border: 1px solid var(--line-strong); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.me .who { min-width: 0; line-height: 1.25; }
.me .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 10px; }
.topbar h1 { flex: 1; min-width: 0; }
.content { padding: 8px 28px 48px; flex: 1; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.tabbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 14px 16px 8px; position: sticky; top: 0; background: var(--bg); z-index: 20; }
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar h1 { font-size: 25px; flex: 1 1 0; }
  .topbar .rel { order: 2; }
  .page-actions:not(:empty) { order: 3; flex-basis: 100%; }
  .page-actions .btn { flex: 0 1 auto; }
  .content { padding: 4px 16px 96px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 600; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar svg { width: 22px; height: 22px; }
}

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px var(--font); padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; min-height: 36px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); border-radius: 999px; padding-left: 18px; padding-right: 18px; }
.btn.primary:hover { background: var(--btn-bg-hi); border-color: var(--btn-bg-hi); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); border-radius: 999px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: 13px; min-height: 30px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=url], select, textarea {
  width: 100%; font: 15px var(--font); color: var(--ink); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 11px; min-height: 38px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; padding: 4px 0; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { font: 600 13px var(--font); border: 0; background: transparent; padding: 7px 12px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1060px) { .split { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 14px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }

/* Stat strip on the dashboard: one quiet row, not four floating cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.stats > div { padding: 16px 18px; border-left: 1px solid var(--line); }
.stats > div:first-child { border-left: 0; }
.stats .v { font-family: var(--font-display); font-size: 34px; font-weight: 600; line-height: 1.1; color: var(--ink); }
.stats .l { font-size: 13px; color: var(--muted); }
.stats a.l { display: block; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr 1fr; } .stats > div:nth-child(3) { border-left: 0; } .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); } }

/* Pipeline bar on dashboard */
.pipebar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--surface-2); margin: 6px 0 12px; }
.pipebar span { display: block; height: 100%; }
.legend { display: grid; gap: 6px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-left: auto; font-weight: 600; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 11px 2px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--ink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list a.title:hover { text-decoration: underline; }

table.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:first-child td { border-top: 0; }
.table tr.rowlink { cursor: pointer; }
.table tr.rowlink:hover td { background: var(--surface-2); }
@media (max-width: 760px) {
  table.table.responsive thead { display: none; }
  table.table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border-top: 1px solid var(--line); padding: 10px 14px; }
  .table.responsive tr:first-child { border-top: 0; }
  .table.responsive td { border: 0; padding: 2px 0; }
  .table.responsive td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  .table.responsive td.primary { font-weight: 650; font-size: 16px; }
}

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; scroll-snap-type: x proximity; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 170px); scroll-snap-align: start; }
.col-head { padding: 12px 12px 8px; border-top: 4px solid var(--stage, var(--line-strong)); border-radius: var(--radius) var(--radius) 0 0; }
.col-head h3 { display: flex; align-items: center; gap: 8px; }
.col-head h3 .n { color: var(--muted); font-weight: 600; font-size: 13px; }
.col-head .sum { font-size: 13px; color: var(--muted); }
.col-body { padding: 4px 8px 10px; overflow-y: auto; flex: 1; min-height: 80px; display: flex; flex-direction: column; gap: 8px; }
.col.drop .col-body { background: var(--accent-soft); border-radius: 0 0 var(--radius) var(--radius); }
.lead-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; }
.lead-card:hover { border-color: var(--line-strong); }
.lead-card.dragging { opacity: .45; }
.lead-card .t { font-weight: 650; display: block; color: var(--ink); line-height: 1.3; }
.lead-card .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.lead-card .meta { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.lead-card .meta .val { font-weight: 650; font-size: 13px; margin-right: auto; }
.drop-marker { height: 3px; background: var(--accent); border-radius: 2px; }
@media (max-width: 860px) { .board { grid-auto-columns: 82%; } .col { max-height: none; } }

/* ---------- Content board ---------- */
.lanes { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
@media (max-width: 860px) { .lanes { grid-auto-columns: 82%; } }
.lane { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.lane > header { padding: 12px 12px 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lane > header .n { color: var(--muted); font-size: 13px; font-weight: 600; }
.lane .lane-body { padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.post-card { display: block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; color: var(--ink); }
.post-card:hover { border-color: var(--line-strong); text-decoration: none; }
.post-card .thumb { aspect-ratio: 4 / 3; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.post-card .thumb video { width: 100%; height: 100%; object-fit: cover; }
.post-card .body { padding: 9px 11px 11px; }
.post-card .t { font-weight: 650; line-height: 1.3; display: block; }
.post-card .s { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* Approval track on the post page: the one bold element of the app */
.track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 4px 0 16px; counter-reset: step; }
.track .step { position: relative; padding: 12px 10px 10px 0; border-top: 4px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; }
.track .step b { display: block; color: var(--ink-2); font-size: 15px; }
.track .step.done { border-top-color: var(--accent); }
.track .step.done b { color: var(--accent-hi); }
.track .step.now { border-top-color: var(--warn); }
.track .step.now b { color: var(--warn); }
.track .step.bad { border-top-color: var(--danger); }
.track .step.bad b { color: var(--danger); }
@media (max-width: 600px) { .track { grid-template-columns: 1fr 1fr; row-gap: 10px; } }
.next-step { border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.next-step.ok { border-left-color: var(--accent); }
.next-step.bad { border-left-color: var(--danger); }
.next-step .grow { flex: 1; min-width: 220px; }
.next-step p { margin: 2px 0 0; color: var(--muted); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.media-tile { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .file { display: grid; place-items: center; height: 100%; padding: 10px; text-align: center; font-size: 13px; color: var(--muted); word-break: break-all; }
.media-tile .tools { position: absolute; inset: auto 6px 6px 6px; display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.media-tile:hover .tools, .media-tile:focus-within .tools { opacity: 1; }
@media (hover: none) { .media-tile .tools { opacity: 1; } }
.media-tile .tools button { width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(20,22,28,.75); color: #fff; cursor: pointer; display: grid; place-items: center; }
.media-tile .tools svg { width: 15px; height: 15px; }
.uploader svg { width: 26px; height: 26px; margin-bottom: 6px; }
.uploader { border: 2px dashed var(--line-strong); border-radius: 10px; display: grid; place-items: center; text-align: center; padding: 14px; color: var(--muted); font-size: 13px; cursor: pointer; aspect-ratio: 1; }
.uploader:hover, .uploader.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.counts .over { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { position: relative; }
.chip-toggle input { position: absolute; opacity: 0; }
.chip-toggle span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 99px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); background: var(--surface); }
.chip-toggle input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .ico { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.timeline .ico svg { width: 14px; height: 14px; }
.timeline .ico.client { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.timeline .body { white-space: pre-wrap; word-break: break-word; }
.timeline .when { font-size: 12.5px; color: var(--muted); }
.composer { display: grid; gap: 8px; margin-bottom: 8px; }
.composer .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.composer .row select { width: auto; }

/* Key/value rows */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Form builder ---------- */
.fb-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.fb-row + .fb-row { margin-top: 10px; }
.fb-row .top { display: grid; grid-template-columns: 1fr 150px auto; gap: 8px; align-items: center; }
.fb-row .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 600px) { .fb-row .top { grid-template-columns: 1fr; } .fb-row .opts { grid-template-columns: 1fr; } }
.fb-row .ctl { display: flex; gap: 4px; }
code.block { display: block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12.5px; word-break: break-all; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; }

/* ---------- Modal, toast, menu ---------- */
dialog.modal { border: 1px solid var(--line-strong); padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: var(--overlay); }
dialog.modal form.inner { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
dialog.modal header { padding: 18px 20px 6px; }
dialog.modal .mbody { padding: 10px 20px; overflow-y: auto; }
dialog.modal footer { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); flex-wrap: wrap; }
dialog.modal .err { color: var(--danger); font-size: 14px; min-height: 1em; margin: 0; }
@media (max-width: 600px) {
  dialog.modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  dialog.modal footer { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
@media (max-width: 860px) { .toasts { left: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); } }
.toast { background: var(--btn-bg); color: var(--btn-ink); padding: 10px 14px; border-radius: 10px; font-weight: 550; box-shadow: var(--shadow); max-width: 420px; }
.toast.error { background: var(--danger); color: var(--danger-ink); }
.popover { position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; max-height: 70vh; overflow-y: auto; }
.popover header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.popover .nitem { display: block; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--ink); }
.popover .nitem:first-of-type { border-top: 0; }
.popover .nitem.unread { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.popover .nitem:hover { background: var(--surface-2); text-decoration: none; }
.popover .nitem b { display: block; font-weight: 650; font-size: 14px; }
.popover .nitem span { font-size: 13px; color: var(--muted); display: block; }
.rel { position: relative; }

/* ---------- Auth screens ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .panel { width: min(420px, 100%); }
.auth .mark { display: flex; flex-direction: column; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 28px; color: var(--accent-hi); margin-bottom: 22px; text-align: center; }
.auth .mark img { width: 88px; height: 88px; object-fit: contain; }
.auth .card { padding: 24px; box-shadow: var(--shadow); }
.auth h1 { font-size: 28px; margin-bottom: 6px; }
.auth .btn.primary { width: 100%; margin-top: 4px; min-height: 42px; }
.auth .err { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 4px 0 8px; }

/* ---------- Portal ---------- */
.portal-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.portal-top .brand { padding: 0; }
.portal { max-width: 860px; margin: 0 auto; padding: 24px 16px 60px; }
.portal h1 { margin-bottom: 4px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Theme picker */
.theme-pick { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px; background: var(--surface-2); }
.theme-pick button { font: 600 13px var(--font); border: 0; background: transparent; color: var(--ink-2); padding: 6px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.theme-pick button svg { width: 15px; height: 15px; }
.theme-pick button.on { background: var(--btn-bg); color: var(--btn-ink); }

/* ---------- Sidebar fits many items ---------- */
.sidebar .nav { overflow-y: auto; min-height: 0; }
.nav a { padding: 7px 10px; }

/* ---------- Service type dot ---------- */
.svc { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.svc i { width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* ---------- Timer bar ---------- */
.timer { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.timer.running { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.timer .clock { font: 600 26px var(--font-display); min-width: 96px; color: var(--accent-hi); font-variant-numeric: tabular-nums; }
.timer input, .timer select { width: auto; flex: 1 1 160px; }
.timer .grow { flex: 1 1 200px; min-width: 0; }
.daygroup { margin-top: 14px; }
.daygroup > header { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- Money / ledger ---------- */
.money-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.money-strip > div { padding: 14px 16px; border-left: 1px solid var(--line); }
.money-strip > div:first-child { border-left: 0; }
.money-strip .v { font: 600 26px/1.1 var(--font-display); }
.money-strip .l { font-size: 13px; color: var(--muted); }
.money-strip .warn { color: var(--warn); }
.money-strip .bad { color: var(--danger); }
@media (max-width: 600px) { .money-strip > div { border-left: 0; border-top: 1px solid var(--line); } .money-strip > div:first-child { border-top: 0; } }
table.ledger td.charge { color: var(--ink); }
table.ledger td.paid { color: var(--ok); }
tr.total td { font-weight: 700; border-top: 1px solid var(--line-strong); }

/* ---------- Invoice editor ---------- */
.inv-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; margin-bottom: 14px; }
.items-edit .row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 110px 110px 34px; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.items-edit .row.head { border-top: 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.items-edit .row .amt { text-align: right; font-variant-numeric: tabular-nums; }
.items-edit .row.time { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; margin: 4px -8px 0; border-top: 0; }
.items-edit .meta { font-size: 12.5px; color: var(--muted); }
@media (max-width: 700px) {
  .items-edit .row { grid-template-columns: 1fr 70px 90px 30px; }
  .items-edit .row > :nth-child(4) { display: none; }
}
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .big { font: 600 22px var(--font-display); border-top: 1px solid var(--line-strong); margin-top: 6px; padding-top: 8px; }

/* ---------- Automation builder ---------- */
.flow { position: relative; padding-left: 26px; }
.flow::before { content: ""; position: absolute; left: 10px; top: 10px; bottom: 10px; width: 2px; background: var(--line-strong); }
.flow-step { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.flow-step::before { content: attr(data-n); position: absolute; left: -26px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-strong); font-size: 11px; font-weight: 700; display: grid; place-items: center; color: var(--ink-2); }
.flow-step.trigger { border-color: var(--accent); }
.flow-step.trigger::before { content: ""; background: var(--btn-bg); border-color: var(--btn-bg); }
.flow-step.wait { background: var(--surface-2); border-style: dashed; }
.flow-step header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.flow-step header b { flex: 1; }
.flow-step .grid-2 label.field { margin-bottom: 8px; }
.var-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.var-chips button { font: 500 12px var(--font); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); border-radius: 99px; padding: 2px 8px; cursor: pointer; }
.var-chips button:hover { border-color: var(--accent); color: var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--btn-bg); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.recipe { display: flex; gap: 14px; align-items: flex-start; }
.recipe .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.recipe .ico svg { width: 20px; height: 20px; }
.log-detail { white-space: pre-wrap; font-size: 13px; color: var(--ink-2); margin-top: 4px; }

/* ---------- Tasks ---------- */
.task { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--btn-bg); flex: none; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .grow { flex: 1; min-width: 0; }
.task .t { font-weight: 600; }

table.ledger td:first-child { white-space: nowrap; }
.items-edit input, .items-edit select { min-height: 34px; padding: 6px 9px; font-size: 14px; }

.split.wide-left { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
@media (max-width: 1060px) { .split.wide-left { grid-template-columns: minmax(0, 1fr); } }
.table-scroll { overflow-x: auto; }
.items-edit .row { grid-template-columns: minmax(0, 1fr) 72px 104px 100px 32px; }

.map-table select{min-width:180px}
@media (max-width:640px){
  .map-table thead{display:none}
  .map-table,.map-table tbody,.map-table tr,.map-table td{display:block;width:100%}
  .map-table tr{padding:10px 0;border-bottom:1px solid var(--line)}
  .map-table td{border:0;padding:3px 0}
  .map-table select{width:100%;min-width:0}
}

.auth .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 14px 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.auth .seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; padding: 8px 10px; border-radius: 999px; cursor: pointer; }
.auth .seg button.on { background: var(--btn-bg); color: var(--btn-ink); }
.auth .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth .auth-alt { font-size: 14px; color: var(--muted); margin: 16px 0 0; text-align: center; line-height: 1.5; }
.auth .linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-hi); text-decoration: underline; cursor: pointer; }
.auth .linkish:disabled { opacity: .5; cursor: default; }
.auth .code-input { font-size: 26px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
