:root {
  --bg: #F3F6F9;
  --surface: #FFFFFF;
  --ink: #1B2733;
  --muted: #5B6B7A;
  --line: #D5DEE6;
  --primary: #1F5F8B;
  --primary-ink: #FFFFFF;
  --primary-hover: #194E73;
  --accent: #2E9E6B;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --warn-bg: #FFF6DB;
  --warn-ink: #7A5A00;
  --focus: #6CA6D1;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1720;
    --surface: #18222D;
    --ink: #E6EDF3;
    --muted: #9AA8B5;
    --line: #2C3A47;
    --primary: #4C93C6;
    --primary-ink: #0B1520;
    --primary-hover: #64A6D6;
    --danger: #F28B82;
    --danger-bg: #3A1A18;
    --warn-bg: #3A3013;
    --warn-ink: #F1D27A;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---- Login: one column on phones, brand panel + form on wide screens ---- */
.auth {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1fr;
}
.auth__brand { display: none; }
.auth__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.card {
  width: 100%;
  max-width: 400px;
}
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo img { width: 44px; height: 44px; }
.logo span { font-weight: 700; font-size: 1.15rem; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 6px; }
.lead { margin: 0 0 24px; color: var(--muted); }

@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(360px, 5fr) 6fr; }
  .auth__brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    background: linear-gradient(160deg, #1F5F8B, #15435F);
    color: #FFFFFF;
  }
  .auth__brand .logo span { color: #FFFFFF; }
  .auth__brand h2 { font-size: 2rem; line-height: 1.2; margin: 0 0 12px; max-width: 14ch; }
  .auth__brand p { margin: 0; color: #CFE0EC; max-width: 36ch; }
  .auth__brand small { color: #9FBCD1; }
  .auth__main .logo { display: none; }
  .card {
    background: var(--surface);
    padding: 40px;
    border: 1px solid var(--line);
    border-radius: 16px;
  }
}

/* ---- Form ---- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 40%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }

.password { position: relative; }
.password .input { padding-right: 72px; }
.password button {
  position: absolute; right: 6px; top: 6px; height: 36px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--primary);
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 22px; flex-wrap: wrap; }
.row a { font-size: 0.92rem; font-weight: 600; text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 48px; border: 0; border-radius: var(--radius);
  background: var(--primary); color: var(--primary-ink);
  font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.7; cursor: progress; }
.btn--ghost { background: transparent; color: var(--primary); border: 1px solid var(--line); width: auto; padding: 0 16px; height: 40px; }
.btn--ghost:hover { background: var(--surface); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 18px; font-size: 0.92rem; }
.alert--error { background: var(--danger-bg); color: var(--danger); }

.foot { margin-top: 24px; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ---- Signed-in shell ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .logo { margin: 0; }
.topbar .logo img { width: 32px; height: 32px; }
.page { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.muted { color: var(--muted); }
.empty {
  margin-top: 24px; padding: 32px 16px; text-align: center;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 12px;
}

/* ---- Login extras ---- */
.alert--info { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--ink); }
.row--end { justify-content: flex-end; }
.help { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); }
.input--code { letter-spacing: 0.4em; font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.code-box { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1rem; line-height: 1.7; white-space: pre-wrap; word-break: break-all; user-select: all; }
.foot a { font-weight: 600; text-decoration: none; }

/* ---- Top bar user + log-out dialog ---- */
.topbar__user { position: relative; display: flex; align-items: center; gap: 8px; }
/* Round icon buttons in the top-right corner: bell, profile, menu (owner, 2026-11-08). */
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 2px; }
/* The drop-downs line up with the right edge of the corner (not their icon), so they never run off a phone screen. */
.bell__wrap, .popover__wrap { position: static; }
.bell { position: relative; }
.bell__count {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--danger); color: var(--surface);
  font-size: 0.75rem; font-weight: 700; line-height: 20px; text-align: center;
}
.bell__count[hidden] { display: none; }
.bell__panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  width: min(360px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(15 23 32 / 0.18);
}
.bell__panel[hidden] { display: none; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  width: min(280px, calc(100vw - 32px)); padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(15 23 32 / 0.18);
}
.popover[hidden] { display: none; }
.account-panel { display: flex; flex-direction: column; gap: 4px; }
.account-panel__who { margin: 0; }
.account-panel__item { justify-content: flex-start; margin-top: 6px; }
.account-panel__item:first-of-type { margin-top: 12px; }
.account-panel__logout { margin-top: 10px; gap: 8px; }
.account-panel__logout svg { width: 18px; height: 18px; }
.bell__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.bell__list { list-style: none; margin: 0; padding: 0; }
.bell__item + .bell__item { border-top: 1px solid var(--line); }
.bell__item > a, .bell__item > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; color: var(--ink); text-decoration: none; }
.bell__item > a:hover { background: var(--bg); }
.bell__item--new { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.bell__item--new .bell__text { font-weight: 600; }
.bell__empty { margin: 0; padding: 16px 14px; }
dialog {
  width: min(400px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
}
dialog::backdrop { background: rgb(15 23 32 / 0.45); }
dialog h2 { margin: 0 0 8px; font-size: 1.25rem; }
dialog p { margin: 0 0 20px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dialog__actions .btn { width: auto; padding: 0 18px; height: 44px; }

/* ---- Navigation (signed-in pages): three lines (menu drop-down) left, logo middle, bell + profile right ---- */
/* Menu in the left corner, logo + name in the middle, bell + profile in the right corner (owner, 2026-11-08). The two
   side columns are equal, so the middle is the true middle of the screen. */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.topbar__menu { justify-self: start; }
.topbar .logo { justify-self: center; text-decoration: none; color: var(--ink); white-space: nowrap; }
.topbar__user { justify-self: end; }
@media (max-width: 420px) {
  .topbar { gap: 8px; padding: 10px 12px; }
  .topbar .logo img { display: none; }
  .topbar .logo span { font-size: 0.95rem; }
  .icon-btn { width: 40px; height: 40px; }
}
/* The menu (owner, 2026-11-09): a drop-down from the three lines, lined up with the left corner. */
.menu-panel { left: 0; right: auto; padding: 8px; max-height: 75vh; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 421px) { .menu-panel { left: 12px; } }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  padding: 12px 14px; border-radius: 8px; text-decoration: none;
  color: var(--ink); font-weight: 600; font-size: 1rem;
}
.nav a:hover { background: var(--bg); }
.nav a[aria-current="page"] { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

/* ---- Page building blocks ---- */
.page__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page__head h1 { margin-bottom: 2px; }
/* One main action in the middle of the page (Shops: + Add shop, owner 2026-11-09). */
.center-action { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 8px 0 16px; }
.center-action a.btn { text-decoration: none; }   /* a link that looks like its neighbour button (Shops: Invoices) */
.center-action[hidden] { display: none; }
.section-title { font-size: 1.1rem; margin: 28px 0 12px; }
.panel .section-title:first-child { margin-top: 0; }
.small { font-size: 0.85rem; }
.hint-line { margin: 8px 0 12px; font-size: 0.92rem; }
.back { text-decoration: none; font-weight: 600; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 16px 0;
}
.actions { display: flex; gap: 10px; align-items: center; }
.actions--wrap { flex-wrap: wrap; margin: 16px 0; }
.btn--auto { width: auto; padding: 0 18px; }
.btn--sm { height: 36px; padding: 0 12px; font-size: 0.9rem; }
/* Small phones (bug 2026-11-09, DEFECT-RESP-001): a file field never wider than its column, and the Reports date
   between "Previous" and "Next" gives way so "Next" stays on the screen. */
input[type="file"] { max-width: 100%; }
.actions > input[type="date"] { flex: 1 1 0; min-width: 0; }
.btn--danger { width: auto; padding: 0 16px; height: 40px; background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--warn { color: var(--warn-ink); border-color: var(--warn-ink); }
.alert--warn { background: var(--warn-bg); color: var(--warn-ink); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
.search { margin-bottom: 12px; }
.search .input { height: 44px; }

/* ---- Lists ---- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list > li > .row-link, .list > li.row, .entry > summary {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
}
.row-link { text-decoration: none; color: inherit; }
.row-link:hover { border-color: var(--primary); }
.row-link__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-link__main strong { overflow-wrap: anywhere; }
.chevron { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.badge {
  padding: 3px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; white-space: nowrap;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
.badge--due { background: var(--warn-bg); color: var(--warn-ink); }
.list .empty { margin-top: 0; }
.list > li.row { margin: 0; }   /* the login page's .row margin must not leak into lists */
.list > li.row .row-link__main { min-width: 60%; }   /* the price editor wraps below the name instead of squeezing it */

/* Pick on the left, details on the right (Invoices: shop names | that shop's invoices, owner 2026-11-09).
   Phones: the list sits above the details. */
.split { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 16px; align-items: start; }
.split__side { position: sticky; top: calc(var(--topbar-h, 69px) + 8px); max-height: calc(100vh - var(--topbar-h, 69px) - 24px); overflow-y: auto; }
.split__title { font-size: 1rem; margin: 0 0 12px; }
.split__title:empty { display: none; }
@media (max-width: 640px) {
  .split { grid-template-columns: 1fr; }
  .split__side { position: static; max-height: 260px; }
}
.pick {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.pick:hover { border-color: var(--primary); }
.pick[aria-current="true"] { background: color-mix(in srgb, var(--primary) 12%, transparent); border-color: var(--primary); color: var(--primary); }
.pick strong { overflow-wrap: anywhere; }

/* ---- Shop page ---- */
.totals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0; }
.totals > div { display: flex; flex-direction: column; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.totals strong { font-size: 1.35rem; }
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 8px; padding: 6px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.entry > summary { cursor: pointer; list-style: none; }
.entry > summary::-webkit-details-marker { display: none; }
.entry[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.entry__lines {
  list-style: none; margin: 0; padding: 8px 16px 12px;
  background: var(--surface); border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 12px 12px;
}
.entry__lines li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 0.92rem; }

/* ---- Give stock ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tiles > .alert, .tiles > .empty { grid-column: 1 / -1; margin: 0; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.tile strong { overflow-wrap: anywhere; }
.tile .btn { margin-top: 6px; }
.tile--picked { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.tile--locked { opacity: 0.6; }
.stepper { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.stepper button {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--primary); font-size: 1.2rem; font-weight: 700; cursor: pointer;
}
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper input {
  width: 64px; height: 36px; text-align: center; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface);
}
.give__footer {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line);
}
.give__summary { margin: 0; font-weight: 600; }

/* ---- Products ---- */
.price-edit { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.input--price { width: 110px; height: 36px; }

/* ---- Add stock (PDF) ---- */
.file-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; cursor: pointer; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick:focus-within .btn { outline: 3px solid var(--focus); outline-offset: 2px; }
.checks { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.92rem; }
.checks .ok { color: var(--accent); }
.checks .bad { color: var(--danger); font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--bg); font-weight: 700; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.input--select { height: 40px; min-width: 200px; padding: 0 8px; font-size: 1rem; }   /* 16px: phones zoom in on smaller fields */

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: var(--danger); color: #FFFFFF; }

/* ---- Images ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.section-head { align-items: center; margin: 28px 0 12px; }
.section-head .section-title { margin: 0; }
.upload__pick { margin: 0 0 4px; }
.upload__preview { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 16px; }
.upload__preview img { max-width: 160px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.gallery__item { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gallery__thumb {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3;
  padding: 0; border: 0; border-bottom: 1px solid var(--line); background: var(--bg); cursor: zoom-in;
}
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery__missing { padding: 12px; text-align: center; }
.gallery__body { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.gallery__body strong { overflow-wrap: anywhere; }
.gallery__body .actions { margin-top: 6px; flex-wrap: wrap; }
@media (max-width: 480px) { .gallery { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; } .gallery__body { padding: 10px; } }
dialog.viewer { width: min(1000px, calc(100% - 16px)); max-height: calc(100% - 16px); padding: 12px; }
.viewer__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.viewer img { display: block; max-width: 100%; max-height: calc(100vh - 140px); margin: 0 auto; border-radius: 8px; }

/* ---- Payments ---- */
.totals { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 420px) { .totals { gap: 8px; } .totals > div { padding: 12px; } .totals strong { font-size: 1.1rem; } }
.amount--paid { color: var(--accent); }
.amount--due { color: var(--warn-ink); }
.input--amount { font-size: 1.3rem; font-weight: 700; max-width: 240px; }
.btn--ghost[aria-pressed="true"] { background: color-mix(in srgb, var(--primary) 12%, transparent); border-color: var(--primary); }
.entry--payment > summary { border-left: 4px solid var(--accent); }
div.entry__lines { padding: 12px 16px; }

/* ---- WhatsApp receipts ---- */
.entry__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.entry__lines li.entry__actions { justify-content: flex-start; padding-top: 10px; }
.panel--done { border-color: var(--accent); }
.panel--done p { margin: 0 0 8px; }
.btn--whatsapp { background: #1F8F4E; color: #FFFFFF; }
.btn--whatsapp:hover { background: #17733E; }

/* ---- Add stock review: one card per PDF line on phones, a table on wide screens ---- */
@media (max-width: 640px) {
  .table--cards, .table--cards tbody { display: block; }
  .table--cards thead { display: none; }
  .table--cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px; border-bottom: 1px solid var(--line); }
  .table--cards tr:last-child { border-bottom: 0; }
  .table--cards td { display: flex; flex-direction: column; gap: 2px; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .table--cards td::before { content: attr(data-label); color: var(--muted); font-size: 0.8rem; font-weight: 600; }
  .table--cards td .muted { white-space: normal; }
  .table--cards .num { text-align: left; white-space: normal; }
  .table--cards td[data-label="#"] { display: none; }
  .table--cards td[data-label="In the PDF"], .table--cards td[data-label="Product"], .table--cards td[data-label="Item"], .table--cards td[data-label^="Boxes"] { grid-column: 1 / -1; }
  .table--cards td[data-label="In the PDF"], .table--cards td[data-label="Item"] { font-weight: 700; }
  .table--cards td[data-label="Item"]::before { display: none; }
  .table--cards .input--select { min-width: 0; width: 100%; }
}
.sum { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Users page (superadmins) ---- */
.user-row { flex-wrap: wrap; }
.user-row .row-link__main { min-width: 50%; }
.user-row__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.user-row__actions .btn { height: 40px; }
.input--area { height: auto; min-height: 64px; padding-top: 10px; padding-bottom: 10px; resize: vertical; }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
dialog form .field:last-of-type { margin-bottom: 20px; }

/* ---- Sign-in page: every form fits a laptop / phone screen without scrolling ---- */
.field label .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-left: 6px; }
.auth .field { margin-bottom: 14px; }
.auth .lead { margin-bottom: 18px; }
.auth .foot { margin-top: 16px; }
.auth__main { padding-top: 20px; padding-bottom: 20px; }
.auth__main .logo { margin-bottom: 18px; }
@media (min-width: 900px) { .card { padding: 32px; } }
@media (max-height: 760px) {
  .auth .card { padding-top: 20px; padding-bottom: 20px; }
  .auth .input, .auth .btn { height: 44px; }
  .auth .password button { top: 4px; }
}
.foot a { white-space: nowrap; }   /* a link that wraps is hard to tap */

/* In-app notifications (components/notices.js) */
.notices__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.bill__totals { margin-top: 8px; }

/* Collect payment parts (components/pay-panel.js) */



/* Document buttons (components/doc-actions.js) */
.doc-actions { margin: 8px 0; }

/* Reports: three blocks at the top - Stock, Transactions, Stock + Transactions (owner, 2026-11-10). */
.report-kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 16px; }
.report-kind {
  min-height: 64px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius, 10px);
  background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-align: center;
}
.report-kind:hover { border-color: var(--primary); }
.report-kind[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink, #fff); border-color: var(--primary); }
/* Team: a user's password with the eye beside it (owner, 2026-11-10). */
.pw { display: inline-flex; align-items: center; gap: 6px; }
.pw-shown { font-family: ui-monospace, Consolas, monospace; min-width: 6ch; }
/* Team: one card per user (owner, 2026-11-10). */
#users { display: flex; flex-direction: column; gap: 12px; padding: 0; list-style: none; }
.team-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius, 10px); padding: 14px 16px; }
.team-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.team-card__head .row-link__main { display: flex; flex-direction: column; }
.team-card__pw { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px; background: var(--bg); border-radius: 8px; }
.team-card__pw .pw { margin-left: auto; }
.team-card__actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.team-card__actions .btn { width: 100%; margin: 0; height: 38px; padding: 0 8px; }
@media (max-width: 560px) { .team-card__actions { grid-template-columns: repeat(2, 1fr); } }
/* Team > Permissions: one checkbox per part of the app (owner, 2026-11-10). */
.perm-actions { display: flex; gap: 8px; margin: 8px 0; }
.perm-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.perm-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.perm-item input { width: 20px; height: 20px; flex: none; }
/* Shop page (owner, 2026-11-10): two even main actions, each part in its own card. */
.shop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.shop-actions .btn { width: 100%; margin: 0; }
.shop-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius, 10px); padding: 14px 16px; margin: 14px 0; }
.shop-card__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.shop-card__head .section-title { margin: 0; }
.shop-card__head .actions { margin: 0; }
.shop-card .list { margin: 0; }
.shop-card .list:empty { display: none; }
/* Collect payment (owner, 2026-11-10: "industrial grade"): due at the top, labelled fields, Cancel / Save at the foot. */
.shop-actions .btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--primary-ink, #fff), 0 0 0 2px var(--primary); }
.pay-panel { padding: 16px; }
.pay-panel__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pay-panel__head .section-title { margin: 0; }
.pay-due { font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); white-space: nowrap; }
.pay-due--none { background: var(--bg); color: var(--muted); }
.pay-panel .help { margin: 8px 0 14px; }
.pay-parts { display: flex; flex-direction: column; gap: 10px; }
.pay-part { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.pay-part > .pay-field[hidden] { display: none; }
.pay-part > .pay-field:nth-child(3) { grid-column: 1 / 3; }
.pay-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pay-field__label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.pay-field .input { width: 100%; height: 44px; margin: 0; }
.pay-amount { position: relative; display: block; }
.pay-amount__rs { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); }
.pay-amount__input { padding-left: 28px; font-size: 1.15rem; font-weight: 700; }
.pay-part__remove { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--danger); cursor: pointer; }
.pay-part__remove { grid-column: 3; grid-row: 1; }
.pay-panel__more { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0 0; }
.pay-total { margin: 0; font-weight: 700; }
.pay-panel__foot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.pay-panel__foot .btn { width: 100%; margin: 0; }
@media (max-width: 420px) { .pay-part, .pay-part:first-child { grid-template-columns: 1fr; } .pay-part > .pay-field:nth-child(3) { grid-column: auto; } .pay-part__remove { width: 100%; } }
.pay-part__amount { grid-column: 1 / -1; }
/* Shop page transactions, WhatsApp style like MilkPro's khata (owner, 2026-11-10). */
.shop-more { display: flex; gap: 8px; margin: -4px 0 12px; }
.chat {
  display: flex; flex-direction: column; gap: 6px; padding: 12px; margin: 12px 0;
  background: #e9eef7; border: 1px solid var(--line); border-radius: var(--radius, 10px);
  max-height: 65vh; overflow-y: auto; overscroll-behavior: contain;
}
.chat__empty { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 16px 0; }
.chat__day { display: flex; justify-content: center; margin: 6px 0 2px; }
.chat__day span { background: #d6e2f5; color: #40506b; font-size: 0.78rem; padding: 2px 10px; border-radius: 999px; }
.chat__note { align-self: center; background: #fff6db; color: #7a5a00; font-size: 0.85rem; padding: 4px 10px; border-radius: 8px; }
.chat__bubble { max-width: 80%; padding: 7px 10px 5px; border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 40, 80, 0.12); color: #1b2733; }
.chat__bubble summary { list-style: none; cursor: pointer; }
.chat__bubble summary::-webkit-details-marker { display: none; }
.chat__bubble--left { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; }
.chat__bubble--right { align-self: flex-end; background: #d9fdd3; border-bottom-right-radius: 4px; }
.chat__bubble--warn { background: #fdecea; }
.chat__bubble--reversed .chat__amt { text-decoration: line-through; opacity: 0.7; }
.chat__text { font-size: 0.9rem; }
.chat__amt { font-weight: 700; font-size: 1.05rem; margin-top: 1px; }
.chat__meta { font-size: 0.72rem; color: #667085; text-align: right; margin-top: 2px; }
.chat__items { border-top: 1px dashed #d5dee6; margin-top: 6px; padding-top: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 0.82rem; }
.chat__item { display: flex; justify-content: space-between; gap: 12px; }
.chat__link { font-size: 0.82rem; font-weight: 600; margin-top: 4px; }
.chat__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chat__actions .btn { width: auto; margin: 0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chat { background: #0f1720; }
  :root:not([data-theme="light"]) .chat__bubble--left { background: #18222d; color: #e6edf3; }
  :root:not([data-theme="light"]) .chat__bubble--right { background: #1e4d2b; color: #e6edf3; }
  :root:not([data-theme="light"]) .chat__day span { background: #2c3a47; color: #c9d4de; }
}
/* Reports (owner, 2026-11-10): shop on the left, bill cycles on the right; the chosen bills' dates on top. */
.report-pick { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin: 8px 0 16px; }
.report-pick .input { height: 44px; width: 100%; margin: 0; }
.report-ready { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.report-ready p { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 420px) { .report-pick { grid-template-columns: 1fr; } }
/* The open menu pushes the page instead of covering it (owner, 2026-11-10: "it overlapping the existing screen").
   Wide screens: a column on the left under the top bar, the page moves right. Phones / tablets: a row of pages
   under the top bar, inside it, so the page moves down. */
@media (min-width: 900px) {
  html.menu-open .menu-panel {
    position: fixed; top: var(--topbar-h, 65px); left: 0; bottom: 0; width: 220px; max-height: none;
    border-radius: 0; border-width: 0 1px 0 0; box-shadow: none; z-index: 9;
  }
  html.menu-open .page { margin-left: max(236px, calc((100vw - 960px) / 2)); }
}
@media (max-width: 899px) {
  html.menu-open .topbar { grid-template-rows: auto auto; row-gap: 8px; }
  html.menu-open .topbar__menu { display: contents; }
  html.menu-open .topbar__menu > .icon-btn { grid-column: 1; grid-row: 1; justify-self: start; }
  html.menu-open .topbar .logo { grid-column: 2; grid-row: 1; }
  html.menu-open .topbar__user { grid-column: 3; grid-row: 1; }
  html.menu-open .menu-panel {
    position: static; grid-column: 1 / -1; grid-row: 2; width: auto; max-height: none; padding: 0;
    border: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: visible;
  }
  html.menu-open .menu-panel .nav { flex-direction: row; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
  html.menu-open .menu-panel .nav a { white-space: nowrap; padding: 8px 12px; font-size: 0.9rem; border: 1px solid var(--line); background: var(--surface); }
}
/* Day close table (owner, 2026-11-10): Payment received has sub-columns; Yes / No at the end. */
.dayclose-day { min-width: 160px; }
.dayclose-day .input { height: 44px; margin: 0; }
.table.dayclose th, .table.dayclose td { white-space: nowrap; vertical-align: middle; }
.table.dayclose .dayclose__group { text-align: center; border-bottom: 1px solid var(--line); }
.table.dayclose tfoot th { border-top: 2px solid var(--line); }
.dayclose__yn { display: inline-flex; gap: 6px; }
#left { margin-top: 24px; }
#note textarea { width: 100%; min-height: 96px; resize: vertical; }
/* Notes (owner, 2026-11-10): one card per open note, Close on each. */
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #d97706; border-radius: 10px; padding: 12px 14px; list-style: none; }
.note__head, .note__foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.note__text { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
/* A date shown as "11 Nov 2026"; the browser's date box sits under the button and only opens its picker. */
.date-pick { position: relative; display: block; }
.date-pick__btn { width: 100%; text-align: left; cursor: pointer; font: inherit; }
.date-pick__input { position: absolute; left: 0; bottom: 0; width: 0; height: 0; opacity: 0; pointer-events: none; border: 0; padding: 0; }
