/* Client & Job Tracker — styles. Theme: data-theme on <html>, tokens below. */
/* Base palette (the "Ακτή" preset). The appearance customizer overrides these
   with a higher-specificity <style id="theme-vars">; everything else derives from them. */
:root, [data-theme="light"] {
  --bg: #f5f2ec;
  --surface: #fffdf8;
  --fg: #15202b;
  --accent: #1f6f6a;
  --accent-fg: #ffffff;
  --amber: #9a6412;
  --bad: #b3261e;
  --shadow: 0 10px 30px rgba(21, 32, 43, 0.12);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #11181f;
  --surface: #18222c;
  --fg: #ece7dd;
  --accent: #5fb3ac;
  --accent-fg: #0b1716;
  --amber: #e8b14f;
  --bad: #f2867d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
/* Derived tokens: computed from the palette so custom colors stay consistent. */
:root {
  --surface-2: color-mix(in srgb, var(--fg) 7%, var(--surface));
  --line: color-mix(in srgb, var(--fg) 13%, var(--surface));
  --muted: color-mix(in srgb, var(--fg) 64%, var(--surface));
  --hover: color-mix(in srgb, var(--fg) 6%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --amber-soft: color-mix(in srgb, var(--amber) 18%, transparent);
  --bad-soft: color-mix(in srgb, var(--bad) 12%, transparent);
  --font: "Commissioner", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-btn: 999px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.45;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[x-cloak] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.mt { margin-top: 18px; }
.upper { text-transform: uppercase; }
kbd { font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* ------------------------------------------------------------- buttons */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--fg); cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 21px; height: 21px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-btn); line-height: 1.2;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.link { color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* -------------------------------------------------------------- splash */
.splash { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: 32px 24px; display: grid; gap: 14px; }
.login-card h1 { font-size: 24px; }
.login-card .muted { margin: -8px 0 6px; }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--fg); color: var(--bg); }
.brand-mark svg { width: 26px; height: 26px; }
.brand-mark.sm { width: 36px; height: 36px; border-radius: 10px; }
.brand-mark.sm svg { width: 20px; height: 20px; }

/* --------------------------------------------------------------- forms */
.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 500; }
.field em { color: var(--bad); font-style: normal; font-size: 12.5px; min-height: 0; }
.field em:empty { display: none; }
.field .hint { color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.form-grid.nested { gap: 14px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form h3 { margin-bottom: 14px; }
.error-box { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0; font-size: 14px; }
.error-box:empty { display: none; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.total-line strong { font-size: 18px; }

/* --------------------------------------------------------------- shell */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.main { min-width: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.back-btn { margin-left: -8px; }
.page-title { font-size: 20px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.search-trigger {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--fg);
}
.search-trigger:hover { background: var(--hover); }
.search-trigger svg { width: 21px; height: 21px; }
.search-trigger .label, .search-trigger kbd { display: none; }
.desktop-only { display: none !important; }
.offline-bar { background: var(--amber-soft); color: var(--fg); padding: 8px 16px; font-size: 13px; }
.content { padding: 8px 16px 24px; margin: 0 auto; }
.view { display: grid; gap: 16px; }
.view.narrow { max-width: 720px; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottombar a, .bottombar button {
  display: grid; justify-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 11.5px; font-weight: 500; border-radius: 12px;
}
.bottombar svg { width: 23px; height: 23px; }
.bottombar .active { color: var(--accent); }
.fab-mic {
  position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 31;
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--fg); color: var(--bg); box-shadow: var(--shadow); display: grid; place-items: center;
}
.fab-mic svg { width: 24px; height: 24px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 20px;
    position: sticky; top: 0; height: 100vh; padding: 20px 14px;
    border-right: 1px solid var(--line); background: var(--surface);
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
  .brand strong { display: block; font-size: 15px; line-height: 1.2; }
  .brand small { color: var(--muted); font-size: 12px; }
  .sidebar nav { display: grid; gap: 2px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
  .sidebar nav a:hover { background: var(--hover); color: var(--fg); }
  .sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
  .sidebar nav svg { width: 20px; height: 20px; }
  .sidebar-foot { margin-top: auto; display: flex; gap: 4px; }
  .main { padding-bottom: 32px; }
  .topbar { padding: 14px 28px; }
  .page-title { font-size: 24px; }
  .content { padding: 8px 28px 32px; }
  .bottombar, .fab-mic, .mobile-only { display: none !important; }
  .desktop-only { display: inline-flex !important; }
  .search-trigger {
    width: auto; height: 40px; display: inline-flex; gap: 10px; padding: 0 10px 0 14px; border-radius: var(--radius-btn);
    border: 1px solid var(--line); background: var(--surface); color: var(--muted); min-width: 260px; justify-content: flex-start;
  }
  .search-trigger svg { width: 18px; height: 18px; }
  .search-trigger .label { display: inline; flex: 1; text-align: left; }
  .search-trigger kbd { display: inline; }
  .topbar-actions { gap: 8px; }
}

/* --------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.grid-2 { display: grid; gap: 16px; }
.stack { display: grid; gap: 16px; align-content: start; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.empty { color: var(--muted); font-size: 14px; margin: 4px 0; }
.empty-state { padding: 32px 16px; text-align: center; display: grid; gap: 12px; justify-items: center; color: var(--muted); }
.empty-state p { margin: 0; }
.notes { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin: 12px 0 0; font-size: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* --------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 6px; min-width: 0; align-content: start; }
a.tile:hover { border-color: var(--accent); }
.tile.accent { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tile.accent .tile-label { color: color-mix(in srgb, var(--bg) 75%, transparent); }
.tile-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .tile-value { font-size: 26px; } }

/* ---------------------------------------------------------------- rows */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.card:not(.flush) .rows > li:first-child .row { padding-top: 6px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 0; background: none; border: 0; text-align: left; cursor: pointer; color: inherit;
}
.card.flush .row { padding: 12px 16px; }
.row:hover { background: var(--hover); }
.card:not(.flush) .row:hover { background: none; }
.card:not(.flush) .row:hover strong { color: var(--accent); }
.row.static { cursor: default; }
.row.static:hover { background: none; }
.rows.compact .row { padding: 8px 0; }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-main strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { display: grid; justify-items: end; gap: 2px; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 13.5px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.owes, .owes { color: var(--amber); }
.amount.credit, .credit { color: var(--accent); }
.amount.zero { color: var(--muted); font-weight: 500; }
.due { font-size: 13px; color: var(--muted); white-space: nowrap; }
.due.overdue { color: var(--bad); font-weight: 600; }
.status-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-dot.planned { background: transparent; border: 2px solid var(--muted); }
.status-dot.in_progress { background: var(--amber); }
.status-dot.done { background: var(--accent); }
.status-dot.cancelled { background: var(--line); }
.kind-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); }
.kind-icon.payment { background: var(--accent-soft); color: var(--accent); }
.kind-icon svg { width: 17px; height: 17px; }
.job-money { display: grid; justify-items: end; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); margin: 6px 0 0; }
.pill.warn { background: var(--amber-soft); color: var(--amber); }

/* ------------------------------------------------------------- toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .search { flex: 1 1 220px; border-radius: var(--radius-btn); padding-left: 16px; }
.select-sm { width: auto; min-height: 40px; border-radius: var(--radius-btn); padding: 6px 12px; font-size: 14px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--radius-btn); background: var(--surface-2); max-width: 100%; }
.seg.scroll { overflow-x: auto; scrollbar-width: none; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg.wrap { flex-wrap: wrap; border-radius: var(--radius-sm); }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: var(--radius-btn); cursor: pointer; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* -------------------------------------------------------------- client */
.client-head { display: grid; gap: 16px; }
.client-id { display: flex; gap: 14px; align-items: center; min-width: 0; }
.client-id h2 { font-size: 20px; }
.client-id p { margin: 2px 0 0; }
.balance-box { display: grid; gap: 2px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.balance-box span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.balance-box strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.balance-box.owes { background: var(--amber-soft); }
.balance-box.owes strong { color: var(--amber); }
.balance-box.credit { background: var(--accent-soft); }
.balance-box.credit strong { color: var(--accent); }
.client-actions { display: flex; gap: 4px; }
@media (min-width: 900px) {
  .client-head { grid-template-columns: 1fr auto auto; align-items: center; }
  .balance-box { min-width: 220px; text-align: right; }
}
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--fg); border-bottom-color: var(--accent); }
.details { margin: 0; display: grid; gap: 8px; }
.details div { display: grid; grid-template-columns: 130px 1fr; gap: 10px; font-size: 14px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.details.inline { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 12px; }
.details.inline div { display: flex; gap: 6px; grid-template-columns: none; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.totals div, .ledger-totals div { display: grid; gap: 2px; }
.totals span, .ledger-totals span { font-size: 12.5px; color: var(--muted); }
.totals strong, .ledger-totals strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.ledger-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }

/* -------------------------------------------------------------- ledger */
.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ledger td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ledger tbody tr { cursor: pointer; }
.ledger tbody tr:hover { background: var(--hover); }
.ledger tr:last-child td { border-bottom: 0; }
.ledger .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger .strong { font-weight: 600; }
.ledger td:first-child, .ledger th:first-child { padding-left: 16px; white-space: nowrap; }
.ledger td:last-child, .ledger th:last-child { padding-right: 16px; }
@media (max-width: 640px) {
  .ledger thead { display: none; }
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; }
  .ledger tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .ledger td { padding: 0 !important; border: 0; }
  .ledger td:nth-child(1) { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 13px; }
  .ledger td:nth-child(2) { grid-column: 1; grid-row: 1; }
  .ledger td:nth-child(3), .ledger td:nth-child(4) { grid-column: 2; grid-row: 1; font-weight: 600; }
  .ledger td:nth-child(3):empty, .ledger td:nth-child(4):empty { display: none; }
  .ledger td:nth-child(5) { grid-column: 2; grid-row: 2; font-size: 13px; color: var(--muted); font-weight: 500; }
}

/* ----------------------------------------------------------------- job */
.job-head h2 { font-size: 21px; margin: 2px 0 14px; }
.job-head > p { margin: 0; }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper button {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-btn);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; color: var(--muted);
}
.stepper .dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid currentColor; }
.stepper button.past { color: var(--accent); }
.stepper button.past .dot { background: currentColor; }
.stepper button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.stepper button.on .dot { background: currentColor; }
.money-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.money-strip > div { background: var(--surface); padding: 12px 16px; display: grid; gap: 2px; }
.money-strip span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.money-strip strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.money-strip small { font-size: 12px; color: var(--muted); }
.money-strip .highlight { background: var(--amber-soft); }
.money-strip .highlight strong { color: var(--amber); }
@media (min-width: 900px) { .money-strip { grid-template-columns: repeat(4, 1fr); } }

