/* Blakely design system: one set of tokens and components that every page inherits.
   Light, neutral surfaces, ink for primary actions, one blue accent, semantic colour only for status. */

/* MOTION (quick, subtle; all switched off under prefers-reduced-motion)
   - Page content rises 8px and fades in once on load (.page > *). Rows of tiles stagger by 35 ms:
     .hm-tiles, .tb-stats, .stats, .hm-more, .hm-actions, or any container with data-animate="stagger".
   - data-animate="rise" on any element: the same rise, once, when it first scrolls into view.
   - Numbers: countUp(el, to, {format}) in app.js counts a stat up once; it only animates again when the value really
     changes (poll refreshes with the same number do nothing). Server-rendered tiles opt in with
     data-count="<number>" data-format="inr-paise|int" on the number element.
   - Charts (static/charts.js): bars grow (.ch-grow), donuts sweep (.ch-sweep), lines stroke in (.ch-line); first draw only.
     Plain HTML bars grow with .bar-grow on the filled element.
   - Sheets, side panels, dialogs and the More menu slide with --ease-spring; buttons and tappable cards press to 98%.
   - Main tab rows get one sliding underline (app.js adds .ink to the tab row).
   - Durations: --t-fast 120 ms, --t-med 160 ms, --t-slow 200 ms, charts 500 ms. Transform and opacity only.
   - Page to page: a 150 ms cross-fade (view transitions) on a canvas-coloured background, so nothing flashes white. */

/* ================================================================ tokens */
:root {
  /* surfaces */
  --bg: #f5f6f8;            /* canvas */
  --card: #ffffff;          /* raised surface */
  --surface-2: #f0f1f4;     /* inset / hover */
  --line: #dfe2e7;          /* strong divider, control border */
  --soft: #eceef2;          /* quiet divider */
  /* text */
  --text: #16181d;
  --text-2: #4b515c;
  --muted: #6b7280;
  --faint: #9aa0aa;
  /* primary action (ink) and the single accent */
  --ink: #16181d;
  --ink-hover: #2e323a;
  --accent: #2456d6;
  --accent-bg: #eaf0fd;
  --accent-line: #b9cbf5;
  /* kept names used across modules */
  --blue: var(--ink);
  --blue-hover: var(--ink-hover);
  --link: var(--accent);
  /* status */
  --green: #17803d;  --green-bg: #e7f5ec;
  --red: #c42b2b;    --red-bg: #fdecec;
  --amber: #a85a00;  --amber-bg: #fff3e0;
  /* shape */
  --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-pill: 999px;
  --radius: var(--r-lg);
  /* elevation */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 0 0 1px rgba(16, 24, 40, .045);
  --shadow-hover: 0 4px 14px rgba(16, 24, 40, .08), 0 0 0 1px rgba(16, 24, 40, .06);
  --shadow-pop: 0 16px 48px rgba(16, 24, 40, .18), 0 0 0 1px rgba(16, 24, 40, .06);
  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;
  /* type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 17px; --fs-lg: 20px; --fs-xl: 24px; --fs-2xl: 30px;
  /* focus and motion */
  --focus: 0 0 0 3px rgba(36, 86, 214, .28);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.32, .72, 0, 1);
  --t-fast: .12s; --t-med: .16s; --t-slow: .2s; --t-chart: .5s;
  /* shell */
  --topbar-h: 56px;
  --sb-w: 240px;
  --sb-w-mini: 68px;
  --tabbar-h: 0px;
}
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } :root { --t-fast: 0s; --t-med: 0s; --t-slow: 0s; } *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; } }

/* ================================================================ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .15s; animation-timing-function: var(--ease); }
.topbar { view-transition-name: topbar; } .sb { view-transition-name: sidebar; } .tabbar { view-transition-name: tabbar; }
::view-transition-group(topbar), ::view-transition-group(sidebar), ::view-transition-group(tabbar) { animation-duration: 0s; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--fs-base); line-height: 1.5;
       letter-spacing: -.006em; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.btn, .seg a, .outlet-card, a.card, .sb a, .tabbar a, .sheet a, .ms-links a, .ms-list a, .sw-menu a, .acct-menu a, .tb-btn, .tb-brand { text-decoration: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
img, svg { max-width: 100%; }
::selection { background: var(--accent-bg); }

h1 { font-size: var(--fs-xl); line-height: 1.2; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h1 .sub { display: block; margin-top: 4px; font-size: var(--fs-base); line-height: 1.45; font-weight: 400; letter-spacing: -.005em; color: var(--muted); max-width: 70ch; }
h2 { font-size: var(--fs-md); line-height: 1.3; font-weight: 600; letter-spacing: -.012em; margin: 32px 0 12px; }
h2 .sub { color: var(--muted); font-weight: 400; font-size: var(--fs-sm); }
h3 { font-size: var(--fs-base); line-height: 1.35; font-weight: 600; margin: 0 0 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); letter-spacing: 0; }
.right { text-align: right; }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.num, .money, .tnum { font-variant-numeric: tabular-nums; }

/* ================================================================ page layout */
.page { max-width: 1200px; margin: 0 auto; padding: 28px 32px 72px; }
.hero, .page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 24px; }
.hero > :first-child, .page-head > :first-child { flex: 1 1 320px; min-width: 0; }
.hero .daybar, .hero > div:last-child:not(:first-child) { flex: 0 1 auto; }
.hero .btn, .page-head .btn { flex: none; }
.s-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.s-head h1 { font-size: var(--fs-xl); }

