/* Araf Receipts — application UI */

:root {
  --navy-950: #0b1733;
  --navy-900: #13244f;
  --navy-800: #1b3166;
  --navy-700: #26407f;
  --gold: #c9a45c;
  --gold-soft: #f5ecda;
  --gold-ink: #8a6a2c;

  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --ink: #141a2e;
  --ink-2: #4a5270;
  --muted: #8189a3;
  --line: #e4e7ef;
  --line-2: #d5d9e4;

  --green: #13854f;
  --green-bg: #e5f5ec;
  --red: #c2352b;
  --red-bg: #fdecea;
  --amber: #a86400;
  --amber-bg: #fff3dd;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 48, .05), 0 4px 16px -6px rgba(16, 24, 48, .08);
  --shadow-lg: 0 24px 60px -18px rgba(11, 23, 51, .35);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px;
}
.boot .spinner { width: 28px; height: 28px; color: var(--navy-800); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-link:focus-visible { outline: 3px solid rgba(201, 164, 92, .55); outline-offset: 2px; }
.btn-primary { background: var(--navy-900); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 6px 16px -8px rgba(19,36,79,.7); }
.btn-primary:hover { background: var(--navy-800); }
.btn-gold { background: var(--gold); color: var(--navy-950); }
.btn-gold:hover { background: #d4b170; }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: #c2c8d6; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a92b22; }
.btn-soft-danger { background: var(--surface); border-color: #f1c7c3; color: var(--red); }
.btn-soft-danger:hover { background: var(--red-bg); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; border: 1px solid transparent; background: none;
  color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-bg); color: var(--red); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input::placeholder { color: #a6adc2; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 4px rgba(38, 64, 127, .12); }
.input.invalid { border-color: var(--red); box-shadow: 0 0 0 4px rgba(194, 53, 43, .1); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 38px; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.input-affix .input { padding-right: 30px; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; color: var(--ink-2); }
.check input { width: 17px; height: 17px; accent-color: var(--navy-900); margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-error { color: var(--red); background: var(--red-bg); border-radius: var(--radius-sm); padding: 10px 12px; font-weight: 500; font-size: 13px; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + .track { background: var(--navy-800); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(201,164,92,.55); outline-offset: 2px; }

/* ---------- Cards, badges ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.section-title .ic { color: var(--gold-ink); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-paid { background: var(--green-bg); color: var(--green); }
.badge-due { background: var(--amber-bg); color: var(--amber); }
.badge-role { background: var(--gold-soft); color: var(--gold-ink); }
.badge-role::before { display: none; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .empty-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-ink); }
.empty h3 { margin: 0 0 4px; color: var(--ink); font-size: 16px; }
.empty p { margin: 0 0 16px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-brand {
  position: relative; overflow: hidden; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; padding: 44px;
  background: radial-gradient(1200px 600px at 110% -10%, rgba(201,164,92,.22), transparent 60%),
              radial-gradient(900px 500px at -20% 120%, rgba(38,64,127,.9), transparent 60%),
              linear-gradient(160deg, var(--navy-900), var(--navy-950));
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.auth-brand > * { position: relative; z-index: 1; }
.brand-mark { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: .02em; }
.brand-mark img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: #fff; }
.auth-hero { max-width: 460px; }
.auth-hero .crest { width: 168px; height: 168px; border-radius: 28px; object-fit: cover; background: #fff; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); margin-bottom: 30px; }
.auth-hero h1 { margin: 0 0 12px; font-size: 38px; line-height: 1.12; font-weight: 800; letter-spacing: -.02em; }
.auth-hero h1 em { font-style: normal; color: var(--gold); }
.auth-hero p { margin: 0; color: rgba(255,255,255,.72); font-size: 15.5px; max-width: 400px; }
.auth-foot { color: rgba(255,255,255,.5); font-size: 12.5px; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.auth-card > p { margin: 0 0 28px; color: var(--muted); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--navy-700); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-wrap .icon-btn { position: absolute; right: 4px; top: 4px; }
.recovery-key {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: .06em;
  text-align: center; padding: 18px; border-radius: 12px; background: var(--gold-soft); color: var(--navy-950);
  border: 1px dashed var(--gold); user-select: all; word-break: break-all;
}

/* ---------- Shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950)); color: #fff; padding: 20px 14px;
}
.sidebar .brand-mark { padding: 4px 8px 22px; }
.sidebar .brand-mark small { display: block; font-weight: 500; color: rgba(255,255,255,.55); font-size: 11.5px; letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 11px;
  color: rgba(255,255,255,.72); text-decoration: none; font-weight: 600; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active { background: rgba(201,164,92,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-link.active .ic { color: var(--gold); }
.nav-cta { margin: 6px 0 14px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--gold); color: var(--navy-950); font-weight: 800; flex: none; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { font-size: 12px; color: rgba(255,255,255,.55); text-transform: capitalize; }
.sidebar-foot .icon-btn { color: rgba(255,255,255,.7); }
.sidebar-foot .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { min-width: 0; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; text-decoration: none; margin-bottom: 8px; font-size: 13px; }
.back-link:hover { color: var(--ink); }

.mobile-bar, .tabbar { display: none; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px 18px 16px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.stat-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--navy-800); }
.stat-ic.gold { background: var(--gold-soft); color: var(--gold-ink); }
.stat-ic.green { background: var(--green-bg); color: var(--green); }
.stat-ic.amber { background: var(--amber-bg); color: var(--amber); }
.stat-value { margin-top: 12px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value .cur { font-size: .7em; color: var(--muted); margin-left: 3px; font-weight: 700; }
.stat-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.stat.hero { background: linear-gradient(145deg, var(--navy-900), var(--navy-800)); color: #fff; border-color: transparent; }
.stat.hero .stat-top { color: rgba(255,255,255,.75); }
.stat.hero .stat-ic { background: rgba(201,164,92,.2); color: var(--gold); }
.stat.hero .stat-sub, .stat.hero .cur { color: rgba(255,255,255,.6); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 10px; height: 210px; padding: 20px 20px 16px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; min-width: 0; }
.bar {
  width: 100%; max-width: 44px; min-height: 4px; border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--navy-700), var(--navy-900)); position: relative; transition: height .5s cubic-bezier(.2,.8,.2,1);
}
.bar-col.today .bar { background: linear-gradient(180deg, #d9b976, var(--gold)); }
.bar-col .bar-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.bar-col.today .bar-label { color: var(--ink); }
.bar-tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }

.list { display: flex; flex-direction: column; }
.list-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); text-decoration: none; transition: background .12s;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.inv-chip { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--bg); color: var(--navy-800); font-weight: 800; font-size: 12.5px; }
.list-row .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .amt { text-align: right; }
.list-row .amt b { display: block; font-variant-numeric: tabular-nums; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); gap: 24px; align-items: start; }
.editor-form { display: flex; flex-direction: column; gap: 18px; }
.editor-side { position: sticky; top: 24px; }
.preview-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; }
.preview-card { padding: 14px; background: #e9ebf2; border-radius: var(--radius); }

.items-head, .item-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 74px 120px 120px 34px; gap: 10px; align-items: start; }
.items-head { padding: 0 20px 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.items-head .r { text-align: right; }
.item-rows { display: flex; flex-direction: column; }
.item-row { padding: 12px 20px; border-top: 1px solid var(--line); animation: rowIn .2s ease-out; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } }
.item-row .idx { height: 42px; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.item-row .name-stack { display: flex; flex-direction: column; gap: 6px; }
.item-row .warranty { height: 34px; font-size: 13px; }
.item-row .line-amt { height: 42px; display: flex; align-items: center; justify-content: flex-end; font-weight: 700; font-variant-numeric: tabular-nums; }
.item-row .icon-btn { margin-top: 4px; }
.items-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.m-label { display: none; }

.totals { display: flex; flex-direction: column; gap: 12px; }
.total-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.total-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.total-line.grand { padding-top: 12px; border-top: 1px dashed var(--line-2); font-size: 16px; }
.total-line.grand b { font-size: 22px; font-weight: 800; }
.total-line.due b { color: var(--amber); }
.total-line.paid b { color: var(--green); }
.words { font-size: 12.5px; color: var(--muted); font-style: italic; text-align: right; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.quick-pay { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip-btn { height: 28px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip-btn:hover { border-color: var(--navy-700); color: var(--navy-800); }

.action-bar { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 11px; padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,.16); margin-left: 4px; }
.btn-ghost .kbd { background: var(--bg); color: var(--muted); }

/* ---------- History ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--bg); border: 1px solid var(--line); }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: none; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16,24,48,.12); }
.date-nav { display: inline-flex; align-items: center; gap: 4px; }
.date-nav .input { width: 160px; height: 38px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .input { height: 38px; }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); border-top: 1px solid var(--line); }
.summary-strip > div { padding: 14px 18px; border-right: 1px solid var(--line); }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.summary-strip b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

.day-group { margin-top: 20px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 4px 10px; }
.day-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.day-head h3 small { font-weight: 600; color: var(--muted); margin-left: 8px; font-size: 13px; }
.day-head .day-sum { color: var(--ink-2); font-size: 13px; }
.day-head .day-sum b { color: var(--ink); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 11px 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 { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table th:first-child { border-radius: var(--radius) 0 0 0; }
.table th:last-child { border-radius: 0 var(--radius) 0 0; }
.table .r { text-align: right; }
.table .inv { font-weight: 800; color: var(--navy-800); }
.table .cust b { display: block; }
.table .cust span, .table .items-cell { color: var(--muted); font-size: 12.5px; }
.table .items-cell { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }

/* Receipt detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.detail-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 24px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; text-decoration: none; }
.settings-nav a:hover { background: var(--surface); color: var(--ink); }
.settings-body { display: flex; flex-direction: column; gap: 20px; }
.settings-body .card { scroll-margin-top: 20px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.logo-edit { display: flex; align-items: center; gap: 16px; }
.logo-edit img { width: 76px; height: 76px; border-radius: 14px; object-fit: contain; border: 1px solid var(--line); background: #fff; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row:first-child { padding-top: 0; }
.setting-row b { display: block; }
.setting-row p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row .avatar { background: var(--navy-900); color: #fff; }
.user-row .who { flex: 1; min-width: 0; }
.user-row .who span { color: var(--muted); font-size: 12.5px; }
.danger-card { border-color: #f3d3cf; }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--gold-soft); color: #5f4a1f; font-size: 13px; }
.note .ic { color: var(--gold-ink); margin-top: 1px; }

/* ---------- Toasts & modals ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 16px;
  border-radius: 12px; background: var(--navy-950); color: #fff; font-weight: 600; box-shadow: var(--shadow-lg);
  transform: translateY(10px); opacity: 0; transition: transform .25s, opacity .25s;
}
.toast.show { transform: none; opacity: 1; }
.toast-success .ic { color: #6fe0a5; }
.toast-error { background: var(--red); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px;
  background: rgba(11, 23, 51, .45); backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s;
}
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; max-width: 440px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.98); transition: transform .18s; }
.modal.wide { max-width: 560px; }
.modal-backdrop.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-body { padding: 14px 20px 6px; }
.modal-text { margin: 0; color: var(--ink-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; }
  .editor-side .preview-card { max-width: 560px; margin: 0 auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 24px 32px; min-height: auto; }
  .auth-hero .crest { width: 88px; height: 88px; border-radius: 18px; margin-bottom: 18px; }
  .auth-hero h1 { font-size: 26px; }
  .auth-hero p { font-size: 14px; }
  .auth-foot, .auth-brand .brand-mark { display: none; }

  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px 16px 96px; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 20; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--navy-900); color: #fff;
  }
  .mobile-bar .brand-mark img { width: 34px; height: 34px; }
  .mobile-bar .icon-btn { color: rgba(255,255,255,.8); }
  .mobile-bar .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px -12px rgba(16,24,48,.15);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 700; color: var(--muted); text-decoration: none; }
  .tabbar a.active { color: var(--navy-900); }
  .tabbar a.fab .ic { width: 46px; height: 46px; padding: 12px; margin-top: -22px; border-radius: 16px; background: var(--gold); color: var(--navy-950); box-shadow: 0 10px 20px -8px rgba(138,106,44,.7); }

  .page-head h1 { font-size: 22px; }
  .dash-grid, .detail, .settings { grid-template-columns: minmax(0, 1fr); }
  .detail-side, .settings-nav { position: static; }
  .settings-nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .settings-nav a { background: var(--surface); border: 1px solid var(--line); white-space: nowrap; height: 36px; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .summary-strip > div:nth-child(2) { border-right: 0; }
  .summary-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 680px) {
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 19px; }
  .grid-2, .grid-3, .pay-grid { grid-template-columns: 1fr; }
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr; gap: 8px 10px; position: relative; padding-top: 14px; }
  .item-row .idx { display: none; }
  .item-row .name-stack { grid-column: 1 / -1; padding-right: 40px; }
  .item-row .icon-btn { position: absolute; top: 14px; right: 14px; margin: 0; }
  .item-row .line-amt { grid-column: 1 / -1; justify-content: space-between; height: auto; padding-top: 2px; }
  .m-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
  .line-amt .m-label { margin: 0; }
  .toolbar .date-nav { width: 100%; }
  .date-nav .input { flex: 1; width: auto; }
  .action-bar .btn { flex: 1; }
  .table .hide-sm { display: none; }
  .card-head { padding: 14px 16px; }
  .list-row { padding: 12px 16px; }
}
