/* Ruchi1 v2.0 design system — no external fonts or frameworks. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e8ec;
  --text: #17212b;
  --muted: #64717e;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f4f2;
  --side: #10201f;
  --side-text: #c9d6d4;
  --side-active: #1d3a38;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --bad: #c2410c;
  --neg: #dc2626;
  --bad-soft: #fdeee6;
  --warn: #a16207;
  --warn-soft: #fdf6e3;
  --pos: #1d4ed8;
  --changed: #fef08a;
  --bar-a: #0f766e;
  --bar-b: #94c9c3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 16px rgba(16, 24, 32, .05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1415; --surface: #142021; --surface-2: #182627; --border: #263739; --text: #e4ecec; --muted: #94a6a6;
    --accent: #2dd4bf; --accent-ink: #062523; --accent-soft: #123331; --side: #091011; --side-text: #a8bab9; --side-active: #16302e;
    --ok: #4ade80; --ok-soft: #12301c; --bad: #fb923c; --neg: #f87171; --bad-soft: #3a1d10; --warn: #facc15; --warn-soft: #33290b;
    --pos: #93c5fd; --changed: #6b5d0a; --bar-a: #2dd4bf; --bar-b: #1f6f67; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
.muted { color: var(--muted); }
p { margin: .25rem 0 0; }
.icon { width: 18px; height: 18px; flex: none; }
.pad { padding: 1rem; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 1.1rem .8rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; gap: .7rem; align-items: center; padding: .2rem .5rem 1.2rem; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 800; letter-spacing: .02em; }
.brand-mark.lg { width: 52px; height: 52px; font-size: 1.2rem; border-radius: 14px; }
.sidebar-logo { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #fff; }
.brand-name { color: #fff; font-weight: 700; }
.brand-sub { font-size: .8rem; opacity: .75; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 1rem .7rem .35rem; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 8px; color: var(--side-text); }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-title { flex: 1; min-width: 0; }
.store-chip { font-weight: 650; text-transform: uppercase; letter-spacing: .03em; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }

.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: .45rem; cursor: pointer; padding: .4rem .7rem; border-radius: 8px; border: 1px solid var(--border); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 160px; padding: .3rem; }
.menu-item { display: flex; gap: .5rem; align-items: center; width: 100%; padding: .5rem .6rem; border: 0; background: none; color: var(--text); font: inherit; border-radius: 6px; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }
body.wide .content { max-width: none; }
.footer { color: var(--muted); font-size: .85rem; padding: 2rem 0 .5rem; }
.crumbs { display: flex; gap: .4rem; font-size: .82rem; color: var(--muted); margin-bottom: 1rem; }
.crumbs [aria-current] { color: var(--text); }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.row-gap { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 1rem; }

/* ---------- cards / kpis ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.muted-card { opacity: .7; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: .82rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .2rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 1rem; align-items: start; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* ---------- buttons / badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .key:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost.danger { color: var(--bad); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-xl { padding: 1rem 1.4rem; font-size: 1.2rem; border-radius: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; }
.badge { white-space: nowrap; display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 650; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- flashes ---------- */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--bad-soft); color: var(--bad); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }
.flash-info { background: var(--accent-soft); color: var(--accent); }

/* ---------- forms ---------- */
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field em { color: var(--bad); font-style: normal; }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; }
.field.inline > span { white-space: nowrap; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .55rem .7rem; width: 100%; min-width: 0; }
input[disabled], select[disabled], fieldset[disabled] input, fieldset[disabled] select { background: var(--surface-2); color: var(--text); opacity: 1; }
input[type=number] { font-variant-numeric: tabular-nums; }
.money { position: relative; }
.money > span { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money > input { padding-left: 1.5rem; text-align: right; }
.form-card { display: flex; flex-direction: column; gap: 1rem; }
.form-card.narrow { max-width: 760px; }
.form-grid { display: grid; gap: .9rem 1rem; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.form-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding-top: .4rem; border-top: 1px solid var(--border); margin-top: .3rem; padding-top: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; align-items: center; flex-wrap: wrap; padding-top: .4rem; }
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1rem; }
.summary span { display: block; font-size: .82rem; color: var(--muted); }
.summary strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.readouts { margin: .2rem 0; display: flex; flex-direction: column; }
.readouts > div { display: flex; justify-content: space-between; gap: 1rem; padding: .42rem 0; border-bottom: 1px dashed var(--border); }
.readouts dt { color: var(--muted); }
.readouts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.readouts .em dd, .readouts .em dt { color: var(--text); font-weight: 700; }
output.calc { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos) !important; }
.neg { color: var(--neg) !important; }
.expense-rows { display: flex; flex-direction: column; gap: .8rem; }
.pair-rows { display: flex; flex-direction: column; gap: .6rem; margin: .8rem 0; }
.pair { display: grid; grid-template-columns: 1.3fr 1fr; gap: .8rem; }
.eod-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.store-switch select { min-width: 260px; }