/* ================================================================ cards and stat tiles */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .shelf > .card + .card, .stats > .card + .card, .rgrid > .card + .card, .tiles > .card + .card,
.hm-cols > .card + .card, .tb-sums > .card + .card, .ud-roles > .card + .card { margin-top: 0; }
.card > h3:first-child, .card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3, .card-head h2 { margin: 0; }
.lift { transition: box-shadow var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
.lift:hover { box-shadow: var(--shadow-hover); text-decoration: none; }
a.card { color: inherit; display: block; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.shelf { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 16px; overflow-x: auto;
         scroll-snap-type: x mandatory; padding: 2px 2px 14px; margin: 0 -2px; }
.shelf > * { scroll-snap-align: start; }
.shelf::-webkit-scrollbar { height: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stats > .stat, .stat.card { padding: 16px 18px; }
.stat .label { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .value.sm { font-size: 20px; }
.stat .hint { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }

/* stat tile with optional trend (new pages) */
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; color: inherit; min-width: 0; }
.kpi .k-label { font-size: var(--fs-sm); color: var(--muted); }
.kpi .k-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: var(--fs-sm); color: var(--muted); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-sm); font-weight: 600; }
.trend.up { color: var(--green); } .trend.down { color: var(--red); } .trend.flat { color: var(--muted); }

.outlet-card { display: block; color: var(--text); }
.outlet-card:hover { text-decoration: none; }
.outlet-card .big { font-size: 30px; font-weight: 650; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.outlet-card .row { display: flex; justify-content: space-between; font-size: 14px; padding: 8px 0; border-top: 1px solid var(--soft); }
.outlet-card .row:first-of-type { border-top: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--soft); border-radius: var(--r-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; background: var(--card); }
.tile b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ================================================================ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; border: 1px solid transparent;
       border-radius: var(--r-md); background: var(--ink); color: #fff; font: inherit; font-size: 14px; font-weight: 550; line-height: 1.2;
       padding: 8px 16px; cursor: pointer; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
       -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--ink-hover); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.btn.ghost, .btn.secondary { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.ghost:hover, .btn.secondary:hover { background: var(--surface-2); }
.btn.light { background: var(--surface-2); color: var(--text); }
.btn.light:hover { background: #e3e5ea; }
.btn.danger { background: var(--card); color: var(--red); border-color: #efc4c4; }
.btn.danger:hover { background: var(--red-bg); }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #1c47b8; }
.btn.sm { min-height: 30px; font-size: 13px; padding: 4px 11px; border-radius: var(--r-sm); }
.btn.lg { min-height: 46px; font-size: 16px; padding: 11px 22px; }
.btn.block { display: flex; width: 100%; }
.link-btn { background: none; border: 0; color: var(--link); font: inherit; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.iconbtn { width: 36px; height: 36px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card); cursor: pointer;
           font-size: 18px; line-height: 1; color: var(--text); display: inline-grid; place-items: center; flex: none; }
.iconbtn:hover { background: var(--surface-2); }

/* ================================================================ tabs and segmented control
   .seg used as a page's main tabs (role=tablist, a "*-tabs" class, or placed straight on the page) becomes an
   underline tab bar that scrolls sideways on a phone. Other .seg stay a compact segmented control. */
.seg { display: inline-flex; flex-wrap: nowrap !important; background: var(--surface-2); border-radius: var(--r-md); padding: 3px; gap: 2px; max-width: 100%;
       overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; vertical-align: middle; }
.seg::-webkit-scrollbar { display: none; }
.seg > a, .seg > button { flex: none; border: 0; background: none; font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text-2);
                          padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; line-height: 1.3; }
.seg > a:hover, .seg > button:hover { color: var(--text); text-decoration: none; }
.seg .on, .seg [aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); font-weight: 600; }

.seg[role="tablist"], .seg[class*="-tabs"], .page > .seg, .tabs {
  display: flex; width: 100%; background: none; border-radius: 0; padding: 0; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.seg[role="tablist"] > *, .seg[class*="-tabs"] > *, .page > .seg > *, .tabs > * {
  padding: 10px 0 11px; border-radius: 0; font-size: 14px; color: var(--muted); position: relative; background: none !important; box-shadow: none !important; }
.seg[role="tablist"] > .on, .seg[class*="-tabs"] > .on, .page > .seg > .on, .tabs > .on,
.seg[role="tablist"] > [aria-selected="true"], .seg[class*="-tabs"] > [aria-selected="true"] { color: var(--text); font-weight: 600; }
.seg[role="tablist"] > .on::after, .seg[class*="-tabs"] > .on::after, .page > .seg > .on::after, .tabs > .on::after,
.seg[role="tablist"] > [aria-selected="true"]::after, .seg[class*="-tabs"] > [aria-selected="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > a, .tabs > button { flex: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.seg.big > a, .seg.big > button { font-size: 15px; padding: 8px 18px; }
.seg.full { display: flex; width: 100%; } .seg.full > * { flex: 1; text-align: center; }

/* chips and badges */
.pill, .badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; line-height: 1.5; padding: 1px 8px;
                border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); white-space: nowrap; vertical-align: middle; }
.pill.ok, .badge.ok { background: var(--green-bg); color: var(--green); }
.pill.bad, .badge.bad { background: var(--red-bg); color: var(--red); }
.pill.warn, .badge.warn { background: var(--amber-bg); color: var(--amber); }
.pill.info, .badge.info { background: var(--accent-bg); color: var(--accent); }
.pill.grey, .badge.grey { background: var(--surface-2); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-pill);
        background: var(--card); font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip[aria-pressed="true"], .chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--green); } .dot.warn { background: var(--amber); } .dot.bad { background: var(--red); } .dot.info { background: var(--accent); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.navbadge[hidden] { display: none; }
.navbadge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
            line-height: 18px; text-align: center; margin-left: 4px; letter-spacing: 0; }

/* ================================================================ forms */
label.f { display: block; min-width: 0; }
label.f > span:first-child { display: block; font-size: var(--fs-sm); color: var(--text-2); margin: 0 0 6px 1px; font-weight: 500; }
input, select, textarea { width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--card); border: 1px solid var(--line);
       border-radius: var(--r-md); padding: 9px 12px; min-height: 40px; outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
