/* EM-IT — calm greys, near-black buttons, logo red used sparingly. */
:root {
  --bg: #f6f7f9; --card: #ffffff; --card-2: #f1f3f5; --line: #e3e6ea; --line-2: #d4d8de;
  --ink: #161b22; --ink-2: #3b434d; --mute: #6b7480;
  --brand: #e10600; --brand-soft: #fdeceb;
  --primary: #1d2530; --primary-ink: #ffffff; --primary-hover: #2c3642;
  --honey: #f6d58a; --honey-bg: #fdf3da; --honey-ink: #7a5300;
  --ok: #1f7a4d; --ok-bg: #e3f4ea;
  --out-bg: #eef2f6; --note-bg: #fbfbf7;
  --danger: #c62828;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --r: 12px; --r-sm: 8px;
  --side: 232px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --card: #191d23; --card-2: #20252c; --line: #2a3039; --line-2: #363d47;
    --ink: #e8ebef; --ink-2: #c3c9d1; --mute: #8d96a2;
    --brand: #ff4b40; --brand-soft: #3a1d1c;
    --primary: #e8ebef; --primary-ink: #111418; --primary-hover: #ffffff;
    --honey: #8a6a20; --honey-bg: #2e2716; --honey-ink: #f2cf7c;
    --ok: #5cc28d; --ok-bg: #16291f;
    --out-bg: #1f2833; --note-bg: #1c1f22;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --card: #191d23; --card-2: #20252c; --line: #2a3039; --line-2: #363d47;
  --ink: #e8ebef; --ink-2: #c3c9d1; --mute: #8d96a2;
  --brand: #ff4b40; --brand-soft: #3a1d1c;
  --primary: #e8ebef; --primary-ink: #111418; --primary-hover: #ffffff;
  --honey: #8a6a20; --honey-bg: #2e2716; --honey-ink: #f2cf7c;
  --ok: #5cc28d; --ok-bg: #16291f;
  --out-bg: #1f2833; --note-bg: #1c1f22;
  --danger: #ff6b6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h3 { font-size: 17px; margin-bottom: 8px; }
p { margin: 0 0 10px; }
code { font: 13px ui-monospace, Consolas, monospace; background: var(--card-2); padding: 2px 5px; border-radius: 5px; word-break: break-all; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ic.big { width: 40px; height: 40px; color: var(--mute); margin-bottom: 6px; }
.muted { color: var(--mute); }
.small, small { font-size: 13px; }
.block { display: block; }
.center { text-align: center; }
.grow { flex: 1; }
.pad { padding: 12px 14px; }
.mt { margin-top: 14px; }
.honey-text { color: var(--honey-ink); }
.ok-text { color: var(--ok); }
.danger-text { color: var(--danger) !important; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.sidenav { display: none; }
.main { min-height: 100vh; padding-bottom: calc(70px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); min-height: 56px;
}
.topbar h1 { font-size: 20px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topActions { display: flex; gap: 6px; align-items: center; }
#view { padding: 4px 16px 24px; max-width: 1200px; margin: 0 auto; }
.narrow { max-width: 680px; margin: 0 auto; }
.narrow-wide { max-width: 860px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11.5px; color: var(--mute); text-decoration: none; font-weight: 500; }
.tabbar .ti { position: relative; display: grid; place-items: center; width: 52px; height: 28px; border-radius: 14px; }
.tabbar .ic { width: 22px; height: 22px; }
.tabbar a.active { color: var(--ink); }
.tabbar a.active .ti { background: var(--brand-soft); color: var(--brand); }
.tabbar .nav-badge { position: absolute; top: -2px; right: 4px; }

.nav-badge, .nav-badge-soft { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.nav-badge { background: var(--brand); color: #fff; }
.nav-badge-soft { background: var(--card-2); color: var(--ink-2); }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .main { margin-left: var(--side); padding-bottom: 0; }
  .sidenav {
    display: flex; flex-direction: column; gap: 2px; position: fixed; inset: 0 auto 0 0; width: var(--side);
    padding: 16px 12px; background: var(--card); border-right: 1px solid var(--line); z-index: 30;
  }
  .sidenav .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: .3px; }
  .sidenav .newbtn { margin: 0 4px 12px; }
  .sidenav > a[data-tab] { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
  .sidenav > a[data-tab].sub { padding-left: 22px; font-size: 14px; }
  .sidenav > a[data-tab] .nav-badge, .sidenav > a[data-tab] .nav-badge-soft { margin-left: auto; }
  .sidenav > a[data-tab]:hover { background: var(--card-2); }
  .sidenav > a[data-tab].active { background: var(--brand-soft); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
  .sidenav > a[data-tab].active .ic { color: var(--brand); }
  .topbar { padding: 14px 24px; }
  #view { padding: 4px 24px 32px; }
  .hide-sm { display: inline; }
  body[data-route="t"] #view, body[data-route="inbox"] #view { max-width: none; }
}
@media (max-width: 899px) { .hide-sm { display: none; } }

.demo-bar { background: var(--honey-bg); color: var(--honey-ink); font-size: 13px; text-align: center; padding: 6px 12px; }

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--card-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { display: flex; width: 100%; }
.btn.running { border-color: var(--ok); color: var(--ok); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--card-2); }
.icon-btn .ic { width: 20px; height: 20px; }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.btn-row.end { justify-content: flex-end; margin-bottom: 0; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 9px 11px; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--ink) 25%, transparent); outline-offset: 0; border-color: var(--ink-2); }
select.sm { width: auto; padding: 6px 10px; font-size: 13px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form label small { font-weight: 400; color: var(--mute); }
.form label.check, label.check { flex-direction: row; align-items: flex-start; gap: 9px; font-weight: 500; font-size: 14px; color: var(--ink); cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.row2, .row3 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .row3 { grid-template-columns: 1fr 1fr; } }
.inline { display: flex; gap: 8px; align-items: center; }
.err { color: var(--danger); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); font: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink); cursor: pointer; }
.chips.radio .chip input { display: none; }
.chips.radio .chip:has(input:checked) { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.chips.static .chip { cursor: default; }
.form .chips label.chip { flex-direction: row; font-weight: 500; color: var(--ink); font-size: 13.5px; }

/* ---------- Cards, lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card.list { padding: 0; overflow: hidden; }
h2.section { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--mute); margin: 22px 2px 8px; }
h2.section .count { background: var(--card-2); color: var(--ink-2); border-radius: 999px; padding: 0 8px; font-size: 12px; }
h2.section.honey { color: var(--honey-ink); }
h2.section.honey .count { background: var(--honey-bg); color: var(--honey-ink); }
h2.section .hint { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 12px; margin-left: auto; }
h2.section .btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.lrow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font: inherit; color: inherit; text-decoration: none; cursor: pointer; }
.lrow:last-child { border-bottom: 0; }
a.lrow:hover, button.lrow:hover, .lrow[data-contact]:hover { background: var(--card-2); }
.lrow .links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-top: 2px; }
.lrow .links a { color: var(--mute); text-decoration: none; display: inline-flex; gap: 5px; align-items: center; }
.lrow .links .ic { width: 14px; height: 14px; }
.w-date { min-width: 64px; font-size: 13px; }
.w-num { min-width: 76px; }
.w-amt { min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill .ic { width: 13px; height: 13px; }
.pill.soft { background: var(--card-2); color: var(--ink-2); }
.pill.honey { background: var(--honey-bg); color: var(--honey-ink); box-shadow: inset 0 0 0 1px var(--honey); }
.pill.honey-soft { background: var(--honey-bg); color: var(--honey-ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }

.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); color: var(--ink-2); font-weight: 700; font-size: 13px; letter-spacing: .3px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

.empty { text-align: center; padding: 48px 16px; }
.empty.small { padding: 28px 16px; }
.empty h3 { margin-bottom: 4px; }
.loading { height: 40vh; }

.searchbox { position: relative; margin: 6px 0 4px; }
.searchbox .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mute); }
.searchbox input { padding-left: 38px; border-radius: 10px; background: var(--card); }

.banner { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 12px 14px; border-radius: var(--r); background: var(--card); border: 1px dashed var(--line-2); text-decoration: none; font-size: 14px; }
.banner:hover { background: var(--card-2); }
.banner span { flex: 1; }

/* ---------- Ticket list ---------- */
.tlist { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.trow { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; align-items: flex-start; }
.trow:last-child { border-bottom: 0; }
.trow:hover { background: var(--card-2); }
.trow.sel { background: var(--card-2); box-shadow: inset 3px 0 0 var(--ink); }
.tmain { flex: 1; min-width: 0; }
.tline1 { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.tline1 .who { font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tline1 .num { color: var(--mute); }
.tline1 .when { margin-left: auto; color: var(--mute); white-space: nowrap; font-size: 12.5px; }
.tsubj { font-weight: 650; margin: 1px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsnip { color: var(--mute); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsnip .ic.ch { width: 14px; height: 14px; margin-right: 5px; vertical-align: -2px; }
.tsnip b { color: var(--ink-2); font-weight: 600; }
.tside { flex: none; padding-top: 18px; }
.tside.stack { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; padding-top: 2px; }
.dot-hi { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 7px; vertical-align: 2px; }
@media (max-width: 520px) { .tside { display: none; } .trow .tside.stack { display: flex; } }

/* Split view on wide screens */
.split { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 20px; align-items: start; }
.split .pane-list { position: sticky; top: 64px; max-height: calc(100vh - 72px); overflow-y: auto; padding: 0 4px 16px 0; }
.split .pane-detail { min-height: calc(100vh - 90px); }
.split .pane-detail > .empty { padding-top: 18vh; }

/* ---------- One ticket ---------- */
.ticket { display: flex; flex-direction: column; }
.split .ticket { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); position: sticky; top: 64px; height: calc(100vh - 80px); overflow: hidden; }
.thead { padding: 4px 0 12px; border-bottom: 1px solid var(--line); }
.split .thead { padding: 16px 18px 12px; }
.thead-top { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.tmeta { font-size: 13px; color: var(--mute); }
.tmeta a { color: var(--ink-2); font-weight: 600; text-decoration: none; }
.tmeta a:hover { text-decoration: underline; }
.tsubject { font-size: 20px; margin: 2px 0 6px; }
.tstatus { font-size: 14px; margin-bottom: 10px; }
.tstatus .ic { width: 15px; height: 15px; vertical-align: -2px; }
.thead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.quick { display: flex; gap: 6px; align-items: center; }
.seg { display: inline-flex; background: var(--card-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--mute); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.timer-face { font-variant-numeric: tabular-nums; }

.timeline { padding: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.split .timeline { flex: 1; overflow-y: auto; padding: 14px 18px; }
.daysep { text-align: center; margin: 6px 0 0; }
.daysep span { font-size: 12px; color: var(--mute); background: var(--bg); padding: 2px 10px; border-radius: 999px; }
.split .daysep span { background: var(--card-2); }
.msg { border-radius: 14px; padding: 10px 14px; max-width: 86%; border: 1px solid var(--line); background: var(--card); }
.msg.in { align-self: flex-start; border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--out-bg); border-color: transparent; border-top-right-radius: 4px; }
.msg.note { align-self: stretch; max-width: none; background: var(--note-bg); border-style: dashed; border-color: var(--line-2); }
.mhead { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 4px; flex-wrap: wrap; }
.mhead .ic { width: 15px; height: 15px; color: var(--mute); }
.mmenu { margin-left: auto; border: 0; background: none; color: var(--mute); cursor: pointer; padding: 2px; border-radius: 6px; opacity: .6; }
.mmenu:hover { opacity: 1; background: var(--card-2); }
.open-link { color: var(--mute); display: inline-flex; }
.msubj { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.mbody { font-size: 14.5px; overflow-wrap: anywhere; }
.mbody a { color: var(--ink); }
.mbody.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.matt { font-size: 13px; color: var(--mute); margin-top: 6px; }
.tl-time { align-self: center; font-size: 13px; color: var(--mute); background: var(--card-2); padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.tl-time .ic { width: 14px; height: 14px; }

/* Composer (sticky at the bottom) */
.composer { position: sticky; bottom: calc(64px + var(--safe-b)); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 8px 10px 10px; margin-top: 8px; z-index: 5; }
.split .composer { position: static; border-radius: 0; border-width: 1px 0 0; box-shadow: none; margin: 0; padding: 10px 18px 14px; }
.ctabs { display: flex; gap: 2px; margin-bottom: 8px; overflow-x: auto; }
.ctabs button { display: inline-flex; gap: 6px; align-items: center; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--mute); padding: 6px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.ctabs button .ic { width: 15px; height: 15px; }
.ctabs button.on { background: var(--card-2); color: var(--ink); }
.cfields { display: none; gap: 6px; margin-bottom: 6px; }
.composer[data-mode="email"] .email-only, .composer[data-mode="sms"] .sms-only { display: flex; }
.cfields input { padding: 7px 10px; font-size: 14px; }
.composer textarea { border: 0; padding: 6px 4px; resize: none; min-height: 60px; background: transparent; }
.composer textarea:focus { outline: none; }
.cfoot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; }
.cfoot .mini { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--mute); font-weight: 500; }
.cfoot .mini input, .cfoot .mini select { width: auto; padding: 5px 8px; font-size: 13px; }
.chint { font-size: 12px; color: var(--mute); margin: 6px 2px 0; }

.timer-pill { position: fixed; right: 16px; bottom: calc(76px + var(--safe-b)); z-index: 40; background: var(--primary); color: var(--primary-ink); padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; text-decoration: none; box-shadow: var(--shadow-lg); display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
@media (min-width: 900px) { .timer-pill { bottom: 20px; } }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Unsorted ---------- */
.ulist { display: flex; flex-direction: column; gap: 10px; }
.uitem .btn-row { margin-bottom: 0; }

/* ---------- Pop-ups ---------- */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 20, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.modal.open { opacity: 1; }
.sheet { background: var(--card); width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); transform: translateY(24px); transition: transform .18s; }
.sheet.wide { max-width: 760px; }
.modal.open .sheet { transform: none; }
@media (min-width: 640px) { .modal { align-items: center; } .sheet { border-radius: 16px; padding: 22px; } }
.menu { display: flex; flex-direction: column; margin: 4px -6px; }
.menu button { display: flex; gap: 12px; align-items: center; padding: 11px 10px; border: 0; background: none; font: inherit; color: var(--ink); text-align: left; border-radius: 9px; cursor: pointer; }
.menu button:hover { background: var(--card-2); }
.picklist { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; margin: 6px -6px; }
.pick { text-align: left; padding: 10px; border: 0; background: none; font: inherit; color: var(--ink); border-radius: 8px; cursor: pointer; }
.pick:hover { background: var(--card-2); }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translate(-50%, 10px); background: var(--primary); color: var(--primary-ink); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500; z-index: 200; opacity: 0; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 28px; left: calc(50% + var(--side) / 2); } }

/* ---------- Clients ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 4px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--line-2); }
.stat span { font-size: 12.5px; color: var(--mute); font-weight: 600; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.stat small { color: var(--mute); }
.cols { display: grid; gap: 0 22px; }
@media (min-width: 900px) { .cols { grid-template-columns: 340px 1fr; } }
.info { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.info > a, .info > div { display: flex; gap: 8px; align-items: flex-start; text-decoration: none; overflow-wrap: anywhere; }
.info .ic { color: var(--mute); margin-top: 2px; }
.info .notes { display: block; background: var(--card-2); border-radius: 8px; padding: 10px; font-size: 13.5px; }

/* ---------- Money ---------- */
.chart { margin: 12px 0 6px; padding: 12px 14px; }
.chart-head { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.legend { font-size: 12px; color: var(--mute); display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.k-inc, .bar .inc { background: var(--ok); }
.k-exp, .bar .exp { background: var(--line-2); }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 120px; margin-top: 10px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar .cols2 { flex: 1; width: 100%; display: flex; gap: 2px; align-items: flex-end; justify-content: center; }
.bar i { width: 42%; max-width: 14px; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar span { font-size: 11px; color: var(--mute); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 4px; }
.tabs a { padding: 9px 14px; text-decoration: none; font-weight: 600; color: var(--mute); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--ink); }

.inv-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; padding: 12px 14px; }
.inv-bar .btn-row { margin: 0; }
.inv-page .card.list { margin-bottom: 12px; }
.paper { background: #fff; color: #161b22; border-radius: 6px; box-shadow: var(--shadow-lg); padding: 36px 40px; max-width: 800px; margin: 0 auto; border-top: 5px solid #e10600; font-size: 14px; }
.paper .muted { color: #6b7480; }
.pp-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.pp-logo { width: 64px; display: block; margin-bottom: 8px; }
.pp-biz { font-size: 13px; color: #555; }
.pp-biz b { font-size: 16px; color: #161b22; }
.pp-title { text-align: right; }
.pp-title h1 { font-size: 26px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.pp-title div { display: flex; gap: 14px; justify-content: flex-end; font-size: 13px; }
.pp-title span, .pp-to span { color: #6b7480; }
.pp-to { margin: 26px 0 18px; font-size: 13.5px; }
.pp-to span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.pp-to b { font-size: 15px; }
.pp-lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pp-lines th { text-align: left; background: #f2f4f6; color: #6b7480; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 10px; }
.pp-lines td { padding: 9px 10px; border-bottom: 1px solid #e8eaed; vertical-align: top; }
.pp-lines .r { text-align: right; white-space: nowrap; }
.pp-tot { margin: 14px 0 0 auto; max-width: 280px; display: flex; flex-direction: column; gap: 4px; }
.pp-tot div { display: flex; justify-content: space-between; }
.pp-tot .big { font-size: 18px; font-weight: 700; border-top: 2px solid #161b22; padding-top: 6px; margin-top: 4px; }
.pp-tot .small { justify-content: flex-end; }
.pp-pay { margin-top: 26px; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; }
.pp-note { margin-top: 18px; color: #6b7480; font-size: 13.5px; }
@media (max-width: 600px) { .paper { padding: 22px 18px; font-size: 13px; } .pp-title { text-align: left; } .pp-title div { justify-content: flex-start; } }

.wide-form { max-width: 920px; margin: 0 auto; }
.ihead, .iline { display: grid; grid-template-columns: 1fr 80px 100px 96px 36px; gap: 8px; align-items: start; }
.ihead { font-size: 12px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .4px; padding: 0 2px; }
.iline { padding: 6px 0; border-bottom: 1px solid var(--line); }
.iline textarea { resize: none; overflow: hidden; min-height: 40px; }
.iline .amt { text-align: right; padding-top: 10px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .ihead { display: none; }
  .iline { grid-template-columns: 1fr 1fr 1fr 36px; }
  .iline textarea { grid-column: 1 / -1; }
  .iline .amt { padding-top: 10px; }
}
.ublist { background: var(--card-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.ublist .btn { align-self: flex-start; }
.itotals { display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.itotals div { display: flex; justify-content: space-between; gap: 16px; }
.itotals .big { font-size: 18px; font-weight: 700; }

/* ---------- Settings & guides ---------- */
.settings .card.form { margin-bottom: 4px; }
.guide ol { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.codebox { display: flex; gap: 8px; align-items: center; margin-top: 6px; background: var(--card-2); border-radius: 8px; padding: 8px 10px; }
.codebox code { background: none; padding: 0; flex: 1; }

/* ---------- Sign-in & splash ---------- */
.signin { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.signin h1 { font-size: 26px; margin: 10px 0 2px; }
.signin .card { text-align: left; margin-top: 18px; }
body.signed-out .tabbar, body.signed-out .sidenav, body.signed-out .topbar { display: none; }
body.signed-out .main { margin-left: 0; }
#splash { position: fixed; inset: 0; z-index: 300; background: var(--bg); display: grid; place-items: center; }

/* Phone tweaks: badge inside the row; compact reply box until you start writing */
.pill-m { display: none; }
@media (max-width: 520px) {
  .tline1 .pill-m { display: inline-flex; margin-left: auto; }
  .tline1 .pill-m ~ .when { display: none; }
}
@media (max-width: 899px) {
  .composer:not(:focus-within):not(.has-text) .cfields,
  .composer:not(:focus-within):not(.has-text) .cfoot,
  .composer:not(:focus-within):not(.has-text) .chint { display: none !important; }
  .composer:not(:focus-within):not(.has-text) textarea { min-height: 40px; height: 40px !important; }
  .composer { padding: 6px 8px 8px; }
  .ctabs { margin-bottom: 4px; }
}
.cols > div { min-width: 0; }
.tl-merge { align-self: center; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mute); background: var(--card-2); padding: 3px 4px 3px 12px; border-radius: 999px; }
.tl-merge .ic { width: 14px; height: 14px; }

/* Tax tab */
.note-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin: 14px 0 4px; font-size: 14px; }
.note-card .ic { color: var(--mute); margin-top: 1px; }
.lrow.static { cursor: default; }
.lrow.total { background: var(--card-2); }
.lrow .plain { border: 0; background: none; font: inherit; color: inherit; text-align: left; padding: 0; cursor: pointer; }
.lrow input[type=checkbox] { width: 18px; height: 18px; flex: none; accent-color: var(--primary); }
.tabs { overflow-x: auto; }
.tabs a { white-space: nowrap; }
@media (max-width: 520px) { .tabs a { padding: 9px 10px; } }

/* Calendar */
.cal-wrap { display: grid; gap: 16px; margin-top: 8px; }
@media (min-width: 900px) { .cal-wrap { grid-template-columns: 360px 1fr; align-items: start; } .cal-month { position: sticky; top: 72px; } }
.cal-month { padding: 10px 12px 12px; }
.cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-grid .dow { font-size: 11px; font-weight: 700; color: var(--mute); padding: 4px 0; }
.cd { position: relative; display: grid; place-items: center; height: 40px; border-radius: 10px; text-decoration: none; font-size: 14px; font-variant-numeric: tabular-nums; }
.cd:hover { background: var(--card-2); }
.cd.out { color: var(--mute); opacity: .55; }
.cd.today span { color: var(--brand); font-weight: 800; }
.cd.sel { background: var(--primary); color: var(--primary-ink); }
.cd.sel.today span { color: var(--primary-ink); }
.cd i { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--mute); }
.cd.sel i { background: var(--primary-ink); }
.agenda { display: flex; flex-direction: column; gap: 10px; }
.ag-day { display: flex; gap: 12px; align-items: flex-start; }
.ag-date { width: 46px; flex: none; text-align: center; display: flex; flex-direction: column; line-height: 1.15; padding-top: 4px; }
.ag-date b { font-size: 11px; text-transform: uppercase; color: var(--mute); letter-spacing: .4px; }
.ag-date span { font-size: 22px; font-weight: 700; }
.ag-date small { font-size: 11px; color: var(--mute); }
.ag-date.today b, .ag-date.today span { color: var(--brand); }
.ag-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ag-ev { display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--ink-2); border-radius: 10px; padding: 9px 12px; cursor: pointer; box-shadow: var(--shadow); }
.ag-ev:hover { border-color: var(--line-2); }
.ag-ev .ag-time { font-size: 12.5px; color: var(--mute); font-weight: 600; }
.ag-ev small { display: flex; gap: 5px; align-items: center; }
.ag-ev small .ic { width: 13px; height: 13px; }
.ag-app { display: flex; gap: 8px; align-items: center; font-size: 13.5px; text-decoration: none; padding: 7px 12px; border-radius: 10px; background: var(--card-2); }
.ag-app .ic { width: 15px; height: 15px; color: var(--mute); }
.ag-app.follow, .ag-app.due { background: var(--honey-bg); color: var(--honey-ink); }
.ag-app.follow .ic, .ag-app.due .ic { color: var(--honey-ink); }
.tabbar a { font-size: 11px; }

/* Security */
.steps { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; margin: 0 0 12px; }
.qr { background: #fff; padding: 10px; border-radius: 10px; width: max-content; margin-top: 8px; }
.qr img { display: block; }

/* Phone polish: no accidental text selection on taps; keep copying where it matters */
html { background: var(--bg); }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, [contenteditable], .mbody, .msubj, .notes, .paper, code, .codebox, .info, .tsnip-copy, .lrow .links a {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
a, button, label, .trow, .lrow, .chip, .cd, .ag-ev, .ag-app, .tabbar, .sidenav { -webkit-tap-highlight-color: transparent; }
/* Fill the strip behind Android's gesture bar with the page colour */
.tabbar::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 120px; background: var(--card); }

/* Calendar v2 (Magic Herd style) */
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip .cdot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; }
.chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.cal-filters { margin: 6px 0 4px; }
.cd { flex-direction: column; gap: 2px; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.cd .dots { display: flex; gap: 2px; height: 6px; align-items: center; }
.cd .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); position: static; }
.cd .dots em { font-size: 9px; font-style: normal; line-height: 1; color: var(--mute); }
.cd.sel .dots i { box-shadow: 0 0 0 1px var(--primary-ink); }
.cd.sel .dots em { color: var(--primary-ink); }
.clist { display: flex; flex-direction: column; gap: 8px; }
.cday { display: flex; flex-direction: column; gap: 6px; }
.cday-h { font-size: 12.5px; font-weight: 700; color: var(--mute); margin-top: 4px; }
.swipe { position: relative; border-radius: 12px; overflow: hidden; }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding-right: 18px; background: var(--ok); color: #fff; font-weight: 700; font-size: 14px; }
.swipe-bg.undo { background: var(--mute); }
.ci { position: relative; display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 12px; text-decoration: none; color: inherit; cursor: pointer; transition: transform .18s; box-shadow: var(--shadow); }
.ci-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.ci-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ci-body b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-body small { color: var(--mute); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-body .ic.xs { width: 12px; height: 12px; vertical-align: -1px; }
.ci-check { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); background: none; color: transparent; display: grid; place-items: center; cursor: pointer; }
.ci-check .ic { width: 16px; height: 16px; }
.ci-check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.ci.done b { text-decoration: line-through; color: var(--mute); }
.ci.done .ci-icon { opacity: .55; }
.ci.app { background: var(--honey-bg); border-color: transparent; border-left-color: var(--c); box-shadow: none; }
.ci.app b { color: var(--honey-ink); }
.type-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tp input { display: none; }
.tp span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tp span .ic { width: 15px; height: 15px; color: var(--c); }
.tp input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px var(--c); }
.form .tp { flex-direction: row; }
.cal-grid .cd { display: flex; align-items: center; justify-content: center; height: 44px; }
.cal-wrap > * { min-width: 0; }
.cal-filters .chip { flex: none; white-space: nowrap; }
.cal-page { min-width: 0; overflow-x: clip; }
