@import url("fonts.css");
/* ─────────── Tokens ─────────── */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1b2220;
  --ink-2: #3b4542;
  --muted: #6c7571;
  --line: #e3e0d7;
  --line-strong: #cfcbc0;
  --accent: #0e6b60;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ec;
  --accent-hover: #0a5a51;
  --ok: #157a3c;
  --ok-soft: #e4f4e9;
  --warn: #a4570a;
  --warn-soft: #fcf1e1;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --info-soft: #e8eef9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(27, 34, 32, .05), 0 4px 16px rgba(27, 34, 32, .04);
  --font: "Plex Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --sidebar: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615; --surface: #1a201e; --surface-2: #161b1a; --ink: #e8ece9; --ink-2: #c7cecb;
    --muted: #8e9994; --line: #2a3230; --line-strong: #3a4441; --accent: #3fb3a3; --accent-ink: #0b1614;
    --accent-soft: #173330; --accent-hover: #5cc6b7; --ok: #4cc27a; --ok-soft: #173123; --warn: #e3a354;
    --warn-soft: #34281a; --danger: #f07b72; --danger-soft: #3a1f1d; --info-soft: #1d2533;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}

/* ─────────── Base ─────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -40px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 18px; height: 18px; flex: none; }
.num, [dir="ltr"].num, .amount, td.num, .totals dd { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ─────────── Shell ─────────── */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.brand-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink-2); }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 6px; }
.me { display: flex; align-items: center; gap: 8px; flex: 1; color: var(--ink); min-width: 0; }
.me span { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.me strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: var(--muted); font-size: 12px; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--bg);
  position: sticky; top: 0; z-index: 20; border-bottom: 1px solid transparent;
}
.page-title { font-size: 20px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle { display: none; }
main { padding: 8px 28px 48px; max-width: 1280px; width: 100%; }
.is-wide main { max-width: 1480px; }
main:focus { outline: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 272px; z-index: 40; transform: translateX(100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  main { padding: 8px 16px 40px; }
}

/* ─────────── Buttons & inputs ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-wa { background: #1f8f4e; color: #fff; }
.btn-wa:hover { background: #197a42; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 0; text-decoration: underline; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; min-height: 40px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
input.invalid, .invalid-field, [aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }
input[type="file"] { padding: 6px; }
.input-lg { font-size: 17px; min-height: 48px; }
.w-sm { width: 96px; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.field > span, .field > label > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-inline { flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-inline > span { white-space: nowrap; }
.field-inline select { width: auto; min-width: 200px; }
.field-error { color: var(--danger); font-size: 13px; margin: 0; min-height: 0; }
.field-error:empty { display: none; }
.hint { color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }

/* ─────────── Layout helpers ─────────── */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ─────────── Cards ─────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-tight { padding: 12px 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card-pad { padding: 16px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-flush .card-head { margin-bottom: 0; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic { width: 36px; height: 36px; margin-bottom: 8px; color: var(--line-strong); }

/* ─────────── Alerts, badges, chips ─────────── */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; border: 1px solid transparent; transition: opacity .4s; }
.alert.fade { opacity: 0; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.alert-info { background: var(--info-soft); }
.flash-stack { margin-bottom: 8px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge-sent { background: var(--info-soft); color: #2f5aa8; border-color: transparent; }
.badge-partial { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-paid { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-cancelled { background: var(--danger-soft); color: var(--danger); border-color: transparent; text-decoration: line-through; }
.badge-overdue { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-quote { background: #efe9fb; color: #6941c6; border-color: transparent; }
@media (prefers-color-scheme: dark) { .badge-sent { color: #8fb1ee; } .badge-quote { background: #2a2340; color: #b9a3f5; } }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.chip-new { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; min-height: 30px;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tax-chip {
  border: 1.5px dashed var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.tax-chip:hover { border-color: var(--accent); color: var(--accent); }
.tax-chip.on { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.warn-text { color: var(--warn); font-size: 13px; font-weight: 600; }
.ok-text { color: var(--ok); }
.error-text { color: var(--danger); }

/* ─────────── Tables ─────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr[data-href] { cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: end; white-space: nowrap; }
table.data .sub { display: block; font-size: 12px; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; }

/* ─────────── Filters ─────────── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { min-width: 150px; }
.filters .search { flex: 1; min-width: 220px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ─────────── Stats ─────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat-lines { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }

/* ─────────── Combobox ─────────── */
.combo { position: relative; }
.combo-list {
  position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 30; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 300px; overflow-y: auto; min-width: 260px;
}
.combo-list li[role="option"] { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.combo-list li[aria-selected="true"], .combo-list li[role="option"]:hover { background: var(--accent-soft); }
.opt-title { font-weight: 600; }
.opt-sub { grid-column: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-side { grid-row: 1; grid-column: 2; font-size: 13px; color: var(--ink-2); direction: ltr; font-variant-numeric: tabular-nums; }
.opt-footer { padding: 8px 10px; font-size: 13px; color: var(--accent); border-top: 1px dashed var(--line); margin-top: 2px; }

/* ─────────── Editor ─────────── */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.editor-side { position: sticky; top: 76px; }
@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: sticky; bottom: 0; top: auto; z-index: 15; }
  .totals-card { margin-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
  .totals-card .card-title { display: none; }
}
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.doc-number { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 6px 16px; border-radius: 6px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg-opt input:checked + span { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); }
.seg-opt input:disabled + span { cursor: default; }
.seg-sm .seg-opt span { padding: 4px 10px; font-size: 13px; }
details.more { margin-top: 12px; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; margin-bottom: 10px; list-style: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }

.currency-bar { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: center; }
.add-currency { display: flex; flex-wrap: wrap; gap: 6px; }
.rates { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.rate-row {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px;
}
.rate-code { display: flex; flex-direction: column; line-height: 1.2; min-width: 90px; }
.rate-pair { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; direction: ltr; font-size: 13px; color: var(--ink-2); }
.rate-pair input { width: 116px; min-height: 36px; padding: 5px 8px; text-align: center; font-weight: 700; }
.rate-swap { color: var(--muted); }
.rate-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; flex: 1 1 auto; min-width: 0; }
.rate-meta > * { white-space: nowrap; }
.rate-del { margin-inline-start: auto; }
@media (max-width: 760px) { .rate-swap { display: none; } }
.print-mode { border: 0; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.print-mode legend { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
@media (max-width: 760px) { .print-mode { grid-template-columns: 1fr; } }
.radio-card { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card span { display: flex; flex-direction: column; }
.radio-card small { color: var(--muted); font-size: 12px; }

table.lines { width: 100%; border-collapse: collapse; min-width: 720px; }
table.lines th { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; text-align: start; background: var(--surface-2); border-block: 1px solid var(--line); white-space: nowrap; }
table.lines td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines tr:focus-within { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.c-idx { width: 36px; color: var(--muted); text-align: center !important; padding-top: 16px !important; font-variant-numeric: tabular-nums; }
.c-item { min-width: 260px; }
.c-num { width: 130px; text-align: end !important; }
.c-tax { width: 44px; text-align: center !important; padding-top: 18px !important; }
.c-act { width: 76px; white-space: nowrap; padding-top: 10px !important; }
.lines input.num { text-align: end; font-weight: 600; }
.ln-desc { margin-top: 6px; min-height: 36px; font-size: 13px; color: var(--ink-2); resize: none; overflow: hidden; }
.ln-total { padding-top: 16px !important; font-weight: 700; }
.ln-total .eq { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.ln-hints { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ln-hints:empty { display: none; }
.hint-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.hint-chip input { width: 14px; height: 14px; }
.hint-new { background: var(--accent-soft); color: var(--accent); border-color: transparent; cursor: pointer; }
.hint-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; cursor: pointer; }
.hint-link { cursor: pointer; font: inherit; font-size: 12px; background: var(--info-soft); color: #2f5aa8; border-color: transparent; }
.lines-foot { display: flex; align-items: center; gap: 16px; }
.discount-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.discount-row .combo { min-width: 180px; }
.d-amount { min-width: 80px; font-variant-numeric: tabular-nums; }

.totals { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 12px 0 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: end; font-weight: 600; white-space: nowrap; }
.totals .neg { color: var(--danger); }
.totals .grand { font-size: 19px; font-weight: 800; color: var(--ink); padding-top: 10px; border-top: 1px solid var(--line); }
.equivalents { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.equivalents:empty { display: none; }
.eq-title { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.eq-row { display: flex; flex-direction: column; background: var(--accent-soft); border-radius: var(--radius-sm); padding: 8px 12px; }
.eq-amt { font-size: 17px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.eq-rate { font-size: 12px; color: var(--muted); }
.save-bar { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.save-state { text-align: center; margin: 0; min-height: 1em; }
@media (max-width: 1100px) {
  .totals { grid-template-columns: 1fr auto; font-size: 14px; }
  .totals dt:not(.grand), .totals dd:not(.grand) { display: none; }
  .totals .grand { border: 0; padding: 0; }
  .equivalents { flex-direction: row; flex-wrap: wrap; margin-top: 8px; }
  .eq-title { display: none; }
  .eq-row { padding: 4px 10px; }
  .eq-amt { font-size: 14px; }
  .save-bar { flex-direction: row; margin-top: 10px; }
}

/* ─────────── Document view ─────────── */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .doc-layout { grid-template-columns: 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { display: inline; margin: 0; }
.doc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.doc-summary .label { color: var(--muted); font-size: 12px; }
.doc-summary .value { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.send-box { display: flex; flex-direction: column; gap: 12px; }
.share-url { display: flex; gap: 6px; }
.share-url input { direction: ltr; font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: flex; flex-direction: column; font-size: 13px; padding-inline-start: 14px; border-inline-start: 2px solid var(--line); }
.timeline li small { color: var(--muted); }
.preview-frame { background: var(--surface-2); border-radius: var(--radius); padding: 8px; }

/* ─────────── Auth ─────────── */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); text-align: center; }
.auth-card h1 { font-size: 22px; margin: 8px 0 4px; }
.auth-card form { text-align: start; margin-top: 20px; }
.auth-icon { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.auth-icon .ic { width: 26px; height: 26px; }

/* ─────────── Toasts ─────────── */
.toast-host { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: opacity .5s, transform .5s; }
.toast-error { background: var(--danger); color: #fff; }
.toast-success { background: var(--ok); color: #fff; }
.toast.hide { opacity: 0; transform: translateY(8px); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.mt { margin-top: 12px; }
.logo-preview { max-height: 56px; max-width: 160px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
.btn-block { white-space: normal; text-align: center; }
.fieldset-plain { border: 0; padding: 0; margin: 0; }
.fieldset-plain legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 8px; }
.chip-check { border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; background: var(--surface); }
.chip-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.color-input { width: 80px; height: 42px; padding: 3px; cursor: pointer; }
