/* ==========================================================================
   Flagship City Software — back office, customer portal and documents
   ========================================================================== */

@font-face { font-family: "Sora"; src: url("../fonts/Sora-var.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-var.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #f3f6fc;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --line: #e2e8f4;
  --line-strong: #cbd5e8;
  --ink: #0b1633;
  --ink-2: #44506e;
  --ink-3: #75809c;
  --brand: #1d6bff;
  --brand-deep: #0a1f63;
  --brand-tint: #e8f0ff;
  --cyan: #0ea5e9;
  --rail: #061233;
  --rail-2: #0a1d52;
  --ok: #059669; --ok-tint: #e3f7ef;
  --warn: #b45309; --warn-tint: #fff4e0;
  --bad: #dc2626; --bad-tint: #fdecec;
  --info: #1d6bff; --info-tint: #e8f0ff;
  --mute-tint: #eef1f7;
  --violet: #6d4bff; --violet-tint: #efeaff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 22, 51, .05), 0 6px 24px -12px rgba(11, 22, 51, .18);
  --display: "Sora", ui-sans-serif, system-ui, sans-serif;
  --body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --rail-w: 252px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050c22; --surface: #0b1634; --surface-2: #0f1c40; --line: #1b2a55; --line-strong: #29407a;
    --ink: #e9efff; --ink-2: #b2bedd; --ink-3: #7f8cb0; --brand: #4b8bff; --brand-tint: #11245a;
    --ok-tint: #0b2e26; --warn-tint: #33240a; --bad-tint: #3a1218; --info-tint: #11245a; --mute-tint: #16224a; --violet-tint: #221a4d;
    --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --info: #7aa8ff; --violet: #a993ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0 0 .5em; letter-spacing: -.015em; line-height: 1.2; color: var(--ink); }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
svg { flex-shrink: 0; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: .92em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: radial-gradient(120% 60% at 0% 0%, #10307f 0%, transparent 60%), linear-gradient(180deg, var(--rail-2), var(--rail));
  color: #c9d5f5; padding: 18px 14px; border-right: 1px solid rgba(255, 255, 255, .06);
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; color: #fff; }
.rail-brand:hover { text-decoration: none; }
.rail-brand img { width: 36px; height: 36px; }
.rail-brand b { display: block; font: 800 .86rem/1 var(--display); letter-spacing: .03em; }
.rail-brand small { display: block; font: 600 .52rem/1 var(--display); letter-spacing: .3em; color: #38bdf8; margin-top: 4px; }
.rail-section { font: 600 .66rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #6f80b5; padding: 18px 10px 8px; }
.rail a.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: #c9d5f5; font-weight: 500; font-size: .92rem;
  transition: background .15s, color .15s;
}
.rail a.nav-item svg { width: 18px; height: 18px; color: #7f93cc; }
.rail a.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.rail a.nav-item[aria-current="page"] { background: linear-gradient(100deg, rgba(29, 107, 255, .45), rgba(14, 165, 233, .15)); color: #fff; box-shadow: inset 0 0 0 1px rgba(56, 189, 248, .25); }
.rail a.nav-item[aria-current="page"] svg { color: #7dd3fc; }
.rail .count { margin-left: auto; min-width: 22px; padding: 2px 7px; border-radius: 999px; background: #1d6bff; color: #fff; font: 600 .7rem/1.3 var(--mono); text-align: center; }
.rail .soon { margin-left: auto; font: 600 .6rem/1 var(--mono); letter-spacing: .08em; padding: 4px 6px; border-radius: 6px; background: rgba(124, 92, 255, .25); color: #c4b5ff; }
.rail-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .08); }
.rail-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #1d6bff, #0ea5e9); color: #fff; font: 700 .85rem/1 var(--display); flex-shrink: 0; }
.rail-user b { display: block; color: #fff; font-size: .88rem; font-weight: 600; }
.rail-user small { color: #7f93cc; font-size: .76rem; }
.rail form button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; width: calc(100% - 20px); color: #c9d5f5; font-size: .92rem; }
.rail form button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.rail form button svg { width: 18px; height: 18px; color: #7f93cc; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1320px; width: 100%; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.crumbs { font-size: .82rem; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 600 .88rem/1.1 var(--body); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(120deg, #1d6bff, #1597e5); border-color: transparent; color: #fff; box-shadow: 0 6px 18px -8px rgba(29, 107, 255, .8); }
.btn-primary:hover { background: linear-gradient(120deg, #2a76ff, #1aa6f0); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-tint); }
.btn-ok { color: var(--ok); }
.btn-ok:hover { border-color: var(--ok); background: var(--ok-tint); }
.btn-sm { padding: 6px 10px; font-size: .8rem; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { width: 100%; justify-content: center; }
form.inline { display: inline; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.stack > .panel + .panel, .stack > * + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 1rem; }
.panel-body { padding: 20px; }
.cols { display: grid; gap: 20px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack { display: grid; gap: 20px; align-content: start; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { position: relative; overflow: hidden; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, var(--brand-tint), transparent 70%); }
.kpi small { display: flex; align-items: center; gap: 7px; color: var(--ink-3); font-weight: 500; font-size: .82rem; }
.kpi small svg { width: 16px; height: 16px; color: var(--brand); }
.kpi b { display: block; font: 700 1.6rem/1.2 var(--display); margin-top: 8px; letter-spacing: -.02em; position: relative; z-index: 1; }
.kpi span { font-size: .8rem; color: var(--ink-3); }
.kpi.hero { background: linear-gradient(135deg, #0a1f63, #1d6bff 120%); border: 0; color: #fff; }
.kpi.hero small, .kpi.hero span { color: #b8cbff; }
.kpi.hero small svg { color: #7dd3fc; }
.kpi.hero::after { background: radial-gradient(circle, rgba(56, 189, 248, .4), transparent 70%); }
.kpi.alert b { color: var(--bad); }

/* ---------- chart ---------- */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 190px; padding-top: 10px; }
.bar { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 8px; }
.bar i { display: block; width: 100%; max-width: 34px; min-height: 3px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, #38bdf8, #1d6bff); transform-origin: bottom; animation: grow .8s cubic-bezier(.2, .8, .2, 1) both; }
.bar.now i { background: linear-gradient(180deg, #7dd3fc, #0ea5e9); box-shadow: 0 0 0 3px var(--brand-tint); }
.bar small { font-size: .72rem; color: var(--ink-3); }
.bar .tip { position: absolute; bottom: calc(var(--h) + 28px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); font: 600 .72rem/1 var(--mono); padding: 6px 8px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 2; }
.bar:hover .tip { opacity: 1; }
@keyframes grow { from { transform: scaleY(0); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font: 600 .72rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table a.row-link { font-weight: 600; color: var(--ink); }
.table td small { display: block; color: var(--ink-3); }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty svg { width: 40px; height: 40px; color: var(--line-strong); margin: 0 auto 10px; display: block; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font: 600 .74rem/1.2 var(--body); white-space: nowrap; background: var(--mute-tint); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { background: var(--mute-tint); color: var(--ink-3); }
.badge-sent, .badge-new, .badge-contacted { background: var(--info-tint); color: var(--info); }
.badge-partial, .badge-qualified { background: var(--warn-tint); color: var(--warn); }
.badge-paid, .badge-accepted, .badge-won { background: var(--ok-tint); color: var(--ok); }
.badge-overdue, .badge-declined { background: var(--bad-tint); color: var(--bad); }
.badge-void, .badge-closed { background: var(--mute-tint); color: var(--ink-3); text-decoration: line-through; }
.badge-closed { text-decoration: none; }
.badge-invoiced { background: var(--violet-tint); color: var(--violet); }

/* ---------- filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.tabs-inline { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs-inline a { padding: 7px 12px; border-radius: 8px; font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.tabs-inline a:hover { background: var(--surface-2); text-decoration: none; }
.tabs-inline a.on { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--ink-3); }
.search input { padding-left: 34px !important; min-width: 240px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field label, .label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: .78rem; color: var(--ink-3); }
.field .error, .error { color: var(--bad); font-size: .8rem; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: 400 .92rem/1.4 var(--body); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
textarea { min-height: 90px; resize: vertical; }
.grid-form { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.check { display: flex; gap: 8px; align-items: center; font-size: .88rem; }

/* line item editor */
.items { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.items th { text-align: left; font: 600 .7rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 0 6px; }
.items td { padding: 0 6px; vertical-align: top; }
.items .desc textarea { min-height: 38px; margin-top: 6px; font-size: .84rem; }
.items .qty { width: 100px; } .items .price { width: 140px; } .items .total { width: 130px; text-align: right; padding-top: 10px; font-variant-numeric: tabular-nums; font-weight: 600; }
.items .del { width: 40px; }
.items .del button { all: unset; cursor: pointer; display: grid; place-items: center; width: 36px; height: 38px; border-radius: 8px; color: var(--ink-3); }
.items .del button:hover { background: var(--bad-tint); color: var(--bad); }
.items .del svg { width: 16px; height: 16px; }
.totals { margin-left: auto; width: min(100%, 340px); display: grid; gap: 8px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.totals .grand { font: 700 1.2rem/1.3 var(--display); padding-top: 10px; border-top: 1px solid var(--line); }
.totals input { width: 90px; text-align: right; }

/* ---------- alerts ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-size: .9rem; border: 1px solid; }
.flash svg { width: 18px; height: 18px; margin-top: 1px; }
.flash-ok { background: var(--ok-tint); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash-bad { background: var(--bad-tint); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.flash-info { background: var(--info-tint); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.flash b { color: var(--ink); }
.secret { font-family: var(--mono); background: var(--surface); color: var(--ink); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); user-select: all; }

/* ---------- definition lists ---------- */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; word-break: break-word; }

/* ---------- activity feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); font-size: .87rem; }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex-shrink: 0; box-shadow: 0 0 0 3px var(--brand-tint); }
.feed small { display: block; color: var(--ink-3); font-size: .76rem; }

/* ---------- planned feature ---------- */
.planned { position: relative; overflow: hidden; padding: clamp(28px, 5vw, 56px); border-radius: 20px; color: #dfe8ff;
  background: radial-gradient(100% 120% at 0% 0%, #1a3fa8 0%, #0a1f63 45%, #061233 100%); border: 1px solid #22408f; }
.planned::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 36px 36px; mask-image: radial-gradient(ellipse at 80% 20%, #000, transparent 70%); -webkit-mask-image: radial-gradient(ellipse at 80% 20%, #000, transparent 70%); }
.planned > * { position: relative; }
.planned h1 { color: #fff; font-size: 1.9rem; }
.planned .tag { display: inline-block; padding: 5px 10px; border-radius: 8px; font: 600 .7rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; background: rgba(124, 92, 255, .25); color: #c4b5ff; margin-bottom: 16px; }
.planned ul { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; padding: 0; list-style: none; margin: 24px 0 0; }
.planned li { display: flex; gap: 10px; align-items: flex-start; color: #c6d4ff; }
.planned li svg { width: 18px; height: 18px; color: #7dd3fc; margin-top: 3px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #dfe8ff;
  background: radial-gradient(90% 70% at 20% 10%, #1747c7 0%, transparent 60%), radial-gradient(70% 60% at 90% 90%, #0e7fb8 0%, transparent 60%), #040c26; }
.auth-side::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(ellipse at center, #000, transparent 75%); -webkit-mask-image: radial-gradient(ellipse at center, #000, transparent 75%); }
.auth-side > * { position: relative; }
.auth-side h2 { color: #fff; font-size: 2rem; max-width: 18ch; }
.auth-side img.mark { width: 140px; filter: drop-shadow(0 20px 40px rgba(29, 107, 255, .6)); animation: float 7s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.auth-main { display: grid; place-items: center; padding: 40px 20px; background: var(--bg); }
.auth-card { width: min(100%, 400px); }
.auth-card h1 { font-size: 1.7rem; }

/* ---------- document (paper) ---------- */
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.paper { background: #fff; color: #0b1633; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: clamp(24px, 5vw, 56px); font-size: 14px; color-scheme: light; }
.paper * { color: inherit; }
.paper-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 28px; border-bottom: 2px solid #0b1633; }
.paper-head img { width: 280px; max-width: 100%; }
.paper-title { text-align: right; }
.paper-title h1 { font-size: 2rem; letter-spacing: .06em; margin: 0; text-transform: uppercase; color: #0a1f63; }
.paper-title .mono { color: #44506e; }
.paper-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding: 28px 0; }
.paper-meta h4 { font: 600 .7rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #75809c; margin-bottom: 10px; }
.paper-meta .dl { grid-template-columns: 110px 1fr; font-size: .88rem; }
.paper-meta .dl dt { color: #75809c; }
.paper .section-title { font: 700 1rem/1.3 var(--display); color: #0a1f63; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f4; }
.paper .prose { white-space: pre-line; color: #2a3553; }
.paper table.lines { width: 100%; border-collapse: collapse; margin-top: 8px; }
.paper .lines th { text-align: left; font: 600 .7rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #fff; background: #0a1f63; padding: 10px 12px; }
.paper .lines th:first-child { border-radius: 8px 0 0 8px; } .paper .lines th:last-child { border-radius: 0 8px 8px 0; }
.paper .lines td { padding: 12px; border-bottom: 1px solid #e2e8f4; vertical-align: top; }
.paper .lines td small { display: block; color: #75809c; white-space: pre-line; margin-top: 2px; }
.paper .lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper .totals { margin-top: 18px; }
.paper .totals .grand { border-top-color: #0b1633; color: #0a1f63; }
.paper .totals .due { background: #e8f0ff; padding: 10px 12px; border-radius: 8px; font-weight: 700; color: #0a1f63; }
.paper-foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid #e2e8f4; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: .8rem; color: #75809c; }
.stamp { display: inline-block; padding: 6px 14px; border: 2px solid currentColor; border-radius: 8px; font: 800 .9rem/1 var(--display); letter-spacing: .14em; text-transform: uppercase; transform: rotate(-4deg); margin-top: 10px; }
.stamp-paid, .stamp-accepted { color: #059669; } .stamp-void, .stamp-declined, .stamp-overdue { color: #dc2626; }
.respond { margin-top: 24px; }
.respond form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.respond .field { flex: 1 1 220px; }

/* public document page */
.public-doc { max-width: 980px; margin: 0 auto; padding: 28px 16px 60px; }
.public-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.public-bar a.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font: 700 .95rem/1 var(--display); }
.public-bar a.brand img { width: 34px; }

/* pagination (Laravel's default markup) */
nav[role="navigation"] { padding: 14px 16px; }
nav[role="navigation"] > div:first-child { display: none; }
nav[role="navigation"] > div:last-child { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-3); }
nav[role="navigation"] svg { width: 16px; height: 16px; }
nav[role="navigation"] span[aria-current] > span, nav[role="navigation"] a, nav[role="navigation"] span[aria-disabled] > span { display: inline-flex; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; margin-left: -1px; background: var(--surface); color: var(--ink-2); }
nav[role="navigation"] span[aria-current] > span { background: var(--brand); color: #fff; border-color: var(--brand); }
nav[role="navigation"] .shadow-sm, nav[role="navigation"] .rounded-md { box-shadow: none; display: inline-flex; }
nav[role="navigation"] p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cols-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 60; transform: translateX(-100%); transition: transform .25s ease; }
  .rail-open .rail { transform: none; box-shadow: 0 0 0 100vmax rgba(3, 10, 31, .5); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--rail); color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar button { all: unset; cursor: pointer; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .2); }
  .topbar button svg { width: 20px; height: 20px; }
  .topbar img { width: 30px; }
  .topbar b { font: 700 .9rem/1 var(--display); }
  .cols-2, .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .grid-form > * { grid-column: span 12; }
  .paper-meta { grid-template-columns: 1fr; }
  .paper-title { text-align: left; }
  .planned ul { grid-template-columns: 1fr; }
  .search input { min-width: 0; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; } .kpi b { font-size: 1.25rem; }
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
  .items td { padding: 0; }
  .items .desc { grid-column: 1 / -1; }
  .items .qty, .items .price { width: auto; }
  .items .total { grid-column: 1 / 3; text-align: left; padding-top: 0; }
  .items .del { grid-row: 2; grid-column: 3; }
  .items, .items tbody { display: block; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; } .dl dd { margin-bottom: 8px; }
}

/* ---------- print: the document only ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .rail, .topbar, .page-head, .no-print, .flash, .public-bar, .respond { display: none !important; }
  .shell { display: block; }
  .content, .public-doc { padding: 0; max-width: none; }
  .paper { box-shadow: none; border: 0; padding: 0; border-radius: 0; }
  .cols-main { display: block; }
  .cols-main > aside { display: none; }
  .paper .lines th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
