@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url(/fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url(/fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url(/fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url(/fonts/inter-latin-700-normal.woff2) format('woff2'); }

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F2F4F7;
  --surface-3: #E9ECF1;
  --border: #E2E5EA;
  --border-strong: #CDD2DA;
  --text: #121826;
  --text-2: #475164;
  --muted: #747E90;
  --primary: #13213C;
  --primary-hover: #1E3157;
  --on-primary: #FFFFFF;
  --accent: #1D6B73;
  --gold: #C99A2E;
  --focus: #3B7EA1;
  --danger: #B42318;
  --danger-bg: #FEF0EE;
  --chip-gray: #EEF0F3;   --chip-gray-ink: #4A5365;
  --chip-blue: #E7EFFD;   --chip-blue-ink: #1D4FB8;
  --chip-green: #E4F5EA;  --chip-green-ink: #1B6E36;
  --chip-amber: #FFF2D9;  --chip-amber-ink: #8A5800;
  --chip-red: #FDE8E6;    --chip-red-ink: #A3261B;
  --chart-a: #2563EB;
  --chart-b: #B7791F;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --sidebar: #0F1729;
  --sidebar-ink: #AEB7C7;
  --sidebar-active: #1B2640;
  --radius: 10px;
  --radius-sm: 7px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1118; --surface: #151A23; --surface-2: #1A202B; --surface-3: #222938;
    --border: #262E3C; --border-strong: #353F50; --text: #E8EBF0; --text-2: #B3BBC9; --muted: #8590A2;
    --primary: #E8EBF0; --primary-hover: #FFFFFF; --on-primary: #0D1118; --accent: #4FB0B9; --focus: #6FA8D6;
    --danger: #F2827A; --danger-bg: #3A1D1B;
    --chip-gray: #232A37; --chip-gray-ink: #B3BBC9; --chip-blue: #1A2B4A; --chip-blue-ink: #8FB4F5;
    --chip-green: #173323; --chip-green-ink: #7DD69C; --chip-amber: #3A2C10; --chip-amber-ink: #F0C46B;
    --chip-red: #3A1D1B; --chip-red-ink: #F2A49C;
    --chart-a: #3B82F6; --chart-b: #BF8113;
    --shadow-sm: none; --shadow: 0 0 0 1px var(--border); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
    --sidebar: #0A0E15; --sidebar-active: #172033;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1118; --surface: #151A23; --surface-2: #1A202B; --surface-3: #222938;
  --border: #262E3C; --border-strong: #353F50; --text: #E8EBF0; --text-2: #B3BBC9; --muted: #8590A2;
  --primary: #E8EBF0; --primary-hover: #FFFFFF; --on-primary: #0D1118; --accent: #4FB0B9; --focus: #6FA8D6;
  --danger: #F2827A; --danger-bg: #3A1D1B;
  --chip-gray: #232A37; --chip-gray-ink: #B3BBC9; --chip-blue: #1A2B4A; --chip-blue-ink: #8FB4F5;
  --chip-green: #173323; --chip-green-ink: #7DD69C; --chip-amber: #3A2C10; --chip-amber-ink: #F0C46B;
  --chip-red: #3A1D1B; --chip-red-ink: #F2A49C;
  --chart-a: #3B82F6; --chart-b: #BF8113;
  --shadow-sm: none; --shadow: 0 0 0 1px var(--border); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  --sidebar: #0A0E15; --sidebar-active: #172033;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, 'SF Mono', monospace; font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

.boot { height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand b { font-size: 15px; letter-spacing: .01em; display: block; }
.brand span { font-size: 11.5px; color: var(--sidebar-ink); }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-ink);
  font-weight: 500; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }
.nav a .count { margin-left: auto; font-size: 11.5px; background: rgba(255, 255, 255, .1); color: #fff; padding: 0 7px; border-radius: 10px; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6C778C; padding: 16px 10px 6px; }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: #fff; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.sidebar .me:hover { background: rgba(255, 255, 255, .05); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #1D6B73, #13213C); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; }
.sidebar .me small { display: block; color: var(--sidebar-ink); font-size: 11.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.search-trigger {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; min-width: 260px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-trigger kbd { margin-left: auto; }
kbd { font: 11px/1 Inter, sans-serif; padding: 3px 5px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.page { padding: 8px 28px 64px; max-width: 1280px; width: 100%; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin: 10px 0 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }

.tabbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; }
  .search-trigger { min-width: 0; flex: 1; }
  .search-trigger kbd { display: none; }
  .page { padding: 4px 16px 96px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
  .tabbar a.active { color: var(--text); font-weight: 600; }
  .tabbar a:hover { text-decoration: none; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 901px) { .show-mobile { display: none !important; } }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-group { display: inline-flex; }
.btn-group .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, textarea.input {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 38px; padding: 8px 11px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover { border-color: var(--muted); }
.input:focus, .select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input.num { text-align: right; }
.input.bare { border-color: transparent; background: transparent; box-shadow: none; }
.input.bare:hover { border-color: var(--border); }
.input.bare:focus { border-color: var(--focus); background: var(--surface); }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23747E90' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.span-2 { grid-column: span 2; }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 14.5px; font-weight: 650; }
.card-body { padding: 18px; }
.card + .card { margin-top: 16px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--chip-gray); color: var(--chip-gray-ink);
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.blue { background: var(--chip-blue); color: var(--chip-blue-ink); }
.chip.green { background: var(--chip-green); color: var(--chip-green-ink); }
.chip.amber { background: var(--chip-amber); color: var(--chip-amber-ink); }
.chip.red { background: var(--chip-red); color: var(--chip-red-ink); }
.chip.plain::before { display: none; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tbody tr { cursor: pointer; transition: background .08s; }
table.list tbody tr:hover { background: var(--surface-2); }
table.list .doc-no { font-weight: 600; font-variant-numeric: tabular-nums; }
table.list .title { color: var(--text-2); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paid-at { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.paid-at .input { max-width: 150px; padding-top: 5px; padding-bottom: 5px; }
table.list .import-desc { color: var(--text-2); min-width: 220px; max-width: 380px; white-space: normal; }
table.list th.num, table.list td.num { text-align: right; }
table.list tfoot td { font-weight: 700; border-top: 1px solid var(--border); }
@media (max-width: 700px) {
  table.list.responsive thead { display: none; }
  table.list.responsive tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 2px 10px; }
  table.list.responsive td { padding: 0; border: none; }
  table.list.responsive td.m-hide { display: none; }
  table.list.responsive td.title, table.list.responsive td.import-desc { grid-column: 1 / -1; max-width: none; }
  /* Phone rows: number + amount, then client, then date + status. */
  table.list.responsive td.m-a { order: 1; }
  table.list.responsive td.m-b { order: 2; font-weight: 600; }
  table.list.responsive td.m-c { order: 3; grid-column: 1 / -1; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
  table.list.responsive td.m-d { order: 4; color: var(--muted); font-size: 13px; }
  table.list.responsive td.m-e { order: 5; justify-self: end; }
}

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; font-weight: 600; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button .n { color: var(--muted); font-weight: 500; margin-left: 4px; }

.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 14px; color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 15.5px; margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; max-width: 380px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 16px 18px; cursor: pointer; transition: border-color .12s, transform .12s; }
.kpi:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.kpi .k { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 14px; font-weight: 600; color: var(--muted); margin-right: 2px; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.alert .v { color: var(--danger); }
.kpi.static { cursor: default; }
.kpi.static:hover { border-color: var(--border); transform: none; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; }
.dash-grid > *, .dash-col > * { min-width: 0; }
.dash-grid .card + .card { margin-top: 0; }
.kpis .card + .card { margin-top: 0; }
.dash-col { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); cursor: pointer; }
.mini-list li:last-child { border-bottom: none; }
.mini-list li:hover { background: var(--surface-2); }
.mini-list .t { font-weight: 600; font-size: 13.5px; }
.mini-list .d { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-dot { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }

.chart { position: relative; padding: 8px 18px 14px; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .gridline { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar-a { fill: var(--chart-a); }
.chart .bar-b { fill: var(--chart-b); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12.5px; min-width: 170px; z-index: 5; transform: translate(-50%, -100%);
}
.tooltip .r { display: flex; justify-content: space-between; gap: 14px; }

/* ---------------------------------------------------------------- editor */
.editor { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.editor.no-preview { grid-template-columns: minmax(0, 860px); }
@media (max-width: 1200px) { .editor { grid-template-columns: 1fr; } .editor .preview-pane { display: none; } .editor.show-preview .preview-pane { display: block; } .editor.show-preview .form-pane { display: none; } }
@media (min-width: 1201px) { .hide-desktop-preview { display: none !important; } }
.preview-pane { position: sticky; top: 72px; }
.preview-frame { width: 100%; height: calc(100vh - 140px); border: 1px solid var(--border); border-radius: var(--radius); background: #E9ECF1; }
.doc-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.doc-bar h1 { font-size: 22px; font-weight: 700; }
.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: #2E9E5B; }
.save-state.saving .dot { background: var(--gold); }
.save-state.error { color: var(--danger); }
.save-state.error .dot { background: var(--danger); }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; background: var(--chip-blue); color: var(--chip-blue-ink); font-size: 13px; margin-bottom: 14px; }
.banner.amber { background: var(--chip-amber); color: var(--chip-amber-ink); }
.banner.red { background: var(--chip-red); color: var(--chip-red-ink); }
.banner.import { align-items: center; flex-wrap: wrap; }
.banner.import .grow { flex: 1 1 320px; min-width: 0; }
.banner .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; opacity: .9; }
.banner .seg { background: color-mix(in srgb, var(--surface) 55%, transparent); border-color: transparent; }

.items { width: 100%; border-collapse: separate; border-spacing: 0; }
.items th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; text-align: left; padding: 0 6px 6px; }
.items th.num { text-align: right; }
.items td { padding: 4px; vertical-align: top; }
.items tr.item-row td { border-top: 1px solid var(--border); padding-top: 10px; padding-bottom: 8px; }
.items .n { width: 22px; color: var(--muted); font-weight: 600; padding-top: 19px; text-align: right; }
.items .qty { width: 64px; }
.items .price { width: 116px; }
.items .amt { width: 100px; text-align: right; font-weight: 600; padding-top: 19px; font-variant-numeric: tabular-nums; }
.items .tools { width: 30px; padding-top: 12px; }
.items tr.note-row textarea { font-style: italic; color: var(--text-2); }
.row-tools { opacity: 0; transition: opacity .1s; }
tr:hover .row-tools, tr:focus-within .row-tools { opacity: 1; }
@media (hover: none) { .row-tools { opacity: 1; } }
.totals-box { margin-left: auto; width: min(340px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; }
.totals-box .grand { font-size: 17px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border); }
@media (max-width: 700px) {
  .items thead { display: none; }
  .items tr.item-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; border-top: 1px solid var(--border); padding: 10px 0; }
  .items tr.item-row td { border: none; padding: 0; }
  .items tr.item-row td.n { display: none; }
  .items tr.item-row td.desc { grid-column: 1 / -1; }
  .items tr.item-row td.model { grid-column: 1 / -1; }
  .items .qty, .items .price, .items .amt { width: auto; }
  .items .amt { padding-top: 9px; }
}

.block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; }
.block-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.block-head .kind { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.block-body { padding: 12px 14px; }
.block textarea.md { min-height: 120px; font-size: 13.5px; }
.grid-edit { width: 100%; border-collapse: collapse; }
.grid-edit th, .grid-edit td { border: 1px solid var(--border); padding: 0; }
.grid-edit th input { font-weight: 600; background: var(--surface-2); }
.grid-edit input, .grid-edit textarea { width: 100%; border: 0; padding: 7px 8px; background: transparent; min-height: 34px; resize: none; display: block; }
.grid-edit input:focus, .grid-edit textarea:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--surface); }
.grid-edit td.x { width: 30px; text-align: center; border: none; }
.add-block { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); justify-content: center; }
.img-drop { border: 1.5px dashed var(--border-strong); border-radius: 9px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.img-drop:hover, .img-drop.over { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 6%, transparent); }
.img-drop img { max-width: 100%; max-height: 260px; border-radius: 6px; }

.side-card .kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.side-card .kv dt { color: var(--muted); }
.side-card .kv dd { margin: 0; text-align: right; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.timeline li { padding: 6px 0 6px 16px; position: relative; color: var(--text-2); }
.timeline li::before { content: ''; position: absolute; left: 3px; top: 13px; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }

/* ---------------------------------------------------------------- overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 22, .45); display: grid; place-items: start center; padding: 10vh 16px 16px; animation: fade .12s ease-out; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .14s ease-out; }
.modal.wide { width: min(720px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.modal-head { padding: 18px 20px 4px; }
.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-head p { margin: 6px 0 0; color: var(--text-2); }
.modal-body { padding: 14px 20px; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

.palette { width: min(640px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden; animation: pop .12s ease-out; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 16px 18px; font-size: 16px; background: transparent; outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow-y: auto; }
.palette li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.palette li.on { background: var(--surface-2); }
.palette .grp { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 10px 12px 4px; cursor: default; }

.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; animation: pop .1s ease-out;
}
.menu.left { right: auto; left: 0; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; font-weight: 500; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.menu .desc { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #121826; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; font-size: 13.5px; animation: pop .15s ease-out; display: flex; gap: 10px; align-items: center; }
.toast.error { background: #A3261B; }
@media (max-width: 900px) { .toasts { bottom: 84px; } }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art {
  background: radial-gradient(1200px 600px at 10% 110%, rgba(29, 107, 115, .55), transparent 60%),
              radial-gradient(800px 500px at 100% 0%, rgba(201, 154, 46, .25), transparent 60%), #0F1729;
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-logo { display: flex; align-items: center; gap: 14px; }
.login-logo img { height: 40px; width: auto; }
.login-logo span { padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .22); font-size: 15px; font-weight: 600; color: #DCE2EC; letter-spacing: .02em; }
.login-art h2 { font-size: 34px; line-height: 1.15; max-width: 440px; letter-spacing: -.02em; }
.login-art p { color: #AEB7C7; max-width: 420px; }
.login-art .steps { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.login-art .steps span { border: 1px solid rgba(255, 255, 255, .18); padding: 6px 12px; border-radius: 99px; font-size: 13px; color: #DCE2EC; }
.login-form { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.login-form form { width: min(360px, 100%); }
.login-form h1 { font-size: 24px; margin-bottom: 6px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }

.settings-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 72px; }
.settings-nav a { padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.settings-nav a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.settings-nav a:hover { text-decoration: none; color: var(--text); }
@media (max-width: 800px) { .settings-layout { grid-template-columns: 1fr; } .settings-nav { flex-direction: row; overflow-x: auto; position: static; } }
.swatch { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border-strong); padding: 0; cursor: pointer; }
.logo-preview { height: 44px; max-width: 220px; object-fit: contain; background: #fff; border-radius: 6px; padding: 4px; border: 1px solid var(--border); }