textarea { min-height: 80px; line-height: 1.45; }
select { padding-right: 32px !important; -webkit-appearance: none; appearance: none; cursor: pointer; background-color: var(--card);
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
         background-repeat: no-repeat !important; background-position: right 11px center !important; }
select[multiple], select[size] { background-image: none !important; padding-right: 12px !important; }
input:hover, select:hover, textarea:hover { border-color: #c7ccd4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--ink); vertical-align: middle; cursor: pointer; box-shadow: none; }
input[type=color] { padding: 2px; width: 48px; }
input[type=file] { padding: 7px; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.fields.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fields .wide { grid-column: span 2; }
.section-title { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 24px 0 10px; }
.section-title:first-child { margin-top: 0; }
.checks { display: flex; gap: 10px 18px; flex-wrap: wrap; font-size: 14px; }
.checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.help-text { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; }

/* ================================================================ day bar, sales entry */
.daybar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.daybar input[type=date], .daybar input[type=month], .daybar select { width: auto; min-height: 36px; padding: 6px 10px; font-size: 14px; }
.daybar select { padding-right: 30px; }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.summary { position: sticky; top: calc(var(--topbar-h) + 16px); }
.summary .line { display: flex; justify-content: space-between; padding: 9px 0; font-size: 14px; border-top: 1px solid var(--soft); font-variant-numeric: tabular-nums; }
.summary .line:first-of-type { border-top: 0; }
.summary .line.total { font-weight: 600; font-size: 15px; }
.summary .closing { margin: 16px 0 6px; }
.summary .closing .value { font-size: 34px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ================================================================ tables (cards on a phone: see .stack below) */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
     letter-spacing: .01em; background: transparent; }
td { padding: 11px 12px; border-bottom: 1px solid var(--soft); white-space: nowrap; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
th.num, td.num { text-align: right; }
tr.click { cursor: pointer; }
tr.sel td { background: var(--accent-bg) !important; }
tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--line); }
.check { text-align: center; color: var(--green); font-weight: 700; }
.cross { text-align: center; color: #c7cbd2; }

/* ================================================================ charts (inline SVG, see app.js) */
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { transition: opacity var(--t-fast); cursor: pointer; }
.chart .bar:hover { opacity: .75; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-sm); color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-table { margin-top: 10px; font-size: var(--fs-sm); }
.chart-table summary { cursor: pointer; color: var(--muted); }

/* ================================================================ feedback: toast, flash, notice, empty, skeleton */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0;
         background: #1d2026; color: #fff; padding: 11px 18px; border-radius: var(--r-md); font-size: 14px; pointer-events: none;
         transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease); z-index: 120; max-width: min(92vw, 520px); text-align: center;
         box-shadow: var(--shadow-pop); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red); }