/* ----------------------------------------------------------- overlays */
.backdrop { position: fixed; inset: 0; background: rgba(10, 15, 20, 0.45); z-index: 40; }
.backdrop.light { background: rgba(10, 15, 20, 0.2); }
.quick-add {
  position: fixed; z-index: 41; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  display: grid; min-width: 220px; padding: 6px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.quick-add button, .quick-add a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; text-align: left; font-weight: 500; }
.quick-add button:hover, .quick-add a:hover { background: var(--hover); }
.quick-add svg { width: 20px; height: 20px; color: var(--accent); }
@media (min-width: 900px) { .quick-add { top: 64px; right: 28px; bottom: auto; } }

.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-wrap .backdrop { z-index: 0; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: calc(var(--radius) + 4px) calc(var(--radius) + 4px) 0 0; box-shadow: var(--shadow);
  animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.sheet-body { padding: 8px 20px 16px; overflow-y: auto; }
.sheet-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .spacer { flex: 1; }
@media (max-width: 520px) { .sheet .form-grid { grid-template-columns: 1fr; } .sheet .span-2 { grid-column: auto; } }
@media (min-width: 900px) {
  .sheet { left: auto; top: 0; width: 480px; max-height: none; border-radius: 0; animation: sheet-in 0.2s ease-out; }
  @keyframes sheet-in { from { transform: translateX(40px); opacity: 0; } }
  .sheet-foot { padding-bottom: 16px; }
}
@media (max-width: 520px) { .form .form-grid { grid-template-columns: 1fr; } .form .span-2 { grid-column: auto; } }

.overlay-wrap { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; padding: 12px; }
.overlay-wrap.top { align-items: flex-start; padding-top: max(12px, env(safe-area-inset-top)); }
.overlay-wrap.center { align-items: center; }
.overlay-wrap .backdrop { z-index: 0; }
.palette { position: relative; width: 100%; max-width: 640px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; max-height: 80vh; }
@media (min-width: 900px) { .overlay-wrap.top { padding-top: 12vh; } }
.palette-input { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.palette-input > span svg { width: 20px; height: 20px; color: var(--muted); }
.palette-input input { border: 0; padding: 10px 4px; font-size: 17px; background: transparent; }
.palette-input input:focus { outline: none; }
.results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.results .empty { padding: 16px; text-align: center; }
.result { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; text-align: left; color: inherit; }
.result.active { background: var(--accent-soft); }
.r-icon svg { width: 18px; height: 18px; color: var(--muted); }
.result.active .r-icon svg { color: var(--accent); }
.r-kind { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.palette-foot { padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.voice-card { position: relative; width: 100%; max-width: 420px; background: var(--surface); border-radius: calc(var(--radius) + 6px); box-shadow: var(--shadow); padding: 28px 22px 18px; display: grid; justify-items: center; gap: 10px; text-align: center; }
.voice-orb { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--fg); }
.voice-orb svg { width: 34px; height: 34px; }
.voice-orb.listening { background: var(--accent); color: var(--accent-fg); animation: pulse 1.4s ease-in-out infinite; }
.voice-orb.done { background: var(--accent); color: var(--accent-fg); }
.voice-orb.error, .voice-orb.unsupported { background: var(--bad-soft); color: var(--bad); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 18px var(--accent-soft); } }
.voice-state { font-weight: 600; font-size: 17px; margin: 4px 0 0; }
.voice-text { font-size: 18px; margin: 0; }
.voice-result { margin: 0; color: var(--accent); font-weight: 600; }
.voice-card .muted { margin: 0; }
.candidates { display: grid; gap: 8px; width: 100%; }
.voice-actions { display: flex; gap: 8px; margin-top: 6px; }

.toasts { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; font-size: 14px; box-shadow: var(--shadow); text-align: center; animation: toast-in 0.2s ease-out; }
.toast.error { background: var(--bad); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@media (min-width: 900px) { .toasts { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Keep long filter rows scrollable instead of widening the page */
.toolbar > * { min-width: 0; }
.toolbar .seg.scroll { flex: 1 1 100%; }
@media (min-width: 900px) { .toolbar .seg.scroll { flex: 0 1 auto; } }
.details div { grid-template-columns: minmax(90px, 130px) 1fr; }
.form-grid > *, .field > * { min-width: 0; }
select { max-width: 100%; text-overflow: ellipsis; }
.view > * { min-width: 0; }

/* ------------------------------------------------- icon + text alignment */
svg { display: block; flex: none; }
.btn > span, .icon-btn > span, .search-trigger > span, .quick-add span, .sidebar nav a > span,
.bottombar a > span, .bottombar button > span, .r-icon, .palette-input > span { display: inline-flex; align-items: center; justify-content: center; }
.btn > span:first-child:not(:only-child) { margin-left: -2px; }
.add-wrap { display: inline-flex; }
.topbar-actions > * { flex: none; }
.form-actions .spacer, .row-between .spacer { flex: 1; }
.form-actions { align-items: center; flex-wrap: wrap; }
.look-label { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.card-head + .look-label { margin-top: 4px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.warn-box { background: var(--amber-soft); color: var(--fg); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; margin: 10px 0 0; }

/* ------------------------------------------------------------ appearance */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.swatch {
  display: grid; gap: 6px; padding: 6px 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; text-align: center; font-size: 13px; font-weight: 500; color: var(--fg);
}
.swatch:hover { border-color: var(--muted); }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch-colors { display: flex; gap: 4px; padding: 10px 8px; border-radius: calc(var(--radius-sm) - 3px); justify-content: center; border: 1px solid rgba(127, 127, 127, 0.18); }
.swatch-colors i { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(127, 127, 127, 0.25); }
.custom-colors { margin-top: 14px; padding: 12px 14px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.custom-colors .look-label { margin: 0; }
.custom-colors .row-between { margin-bottom: 10px; flex-wrap: wrap; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.color-field { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.color-field input[type="color"] {
  width: 40px; height: 40px; min-height: 0; padding: 0; border: 1px solid var(--line); border-radius: 50%; overflow: hidden; cursor: pointer; flex: none; background: none;
  -webkit-appearance: none; appearance: none;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.color-field input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }
.color-meta { display: grid; gap: 2px; min-width: 0; }
.color-meta strong { font-size: 13px; }
.color-meta .hex { min-height: 0; padding: 2px 6px; font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; border-radius: 6px; width: 92px; }
.look-options { margin-top: 16px; align-items: end; }
.look-options .seg { display: flex; width: 100%; }
.look-options .seg button { flex: 1; padding-left: 8px; padding-right: 8px; }
@media (max-width: 640px) { .look-options { grid-template-columns: 1fr; } .seg button { padding: 7px 11px; } }

/* --------------------------------------------------------- microphone help */
.mic-help { text-align: left; width: 100%; font-size: 14px; }
.mic-help p { margin: 0 0 8px; }
.mic-help ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); }
.voice-card .btn.primary { min-width: 200px; }
.voice-orb.blocked, .voice-orb.asking { background: var(--amber-soft); color: var(--amber); }
.voice-orb.checking { background: var(--surface-2); }
.voice-orb.ready { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 520px) {
  .form-actions { gap: 6px; }
  .form-actions .btn { padding-left: 12px; padding-right: 12px; }
  .form-actions .btn.ghost { padding-left: 4px; padding-right: 4px; }
}
@media (min-width: 900px) {
  .toolbar { flex-wrap: nowrap; }
  .toolbar .search { flex: 1 1 240px; min-width: 200px; }
  .toolbar .seg.scroll { flex: 0 1 auto; min-width: 0; }
  .toolbar > .btn, .toolbar > .select-sm { flex: none; }
}

/* v1.1.1: search box alignment + header aligned with content on wide screens */
@media (min-width: 900px) {
  .search-trigger { align-items: center; line-height: 1; }
  .search-trigger > span:first-child { flex: none; }
  .search-trigger .label { display: block; flex: 1; text-align: left; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search-trigger kbd { display: block; flex: none; line-height: 1; }
  .main { display: flex; flex-direction: column; align-items: center; }
  .topbar, .offline-bar, .content { width: 100%; max-width: 1280px; margin-left: auto; margin-right: auto; }
}

.update-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: var(--accent-soft); font-size: 14px; font-weight: 500; }
@media (min-width: 900px) { .update-bar { width: 100%; max-width: 1280px; margin: 0 auto; padding: 8px 28px; } }
.voice-card { max-height: calc(100vh - 24px); overflow-y: auto; }

/* ------------------------------------------------------------- v1.2: overdue */
.tile.alert .tile-value { color: var(--bad); }
.tile-sub { font-size: 12.5px; color: var(--muted); }
.overdue-note { font-size: 12px; font-weight: 600; color: var(--bad); white-space: nowrap; }
.balance-box .overdue-note { font-size: 12.5px; }
.due-line { font-size: 12.5px; color: var(--muted); }
.due-line.overdue { color: var(--bad); font-weight: 600; }
.ledger .due-line { margin-top: 2px; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.due-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.kind-icon.job { background: var(--surface-2); color: var(--muted); }

/* --------------------------------------------------------- v1.2: income chart */
.income-now { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 12px; }
.income-now strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.income-now span { color: var(--muted); font-size: 13px; }
.income-now .delta { font-weight: 600; }
.income-now .delta.up { color: var(--accent); }
.income-now .delta.down { color: var(--amber); }
.ichart { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 6px; }
.ichart-y { display: flex; flex-direction: column; justify-content: space-between; height: 160px; font-size: 11.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; margin-top: -7px; margin-bottom: -7px; }
.ichart-plot { position: relative; height: 160px; display: grid; grid-template-columns: repeat(12, 1fr); align-items: end; }
.ichart-plot .grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--line); }
.ichart-plot .g1 { top: 0; } .ichart-plot .g2 { top: 50%; } .ichart-plot .g3 { bottom: 0; border-top-color: color-mix(in srgb, var(--fg) 30%, var(--surface)); }
.ibar-slot { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; z-index: 1; }
.ibar { width: 62%; max-width: 26px; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--accent) 55%, var(--surface)); transition: background .15s; }
.ibar.current, .ibar.on { background: var(--accent); }
.itip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); border-radius: 8px; padding: 6px 10px; display: grid; gap: 1px; white-space: nowrap; font-size: 12px; z-index: 5; pointer-events: none; }
.itip strong { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.itip.left { left: auto; right: 0; transform: none; }
.itip.right { left: 0; transform: none; }
.ibar-slot:has(.itip) { }
.ichart-x { display: grid; grid-template-columns: repeat(12, 1fr); font-size: 11.5px; color: var(--muted); text-align: center; }
.ichart-x .current { color: var(--fg); font-weight: 700; }
@media (max-width: 520px) { .ichart-x .odd:not(.current) { visibility: hidden; } }
.compact-table td, .compact-table th { padding: 8px 4px; }
.ledger tr.static { cursor: default; }

/* ----------------------------------------------------------------- v1.2: logo */
.brand-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; flex: none; }
.login-logo { width: 96px; height: 96px; object-fit: contain; margin: 0 auto 4px; display: block; }
.logo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 96px; height: 96px; border-radius: var(--radius-sm); background: var(--surface-2); display: grid; place-items: center; flex: none; overflow: hidden; }
.logo-preview img { max-width: 84px; max-height: 84px; object-fit: contain; }
.logo-actions { flex: 1; min-width: 200px; display: grid; gap: 8px; }
.logo-actions p { margin: 0; }
.row-main small.overdue-note { color: var(--bad); font-weight: 600; }
