/* BrewCup Hisaab: small, mobile-first stylesheet. No external CSS/JS (strict CSP). */
:root {
  --bg: #f7f4f0;
  --surface: #ffffff;
  --text: #2a211c;
  --muted: #7a6d64;
  --border: #e3dbd3;
  --brand: #6b3e26;
  --brand-ink: #ffffff;
  --ok: #1f7a45;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4e00;
  --err-bg: #fde5e3;
  --err-ink: #8a1c12;
  --info-bg: #e6f0fb;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714; --surface: #26201c; --text: #f1ebe5; --muted: #b3a79e; --border: #3a322c;
    --brand: #d79a6b; --brand-ink: #1b1714; --ok: #5fcf8c;
    --warn-bg: #3d3214; --warn-ink: #f5d98a; --err-bg: #3f1d1a; --err-ink: #ffb4aa; --info-bg: #1c2a3a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .75rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.brand span { color: var(--brand); }
.nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
.nav a, .nav .link { text-decoration: none; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin: 0; }
.muted { color: var(--muted); }

label { display: block; font-weight: 600; margin: .75rem 0 .25rem; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: .7rem .75rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn { display: inline-block; margin-top: 1rem; padding: .7rem 1.1rem; min-height: 44px; border: 0; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font-size: 1rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn-secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn-danger { background: var(--err-ink); color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--info-bg); }
.alert-warning { background: var(--warn-bg); color: var(--warn-ink); }
.alert-error { background: var(--err-bg); color: var(--err-ink); }
.alert-success { background: var(--info-bg); }
.error { color: var(--err-ink); margin: .25rem 0 0; font-size: .9rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); }
.badge.off { color: var(--muted); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.qr { background: #fff; padding: .5rem; border-radius: 8px; width: 220px; max-width: 100%; margin: .5rem auto 1rem; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { display: inline-block; word-break: break-all; font-size: 1rem; padding: .25rem .4rem; background: var(--bg); border-radius: 6px; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; font-size: 1.1rem; }
.steps { padding-left: 1.2rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .25rem; }
.tile-label { color: var(--muted); font-size: .9rem; }
.tile-value { font-size: 1.4rem; font-weight: 700; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters .btn { margin-top: 0; }
.pager { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }

@media print { .topbar, .btn, .actions { display: none; } body { background: #fff; } }

/* Forms */
.field { margin-bottom: .25rem; }
.help { color: var(--muted); font-size: .85rem; margin: .25rem 0 0; }
.req { color: var(--err-ink); }
input[type=search] { width: 100%; padding: .7rem .75rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
td.wrap { white-space: normal; min-width: 220px; }

/* List rows (mobile-friendly alternative to tables) */
.rows { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.row-main { display: flex; flex-direction: column; text-decoration: none; color: var(--text); min-width: 0; flex: 1; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: .9rem; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.row-label { color: var(--muted); font-size: .75rem; }
.row-amount { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Change history list */
.history { list-style: none; padding: 0; margin: 0; }
.history > li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.history > li:last-child { border-bottom: 0; }
.changes { margin: .25rem 0 0; padding-left: 1rem; font-size: .95rem; }

/* M3: ledger, approvals */
a.tile { text-decoration: none; color: var(--text); }
.is-over { color: var(--err-ink); }
.is-in { color: var(--ok); }
.count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: var(--err-ink); color: #fff; font-size: .8rem; text-align: center; }
.status { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.status-pending { color: var(--warn-ink); background: var(--warn-bg); }
.status-approved { color: var(--ok); }
.status-rejected { color: var(--err-ink); background: var(--err-bg); }
.status-cancelled { color: var(--muted); }
.amount-big { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: .25rem 0 1rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-small { margin-top: .35rem; padding: .35rem .7rem; min-height: 36px; font-size: .9rem; }
.decide { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin: 1rem 0 .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.decide .btn { margin-top: 0; }
.reject-form { display: flex; gap: .5rem; flex: 1; min-width: 240px; }
.reject-form input { flex: 1; min-width: 0; }
.reverse { margin-top: 1rem; }
.reverse summary { cursor: pointer; color: var(--brand); }
.items { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem .75rem; margin: 1rem 0 .25rem; }
.items legend { font-weight: 600; padding: 0 .25rem; }
.item-row { display: grid; grid-template-columns: 1fr 70px 100px; gap: .4rem; margin-top: .4rem; }
.item-row > div { min-width: 0; }
.row-approval { align-items: flex-start; }
.pick { display: flex; align-items: center; padding-top: .2rem; }
.pick input { width: 22px; height: 22px; }
.flags { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.flag { font-size: .75rem; padding: .05rem .45rem; border-radius: 999px; background: var(--info-bg); color: var(--text); }
.flag-warn { background: var(--warn-bg); color: var(--warn-ink); }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; }
.tabs a { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: .9rem; }
.tabs a.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* M4: delivery status */
.dstatus { display: inline-block; padding: .1rem .55rem; border-radius: 6px; font-size: .8rem; font-weight: 600; background: var(--info-bg); white-space: nowrap; }
.d-delivered { background: transparent; color: var(--ok); border: 1px solid currentColor; }
.d-rto, .d-cancelled { background: var(--err-bg); color: var(--err-ink); }
.d-shipped, .d-in_transit { background: var(--warn-bg); color: var(--warn-ink); }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

/* Collapsible menu on phones (no JavaScript: checkbox toggle) */
.menu-toggle { position: absolute; opacity: 0; pointer-events: none; }
.menu-button { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .85rem; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-weight: 600; user-select: none; }
.menu-toggle:focus-visible + .menu-button { outline: 2px solid var(--brand); outline-offset: 2px; }
.topbar .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0; padding-top: .5rem; }
.topbar .nav a, .topbar .nav .link { padding: .6rem .25rem; border-bottom: 1px solid var(--border); text-align: left; }
.menu-toggle:checked ~ .nav { display: flex; }
.nav-sep { height: .5rem; }
@media (min-width: 900px) {
  .menu-button { display: none; }
  .topbar .nav { display: flex; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; padding-top: 0; }
  .topbar .nav a, .topbar .nav .link { padding: 0; border: 0; }
  .nav-sep { width: 1px; height: 1.2rem; background: var(--border); }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.report-row { flex-wrap: wrap; }
.report-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.report-form input[type=date] { width: auto; padding: .4rem .5rem; }
.report-form .btn { margin-top: 0; }