/* ---------- lotto ---------- */
.lotto-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.sticky { position: sticky; top: 76px; }
.racks { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .8rem; }
.rack-table th[scope=row] { width: 2.4rem; text-align: center; border-radius: 6px; }
.rack-table td { padding: 2px 3px !important; }
.rack-table .x { color: var(--muted); text-align: center; width: 1rem; }
.rack-in { padding: .25rem .35rem; text-align: center; border-radius: 6px; min-width: 3.2rem; }
.rack-table tr.changed th, .rack-in.changed { background: var(--changed); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--surface-2); white-space: nowrap; position: relative; }
.table thead th[data-sortable], .table thead th[data-rt-sort] { cursor: pointer; user-select: none; }
.table thead th[aria-sort=ascending]::after { content: " ▲"; font-size: .65rem; }
.table thead th[aria-sort=descending]::after { content: " ▼"; font-size: .65rem; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot th { background: var(--surface-2); font-weight: 700; }
.table .num { text-align: right; white-space: nowrap; }
.table.compact th, .table.compact td { padding: .35rem .5rem; font-size: .9rem; }
.stack-cell div { white-space: nowrap; }
.table-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.table-tools .row-gap { flex-wrap: nowrap; align-items: center; }
.table-tools input[type=search] { width: 240px; }
.table-tools select { width: auto; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .8rem; font-size: .88rem; color: var(--muted); }
.pager { display: flex; gap: .3rem; flex-wrap: wrap; }
.pager button { min-width: 34px; padding: .3rem .55rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 7px; cursor: pointer; font: inherit; }
.pager button[aria-current=page] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pager button[disabled] { opacity: .4; cursor: default; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart .bar-a { fill: var(--bar-a); }
.chart .bar-b { fill: var(--bar-b); }
.chart g:hover rect { opacity: .85; }
.legend { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-left: .5rem; }
.sw-a { background: var(--bar-a); } .sw-b { background: var(--bar-b); }
.chart-data { margin-top: .6rem; }
.chart-data summary { cursor: pointer; color: var(--muted); font-size: .85rem; }

/* ---------- dialogs / toasts ---------- */
dialog { max-height: calc(100dvh - 2rem); overflow-y: auto; border: 1px solid var(--border); border-radius: 16px; padding: 1.4rem; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); width: min(440px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(10, 18, 20, .5); }
.dialog-actions, .alert-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .6rem; }
.alert-dialog { text-align: center; }
.alert-dialog h2 { font-size: 1.3rem; margin: .4rem 0; }
.alert-text { color: var(--muted); }
.alert-actions { justify-content: center; margin-top: 1.2rem; }
.alert-icon { width: 58px; height: 58px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; }
.alert-icon.success { background: var(--ok-soft); color: var(--ok); }
.alert-icon.error { background: var(--bad-soft); color: var(--bad); }
.alert-icon.warning { background: var(--warn-soft); color: var(--warn); }
.alert-icon.info { background: var(--accent-soft); color: var(--accent); }
.alert-dialog img.alert-logo { max-width: 240px; max-height: 110px; margin: 0 auto .4rem; display: block; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .6rem; z-index: 100; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow); padding: .8rem 1rem; min-width: 260px; max-width: 360px; animation: pop .2s ease-out; }
.toast strong { display: block; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), var(--bg); }
.auth { width: 100%; padding: 1rem; display: grid; place-items: center; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 2rem; }
.auth-brand { display: flex; gap: .9rem; align-items: center; margin-bottom: 1.6rem; }
.auth-brand h1 { font-size: 1.35rem; }
.auth-brand p { color: var(--muted); margin: 0; }
.auth-card form h2 { font-size: 1.15rem; }
.auth-foot { color: var(--muted); font-size: .8rem; text-align: center; margin-top: 1.4rem; }
.error-page { max-width: 480px; margin: 15vh auto; text-align: center; padding: 1rem; }
.error-page h1 { font-size: 3rem; color: var(--accent); }

