/* Spec 033 v2 — Mobile reporting client. RTL-first Arabic theme.
   Layout flips automatically via <html dir="rtl">; uses CSS logical properties
   (inline-start/end, margin-inline) so there is no per-component mirroring. */

:root {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-soft: #64748b;
    --primary: #0f766e;
    --primary-soft: #ccfbf1;
    --primary-ink: #134e4a;
    --accent: #2563eb;
    --good: #16a34a;
    --warn: #d97706;
    --bad: #dc2626;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --radius: 14px;
    --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
    background: var(--surface-2);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; line-height: 1.3; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
a { color: var(--primary); text-decoration: none; }

/* ---------- boot splash (shown until WASM renders into #app) ---------- */
.boot-splash {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.boot-card { text-align: center; color: #e2e8f0; }
.boot-spinner {
    width: 48px; height: 48px; margin: 0 auto 1rem;
    border: 4px solid rgba(255,255,255,.18);
    border-top-color: #5eead4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.boot-text { font-size: .95rem; opacity: .9; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Blazor framework error bar ---------- */
#blazor-error-ui {
    display: none;
    position: fixed; inset-inline: 0; bottom: 0; z-index: 1000;
    padding: .75rem 1.25rem;
    background: #fee2e2; color: #991b1b;
    box-shadow: 0 -1px 3px rgba(0,0,0,.1);
    text-align: center;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; inset-inline-end: 1rem; top: .6rem; }
#blazor-error-ui .reload { margin-inline-start: .5rem; font-weight: 600; }

/* ---------- app shell ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: .75rem;
    padding-inline: 1rem;
    background: var(--primary); color: #fff;
    box-shadow: var(--shadow);
}
.topbar .brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.topbar .brand img { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: .85rem; opacity: .9; }
.icon-btn {
    background: rgba(255,255,255,.15); color: #fff; border: 0;
    width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 1rem;
}
.icon-btn:hover { background: rgba(255,255,255,.28); }

.layout { min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; padding: 1rem; padding-bottom: 5.5rem; max-width: 980px; width: 100%; margin: 0 auto; }
.page-pad { padding: 1rem; }

/* bottom nav (mobile-first) */
.bottom-nav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
    display: flex; justify-content: space-around;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
}
.bottom-nav a {
    flex: 1; text-align: center; color: var(--text-soft);
    font-size: .72rem; padding: .35rem .2rem; border-radius: 10px;
    display: flex; flex-direction: column; align-items: center; gap: .15rem;
}
.bottom-nav a .ico { font-size: 1.15rem; line-height: 1; }
.bottom-nav a.active { color: var(--primary); font-weight: 700; }

/* ---------- cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1rem; margin-bottom: 1rem;
}
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.card-title h2 { margin: 0; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
.kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: .9rem 1rem;
}
.kpi .kpi-label { color: var(--text-soft); font-size: .8rem; margin-bottom: .3rem; }
.kpi .kpi-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: .72rem; color: var(--text-soft); margin-top: .2rem; }
.kpi.accent .kpi-value { color: var(--primary); }
.kpi.good .kpi-value { color: var(--good); }
.kpi.warn .kpi-value { color: var(--warn); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { padding: .55rem .6rem; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { color: var(--text-soft); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: end; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface-2); }
.row-muted td { color: var(--text-soft); }

/* ---------- simple bar chart (dependency-free) ---------- */
.bars { display: flex; flex-direction: column; gap: .4rem; }
.bar-row { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: .5rem; font-size: .8rem; }
.bar-row .bar-label { color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--surface-2); border-radius: 8px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #14b8a6); border-radius: 8px; }
.bar-row .bar-value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- forms / buttons ---------- */
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .82rem; color: var(--text-soft); margin-bottom: .3rem; }
.input, select.input {
    width: 100%; padding: .6rem .7rem; font: inherit;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
    color: var(--text);
}
.input:focus, select.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.filters .field { margin-bottom: 0; flex: 1; min-width: 130px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .6rem 1.1rem; font: inherit; font-weight: 600;
    border: 0; border-radius: 10px; cursor: pointer;
    background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-ink); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.block { width: 100%; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { padding: .5rem 1rem; font: inherit; border: 0; background: var(--surface); color: var(--text-soft); cursor: pointer; }
.seg button.active { background: var(--primary); color: #fff; font-weight: 700; }

/* ---------- badges / banners ---------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge.good { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }

.stamp { font-size: .75rem; color: var(--text-soft); }

.banner {
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem .85rem; border-radius: 10px; font-size: .82rem; margin-bottom: 1rem;
}
.banner.stale { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.banner.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- states ---------- */
.center-state { text-align: center; color: var(--text-soft); padding: 2.5rem 1rem; }
.spinner-sm { width: 26px; height: 26px; margin: 0 auto .6rem; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
.empty { color: var(--text-soft); text-align: center; padding: 1.5rem; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background: radial-gradient(1200px 600px at 50% -10%, #134e4a, var(--bg)); }
.login-card { background: var(--surface); border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.35); padding: 1.6rem 1.4rem; width: 100%; max-width: 380px; }
.login-card .logo { width: 54px; height: 54px; display: block; margin: 0 auto .6rem; }
.login-card h1 { text-align: center; font-size: 1.25rem; }
.login-card .subtitle { text-align: center; color: var(--text-soft); font-size: .85rem; margin-bottom: 1.2rem; }

@media (min-width: 720px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   Spec 036 — Electronic Menu · public menu (M0 design spike).
   Balanced-cards, RTL. Namespaced .menu-* / .mi-* — no collision
   with the reporting dashboard styles above. Logical properties
   (inline-start/end) so it flips with dir="rtl".
   ============================================================ */
/* ============================================================
   Public diner menu — appetite-first redesign (Spec-010).
   Image-forward media cards · cover hero + shrinking sticky bar ·
   scroll-spy pills · tap-to-open detail sheet. Accent = --menu-accent
   (Spec-005); all-NULL falls back to the default teal. RTL-first.
   ============================================================ */
.menu-root { max-width: 640px; margin: 0 auto; background: var(--surface); min-height: 100vh; padding-bottom: 2rem; }

/* hero (cover-forward) */
.menu-hero { position: relative; min-height: 232px; display: flex; align-items: flex-end; justify-content: center; text-align: center; padding: 2.6rem 1.25rem 1.6rem; color: #fff; background: linear-gradient(160deg, var(--menu-accent, #0f766e), rgba(0,0,0,.6)); background-size: cover; background-position: center; }
.menu-hero-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.menu-logo { width: 86px; height: 86px; display: flex; align-items: center; justify-content: center; font-size: 2.4rem; background: rgba(255,255,255,.96); color: var(--menu-accent, var(--primary)); border-radius: 22px; box-shadow: 0 12px 32px rgba(0,0,0,.4); overflow: hidden; }
.menu-logo img { width: 100%; height: 100%; object-fit: cover; }
.menu-name { font-size: 1.85rem; font-weight: 800; margin: 0; letter-spacing: -.3px; text-shadow: 0 2px 16px rgba(0,0,0,.55); }
.menu-tagline { font-size: .9rem; opacity: .95; text-shadow: 0 1px 8px rgba(0,0,0,.5); }

/* sticky bar: a compact brand row (revealed on scroll) + the scroll-spy pills */
.menu-stickybar { position: sticky; top: 0; z-index: 40; background: var(--surface); }
.menu-root.scrolled .menu-stickybar { box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.menu-bar-brand { display: flex; align-items: center; justify-content: center; gap: .5rem; max-height: 0; opacity: 0; overflow: hidden; padding: 0 1rem; transition: max-height .25s ease, opacity .25s ease, padding .25s ease; }
.menu-root.scrolled .menu-bar-brand { max-height: 56px; opacity: 1; padding: .5rem 1rem; }
.menu-bar-logo { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; }
.menu-bar-name { font-weight: 800; font-size: 1rem; }
.menu-nav { display: flex; gap: .5rem; overflow-x: auto; padding: .65rem 1rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.menu-nav::-webkit-scrollbar { display: none; }
.menu-pill { white-space: nowrap; flex: 0 0 auto; padding: .5rem 1rem; border-radius: 999px; font-size: .85rem; font-weight: 700; color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border); text-decoration: none; transition: background .15s, color .15s, border-color .15s; }
.menu-pill.active { color: #fff; background: var(--menu-accent, var(--primary)); border-color: var(--menu-accent, var(--primary)); }

/* sections */
.menu-sections { padding: 1.1rem 1rem 0; }
.menu-section { margin-bottom: 1.9rem; scroll-margin-top: 116px; }
.menu-section-title { font-size: 1.3rem; font-weight: 800; margin: 0 0 .9rem; letter-spacing: -.2px; display: flex; align-items: baseline; gap: .5rem; }
.menu-section-count { font-size: .8rem; font-weight: 600; color: var(--text-soft); }

/* item card — appetite-first media list */
.menu-list { display: flex; flex-direction: column; gap: .7rem; }
.mi { display: flex; gap: .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.05); overflow: hidden; }
.mi-tappable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.mi-tappable:active { transform: scale(.985); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.mi-photo { position: relative; flex: 0 0 112px; width: 112px; aspect-ratio: 1; background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; }
.mi-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* photo-less items: a soft, light, brand-tinted placeholder (no heavy dark blocks) */
.mi-photo-empty { background: linear-gradient(135deg, var(--surface-2), var(--border)); }
.mi-emoji { font-size: 3rem; line-height: 1; opacity: .5; }
.mi-offer { position: absolute; inset-block-start: .45rem; inset-inline-start: .45rem; background: #dc2626; color: #fff; font-size: .66rem; font-weight: 800; padding: .14rem .5rem; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.mi-out-tag { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.55); color: #fff; font-size: .8rem; font-weight: 800; }
.mi-body { flex: 1; min-width: 0; padding: .8rem; padding-inline-start: 0; display: flex; flex-direction: column; }
.mi-name { font-size: 1.05rem; font-weight: 700; margin: 0 0 .25rem; }
.mi-desc { font-size: .85rem; color: var(--text-soft); margin: 0 0 .5rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mi-price { margin-top: auto; display: flex; align-items: baseline; gap: .5rem; }
.mi-now { font-size: 1.05rem; font-weight: 800; color: var(--menu-accent, var(--primary)); font-variant-numeric: tabular-nums; }
.mi-old { font-size: .82rem; color: var(--text-soft); text-decoration: line-through; }
.mi-out { opacity: .6; }

/* item detail bottom-sheet */
.menu-sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; animation: menuSheetFade .2s ease; }
.menu-sheet { position: fixed; inset-inline: 0; bottom: 0; margin-inline: auto; width: 100%; max-width: 640px; background: var(--surface); z-index: 91; border-radius: 24px 24px 0 0; max-height: 90vh; overflow-y: auto; animation: menuSheetUp .3s cubic-bezier(.22,1,.36,1); }
.menu-grabber { width: 42px; height: 5px; border-radius: 999px; background: rgba(255,255,255,.7); position: absolute; top: .6rem; inset-inline: 0; margin-inline: auto; z-index: 2; }
.menu-sheet-close { position: absolute; top: .7rem; inset-inline-end: .7rem; z-index: 2; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.menu-sheet-photo { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.menu-sheet-photo-empty { width: 100%; aspect-ratio: 16/10; display: flex; align-items: center; justify-content: center; font-size: 3.6rem; color: #fff; background: linear-gradient(135deg, var(--menu-accent, #0f766e), rgba(0,0,0,.5)); }
.menu-sheet-body { padding: 1rem 1.25rem 1.9rem; }
.menu-sheet-name { font-size: 1.4rem; font-weight: 800; margin: .3rem 0 .55rem; }
.menu-sheet-desc { color: var(--text-soft); line-height: 1.65; margin: 0 0 1.1rem; white-space: pre-line; }
.menu-sheet-price { display: flex; align-items: baseline; gap: .6rem; font-variant-numeric: tabular-nums; }
.menu-sheet-now { font-size: 1.45rem; font-weight: 800; color: var(--menu-accent, var(--primary)); }
.menu-sheet-old { color: var(--text-soft); text-decoration: line-through; }
.menu-sheet-out { display: inline-block; margin-top: .7rem; font-weight: 800; color: #dc2626; }
@keyframes menuSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes menuSheetFade { from { opacity: 0; } to { opacity: 1; } }

/* footer */
.menu-footer { text-align: center; padding: 1.6rem 1rem 2.5rem; color: var(--text-soft); }
.menu-footer-brand { font-weight: 800; color: var(--text); margin-bottom: .2rem; }
.menu-powered { font-size: .78rem; }

/* ---------- branding templates (Spec-005), re-based on the Spec-010 look ----------
   .tpl-classic = base (no overrides). --menu-accent drives all accents; these only tweak
   typography / surface treatment. */
.tpl-warm .menu-name,
.tpl-warm .menu-section-title,
.tpl-warm .menu-sheet-name { font-family: Georgia, "Times New Roman", serif; }
.tpl-warm .mi { border-radius: 22px; }

.tpl-minimal .mi { box-shadow: none; }
.tpl-minimal .menu-root.scrolled .menu-stickybar,
.tpl-minimal.menu-root.scrolled .menu-stickybar { box-shadow: none; }
.tpl-minimal .menu-section-title { font-weight: 700; }

/* ---------- owner menu editor (Spec-002) ---------- */
.menu-edit-row { display: flex; align-items: center; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.menu-edit-row:last-child { border-bottom: 0; }
.menu-edit-spacer { flex: 1; min-width: 120px; }
.menu-edit-check { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--text-soft); }
.menu-edit-form { margin-top: 1rem; padding-top: 1rem; border-top: 2px solid var(--border); }
.menu-edit-form h3 { margin: 0 0 .6rem; font-size: 1rem; }
.banner.menu-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.menu-edit-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); flex: 0 0 auto; }
.menu-edit-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 1.6rem; background: var(--surface-2); color: var(--text-soft); }
.menu-edit-thumb-sm { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); flex: 0 0 auto; }

/* ── Spec-012: professional monitoring UI ─────────────────────────────── */

/* page head with inline store filter */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .25rem; }
.page-head h1 { margin: 0; }
.input.slim { width: auto; min-width: 150px; padding: .45rem .6rem; font-size: .85rem; }

/* period preset chips */
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .35rem; margin-bottom: .75rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; flex: 0 0 auto; padding: .45rem .95rem; border-radius: 999px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--text-soft); background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.chip.active { color: #fff; background: var(--primary); border-color: var(--primary); font-weight: 700; }

/* delta badges (vs previous period) */
.delta { display: inline-block; font-size: .72rem; font-weight: 700; padding: .05rem .4rem; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); }
.delta.up { background: #dcfce7; color: #166534; }
.delta.down { background: #fee2e2; color: #991b1b; }

/* vertical 14-day trend chart */
.vchart { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: .25rem; }
.vcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.vfill { width: 100%; max-width: 26px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #14b8a6, var(--primary)); }
.vfill.today { background: linear-gradient(180deg, #f59e0b, #d97706); }
.vlabel { font-size: .62rem; color: var(--text-soft); margin-top: .3rem; font-variant-numeric: tabular-nums; }

/* action tiles (low stock / debts) */
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
.tile { display: flex; flex-direction: column; align-items: center; gap: .2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .9rem .6rem; text-decoration: none; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.tile .tile-ico { font-size: 1.3rem; }
.tile .tile-num { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile .tile-label { font-size: .75rem; color: var(--text-soft); }
.tile.warn .tile-num { color: var(--warn); }

/* misc report helpers */
.kpi-grid.three { grid-template-columns: repeat(3, 1fr); }
.seg.seg-block { display: flex; width: 100%; margin-bottom: 1rem; }
.seg.seg-block button { flex: 1; }
.bar-row.wide-label { grid-template-columns: minmax(110px, 38%) 1fr auto; }
.bar-fill.neg { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.field.grow { flex: 2; min-width: 160px; }
.sortable { cursor: pointer; user-select: none; }
.table-total { text-align: end; padding-top: .7rem; font-size: .9rem; color: var(--text-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* deleted-invoices monitor tile (owner oversight) */
.tile.alert { border-color: #fecaca; background: #fef2f2; }
.tile.alert .tile-num { color: #dc2626; }
.tile .tile-sub { font-size: .68rem; color: var(--text-soft); }
