:root {
  --bg: #f5f2ee; --surface: #ffffff; --surface-2: #f0ebe5; --line: #e4ddd5;
  --ink: #1e1916; --ink-2: #5b524c; --ink-3: #877d76;
  --brand: #8a1c1c; --brand-2: #6e1414; --brand-ink: #ffffff; --brand-soft: #f6e6e1; --gold: #b5852a; --gold-soft: #f6ecd6;
  --good: #1d7a4b; --good-soft: #e1f2e8; --warn: #9a5b00; --warn-soft: #fbecd0; --bad: #b3261e; --bad-soft: #fbe3e0; --info: #2c5a98; --info-soft: #e3ecf8;
  --r-occ: #8a1c1c; --r-grp: #6a3c9c; --r-vac: #e0f0e6; --r-vac-ink: #1d6b43; --r-dirty: #f6e2b8; --r-dirty-ink: #7a4d00; --r-blk: #3b3633;
  --bar: #8a1c1c; --bar-hi: #c0392b; --grid: #ece6df;
  --c-cash: #2c7a4b; --c-upi: #2c5a98; --c-card: #b5852a; --c-credit: #b8433a;
  --shadow: 0 1px 2px rgba(30, 20, 15, .06), 0 1px 1px rgba(30, 20, 15, .04);
  --radius: 14px; --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110f; --surface: #1e1a17; --surface-2: #28231f; --line: #342d28;
    --ink: #f3eee9; --ink-2: #c3b8b0; --ink-3: #93877e;
    --brand: #5e1515; --brand-2: #4a1010; --brand-ink: #ffffff; --brand-soft: #3a1d1a; --gold: #d9ad55; --gold-soft: #3a2f1a;
    --good: #5cc48d; --good-soft: #17301f; --warn: #e5a54a; --warn-soft: #3a2a12; --bad: #f08a80; --bad-soft: #3e1a17; --info: #86aee6; --info-soft: #1a2638;
    --r-occ: #b53a2e; --r-grp: #8a62c2; --r-vac: #1b3325; --r-vac-ink: #7fd3a4; --r-dirty: #3d3017; --r-dirty-ink: #efc36e; --r-blk: #56504c;
    --bar: #d8695c; --bar-hi: #f29a8c; --grid: #2e2824;
    --c-cash: #3c9564; --c-upi: #5b82c8; --c-card: #bd8a2e; --c-credit: #c9493f;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14110f; --surface: #1e1a17; --surface-2: #28231f; --line: #342d28;
  --ink: #f3eee9; --ink-2: #c3b8b0; --ink-3: #93877e;
  --brand: #5e1515; --brand-2: #4a1010; --brand-ink: #ffffff; --brand-soft: #3a1d1a; --gold: #d9ad55; --gold-soft: #3a2f1a;
  --good: #5cc48d; --good-soft: #17301f; --warn: #e5a54a; --warn-soft: #3a2a12; --bad: #f08a80; --bad-soft: #3e1a17; --info: #86aee6; --info-soft: #1a2638;
  --r-occ: #b53a2e; --r-grp: #8a62c2; --r-vac: #1b3325; --r-vac-ink: #7fd3a4; --r-dirty: #3d3017; --r-dirty-ink: #efc36e; --r-blk: #56504c;
  --bar: #d8695c; --bar-hi: #f29a8c; --grid: #2e2824;
    --c-cash: #3c9564; --c-upi: #5b82c8; --c-card: #bd8a2e; --c-credit: #c9493f;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.num, .money, td.r, .stat .v, .hero .v { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strike { text-decoration: line-through; color: var(--ink-3); }
.hide { display: none !important; }

/* ---------- header */
.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-ink); padding: calc(env(safe-area-inset-top) + 8px) 16px 10px; }
.top-row { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--gold); color: #3a1a00; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.brand .t { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .s { font-size: 12px; opacity: .8; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .12); color: inherit; display: grid; place-items: center; flex: none; }
.icon-btn:active { background: rgba(255, 255, 255, .22); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.switch { display: flex; gap: 4px; background: rgba(0, 0, 0, .22); border-radius: 12px; padding: 4px; margin: 10px auto 0; max-width: 760px; }
.switch button { flex: 1; border: 0; background: transparent; color: rgba(255, 255, 255, .85); padding: 8px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.switch button[aria-selected="true"] { background: #fff; color: var(--brand-2); }
:root[data-theme="dark"] .switch button[aria-selected="true"] { background: var(--gold); color: #2a1a00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .switch button[aria-selected="true"] { background: var(--gold); color: #2a1a00; } }

/* ---------- layout */
main { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.tabs .in { display: flex; width: 100%; max-width: 760px; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav-h); color: var(--ink-3); font-size: 11.5px; font-weight: 600; }
.tabs a svg { width: 23px; height: 23px; }
.tabs a[aria-current="page"] { color: var(--brand); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabs a[aria-current="page"] { color: var(--gold); } }
:root[data-theme="dark"] .tabs a[aria-current="page"] { color: var(--gold); }

h2.sec { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: 22px 2px 8px; font-weight: 700; }
h2.sec:first-child { margin-top: 4px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.card-head a, .link { color: var(--brand); font-weight: 600; font-size: 13.5px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card-head a, :root:not([data-theme="light"]) .link { color: var(--gold); } }
:root[data-theme="dark"] .card-head a, :root[data-theme="dark"] .link { color: var(--gold); }

/* ---------- hero & stats */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 12px; box-shadow: var(--shadow); }
.hero > div { background: var(--surface); padding: 14px; }
.hero .l { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.hero .v { font-size: 25px; font-weight: 800; letter-spacing: -.01em; margin-top: 2px; line-height: 1.15; word-break: break-word; }
.hero .s { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (min-width: 560px) { .stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); display: block; min-width: 0; }
a.stat:active, .row.tap:active { background: var(--surface-2); }
.stat .l { font-size: 12.5px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 21px; font-weight: 800; margin-top: 2px; line-height: 1.2; word-break: break-word; }
.stat .s { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.stat.alert { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-soft); }
.stat.alert .v { color: var(--bad); }
.stat.warnish { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.stat.warnish .v { color: var(--warn); }

/* ---------- rows & lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t.wrap { white-space: normal; }
.row .sub { font-size: 13px; color: var(--ink-2); margin-top: 1px; overflow-wrap: anywhere; }
.row .sub2 { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; overflow-wrap: anywhere; }
.row .end { text-align: right; flex: none; max-width: 48%; }
.row .end .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.row .end .sub2 { margin-top: 2px; }
.row.tap { cursor: pointer; }
.row .chev { color: var(--ink-3); flex: none; }
.row.head { background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--ink-2); padding-top: 8px; padding-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-3); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; vertical-align: 1px; }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

/* key-value */
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 0; }
.kv > div { padding: 9px 0; border-top: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.kv > div:nth-child(-n+2) { border-top: 0; }
.kv .k { color: var(--ink-2); font-size: 13.5px; padding-right: 10px; }
.kv .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv .v.total { font-weight: 800; }
.kv .k.total { font-weight: 800; color: var(--ink); }

/* tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .02em; color: var(--ink-3); font-weight: 700; padding: 6px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 8px 5px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl th.r, table.tbl td.r { text-align: right; white-space: nowrap; }
table.tbl tr.total td { font-weight: 800; border-top: 1.5px solid var(--ink-3); }
table.tbl td:first-child, table.tbl th:first-child { padding-left: 0; }
table.tbl td:last-child, table.tbl th:last-child { padding-right: 0; }

/* ---------- controls */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 999px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg button .n { font-weight: 800; margin-left: 4px; }
.bar-controls { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; height: 44px; }
.field input, .field select { border: 0; background: transparent; outline: none; width: 100%; height: 42px; min-width: 0; }
.field svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.field:focus-within { border-color: var(--ink-3); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; height: 44px; padding: 0 14px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }
.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.datebar .field { justify-content: center; }
.datebar input[type=date] { text-align: center; font-weight: 650; }
.range-inputs { display: flex; gap: 8px; margin: -2px 0 12px; }
.range-inputs .field { height: 42px; }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); font-weight: 650; margin: 0 0 10px -4px; padding: 4px; border: 0; background: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .back { color: var(--gold); } }
:root[data-theme="dark"] .back { color: var(--gold); }
.back svg { width: 20px; height: 20px; }
.title-block { margin: 0 0 14px; }
.title-block h1 { font-size: 21px; margin: 0; line-height: 1.25; overflow-wrap: anywhere; }
.title-block .sub { color: var(--ink-2); margin-top: 3px; }

.note { font-size: 12.5px; color: var(--ink-3); margin: 6px 2px 14px; }
.callout { border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.info { background: var(--info-soft); color: var(--info); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }
.asof { font-size: 12px; color: var(--ink-3); text-align: center; margin: 8px 0 0; }
.loading { padding: 40px 0; text-align: center; color: var(--ink-3); }
.loading .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin: 0 3px; animation: blink 1s infinite ease-in-out; }
.loading .dot:nth-child(2) { animation-delay: .15s; } .loading .dot:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.err { text-align: center; padding: 30px 12px; }
.err p { color: var(--ink-2); }

/* ---------- mode split bars */
.split { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 4px 0 10px; background: var(--surface-2); }
.split span { display: block; height: 100%; min-width: 3px; }
.m-cash { --mc: var(--c-cash); } .m-upi { --mc: var(--c-upi); } .m-card { --mc: var(--c-card); } .m-credit { --mc: var(--c-credit); }
.split span { background: var(--mc, var(--ink-3)); }
.dotm { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; background: var(--mc, var(--ink-3)); }

/* ---------- rooms board */
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.legend button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.legend button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; }
.sw.occupied, .tile.occupied { background: var(--r-occ); color: #fff; }
.sw.group, .tile.group { background: var(--r-grp); color: #fff; }
.sw.vacant, .tile.vacant { background: var(--r-vac); color: var(--r-vac-ink); }
.sw.dirty, .tile.dirty { background: var(--r-dirty); color: var(--r-dirty-ink); }
.sw.blocked, .tile.blocked { background: var(--r-blk); color: #fff; }
.type-h { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 2px 8px; font-weight: 700; font-size: 14px; }
.type-h .muted { font-weight: 500; font-size: 12.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.tile { position: relative; border: 0; border-radius: 10px; min-height: 52px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; line-height: 1.1; }
.tile .g { font-size: 10px; font-weight: 600; opacity: .9; margin-top: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .flag { position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; color: var(--bad); font-size: 11px; font-weight: 900; display: grid; place-items: center; }

/* ---------- chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-t { fill: var(--ink-3); font-size: 10px; }
.chart .b { fill: var(--bar); }
.chart .b.sel { fill: var(--bar-hi); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart-cap { font-size: 13px; color: var(--ink-2); min-height: 20px; margin-top: 6px; }
.chart-cap b { color: var(--ink); }
details.tv summary { font-size: 13px; color: var(--ink-3); cursor: pointer; margin-top: 6px; }

/* ---------- login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, var(--brand) 0 38%, var(--bg) 38%); }
.login .box { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 24px 20px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(40, 10, 5, .15); }
.login .logo { width: 52px; height: 52px; border-radius: 12px; background: var(--gold); color: #3a1a00; display: grid; place-items: center; font-weight: 900; font-size: 12.5px; margin-bottom: 12px; }
.login h1 { margin: 0 0 2px; font-size: 21px; }
.login p.sub { margin: 0 0 18px; color: var(--ink-2); font-size: 14px; }
.login label { display: block; font-size: 13px; font-weight: 650; color: var(--ink-2); margin: 12px 0 6px; }
.login input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; }
.login input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.login .btn { width: 100%; margin-top: 18px; height: 48px; }
.login .msg { color: var(--bad); font-size: 13.5px; min-height: 20px; margin-top: 10px; }
.login .fine { font-size: 12px; color: var(--ink-3); margin-top: 14px; text-align: center; }

/* account menu */
.menu-pop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; }
.menu-pop .panel { width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.menu-pop .panel h3 { margin: 0 0 2px; }
.menu-pop .panel .btn { width: 100%; margin-top: 10px; }
.theme-row { display: flex; gap: 6px; margin-top: 14px; }
.theme-row .btn { flex: 1; margin-top: 0; }
.theme-row .btn[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.change { font-size: 13px; margin-top: 3px; }
.change .f { color: var(--ink-3); text-transform: capitalize; }
.change .from { color: var(--bad); text-decoration: line-through; }
.change .to { color: var(--good); font-weight: 700; }

@media (min-width: 700px) {
  .hero .v { font-size: 28px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}