.flash { padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--green-bg); color: var(--green); border-color: #cbe8d4; }
.flash.error { background: var(--red-bg); color: var(--red); border-color: #f3cccc; }
.notice { padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; background: var(--amber-bg); color: var(--amber); border: 1px solid #f6dcb4; }
.notice.info { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-line); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 14px; }
.empty-state { text-align: center; padding: 40px 20px; display: grid; justify-items: center; gap: 8px; }
.empty-state .es-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); margin-bottom: 4px; }
.empty-state h3 { font-size: var(--fs-md); margin: 0; }
.empty-state p { color: var(--muted); max-width: 46ch; margin: 0 0 8px; }
.saving { opacity: .6; pointer-events: none; }
.sk { background: linear-gradient(90deg, #eceef2 25%, #f5f6f8 50%, #eceef2 75%); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: var(--r-sm); }
.sk-line { height: 14px; margin: 8px 0; } .sk-line.w40 { width: 40%; } .sk-line.w60 { width: 60%; }
.sk-big { height: 44px; width: 60%; margin: 10px 0; } .sk-tile { height: 120px; border-radius: var(--radius); }
@keyframes sk { to { background-position: -200% 0; } }

/* ================================================================ dialogs and sheets */
.modal-bg { position: fixed; inset: 0; background: rgba(16, 18, 24, .42); display: none; align-items: center; justify-content: center; z-index: 110; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: var(--card); border-radius: var(--r-xl); padding: 24px; width: 100%; max-width: 480px; max-height: calc(100vh - 40px); overflow: auto;
         box-shadow: var(--shadow-pop); animation: pop var(--t-med) var(--ease); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal h3 { font-size: var(--fs-lg); margin-bottom: 14px; }
.modal .actions, .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
/* side panel (desktop) / bottom sheet (phone) */
.sheet-bg { position: fixed; inset: 0; z-index: 110; background: rgba(16, 18, 24, .36); display: none; }
.sheet-bg.open { display: block; }
.sheet { position: fixed; z-index: 111; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--card); box-shadow: var(--shadow-pop);
         display: flex; flex-direction: column; transform: translateX(104%); transition: transform var(--t-med) var(--ease); visibility: hidden; }
.sheet.open { transform: none; visibility: visible; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--soft); }
.sheet-head h2, .sheet-head h3 { margin: 0; font-size: var(--fs-lg); }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--soft); background: var(--card); }
.x-btn { width: 36px; height: 36px; border-radius: var(--r-md); border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--text); flex: none; }
.x-btn:hover { background: #e3e5ea; }

/* ================================================================ login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.login { width: 100%; max-width: 400px; text-align: center; }
.login h1 { font-size: var(--fs-2xl); margin-bottom: 6px; }
.login form { text-align: left; margin-top: 28px; display: grid; gap: 14px; }
.login-logo { display: block; width: 200px; max-width: 70%; height: auto; margin: 0 auto 24px; }
.brand { display: inline-flex; align-items: center; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 22px; width: auto; }

/* ================================================================ simple look: daily sales and expenses */
body.simple .card { border-radius: var(--r-lg); }
body.simple input, body.simple select { min-height: 48px; font-size: 17px; }
body.simple input[type=date] { font-size: 15px; padding: 8px 10px; }
body.simple .daybar input[type=date] { min-height: 40px; }
body.simple .iconbtn { width: 42px; height: 42px; }
body.simple .btn.lg { font-size: 16px; padding: 13px 26px; font-weight: 600; }
body.simple .summary .closing { margin: 8px 0 10px; }
body.simple .summary .closing .value { font-size: 38px; }
body.simple #drawerPill { margin-bottom: 16px; }
body.simple #drawerPill .pill { font-size: 14px; padding: 4px 12px; }
body.simple .section-title { text-transform: none; letter-spacing: -.01em; font-size: var(--fs-md); color: var(--text); font-weight: 600; margin: 26px 0 12px; }
body.simple label.f > span:first-child { font-size: 14px; }
.mobile-bar { display: none; }
details.more { margin-top: 22px; }
details.more > summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; padding: 12px 0; border-top: 1px solid var(--soft); }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "+"; float: right; font-weight: 400; font-size: 20px; line-height: 1; color: var(--muted); }
details.more[open] > summary::after { content: "–"; }
details.more > .fields { margin-top: 6px; }
details.working { margin-top: 16px; }
details.working > summary { font-size: 14px; font-weight: 500; color: var(--text-2); }
details.month { margin-top: 26px; }
details.month > summary { border-top: 0; padding: 0; font-size: 17px; }
details.month[open] > summary { margin-bottom: 14px; }
.month-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 600; }
details.month .stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0; border: 1px solid var(--soft); border-radius: var(--r-md); overflow: hidden; }
details.month .stat { padding: 12px 14px; border-right: 1px solid var(--soft); }
details.month .stat .value.sm { font-size: 18px; }
.exp-sum { margin: 0 0 14px; font-size: 16px; }
.xlist { list-style: none; margin: 14px 0 0; padding: 0; }
.xlist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; padding: 14px 0; border-top: 1px solid var(--soft); align-items: center; }
.xlist li.empty { display: block; }
.x-what { font-size: 15px; font-weight: 500; }
.x-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.x-side { text-align: right; }
.x-amt { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.x-act { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }

/* documents */
.doc-chip { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; padding: 2px 9px; border-radius: var(--r-pill); background: var(--surface-2); color: inherit; }
.doc-chip:hover { text-decoration: underline; }
.doc-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.doc-btns button { font: inherit; font-size: 13px; padding: 2px 9px; border-radius: var(--r-pill); border: 1px dashed #b5bac3; background: none; cursor: pointer; color: var(--accent); }
.install-steps { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.install-steps li { margin-bottom: 6px; }
@media print { .topbar, .sb, .tabbar, .hero, #newCard, #beanCard, #detail { display: none !important; } .app-main { margin: 0 !important; } }

/* ================================================================ SHELL: sidebar, top bar, bottom tabs, sheets */
.shell-skip { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: var(--r-sm); }
.shell-skip:focus { left: 8px; }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* sidebar */
.sb { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: var(--sb-w); background: #fbfbfc; border-right: 1px solid var(--line);
      display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); transition: width var(--t-med) var(--ease); }
.sb-brand { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 20px; flex: none; }
.sb-brand img { height: 20px; width: auto; display: block; }
.sb-brand .mark { display: none; width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 700; font-size: 15px; place-items: center; }
.sb-nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; }
.sb-area { margin: 1px 0; }
.sb-area > summary, .sb-link { list-style: none; display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: var(--r-sm);
      color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer; user-select: none; position: relative; white-space: nowrap; }
.sb-area > summary::-webkit-details-marker { display: none; }
.sb-area > summary:hover, .sb-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sb-area.on > summary, .sb-link.on { color: var(--text); font-weight: 600; }
.sb-area.on > summary .ico, .sb-link.on .ico { color: var(--accent); }
.sb-link.on { background: var(--surface-2); }
.sb-area > summary .chev { margin-left: auto; width: 14px; height: 14px; opacity: .5; transition: transform var(--t-fast); }
.sb-area[open] > summary .chev { transform: rotate(90deg); }
.sb-label { overflow: hidden; text-overflow: ellipsis; }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-left: 4px; }
.sb-dot[hidden] { display: none; }
.sb-sub { display: grid; padding: 2px 0 8px 31px; }
.sb-sub a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: var(--r-sm); font-size: 13.5px;
            color: var(--text-2); line-height: 1.3; position: relative; }
.sb-sub a:hover { background: var(--surface-2); color: var(--text); }
.sb-sub a.on { color: var(--text); font-weight: 600; background: var(--surface-2); }
.sb-sub a.on::before { content: ""; position: absolute; left: -9px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent); }
.sb-sub-title { display: none; }
.sb-foot { flex: none; border-top: 1px solid var(--line); padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 1px; }
.sb-collapse { border: 0; background: none; font: inherit; width: 100%; }
.sb-collapse .ico { transition: transform var(--t-med); }

/* collapsed sidebar: icons only, pages open as a flyout */
html.sb-mini { --sb-w: var(--sb-w-mini); }
html.sb-mini .sb-brand { padding: 0; justify-content: center; }
html.sb-mini .sb-brand img { display: none; }
html.sb-mini .sb-brand .mark { display: grid; }
html.sb-mini .sb-label, html.sb-mini .sb-area > summary .chev, html.sb-mini .sb-link .navbadge { display: none; }
html.sb-mini .sb-area > summary, html.sb-mini .sb-link { justify-content: center; padding: 0; }
html.sb-mini .sb-collapse .ico { transform: rotate(180deg); }
html.sb-mini .sb-sub { position: fixed; left: calc(var(--sb-w-mini) + 6px); min-width: 230px; background: var(--card); border-radius: var(--r-lg);
                       box-shadow: var(--shadow-pop); padding: 6px; z-index: 70; margin-top: -40px; }
