/* Sarkar iPhones billing — black wordmark, orange crown.
   Orange is the single accent. Text on orange is always ink (white fails contrast). */

:root {
  --ink: #0d0d12;
  --ink-2: #181820;
  --ink-3: #262631;
  --crown: #ff6600;
  --crown-hover: #ff7a24;
  --crown-press: #e65c00;
  --crown-soft: #ffeee2;

  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --line: #e2e4ec;
  --text: #12131a;
  --muted: #666a7d;
  --focus: #0d0d12;

  --ok: #0c7f58;
  --ok-bg: #e2f5ec;
  --bad: #c0332a;
  --bad-bg: #fdeae8;
  --warn: #8f5600;
  --warn-bg: #fff1d6;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 0 rgba(13, 13, 18, .04), 0 18px 40px -22px rgba(13, 13, 18, .28);
  --font-display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #08080c;
  --surface: #13131a;
  --surface-2: #1a1a23;
  --line: #272733;
  --text: #f1f1f6;
  --muted: #9b9eb2;
  --crown-soft: rgba(255, 102, 0, .14);
  --focus: #ff6600;
  --ok: #3ddc9a;
  --ok-bg: rgba(61, 220, 154, .12);
  --bad: #ff8a80;
  --bad-bg: rgba(255, 138, 128, .12);
  --warn: #ffc15c;
  --warn-bg: rgba(255, 193, 92, .12);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 18px 40px -22px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15.5px/1.5 var(--font-body); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
a { color: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--ink); color: #fff;
}
.topbar img { height: 32px; width: auto; }
.topbar .title { font: 600 17px var(--font-display); flex: 1; }
.main { padding: 20px 16px 120px; max-width: 1240px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr;
  align-items: end; padding: 0 6px calc(8px + env(safe-area-inset-bottom)); background: var(--ink); color: #b9bccb;
  border-top-left-radius: 22px; border-top-right-radius: 22px;
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px 4px; font: 500 11.5px var(--font-body);
  color: inherit; text-decoration: none; background: none; border: 0; cursor: pointer;
}
.tabbar a[aria-current="page"] { color: #fff; }
.tabbar a[aria-current="page"] svg { color: var(--crown); }
.tabbar .fab {
  width: 62px; height: 62px; margin: -26px auto 0; border-radius: 50%; background: var(--crown); color: var(--ink);
  display: grid; place-items: center; padding: 0; border: 5px solid var(--bg); box-shadow: 0 10px 24px -8px rgba(255, 102, 0, .7);
}
.tabbar .fab svg { width: 28px; height: 28px; stroke-width: 2.4; }
.tabbar .fab-label { text-align: center; font: 500 11.5px var(--font-body); color: #fff; padding-bottom: 4px; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 264px 1fr; }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 26px 16px 18px;
    background: var(--ink); color: #c9ccda;
  }
  .sidebar .brand { padding: 0 8px 26px; }
  .sidebar .brand img { width: 100%; max-width: 190px; display: block; }
  .nav-group { font: 500 12px var(--font-body); color: #7d8197; padding: 20px 12px 8px; }
  .nav a, .nav button {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; margin-bottom: 2px; border-radius: 12px;
    color: inherit; text-decoration: none; font: 500 15px var(--font-body); background: none; border: 0; cursor: pointer; text-align: left;
    position: relative;
  }
  .nav a:hover, .nav button:hover { background: var(--ink-2); color: #fff; }
  .nav a[aria-current="page"] { background: var(--ink-3); color: #fff; }
  .nav a[aria-current="page"]::before {
    content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--crown);
  }
  .nav a[aria-current="page"] svg { color: var(--crown); }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
  .who { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--ink-2); }
  .who .av { width: 36px; height: 36px; border-radius: 50%; background: var(--crown); color: var(--ink); display: grid; place-items: center; font: 700 15px var(--font-display); }
  .who b { display: block; color: #fff; font-weight: 600; line-height: 1.2; }
  .who span { font-size: 12.5px; color: #8f93a8; }
  .main { padding: 34px 40px 60px; }
}

.theme-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,.14);
  background: transparent; color: #fff; cursor: pointer;
}
.theme-btn:hover { background: rgba(255,255,255,.08); }
.theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .sun { display: block; }
[data-theme="dark"] .theme-btn .moon { display: none; }

/* ---------- page head ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head h1 { font-size: clamp(26px, 4.2vw, 36px); font-weight: 700; line-height: 1.1; }
.head p { margin: 6px 0 0; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; padding: 0 22px; border-radius: 14px;
  border: 0; background: var(--crown); color: var(--ink); font: 600 15.5px var(--font-body); text-decoration: none; cursor: pointer;
  transition: background .15s, transform .08s;
}
.btn:hover { background: var(--crown-hover); }
.btn:active { background: var(--crown-press); transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ink { background: var(--ink); color: #fff; }
[data-theme="dark"] .btn.ink { background: var(--surface-2); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--text); background: transparent; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn svg.i { width: 19px; height: 19px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }

/* ---------- forms ---------- */
.field { display: block; min-width: 0; }
.field > span.lbl { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.field small { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }
.input {
  width: 100%; min-height: 50px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 13px; background: var(--surface-2);
  color: var(--text); font: 500 16px var(--font-body); transition: border-color .15s, background .15s;
}
.input::placeholder { color: #9a9db0; font-weight: 400; }
.input:hover { border-color: #c4c7d6; }
.input:focus { outline: none; border-color: var(--text); background: var(--surface); box-shadow: 0 0 0 4px rgba(255, 102, 0, .25); }
.input[readonly] { color: var(--muted); border-style: dashed; }
.input.bad { border-color: var(--bad); }
.pre { position: relative; }
.pre > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font: 600 16px var(--font-body); color: var(--muted); font-style: normal; pointer-events: none; }
.pre .input { padding-left: 38px; }
.pre.ph .input { padding-left: 52px; }
.err { color: var(--bad); font-size: 13.5px; margin-top: 6px; font-weight: 500; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid2.tight { grid-template-columns: 1fr 1fr; gap: 10px; }
.span2 { grid-column: 1 / -1; }
.opt { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.item { border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface-2); }
.item + .item { margin-top: 12px; }
.item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.item-head b { font-family: var(--font-display); font-size: 15px; }
.item:only-child .rm { display: none; }
.adders { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.chipbtn { border: 1.5px dashed var(--line-strong, var(--line)); background: transparent; color: var(--ink); border-radius: 999px; padding: 8px 14px; font: 600 14px var(--font-body); cursor: pointer; min-height: 40px; }
.chipbtn:hover { border-color: var(--crown); background: var(--crown-soft, transparent); }
.chipbtn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.chipbtn[disabled] { opacity: .4; cursor: not-allowed; }

.switch { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; background: var(--surface-2); }
.switch + .switch { margin-top: 10px; }
.switch input { position: absolute; opacity: 0; }
.switch .tr { width: 48px; height: 28px; border-radius: 999px; background: #c9ccda; position: relative; flex-shrink: 0; transition: background .18s; }
.switch .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s; }
.switch input:checked + .tr { background: var(--crown); }
.switch input:checked + .tr::after { transform: translateX(20px); }
.switch input:focus-visible + .tr { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .tr { opacity: .45; }
.switch b { display: block; font-weight: 600; }
.switch small { color: var(--muted); font-size: 13px; }

/* ---------- alerts ---------- */
.toasts { position: fixed; z-index: 80; left: 16px; right: 16px; top: 70px; display: grid; gap: 10px; pointer-events: none; }
@media (min-width: 960px) { .toasts { left: auto; right: 28px; top: 24px; width: 400px; } }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--ink); color: #fff; box-shadow: 0 18px 40px -12px rgba(0,0,0,.5); animation: toast-in .25s ease-out; }
.toast.warn { background: #3a2500; color: #ffd9a0; }
.toast .i { color: var(--crown); margin-top: 1px; }
.toast p { margin: 0; flex: 1; }
.toast button { background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- dashboard ---------- */
.dash { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .dash { grid-template-columns: 1.65fr 1fr; } .dash .span { grid-column: 1 / -1; } }
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 26px; background: var(--ink); color: #fff;
  border: 1px solid var(--ink-3); isolation: isolate;
}
.hero .k { color: #b6b9ca; font-weight: 500; }
.hero .big { font: 800 clamp(44px, 9vw, 76px)/1 var(--font-display); letter-spacing: -.03em; margin: 8px 0 6px; }
.hero .delta { display: inline-flex; gap: 6px; align-items: center; padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,.09); font-size: 13.5px; font-weight: 500; }
.hero .delta.up { color: #7df0b9; } .hero .delta.down { color: #ffb4a8; }
.hero .meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; color: #d4d6e2; }
.hero .meta b { color: #fff; font: 700 22px var(--font-display); margin-right: 6px; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 130px; margin-top: 26px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 8px; }
.bar i { display: block; width: 100%; max-width: 46px; min-height: 5px; border-radius: 9px 9px 4px 4px; background: rgba(255,255,255,.2); transform-origin: bottom; animation: grow .7s cubic-bezier(.2,.8,.2,1) both; }
.bar.today i { background: var(--crown); }
.bar span { font-size: 12.5px; color: #a3a6ba; }
.bar.today span { color: #fff; font-weight: 600; }
@keyframes grow { from { transform: scaleY(.05); } }
.stack { display: grid; gap: 16px; align-content: start; }
.stack .card + .card { margin-top: 0; }
.mini .k { color: var(--muted); font-weight: 500; }
.mini .v { font: 700 30px/1.1 var(--font-display); margin: 4px 0 2px; letter-spacing: -.02em; }
.quick { display: grid; gap: 10px; }
.quick a { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.quick a:hover { border-color: var(--text); }
.quick a .i { color: var(--crown); }
.quick a em { margin-left: auto; font-style: normal; color: var(--muted); font-weight: 400; font-size: 13px; }

/* ---------- lists ---------- */
.tbl { width: 100%; border-collapse: collapse; display: none; }
.tbl th { text-align: left; font: 600 13px var(--font-body); color: var(--muted); padding: 10px 12px; border-bottom: 1.5px solid var(--line); }
.tbl td.nw { white-space: nowrap; }
.tbl td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .r, .tbl th.r { text-align: right; }
.tbl .num { font-weight: 700; }
.cards { display: grid; gap: 10px; }
.row-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); text-decoration: none; }
.row-card b { font-weight: 600; }
.row-card .amt { font: 700 18px var(--font-display); text-align: right; }
.row-card small { color: var(--muted); font-size: 13px; }
@media (min-width: 760px) { .tbl { display: table; } .cards { display: none; } }
.chip { display: inline-block; white-space: nowrap; padding: 2px 10px; border-radius: 999px; background: var(--crown-soft); font-size: 12.5px; font-weight: 600; }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty img { width: 64px; opacity: .85; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font: 600 18px var(--font-display); margin-bottom: 4px; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 18px; color: var(--muted); }
.pager a { padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 11px; text-decoration: none; font-weight: 600; color: var(--text); }
.pager span.dis { opacity: .4; padding: 8px 14px; }
.filters { margin-bottom: 16px; }
.filters summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; font-weight: 600; }
.filters summary::-webkit-details-marker { display: none; }
.filters[open] summary { margin-bottom: 14px; }
.filters .grid3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .filters .grid3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .filters .grid3 { grid-template-columns: repeat(4, 1fr); } }
.sumline { display: flex; gap: 6px 22px; flex-wrap: wrap; align-items: baseline; margin-bottom: 14px; }
.sumline b { font: 700 24px var(--font-display); }
.sumline span b { margin-right: 4px; }

/* ---------- create / show: form + live bill ---------- */
.work { display: grid; gap: 18px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1100px) { .work { grid-template-columns: minmax(0, 1fr) minmax(0, 560px); } .work .preview { position: sticky; top: 24px; } }
.preview .card { padding: 14px; background: var(--surface-2); }
.preview-top { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 12px; font-weight: 600; }
.preview-top small { color: var(--muted); font-weight: 400; }
.totalbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: flex; gap: 10px; align-items: center;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; border-top-left-radius: 20px; border-top-right-radius: 20px;
}
.totalbar .t { flex: 1; line-height: 1.15; }
.totalbar .t small { color: #aeb1c4; font-size: 12.5px; display: block; }
.totalbar .t b { font: 700 24px var(--font-display); }
.totalbar .btn.ghost { color: #fff; border-color: #3a3a49; }
.has-totalbar .tabbar { display: none; }
.has-totalbar .main { padding-bottom: 110px; }
@media (min-width: 960px) { .totalbar { display: none; } .has-totalbar .main { padding-bottom: 60px; } }
.desk-total { display: none; margin-top: 18px; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-radius: 18px; background: var(--ink); color: #fff; }
.desk-total small { color: #aeb1c4; display: block; }
.desk-total .btn { white-space: nowrap; flex-shrink: 0; }
.desk-total b { font: 800 30px var(--font-display); letter-spacing: -.02em; }
@media (min-width: 960px) { .desk-total { display: flex; } }
.sheet { display: none; }
@media (max-width: 1099px) {
  .preview.sheetmode { position: fixed; inset: 0; z-index: 60; background: rgba(8,8,12,.6); display: none; align-items: flex-end; }
  .preview.sheetmode.open { display: flex; }
  .preview.sheetmode .card { width: 100%; max-height: 92vh; overflow: auto; border-radius: 24px 24px 0 0; padding: 16px 14px 24px; }
  .sheet { display: inline-flex; }
}
@media (min-width: 1100px) { .preview .close, .sheet { display: none !important; } }

/* the bill: sized from the paper width so the printed layout scales perfectly */
.paper-wrap { container-type: inline-size; }
.paper {
  --mm: calc(100cqw / 210); --pt: calc(var(--mm) * .3528);
  position: relative; width: 100%; aspect-ratio: 210 / 221.8; background: #fff; border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 20px 40px -24px rgba(0,0,0,.4); color: #111; text-align: left;
  font-family: "DejaVu Sans", Verdana, "Segoe UI", sans-serif;
}
.paper .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.bill { position: absolute; left: calc(var(--mm) * 16); top: calc(var(--mm) * 46); width: calc(var(--mm) * 181); height: calc(var(--mm) * 136); color: #17171c; }
.bill .lbl { display: block; font-size: calc(var(--pt) * 6.5); color: #7a7b86; }
.bill .top { display: flex; justify-content: space-between; align-items: center; height: calc(var(--mm) * 11); }
.bill .ttl { display: flex; align-items: center; gap: calc(var(--mm) * 3); font-weight: 700; font-size: calc(var(--pt) * 15); letter-spacing: .04em; line-height: 1; }
.bill .ttl i { width: calc(var(--mm) * 1.3); height: calc(var(--mm) * 7); background: var(--acc); }
.bill .meta { display: flex; gap: calc(var(--mm) * 9); }
.bill .meta b { display: block; font-size: calc(var(--pt) * 10.5); }
.bill .to { display: grid; grid-template-columns: 104fr 77fr; gap: calc(var(--mm) * 3); margin-top: calc(var(--mm) * 3); }
.bill .pill { box-sizing: border-box; height: calc(var(--mm) * 13); padding: calc(var(--mm) * 2) calc(var(--mm) * 4); border-radius: calc(var(--mm) * 2.5); background: #f0f1f5; overflow: hidden; }
.bill .pill b { display: block; font-size: calc(var(--pt) * 11); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: calc(var(--mm) * 5); }
.bill th { font-size: calc(var(--pt) * 7); font-weight: 700; color: #7a7b86; text-align: left; padding: 0 calc(var(--mm) * 2) calc(var(--mm) * 1.6); border-bottom: calc(var(--mm) * .45) solid #17171c; }
.bill th.r, .bill td.r { text-align: right; }
.bill td { box-sizing: border-box; padding: calc(var(--mm) * 1.5) calc(var(--mm) * 2); vertical-align: top; border-bottom: calc(var(--mm) * .2) solid #d9dae2; font-size: calc(var(--pt) * 10); }
.bill td.n { font-size: calc(var(--pt) * 9); color: #7a7b86; }
.bill td b { display: block; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill td .pname { font-size: calc(var(--pt) * 9.5); }
.bill td small { display: block; margin-top: calc(var(--mm) * .6); font-size: calc(var(--pt) * 7); color: #555660; letter-spacing: .03em; }
.bill td.o { font-size: calc(var(--pt) * 9.5); color: #8a8b95; text-decoration: line-through; }
.bill td.o.none { text-decoration: none; }
.bill .sum { display: flex; justify-content: space-between; gap: calc(var(--mm) * 6); margin-top: calc(var(--mm) * 4); }
.bill .words { width: calc(var(--mm) * 90); font-size: calc(var(--pt) * 9); line-height: 1.4; }
.bill .words b { display: block; margin-top: calc(var(--mm) * .8); font-size: calc(var(--pt) * 9); }
.bill .words em { display: block; margin-top: calc(var(--mm) * 2); font-style: normal; color: #7a7b86; font-size: calc(var(--pt) * 7.5); }
.bill .tots { width: calc(var(--mm) * 83); }
.bill .tots .sub { display: flex; justify-content: space-between; align-items: center; height: calc(var(--mm) * 5.5); padding: 0 calc(var(--mm) * 3); font-size: calc(var(--pt) * 9); color: #555660; }
.bill .tots .grand { display: flex; justify-content: space-between; align-items: center; height: calc(var(--mm) * 11); margin-top: calc(var(--mm) * 1.5); padding: 0 calc(var(--mm) * 4); background: var(--acc); color: #fff; font-weight: 700; font-size: calc(var(--pt) * 12.5); border-radius: calc(var(--mm) * 2.5); }
.bill .thanks { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: calc(var(--pt) * 7.5); color: #7a7b86; }

/* ---------- show page ---------- */
.lines { border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; }
.line { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; background: var(--surface-2); }
.line + .line { border-top: 1px solid var(--line); }
.line .n { color: var(--muted); font-size: 14px; }
.line small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.more { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--crown-soft); color: var(--ink); font-weight: 600; font-size: 12px; }
.facts { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.facts span { display: block; color: var(--muted); font-size: 13px; }
.facts b { font-weight: 600; word-break: break-word; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
@media (max-width: 559px) { .actions .btn { flex: 1 1 100%; } }
.wa { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- settings ---------- */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; margin-bottom: 18px; flex-wrap: wrap; }
.seg a, .seg button { padding: 9px 16px; border-radius: 11px; text-decoration: none; font: 600 14.5px var(--font-body); color: var(--muted); background: none; border: 0; cursor: pointer; }
.seg a[aria-current="page"] { background: var(--ink); color: #fff; }
[data-theme="dark"] .seg a[aria-current="page"] { background: var(--crown); color: var(--ink); }
.prose { max-width: 70ch; line-height: 1.7; }
.prose p { margin: 0 0 14px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.login .brandside { background: var(--ink); color: #fff; padding: 34px 26px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; min-height: 240px; isolation: isolate; }
.login .brandside img.logo { width: min(320px, 70%); }
.login .brandside::after { content: ""; position: absolute; right: -50px; top: 90px; width: 360px; height: 340px; background: url("../images/crown.png") no-repeat center / contain; opacity: .08; transform: rotate(14deg); z-index: -1; }
.login .brandside h2 { font: 700 clamp(26px, 4vw, 40px)/1.15 var(--font-display); max-width: 14ch; margin-top: 28px; }
.login .brandside p { color: #b4b7c9; max-width: 34ch; }
.login .formside { display: grid; place-items: center; padding: 30px 20px 50px; }
.login form { width: 100%; max-width: 400px; }
.login form h1 { font-size: 30px; margin-bottom: 6px; }
.login .stackf { display: grid; gap: 14px; margin: 22px 0; }
@media (min-width: 900px) { .login { grid-template-columns: 1.1fr 1fr; } .login .brandside { padding: 48px; } }

/* ---------- crown pop on save ---------- */
.pop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(8,8,12,.55); pointer-events: none; animation: pop-bg 1.5s ease both; }
.pop div { width: 130px; height: 130px; border-radius: 34px; background: var(--ink); display: grid; place-items: center; animation: pop-in 1.5s cubic-bezier(.2,.9,.25,1.2) both; }
.pop img { width: 62px; }
@keyframes pop-in { 0% { transform: translateY(-120px) scale(.6) rotate(-8deg); opacity: 0; } 35% { transform: none; opacity: 1; } 80% { transform: none; opacity: 1; } 100% { transform: scale(.9); opacity: 0; } }
@keyframes pop-bg { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .pop { display: none; }
}
@media print { .sidebar, .topbar, .tabbar, .totalbar, .actions, .toasts { display: none !important; } }

/* ---- payment split popup ---- */
.paydlg { border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(0,0,0,.45); }
.paydlg::backdrop { background: rgba(8, 8, 12, .62); }
.pay-box { padding: 22px; display: grid; gap: 14px; }
.pay-box h2 { margin: 0; }
.pay-box p { margin: 0; }
.pay-sum { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-weight: 600; }
.pay-sum.ok { background: var(--ok-bg); color: var(--ok); }
.pay-sum.bad { background: var(--bad-bg); color: var(--bad); }
.pay-box .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 520px) { .pay-box .actions .btn { flex: 1; } }
@media print { .noprint { display: none !important; } .main { padding: 0 !important; } .card { box-shadow: none !important; break-inside: avoid; } }

/* ---- report tables: scroll on screen, fit the page when printed ---- */
.rptwrap { overflow-x: auto; }
.rpt { display: table; width: 100%; min-width: 760px; font-size: 13.5px; }
.rpt th, .rpt td { padding: 10px 8px; }
.rpt td, .rpt th { white-space: nowrap; }
.rpt td.mdl { white-space: normal; min-width: 170px; font-weight: 600; }
.rpt td.rmk { white-space: normal; min-width: 180px; }
.rpt td.nof { width: 1%; text-align: center; }
.rpt tr.dayrow td { background: var(--surface-2); font-weight: 700; padding: 7px 8px; }
.rpt tfoot td { border-top: 2px solid var(--line); }
@media print {
  .rptwrap { overflow: visible !important; }
  .rpt { min-width: 0 !important; width: 100% !important; }
  .rpt { font-size: 11px; }
  .rpt th, .rpt td { padding: 5px 6px; white-space: normal; border-bottom: 1px solid #bbb; }
  .rpt td.num, .rpt th.r { white-space: nowrap; }
  .rpt tbody tr:hover { background: none; }
  body { background: #fff !important; color: #000 !important; }
  .shell { display: block !important; }
  .facts { grid-template-columns: repeat(3, 1fr); }
}

/* ---- icon action buttons in invoice lists ---- */
.iconrow { display: inline-flex; gap: 8px; align-items: center; }
.iconrow form { margin: 0; }
.iconbtn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; padding: 0; text-decoration: none; }
.iconbtn:hover { border-color: var(--crown); }
.iconbtn:focus-visible { outline: 3px solid var(--crown); outline-offset: 2px; }
.iconbtn .i { width: 20px; height: 20px; }
.iconbtn.wa { color: #1fa855; }
.iconbtn.main { background: var(--crown); border-color: var(--crown); color: var(--ink); }
.iconbtn:disabled { opacity: .5; cursor: wait; }
.cards .iconrow { width: 100%; justify-content: flex-end; }
@media print { .iconrow { display: none !important; } }

.chip.bk-open { background: var(--ok-bg); color: var(--ok); }
.chip.bk-expired, .chip.bk-cancelled { background: var(--bad-bg); color: var(--bad); }
.chip.bk-delivered { background: var(--surface-2); color: var(--muted); }

/* ---- sidebar: the menu scrolls when it is taller than the screen; the user and logout stay in view ---- */
@media (min-width: 960px) {
  .sidebar .brand { flex-shrink: 0; padding-bottom: 10px; }
  .sidebar .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -16px; padding: 0 10px 0 16px; scrollbar-width: thin; scrollbar-color: #3a3d4f transparent; }
  .sidebar .nav::-webkit-scrollbar { width: 6px; }
  .sidebar .nav::-webkit-scrollbar-thumb { background: #3a3d4f; border-radius: 6px; }
  .sidebar .nav-group { padding: 14px 12px 6px; }
  .sidebar .nav a { padding: 9px 12px; }
  .sidebar .side-foot { flex-shrink: 0; padding-top: 10px; }
}

/* payment popup: one card per payment, with labelled fields; % and note appear inside the card when the mode asks for them */
.paydlg { width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; }
.pay-row { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 16px; margin-bottom: 12px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.pay-row:focus-within { border-color: var(--crown); }
.pay-row .input { background: var(--surface); }
.pf { display: grid; gap: 6px; min-width: 0; margin: 0; }
.pf > span:first-child { font-size: 13px; font-weight: 600; color: var(--muted); }
.pf em { font-style: normal; font-weight: 500; font-size: 12px; color: var(--muted); opacity: .8; margin-left: 4px; }
.pf .pre { min-width: 0; }
.pay-x { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; padding: 0; }
.pay-x:hover { color: var(--bad); border-color: var(--bad); }
.pay-x:focus-visible { outline: 3px solid var(--crown); outline-offset: 2px; }
.pay-x .i { width: 18px; height: 18px; }
.pay-row .pay-extra { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(130px, 190px) minmax(0, 1fr); gap: 12px; padding-top: 14px; border-top: 1.5px dashed var(--line); }
.pay-row .pay-extra[hidden], .pay-row .pay-extra [hidden] { display: none; }
.pay-row .pay-extra:has([data-pay-percent-wrap][hidden]) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 520px) {
  .pay-row { grid-template-columns: 1fr auto; }
  .pay-row > .pf:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .pay-row .pay-extra { grid-template-columns: 1fr; }
}

/* ---- advance booking receipt: one A4 page, the same on screen, in print and in dark mode ---- */
.bk-page { overflow-x: auto; padding: 20px 0 8px; }
.bk-sheet { --bk-ink: #14151c; --bk-mute: #6b6f80; --bk-line: #d9dbe4; width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: var(--bk-ink); font-family: Arial, Helvetica, sans-serif; padding: 20mm 18mm 14mm; box-sizing: border-box; box-shadow: 0 6px 28px rgba(0,0,0,.14); border-radius: 4px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bk-head { position: relative; margin-bottom: 11mm; }
.bk-title { margin: 0; text-align: center; font-size: 22px; letter-spacing: .1em; text-transform: uppercase; }
.bk-title span { border-bottom: 2.5px solid #ff6600; padding-bottom: 2mm; }
.bk-ref { position: absolute; right: 0; top: 0; font-size: 13px; color: var(--bk-mute); }
.bk-ref b { font-size: 16px; color: var(--bk-ink); letter-spacing: .08em; }
.bk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm 10mm; margin: 0; }
.bk-grid > div { border-bottom: 1.5px solid var(--bk-line); padding-bottom: 2.5mm; min-height: 15mm; }
.bk-grid .wide { grid-column: 1 / -1; }
.bk-grid dt { font-size: 12px; color: var(--bk-mute); margin-bottom: 1mm; }
.bk-grid dd { margin: 0; font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.bk-grid dd.mono { letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.bk-amts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6mm; margin-top: 11mm; }
.bk-amts > div { border: 1.5px solid var(--bk-line); border-radius: 3mm; padding: 6mm 6mm; }
.bk-amts small { display: block; font-size: 12px; margin-bottom: 1.5mm; color: var(--bk-mute); }
.bk-amts b { font-size: 23px; }
.bk-amts .due { background: #fff1e6; border-color: #ff6600; }
.bk-amts .due b { color: #c24a00; }
.bk-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 24mm; margin-top: 26mm; text-align: center; font-size: 12px; font-weight: 700; }
.bk-sign u { display: block; border-top: 1.5px solid var(--bk-ink); margin-bottom: 2mm; text-decoration: none; }
.bk-terms { margin-top: 18mm; border-top: 2px dashed var(--bk-line); padding-top: 7mm; }
.bk-terms h3 { margin: 0 0 5mm; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }
.bk-terms ol { margin: 0; padding-left: 6mm; font-size: 13px; line-height: 1.55; color: #2b2d38; }
.bk-terms li { margin-bottom: 3.4mm; }
@media print {
  .bk-page { overflow: visible; padding: 0; }
  .bk-sheet { box-shadow: none; border-radius: 0; width: 210mm; height: 296mm; min-height: 0; overflow: hidden; }
}
@media print { .card:has(.rpt) { break-inside: auto !important; } }

/* ---- no internet: a full-screen notice that blocks the page until the connection is back ---- */
.offline { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 20px; background: rgba(8, 8, 12, .86); backdrop-filter: blur(4px); }
.offline[hidden] { display: none; }
.offline-box { max-width: 420px; text-align: center; background: var(--surface); color: var(--text); border-radius: 22px; padding: 30px 26px; box-shadow: 0 24px 80px rgba(0,0,0,.5); display: grid; gap: 10px; justify-items: center; }
.offline-box svg { color: var(--crown); }
.offline-box h2 { margin: 6px 0 0; font-size: 22px; }
.offline-box p { margin: 0 0 8px; color: var(--muted); }
body.is-offline { overflow: hidden; }