/* ---------- kiosk ---------- */
.kiosk-page { background: #2c3644; min-height: 100vh; color-scheme: light; }
.kiosk { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.kiosk-card { width: min(460px, 100%); background: #fff; color: #17212b; border-radius: 24px; padding: 1.6rem; box-shadow: 0 30px 80px rgba(0,0,0,.35); text-align: center; }
.kiosk-logo { max-width: 300px; max-height: 126px; width: 100%; object-fit: contain; }
.kiosk-title { font-size: 1.15rem; letter-spacing: .12em; margin: 1rem -1.6rem; padding: .7rem; }
.kiosk-title.band { background: #50a945; color: #fff; }
.kiosk-display::placeholder { font-size: 1rem; letter-spacing: 0; }
.kiosk-display { font-size: 1.6rem; text-align: center; padding: .8rem; border-radius: 14px; margin-bottom: 1rem; letter-spacing: .04em; font-variant-numeric: tabular-nums; background: #f4f6f8; color: #17212b; border-color: #d5dde3; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-bottom: 1.1rem; }
.key { aspect-ratio: 1.5; border-radius: 16px; border: 1px solid #d5dde3; background: #f8fafb; font: 700 1.7rem/1 var(--font); color: #17212b; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; touch-action: manipulation; }
.key small { font-size: .62rem; letter-spacing: .12em; color: #64717e; font-weight: 600; min-height: .8em; }
.key:active { transform: scale(.96); background: #e6f4f2; }
.key-clear { font-size: .95rem; color: #c2410c; }
.key-back { font-size: 1.5rem; }
.kiosk .btn-primary { background: #0f766e; border-color: #0f766e; color: #fff; }

.icon-btn.menu-toggle { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .eod-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1400px) {
  .lotto-layout { grid-template-columns: 1fr; }
  .lotto-layout .sticky { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .icon-btn.menu-toggle { display: inline-grid; }
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid.cols-2, .form-grid.cols-3, .pair, .summary { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .user-menu summary span { display: none; }
}
@media print {
  .sidebar, .topbar, .table-tools, .table-foot, .form-actions, .crumbs, .btn { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; border: 0; padding: 0; }
  body { background: #fff; }
}

/* ---------- admin: users / backups ---------- */
dialog.modal.wide { width: min(620px, calc(100vw - 2rem)); }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 600; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn { margin-left: .2rem; }
.inline-form { display: inline; }
.small { font-size: .82rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.card h3 { font-size: .95rem; margin: 1rem 0 .3rem; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: .6rem .8rem; overflow-x: auto; font-size: .85rem; }
input[readonly] { background: var(--surface-2); }
@media (max-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr; } .form-grid.cols-2 .span-2 { grid-column: auto; } }
@media (max-width: 640px) { .table-tools .row-gap { flex-wrap: wrap; width: 100%; } .table-tools input[type=search] { width: auto; flex: 1 1 160px; } }
.content > .card + .card, .content > section.card + section.card { margin-top: 1rem; }


/* ---------- responsive tables: app.js adds .as-cards when a table is wider than its box ---------- */
.table thead th { white-space: normal; }
.table-tools [data-sort-pick] { display: none; }
.table-tools.cards [data-sort-pick] { display: block; }
.table.as-cards, .table.as-cards tbody, .table.as-cards tfoot { display: block; width: 100%; }
.table.as-cards thead { display: none; }
.table.as-cards tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: .6rem 1rem; padding: .8rem .95rem; margin-bottom: .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.table.as-cards tbody tr:hover { background: var(--surface); }
.table.as-cards tfoot tr { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.table.as-cards td, .table.as-cards th { display: block; padding: 0; border: 0; text-align: left; background: none; min-width: 0; font-size: .95rem; overflow-wrap: anywhere; }
.table.as-cards .num { white-space: normal; }
.table.as-cards td:empty, .table.as-cards th:empty { display: none; }
.table.as-cards [data-label]::before { content: attr(data-label); display: block; font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .1rem; }
.table.as-cards [data-cell=title] { grid-column: 1 / -1; order: -1; font-weight: 700; font-size: 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.table.as-cards [data-cell=action] { grid-column: 1 / -1; order: 99; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .3rem; }
.table.as-cards [data-cell=action] .btn { margin: 0; }
.table.as-cards td[colspan] { grid-column: 1 / -1; }

/* ---------- phones ---------- */
@media (max-width: 860px) {
  input, select, textarea { font-size: 16px; }          /* stops iPhone zooming in on every field */
}
@media (max-width: 600px) {
  .content { padding: .75rem; }
  .card { padding: .9rem; }
  .kpi { padding: .8rem .9rem; }
  .kpi-value { font-size: 1.3rem; }
  h1 { font-size: 1.3rem; }
  .page-head { align-items: stretch; }
  .page-head > .btn, .page-head > .row-gap { width: 100%; }
  .page-head > .row-gap > .btn, .page-head > .btn { flex: 1 1 auto; }
  .table-tools { gap: .5rem; }
  .table-tools [data-sort-pick] { flex: 1 1 100%; width: 100%; }
  .table-foot { justify-content: center; }
  .toasts { left: .75rem; right: .75rem; }
  .toast { min-width: 0; max-width: none; }
  dialog { padding: 1.1rem; }
  .crumbs { flex-wrap: wrap; }
}

/* ---------- loyalty mobile page (/<Program>/Mobile) ---------- */
.m-page { background: var(--bg); }
.m-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }
.m-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); }
.m-logo { width: 46px; height: 46px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--border); }
.m-top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.m-top-title strong { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-top-title span { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.m-main { flex: 1; padding: 1rem 1rem calc(88px + env(safe-area-inset-bottom)); }
.m-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1.3rem .2rem .6rem; font-weight: 700; }
.m-view > .m-h:first-child { margin-top: .2rem; }
.m-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1rem; box-shadow: var(--shadow); }
.m-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .75rem; }
.m-stats > div { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: .85rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.m-stats strong { font-size: 1.7rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.15; }
.m-stats span { font-size: .8rem; color: var(--muted); }
.m-notify-row { display: flex; gap: .8rem; align-items: flex-start; }
.m-notify-row p { color: var(--muted); font-size: .88rem; margin-top: .15rem; }
.m-notify-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.m-notify[data-state=on] .m-notify-icon { background: var(--ok-soft); color: var(--ok); }
.m-notify[data-state=ready] .m-notify-icon, .m-notify[data-state=setup] .m-notify-icon { background: var(--accent-soft); color: var(--accent); }
.m-notify-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.m-notify-actions:not(:has(button:not([hidden]))) { display: none; }
.m-notify-actions .btn-primary { flex: 1 1 100%; padding: .8rem 1rem; }
.m-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.m-item { display: flex; align-items: center; gap: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .7rem .8rem; min-height: 64px; }
.m-item.m-new { animation: m-flash 2.4s ease-out; border-color: var(--accent); }
@keyframes m-flash { from { background: var(--accent-soft); } }
.m-avatar { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 750; font-size: .95rem; }
.m-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-item-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-item-main span, .m-when span { font-size: .82rem; color: var(--muted); }
.m-when { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; }
.m-when strong { font-variant-numeric: tabular-nums; font-size: .95rem; }
.m-empty { text-align: center; color: var(--muted); padding: 2rem 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; }
.m-del { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--bad); cursor: pointer; }
.m-search { display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0 .8rem; color: var(--muted); }
.m-search:focus-within { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.m-search input { border: 0; background: transparent; padding: .85rem 0; outline: none; }
.m-hint { color: var(--muted); font-size: .85rem; margin: .6rem .2rem .7rem; }
.m-page .field input { padding: .8rem .85rem; font-size: 16px; }
.m-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, 1fr); max-width: 640px; margin: 0 auto; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.m-tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .6rem 0 .55rem; min-height: 60px; border: 0; background: none; color: var(--muted); font: 600 .75rem/1 var(--font); cursor: pointer; }
.m-tabs button .icon { width: 24px; height: 24px; }
.m-tabs button[aria-current] { color: var(--accent); }
.m-tabs button[aria-current]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.m-tabs em { position: absolute; top: .35rem; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font: 700 .7rem/18px var(--font); font-style: normal; }
.m-page .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); left: .75rem; right: .75rem; }
.m-page .toast { min-width: 0; max-width: none; }

/* ---------- Rewards app ---------- */
.auth-logo { height: 54px; width: auto; max-width: 130px; object-fit: contain; border-radius: 10px; background: #fff; padding: 4px; }
