/* Saral Launch control panel.
   One accent (Saral blue, deepened from #007bff so text and buttons pass AA), neutrals tinted toward the same hue,
   and real steps between page, surface and raised layers. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --line: #dbe2eb;
  --line-strong: #c3cdda;
  --ink: #0b1524;
  --ink-2: #3a4759;
  --ink-3: #5d6b80;
  --brand: #0062d6;
  --brand-hover: #004fae;
  --brand-tint: #e7f0fc;
  --brand-on: #ffffff;
  --ok: #0b7a49;
  --ok-tint: #e3f4ec;
  --warn: #965400;
  --warn-tint: #fbf0de;
  --bad: #c0262d;
  --bad-tint: #fbe7e8;
  --focus: 0 0 0 3px rgb(0 98 214 / .28);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(11 21 36 / .06), 0 1px 1px rgb(11 21 36 / .04);
  --font: "Satoshi", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1019;
    --surface: #111924;
    --surface-2: #17212f;
    --line: #233041;
    --line-strong: #31415a;
    --ink: #e9eef5;
    --ink-2: #b6c2d2;
    --ink-3: #8d9bb0;
    --brand: #5aa2ff;
    --brand-hover: #84b9ff;
    --brand-tint: #132a49;
    --brand-on: #04121f;
    --ok: #4cc98b;
    --ok-tint: #0f2b1f;
    --warn: #f0b155;
    --warn-tint: #2e220e;
    --bad: #ff7b80;
    --bad-tint: #341518;
    --focus: 0 0 0 3px rgb(90 162 255 / .35);
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 13px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* ── shell ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 6px; color: var(--ink); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: var(--brand-on); display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; padding: 0 10px 6px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.nav .count { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); display: grid; gap: 6px; }
.side-foot form { margin: 0; }
.main { padding: 28px 36px 64px; min-width: 0; }
.wrap { max-width: 1180px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head p { color: var(--ink-3); margin-top: 6px; max-width: 70ch; }
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; display: block; }

/* ── surfaces ──────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.stack > * + * { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.card-head p { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 18px 20px; }
.stat .label { color: var(--ink-3); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }

/* ── tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-title { font-weight: 600; color: var(--ink); }
.row-sub { font-size: 13px; color: var(--ink-3); margin-top: 1px; }
.empty { padding: 44px 22px; text-align: center; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

/* ── badges ────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.brand { background: var(--brand-tint); color: var(--brand); }

/* ── tabs ──────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--ink-3); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); }

/* ── forms ─────────────────────────────────────────────── */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.req { color: var(--bad); margin-left: 2px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], select, textarea {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: .8; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; color: var(--ink-2); }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.secret-state { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-3); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 650; padding-top: 6px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline > .field { flex: 1 1 160px; }
.code-input { font-family: var(--mono); font-size: 22px !important; letter-spacing: .35em; text-align: center; }