html.sb-mini .sb-sub-title { display: block; padding: 8px 10px 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
html.sb-mini .sb-sub a.on::before { display: none; }
html.sb-mini .sb-area:not([open]) > .sb-sub { display: none; }
html.sb-mini .sb-area[data-autoopen][open]:not(.flyout) > .sb-sub { display: none; }

/* main column and top bar */
.app-main { margin-left: var(--sb-w); min-width: 0; transition: margin-left var(--t-med) var(--ease); }
.topbar { position: sticky; top: 0; z-index: 50; height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
          background: rgba(245, 246, 248, .86); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
          border-bottom: 1px solid var(--line); }
.topbar-in { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 20px 0 24px; }
.topbar .spacer { flex: 1; }
.tb-brand { display: none; }
.tb-btn { height: 36px; min-width: 36px; border-radius: var(--r-md); border: 0; background: none; color: var(--text-2); display: inline-flex; align-items: center;
          justify-content: center; gap: 6px; cursor: pointer; font: inherit; font-size: 14px; padding: 0 8px; position: relative; }
.tb-btn:hover { background: rgba(16, 24, 40, .06); color: var(--text); text-decoration: none; }
.tb-crumb { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-crumb b { color: var(--text); font-weight: 600; }

/* outlet switcher */
.sw { position: relative; flex: none; }
.sw > summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 8px; border-radius: var(--r-md);
                border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 14px; font-weight: 550; color: var(--text); white-space: nowrap; user-select: none; max-width: 62vw; }
.sw > summary::-webkit-details-marker { display: none; }
.sw > summary:hover { border-color: #c7ccd4; }
.sw > summary .sw-k { font-weight: 400; color: var(--muted); }
.sw > summary .sw-v { overflow: hidden; text-overflow: ellipsis; }
.sw > summary .ico { width: 16px; height: 16px; color: var(--muted); }
.sw-static { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 4px; font-size: 14px; font-weight: 550; white-space: nowrap; }
.sw-static .ico { width: 16px; height: 16px; color: var(--muted); }
.sw-menu, .acct-menu { position: absolute; top: calc(100% + 6px); min-width: 250px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
                       padding: 6px; display: grid; z-index: 90; font-size: 14px; line-height: 1.3; animation: pop var(--t-fast) var(--ease); }
.sw-menu { left: 0; }
.sw-head { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); }
.sw-menu a, .acct-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--text); min-height: 40px; }
.sw-menu a:hover, .acct-menu a:hover, .acct-menu a.on { background: var(--surface-2); text-decoration: none; }
.sw-menu a .tick { margin-left: auto; color: var(--accent); visibility: hidden; }
.sw-menu a.on { font-weight: 600; }
.sw-menu a.on .tick { visibility: visible; }
.sw-menu .sw-ic { width: 28px; height: 28px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text-2); flex: none; }
.sw-menu .sep { height: 1px; background: var(--soft); margin: 4px 6px; }

/* account menu */
.acct { position: relative; flex: none; }
.acct > summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 4px; border-radius: var(--r-pill); cursor: pointer;
                  color: var(--text-2); font-size: 14px; white-space: nowrap; user-select: none; }
.acct > summary::-webkit-details-marker { display: none; }
.acct > summary:hover, .acct[open] > summary { background: rgba(16, 24, 40, .06); color: var(--text); }
.av { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; letter-spacing: 0; }
.acct-menu { right: 0; min-width: 230px; }
.acct-head { padding: 10px; border-bottom: 1px solid var(--soft); margin-bottom: 4px; display: grid; gap: 2px; }
.acct-head span { color: var(--muted); font-size: 12px; }
.acct-menu a.out { color: var(--red); }
.acct-menu .sep { height: 1px; background: var(--soft); margin: 4px 6px; }
.chev { width: 12px; height: 12px; }

/* phone: bottom tab bar and the More sheet */
.tabbar { display: none; }
.more-sheet[hidden] { display: none; }
.more-sheet { position: fixed; inset: 0; z-index: 115; }
.more-sheet .ms-scrim { position: absolute; inset: 0; background: rgba(16, 18, 24, .4); animation: fade var(--t-med); }
@keyframes fade { from { opacity: 0; } }
.more-sheet .ms-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: var(--card); border-radius: 20px 20px 0 0;
                        padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); animation: up var(--t-med) var(--ease); -webkit-overflow-scrolling: touch; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.ms-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.ms-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 8px; }