/* ── buttons ───────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 600; min-height: 38px; padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; transition: background-color .15s ease, border-color .15s ease, transform .1s ease; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-on); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: var(--bad-tint); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; font-weight: 500; }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── notices ───────────────────────────────────────────── */
.note { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid; }
.note.ok { background: var(--ok-tint); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.note.bad { background: var(--bad-tint); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.note.warn { background: var(--warn-tint); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.note.info { background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 25%, transparent); color: var(--ink-2); }
.note strong { color: inherit; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ── key/value lists ───────────────────────────────────── */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 0; font-size: 14px; }
.kv dt { color: var(--ink-3); padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.secret-box { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; max-height: 260px; overflow: auto; }

/* ── sign-in ───────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 18px; }
.auth-card h1 { font-size: 20px; text-align: center; }
.auth-card .lede { text-align: center; color: var(--ink-3); margin: 6px 0 20px; font-size: 14px; }
.qr { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--line); width: max-content; margin: 0 auto; }
.qr img { width: 184px; height: 184px; image-rendering: pixelated; display: block; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-family: var(--mono); font-size: 15px; }
.codes span { padding: 8px; text-align: center; background: var(--surface-2); border-radius: 6px; }

/* ── responsive ────────────────────────────────────────── */
@media (max-width: 1060px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; flex-wrap: nowrap; align-items: center; overflow-x: auto; padding: 8px 12px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .side .nav { flex-direction: row; flex-wrap: nowrap; }
  .side .nav a { white-space: nowrap; }
  .brand { padding: 4px 8px 4px 2px; flex: none; }
  .brand small { display: none; }
  .nav-label, .side-foot { display: none; }
  .main { padding: 20px 16px 48px; }
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 0; }
}
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.edit-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1060px) { .edit-grid { grid-template-columns: 1fr; } }

/* ── small utilities (the CSP forbids inline style attributes) ── */
.u-mt6 { margin-top: 6px; } .u-mt8 { margin-top: 8px; } .u-mt12 { margin-top: 12px; } .u-mt16 { margin-top: 16px; }
.u-mb4 { margin-bottom: 4px; } .u-mb10 { margin-bottom: 10px; } .u-mb16 { margin-bottom: 16px; }
.u-gap-sm-md { margin: 6px 0 12px; } .u-gap-sm-sm { margin: 6px 0 10px; } .u-gap-qr { margin: 10px 0 18px; }
.u-grow { flex: 1; min-width: 0; } .u-w92 { width: 92px; flex: none; } .u-nowrap { white-space: nowrap; }
.u-center { text-align: center; } .u-short { min-height: 64px; } .u-pre { white-space: pre-wrap; }
.u-between { justify-content: space-between; } .u-plainlink { color: inherit; } .u-plainlink:hover { text-decoration: none; }

/* ── collapsible cards ── */
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary.summary { border-bottom: 0; }
details.card[open] > summary.summary { border-bottom: 1px solid var(--line); }
details.card > summary.summary::after { content: "+"; font-size: 20px; color: var(--ink-3); font-weight: 400; }
details.card[open] > summary.summary::after { content: "−"; }
details.inline-menu > summary { list-style: none; display: inline-flex; }
details.inline-menu > summary::-webkit-details-marker { display: none; }

/* ── invoice paper (A4) ── */
.paper { background: #fff; color: #111827; border: 1px solid var(--line); border-radius: var(--radius); padding: 44px 48px; max-width: 860px; font-size: 14px; line-height: 1.5; position: relative; box-shadow: var(--shadow); }
.paper.is-void::after { content: "VOID"; position: absolute; inset: 40% 0 auto; text-align: center; font-size: 110px; font-weight: 800; color: rgb(192 38 45 / .14); transform: rotate(-18deg); pointer-events: none; }
.paper-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 22px; border-bottom: 2px solid #0062d6; }
.paper-seller { font-size: 20px; font-weight: 750; letter-spacing: -.01em; margin-bottom: 4px; }
.paper-small { font-size: 12.5px; color: #4b5563; }
.paper-title { text-align: right; }
.paper-doc { font-size: 22px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: #0062d6; margin-bottom: 10px; }
.paper-meta { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0; font-size: 13px; justify-content: end; }
.paper-meta dt { color: #6b7280; } .paper-meta dd { margin: 0; font-weight: 600; text-align: right; }
.paper-buyer { padding: 20px 0; }
.paper-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; margin-bottom: 4px; }
.paper-strong { font-weight: 700; font-size: 15.5px; }
.paper-lines { width: 100%; border-collapse: collapse; margin-top: 4px; }
.paper-lines th { background: #f3f6fa; color: #374151; font-size: 11.5px; padding: 9px 10px; border-bottom: 1px solid #d1d9e4; text-transform: uppercase; letter-spacing: .05em; }
.paper-lines td { padding: 10px; border-bottom: 1px solid #e5e9f0; vertical-align: top; }
.paper-lines .sn { width: 44px; } .paper-lines tbody tr:hover td { background: transparent; }
.paper-bottom { display: grid; grid-template-columns: 1fr 300px; gap: 28px; margin-top: 18px; }
.paper-totals { display: grid; grid-template-columns: 1fr auto; gap: 5px 16px; margin: 0; align-self: start; }
.paper-totals dt { color: #4b5563; } .paper-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.paper-totals .grand { font-weight: 750; color: #111827; font-size: 15px; border-top: 1px solid #d1d9e4; padding-top: 6px; }
.paper-foot { margin-top: 34px; padding-top: 14px; border-top: 1px solid #e5e9f0; display: grid; gap: 4px; }
@media (max-width: 700px) { .paper { padding: 24px 18px; } .paper-head, .paper-bottom { display: grid; grid-template-columns: 1fr; } .paper-title { text-align: left; } .paper-meta { justify-content: start; } }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .side, .no-print, .head { display: none !important; }
  .shell { display: block; } .main { padding: 0; } .wrap { max-width: none; }
  .paper { border: 0; box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .paper-lines th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
/* grid columns must be allowed to shrink below their widest table (the table scrolls inside its card) */
.grid > * { min-width: 0; }

/* ── client panel ── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-in { max-width: 1080px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.topnav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { padding: 7px 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topnav a[aria-current="page"] { background: var(--brand-tint); color: var(--brand); }
.topbar-out { margin: 0; flex: none; }
.client-main { max-width: 1080px; margin: 0 auto; padding: 30px 20px 64px; }
.hello { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.steps { display: grid; gap: 10px; counter-reset: step; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(step); width: 26px; height: 26px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.codeblock { position: relative; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; white-space: pre-wrap; word-break: break-all; margin-top: 8px; }
.key-once { font-family: var(--mono); font-size: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ok-tint); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); word-break: break-all; }
@media (max-width: 640px) { .topbar-in { padding: 8px 12px; gap: 8px; } .topbar .brand span:last-child { display: none; } .client-main { padding: 20px 16px 48px; } }
.value-lg { font-size: 30px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .small-value { font-size: 15px; display: flex; gap: 6px; padding-top: 6px; }
@media print { .topbar { display: none !important; } .client-main { padding: 0; max-width: none; } }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; border-top: 1px solid var(--line); }
.media-item { margin: 0; display: grid; gap: 6px; align-content: start; }
.media-item img, .media-file { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.media-file { display: grid; place-items: center; font-weight: 700; color: var(--ink-3); }
.media-item figcaption { display: grid; gap: 1px; word-break: break-word; }
.thread .msg.from-saral { border-left: 3px solid var(--brand); }
.log-box { max-height: 70vh; font-size: 12px; line-height: 1.5; }