.ms-top h2 { margin: 0; font-size: var(--fs-lg); }
.ms-area { border-top: 1px solid var(--soft); padding: 10px 0 6px; }
.ms-area h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); font-weight: 600; margin: 4px 4px 8px; }
.ms-area h3 .ico { width: 16px; height: 16px; }
.ms-links { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ms-links a { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 48px; padding: 8px 12px; border-radius: var(--r-md);
              background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.25; }
.ms-links a.on { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

/* ================================================================ responsive */
@media (max-width: 1100px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry { grid-template-columns: 1fr; }
  .summary { position: static; }
}
@media (max-width: 900px) {
  :root { --topbar-h: 54px; --tabbar-h: 62px; }
  body { font-size: 15.5px; }
  input, select, textarea { font-size: 16px; }          /* no zoom-in on iPhone */
  .sb { display: none; }
  .app-main { margin-left: 0; }
  .topbar-in { padding: 0 10px 0 14px; gap: 6px; }
  .tb-brand { display: inline-flex; margin-right: 4px; }
  .tb-brand img { height: 18px; width: auto; display: block; }
  .tb-crumb, .acct .acct-name, .tb-help { display: none; }
  .sw > summary { padding: 0 8px; } .sw > summary .sw-k { display: none; }
  /* switcher and account menu open as bottom sheets, within thumb reach (no blur on the bar: it would trap fixed sheets inside it) */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .topbar.pop-open, .topbar:has(details[open]) { z-index: 116; }
  .topbar.pop-open::after { content: ""; position: absolute; inset: 0; background: rgba(16, 18, 24, .4); z-index: 88; pointer-events: none; animation: fade var(--t-med); }
  .sw[open]::before, .acct[open]::before { content: ""; position: fixed; inset: 0; background: rgba(16, 18, 24, .4); z-index: 89; animation: fade var(--t-med); }
  .sw-menu, .acct-menu { position: fixed; left: 0; right: 0; top: auto; bottom: 0; min-width: 0; border-radius: 20px 20px 0 0; z-index: 90;
                         padding: 14px 12px calc(16px + env(safe-area-inset-bottom)); animation: up var(--t-med) var(--ease); max-height: 80vh; overflow-y: auto; }
  .sw-head { font-size: 13px; padding: 4px 12px 10px; }
  .sw-menu a, .acct-menu a { min-height: 52px; font-size: 16px; }
  .page { padding: 18px 16px calc(40px + var(--tabbar-h) + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  h1 .sub { font-size: 14px; }
  h2 { margin-top: 26px; }
  .hero { margin-bottom: 18px; }
  .hero > :first-child { flex-basis: 100%; }
  .card { padding: 18px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
  .fields, .fields.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }   /* minmax: a wide table inside must not push the page sideways */
  .btn { min-height: 42px; }
  .btn.sm { min-height: 34px; }
  .iconbtn { width: 42px; height: 42px; }
  .seg[role="tablist"], .seg[class*="-tabs"], .page > .seg { gap: 18px; margin-left: -16px; margin-right: -16px; padding: 0 16px; width: auto; max-width: none; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation-name: up; }
  .sheet { top: auto; left: 0; width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; transform: translateY(104%); }

  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
            height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
            background: rgba(252, 252, 253, .94); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
            border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; font: inherit;
            font-size: 11px; font-weight: 500; color: var(--muted); cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; min-width: 0; }
  .tabbar .ico { width: 24px; height: 24px; }
  .tabbar .on { color: var(--accent); font-weight: 600; }
  .tabbar .tb-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .tabbar .navbadge { position: absolute; top: 6px; left: 50%; margin-left: 6px; }
  body.no-tabbar { --tabbar-h: 0px; }
  body.no-tabbar .tabbar { display: none; }
  .mobile-bar { display: flex; position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 55; align-items: center; justify-content: space-between; gap: 12px;
                padding: 10px 16px; background: rgba(255, 255, 255, .96);
                backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid var(--line); }
  body.no-tabbar .mobile-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .mobile-bar .v { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
  body.has-bar .page { padding-bottom: calc(110px + var(--tabbar-h)); }
  body.simple #saveBtn { display: none; }
  body.simple .mobile-bar .btn { font-size: 16px; padding: 11px 26px; font-weight: 600; }
  .s-head .seg.big { width: 100%; } .s-head .seg.big > a { flex: 1; text-align: center; }
  body.simple .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.simple .card { padding: 16px; }
}
@media (max-width: 560px) {
  .grid.four { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats > .stat, .stat.card { padding: 14px; }
  .stat .value { font-size: 21px; }
  .daybar input[type=date], .daybar input[type=month] { flex: 1 1 150px; }
  /* tables marked .stack (app.js marks simple ones) become one card per row */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 10px 0; border-bottom: 1px solid var(--soft); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0; white-space: normal; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; justify-items: end; align-items: center; text-align: right; }
  table.stack td > * { grid-column: 2; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; grid-column: 1; justify-self: start; max-width: 45vw; }
  table.stack td:first-child { font-weight: 600; font-size: 15px; text-align: left; display: block; justify-items: start; }
  table.stack td:first-child::before { display: none; }
  table.stack td[data-label=""]::before { display: none; }
  table.stack td:empty { display: none; }
  table.stack tfoot { display: block; } table.stack tfoot tr { border-top: 1px solid var(--line); }
  tbody tr:hover td { background: none; }
  .table-wrap:has(> table.stack) { margin: 0; padding: 0; overflow: visible; }
}

/* header actions that fold on a phone (app.js foldActions) */
.ovf-more { display: none; }
.ovf-list { display: grid; gap: 2px; margin-bottom: 10px; }
.ovf-opt { display: flex; align-items: center; min-height: 52px; padding: 0 14px; border: 0; border-radius: var(--r-md); background: none; font: inherit; font-size: 16px; color: var(--text); text-align: left; cursor: pointer; }
.ovf-opt:hover, .ovf-opt:focus-visible { background: var(--surface-2); }
@media (max-width: 600px) {
  .ovf-ready { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .ovf-ready > .ovf-item { display: none; }
  .ovf-ready > .ovf-more { display: inline-flex; }
}

/* live.js bell sits in the top bar */
.tb-bell .live-bell { width: 36px; height: 36px; border-radius: var(--r-md); justify-content: center; align-items: center; color: var(--text-2); }
.tb-bell .live-bell:hover { background: rgba(16, 24, 40, .06); }

/* Installed app (PWA) */
@media (display-mode: standalone) { body { overscroll-behavior-y: none; } }

/* kitchen screen: the shell goes dark with the page */
body.kds-mode { background: #0d0d0f; color-scheme: dark; }
body.kds-mode .topbar { background: #111113; border-bottom-color: #26262a; backdrop-filter: none; -webkit-backdrop-filter: none; }
body.kds-mode .sb { background: #111113; border-right-color: #26262a; }
body.kds-mode .sb-brand .mark, body.kds-mode .av { background: #f2f2f4; color: #111; }
body.kds-mode .sb-area > summary, body.kds-mode .sb-link, body.kds-mode .tb-btn, body.kds-mode .tb-bell .live-bell, body.kds-mode .tb-crumb { color: #a1a1aa; }
body.kds-mode .tb-crumb b { color: #f4f4f5; }
body.kds-mode .sb-area > summary:hover, body.kds-mode .sb-link:hover, body.kds-mode .tb-btn:hover, body.kds-mode .sb-link.on { background: #1f1f23; color: #fff; }
body.kds-mode .tb-brand img, body.kds-mode .sb-brand img { filter: invert(1); }
body.kds-mode .sw > summary { background: #1a1a1d; border-color: #2e2e33; color: #f4f4f5; }
body.kds-mode .sw-static { color: #f4f4f5; }
body.kds-mode .sb-foot { border-top-color: #26262a; }

/* ================================================================ friendly stat tile (home, attendance board, marketing)
   <a|div class="stile t-blue"><span class="st-ic"><svg…></span><span class="st-label">…</span><span class="st-value">…</span><span class="st-sub">…</span></…>
   Five calm tints; the icon chip is a shade stronger than the tile. */
.stile { --t-bg: #f4f6fb; --t-ic: #e2e8f8; --t-fg: var(--accent);
         display: flex; flex-direction: column; gap: 2px; padding: 16px 16px 14px; border-radius: var(--r-lg); background: var(--t-bg);
         border: 1px solid rgba(16, 24, 40, .05); color: var(--text); text-decoration: none !important; min-width: 0; transition: box-shadow var(--t-med), transform var(--t-med); }
a.stile:hover { box-shadow: var(--shadow-hover); }
.stile .st-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--t-ic); color: var(--t-fg); display: grid; place-items: center; margin-bottom: 8px; flex: none; }
.stile .st-ic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stile .st-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.stile .st-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stile .st-sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stile .st-sub:empty { display: none; }
.stile.nodata .st-value { color: var(--faint); }
.stile.warn .st-value { color: var(--amber); } .stile.bad .st-value { color: var(--red); }
.t-blue  { --t-bg: #f3f6fd; --t-ic: #dfe7fb; --t-fg: #2456d6; }
.t-green { --t-bg: #f1f8f4; --t-ic: #d7efe0; --t-fg: #17803d; }
.t-amber { --t-bg: #fdf7ee; --t-ic: #f8e6c9; --t-fg: #a85a00; }
.t-rose  { --t-bg: #fcf3f4; --t-ic: #f6dcdf; --t-fg: #b4323f; }
.t-slate { --t-bg: #f5f6f8; --t-ic: #e4e7ec; --t-fg: #4b515c; }
.card-link { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--muted); flex: none; }
.card-link:hover { background: var(--surface-2); color: var(--text); }
.card-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 380px) { .stile { padding: 14px 12px 12px; } .stile .st-value { font-size: 22px; } }


/* ================================================================ motion layer (see the note at the top) */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page > * { animation: rise var(--t-slow) var(--ease) backwards; }
.page > :nth-child(2) { animation-delay: 30ms; } .page > :nth-child(3) { animation-delay: 60ms; } .page > :nth-child(4) { animation-delay: 90ms; }
.page > :nth-child(n+5) { animation-delay: 120ms; }
.hm-tiles > *, .tb-stats > *, .stats > *, .hm-more > *, .hm-actions > *, [data-animate="stagger"] > * { animation: rise var(--t-slow) var(--ease) backwards; }
.hm-tiles > :nth-child(2), .tb-stats > :nth-child(2), .stats > :nth-child(2), .hm-more > :nth-child(2), .hm-actions > :nth-child(2), [data-animate="stagger"] > :nth-child(2) { animation-delay: 35ms; }
.hm-tiles > :nth-child(3), .tb-stats > :nth-child(3), .stats > :nth-child(3), .hm-more > :nth-child(3), .hm-actions > :nth-child(3), [data-animate="stagger"] > :nth-child(3) { animation-delay: 70ms; }
.hm-tiles > :nth-child(4), .tb-stats > :nth-child(4), .stats > :nth-child(4), .hm-more > :nth-child(4), .hm-actions > :nth-child(4), [data-animate="stagger"] > :nth-child(4) { animation-delay: 105ms; }
.hm-tiles > :nth-child(n+5), .tb-stats > :nth-child(n+5), .stats > :nth-child(n+5), .hm-more > :nth-child(n+5), .hm-actions > :nth-child(n+5), [data-animate="stagger"] > :nth-child(n+5) { animation-delay: 140ms; }
[data-animate="rise"] { opacity: 0; transform: translateY(8px); transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease); }
[data-animate="rise"].in { opacity: 1; transform: none; }
/* charts draw in once */
.ch-grow { transform-box: fill-box; transform-origin: 50% 100%; animation: chGrow var(--t-chart) var(--ease) backwards; }
@keyframes chGrow { from { transform: scaleY(0); } }
.ch-sweep { transform-origin: 50% 50%; animation: chSweep var(--t-chart) var(--ease-spring) backwards; }
@keyframes chSweep { from { transform: rotate(-90deg) scale(.9); opacity: 0; } }
.ch-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: chLine var(--t-chart) var(--ease) forwards; }
@keyframes chLine { to { stroke-dashoffset: 0; } }
.bar-grow { transform-origin: 0 50%; animation: barGrow var(--t-chart) var(--ease) backwards; }
@keyframes barGrow { from { transform: scaleX(0); } }
/* press and hover */
.btn { transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease); }
.btn:active:not(:disabled) { transform: scale(.98); }
a.stile:active, a.card:active, a.kpi:active, .hm-action:active, .hm-mini:active, .ms-links a:active, .tabbar a:active, .tabbar button:active { transform: scale(.98); transition: transform var(--t-fast); }
a.stile:hover, .hm-action:hover, .hm-mini:hover { transform: translateY(-1px); }
.sb-area > summary, .sb-link, .sb-sub a { transition: background var(--t-fast), color var(--t-fast); }
/* sheets and dialogs: spring-like slide */
.sheet { transition: transform var(--t-slow) var(--ease-spring), visibility 0s linear var(--t-slow); }
.sheet.open { transition: transform var(--t-slow) var(--ease-spring), visibility 0s; }
.sheet-bg.open { animation: fade var(--t-med) var(--ease); }
.more-sheet .ms-panel, .ovf-ready ~ .more-sheet .ms-panel { animation: up var(--t-slow) var(--ease-spring); }
.modal { animation: pop var(--t-med) var(--ease-spring); }
@media (max-width: 900px) { .modal { animation: up var(--t-slow) var(--ease-spring); } .sw-menu, .acct-menu { animation: up var(--t-slow) var(--ease-spring); } }
.sw-menu, .acct-menu { animation-timing-function: var(--ease-spring); }
.sb, .app-main { transition-timing-function: var(--ease-spring); }
/* one sliding underline per main tab row (app.js) */
.ink { position: relative; }
.ink > .on::after, .ink > [aria-selected="true"]::after { display: none; }
.ink-bar { position: absolute; left: 0; bottom: -1px; height: 2px; width: 1px; background: var(--ink); border-radius: 2px; pointer-events: none;
           transform-origin: 0 0; transition: transform var(--t-slow) var(--ease-spring); }
@media (prefers-reduced-motion: reduce) {
  .page > *, [data-animate] > *, .hm-tiles > *, .tb-stats > *, .stats > *, .hm-more > *, .hm-actions > *, .ch-grow, .ch-sweep, .bar-grow { animation: none !important; }
  [data-animate="rise"] { opacity: 1; transform: none; }
  .ch-line { stroke-dashoffset: 0; animation: none; }
}


/* file viewer / share sheet for the installed app (app.js bkOpenFile) */
.fv { position: fixed; inset: 0; z-index: 130; }
.fv-scrim { position: absolute; inset: 0; background: rgba(16, 18, 24, .45); animation: fade var(--t-med); }
.fv-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 20px 20px 0 0; padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
            animation: up var(--t-slow) var(--ease-spring); display: flex; flex-direction: column; }
.fv-pdf .fv-panel { top: 0; border-radius: 0; padding-top: calc(8px + env(safe-area-inset-top)); }
.fv-bar { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.fv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; text-align: center; }
.fv-frame { flex: 1; width: 100%; border: 0; border-radius: var(--r-md); background: var(--surface-2); margin-top: 8px; }
.fv-msg { margin: 10px 4px 6px; color: var(--text-2); }

/* All modules sheet: grouped list, icon + title + one plain line */
.ms-list { display: grid; gap: 2px; background: var(--card); }
.ms-list a { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 6px; border-radius: var(--r-md); color: var(--text); }
.ms-list a:hover, .ms-list a:active { background: var(--surface-2); }
.ms-list a.on { background: var(--accent-bg); }
.ms-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; flex: none; }
.ms-list a.on .ms-ic { background: #fff; color: var(--accent); }
.ms-ic .ico { width: 18px; height: 18px; }
.ms-t { flex: 1; min-width: 0; } .ms-t b { display: block; font-size: 15px; font-weight: 600; } .ms-t small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; margin-top: 1px; }
.ms-go { width: 16px; height: 16px; color: var(--faint); }
.tab-dot { position: absolute; top: 7px; left: 50%; margin-left: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px #fff; }

/* daily sales: note and coin count, required markers */
.req { font-style: normal; font-size: 11px; font-weight: 600; color: var(--red); background: var(--red-bg); border-radius: 6px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; vertical-align: 1px; text-transform: none; letter-spacing: 0; }
.ferr { display: block; color: var(--red); font-size: 13px; margin: 6px 0 0 1px; }
input.bad, .dn.bad .dn-q { border-color: var(--red) !important; }
.dn { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; }
.dn-head, .dn-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(84px, auto); align-items: center; gap: 10px; }
.dn-head { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.dn-head span:last-child, .dn-t { text-align: right; }
.dn-row { padding: 4px 0; }
.dn-l { font-weight: 600; font-variant-numeric: tabular-nums; }
.dn-q { min-height: 44px; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.dn-t { font-variant-numeric: tabular-nums; color: var(--text-2); }
.dn-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); font-weight: 600; }
.dn-total b { font-size: 19px; font-variant-numeric: tabular-nums; }
input[readonly].money { background: var(--surface-2); }
.dn-view .line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.dn-view .line.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; font-weight: 600; }
tr.dn-exp > td { background: var(--surface-2); padding: 10px 14px; }
tr.dn-exp .dn-view { max-width: 360px; }
@media (max-width: 700px) { .dn { grid-template-columns: minmax(0, 1fr); } .dn-q { min-height: 48px; } }

/* Action bars pinned to the bottom of a page (Save on Count cash, the order dock, checklist progress, the day's Save bar)
   sit above the bottom tab bar and the phone's home indicator, never behind them. New bars: add class "bottom-bar". */
:root { --bottom-clear: 0px; }
@media (max-width: 900px) {
  body.has-shell:not(.no-tabbar) { --bottom-clear: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  body.has-shell:not(.no-tabbar) .cc-bar, body.has-shell:not(.no-tabbar) .cap-dock, body.has-shell:not(.no-tabbar) .cl-bar,
  body.has-shell:not(.no-tabbar) .mobile-bar, body.has-shell:not(.no-tabbar) .bottom-bar { bottom: var(--bottom-clear); padding-bottom: 12px; }
  body.has-shell:not(.no-tabbar) .cc-bar, body.has-shell:not(.no-tabbar) .cap-dock { z-index: 55; }
  body.has-shell:not(.no-tabbar) .mobile-bar { padding-bottom: 10px; }
}
@media (max-width: 900px) { body.has-bar #toast { bottom: calc(92px + var(--tabbar-h) + env(safe-area-inset-bottom)); } }

/* long rupee figures wrap instead of widening the page (Home tiles and rows) */
.stile .st-value, .hm-kv b, .hm-hero-v, .hm-split b, .hm-att small { overflow-wrap: anywhere; min-width: 0; }
.stile { min-width: 0; }

/* the closing bar keeps its Save button on screen whatever the figure: the amount wraps, the button never shrinks */
.mobile-bar > div:first-child { min-width: 0; flex: 1 1 auto; }
.mobile-bar .v { overflow-wrap: anywhere; line-height: 1.15; }
.mobile-bar .btn { flex: 0 0 auto; }
