/* Floor analytics dashboard: dark by default, tuned for a landscape tablet. */
:root, [data-theme="dark"] {
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1b232e;
  --surface-3: #232d3a;
  --border: #2a3441;
  --text: #e8eef5;
  --muted: #8d9aab;
  --faint: #5d6a7b;

  --empty: #3fb96f;      /* available table */
  --occ: #5aa7ff;        /* occupied, chairs free */
  --full: #b67cff;       /* occupied, no free chairs */
  --warn: #e3a72f;
  --empty-fill: rgba(63, 185, 111, .13);
  --occ-fill: rgba(90, 167, 255, .17);
  --full-fill: rgba(182, 124, 255, .2);
  --chair-on: #e8eef5;
  --chair-off: #5d6a7b;

  --zone: rgba(255, 255, 255, .025);
  --zone-line: rgba(255, 255, 255, .08);
  --staff-0: #1b232e;
  --staff-1: #2f9e8f;
  --staff-2: #b8f5e4;

  --z-patio: #3fb6a8; --z-window: #5aa7ff; --z-main: #a371f7; --z-booths: #f0883e;
  --z-bar: #e3b341; --z-host: #ff7b9c; --z-pass: #8b949e; --z-break: #3a4452;

  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --radius: 16px;
}

[data-theme="light"] {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #e7ebf0;
  --border: #d9dfe7;
  --text: #17202b;
  --muted: #5b6878;
  --faint: #96a1af;

  --empty: #1f9d55;
  --occ: #2f7fe0;
  --full: #7a3fe0;
  --warn: #c48309;
  --empty-fill: rgba(31, 157, 85, .1);
  --occ-fill: rgba(47, 127, 224, .12);
  --full-fill: rgba(122, 63, 224, .13);
  --chair-on: #17202b;
  --chair-off: #a7b1bd;

  --zone: rgba(20, 40, 70, .03);
  --zone-line: rgba(20, 40, 70, .11);
  --staff-0: #eef2f4;
  --staff-1: #2bb3a0;
  --staff-2: #0b4f47;
  --z-break: #c9d1db;
  --shadow: 0 10px 40px rgba(20, 30, 50, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  padding: 0 16px 16px;
}
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 16px; font-weight: 650; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px 0; background: linear-gradient(var(--bg) 80%, transparent); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: conic-gradient(from 210deg, var(--occ), var(--empty), var(--full), var(--occ)); box-shadow: inset 0 0 0 7px var(--surface); border: 1px solid var(--border); }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.live-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.live-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-chip.ok .dot { background: var(--empty); animation: live 2s infinite; }
.live-chip.bad .dot { background: #ff5c55; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(63,185,111,.6); } 70% { box-shadow: 0 0 0 8px rgba(63,185,111,0); } 100% { box-shadow: 0 0 0 0 rgba(63,185,111,0); } }
.clock { margin-left: auto; text-align: right; }
.clock-time { font-size: 24px; font-weight: 700; }
.clock-sub { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active, .btn:active { transform: scale(.97); }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.segmented button { border: 0; background: transparent; min-width: 44px; height: 36px; padding: 0 10px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.segmented button.active { background: var(--surface-3); color: var(--text); }
.segmented.small button { height: 32px; font-size: 13px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.kpi-value small { font-size: 16px; color: var(--muted); font-weight: 600; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--occ); border-radius: 3px; transition: width .6s; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 12px; align-items: start; }
.main-col { display: grid; gap: 12px; min-width: 0; }
.lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--faint); }

/* ---------- Floor plan ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; border: 2px solid; }
.sw-empty { border-color: var(--empty); background: var(--empty-fill); }
.sw-occ { border-color: var(--occ); background: var(--occ-fill); }
.sw-full { border-color: var(--full); background: var(--full-fill); }
.chair-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 2px solid var(--chair-off); }
.chair-dot.on { background: var(--chair-on); border-color: var(--chair-on); }
#floor { width: 100%; height: auto; display: block; max-height: 60vh; }
.zone-rect { fill: var(--zone); stroke: var(--zone-line); stroke-width: 1.5; }
.zone-label { fill: var(--faint); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.fixture { fill: var(--surface-3); stroke: var(--border); stroke-width: 1.5; }
.fixture-label { fill: var(--muted); font-size: 13px; font-weight: 600; }
.door { stroke: var(--empty); stroke-width: 5; stroke-linecap: round; }

.tbl { cursor: pointer; }
.tbl .shape { stroke-width: 3; transition: fill .4s, stroke .4s; }
.tbl.empty .shape { fill: var(--empty-fill); stroke: var(--empty); }
.tbl.occupied .shape { fill: var(--occ-fill); stroke: var(--occ); }
.tbl.full .shape { fill: var(--full-fill); stroke: var(--full); }
.tbl .t-id { font-size: 18px; font-weight: 750; fill: var(--text); }
.tbl .t-sub { font-size: 15px; font-weight: 700; fill: var(--muted); }
.tbl.occupied .t-sub { fill: var(--occ); }
.tbl.full .t-sub { fill: var(--full); }
.tbl .chair { stroke-width: 2.5; transition: fill .3s, stroke .3s; }
.tbl .chair.off { fill: var(--surface); stroke: var(--chair-off); }
.tbl .chair.on { fill: var(--chair-on); stroke: var(--chair-on); }
.tbl.changed .shape { animation: pop 1s ease-out; }
@keyframes pop { 30% { stroke-width: 7; } }
.tbl:focus { outline: none; }
.tbl:focus-visible .shape { stroke-width: 5; }

/* ---------- Heatmaps ---------- */
.heat-wrap { position: relative; width: 100%; aspect-ratio: 1000 / 620; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.heat-wrap canvas, .heat-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.heat-outline-zone { fill: none; stroke: var(--zone-line); stroke-width: 2; }
.heat-outline-tbl { fill: none; stroke: var(--faint); stroke-width: 2; opacity: .7; }
.heat-outline-label { fill: var(--muted); font-size: 22px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.scale i { flex: 1; height: 8px; border-radius: 4px; border: 1px solid var(--border); }
.scale-guest { background: linear-gradient(90deg, rgba(40,80,220,.25), #2d6cdf, #19c3c3, #5ad25a, #f4d03f, #f39c12, #e8452c); }
.scale-staff { background: linear-gradient(90deg, var(--staff-0), var(--staff-1), var(--staff-2)); }
.hotspots { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.hotspots li { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.hotspots .bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.hotspots .bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #19c3c3, #f4d03f, #e8452c); }
.hotspots b { text-align: right; }

.zone-map { width: 100%; height: auto; display: block; }
.zm-zone { stroke: var(--surface); stroke-width: 6; transition: fill .8s; }
.zm-label { font-size: 30px; font-weight: 700; }
.zm-now { font-size: 46px; font-weight: 800; }
.zm-sub { font-size: 28px; font-weight: 600; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.mini-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: 12px; }
.mini-table td { padding: 7px 4px; border-bottom: 1px solid var(--border); }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-table .num { text-align: right; }
.mini-table .zdot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; vertical-align: 0; }
.occ-bar { display: inline-block; width: 70px; height: 7px; border-radius: 4px; background: var(--surface-3); vertical-align: middle; margin-right: 6px; overflow: hidden; }
.occ-bar i { display: block; height: 100%; background: var(--occ); }

/* ---------- Trend ---------- */
.trend { width: 100%; height: auto; max-height: 260px; display: block; }
.trend .grid { stroke: var(--zone-line); stroke-width: 1; }
.trend .axis { fill: var(--faint); font-size: 11px; }
.trend .area { fill: url(#trendFill); }
.trend .line { fill: none; stroke: var(--occ); stroke-width: 2.25; stroke-linejoin: round; }
.trend .now-line { stroke: var(--muted); stroke-dasharray: 3 4; }
.trend .cap { stroke: var(--full); stroke-dasharray: 6 5; stroke-width: 1.25; opacity: .8; }
.trend .cap-label { fill: var(--full); font-size: 11px; }
.trend .dot { fill: var(--occ); stroke: var(--surface); stroke-width: 3; }
.trend .now-label { fill: var(--text); font-size: 12px; font-weight: 700; }

/* ---------- Side panel ---------- */
.side { position: sticky; top: 76px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1; height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 650; }
.tabs button.active { background: var(--surface-3); color: var(--text); }
.tab-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.tab-panel[hidden] { display: none; }
.staff-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.staff-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.staff-stats span { display: block; font-size: 11px; color: var(--muted); }
.staff-stats b { font-size: 18px; }
.staff-list, .table-list { list-style: none; margin: 0; padding: 0 2px 0 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.staff-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; }
.avatar { grid-row: 1; grid-column: 1; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 14px; color: #0d1117; }
.s-name { font-weight: 650; }
.s-name small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.s-zone { justify-self: end; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); white-space: nowrap; }
.s-zone.break { color: var(--warn); }
.s-meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.s-meta b { color: var(--text); font-weight: 650; }
.stack { grid-column: 1 / -1; display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.stack i { display: block; height: 100%; }
.zone-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11px; color: var(--muted); margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.zone-legend span { display: inline-flex; align-items: center; gap: 5px; }
.zone-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.filters { display: flex; gap: 6px; margin-bottom: 10px; }
.filters button { flex: 1; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.filters button.active { background: var(--surface-3); color: var(--text); border-color: var(--faint); }
.filters .n { font-size: 11px; opacity: .8; margin-left: 4px; }
.table-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); border-left: 5px solid var(--c); cursor: pointer; }
.table-row.empty { --c: var(--empty); }
.table-row.occupied { --c: var(--occ); }
.table-row.full { --c: var(--full); }
.table-row .tid { grid-column: 1; grid-row: 1 / span 2; font-size: 18px; font-weight: 750; }
.table-row .tz { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--muted); }
.table-row .tcount { grid-column: 3; grid-row: 1 / span 2; text-align: right; }
.table-row .tcount b { font-size: 20px; }
.table-row .tcount span { display: block; font-size: 12px; color: var(--muted); }
.seats { display: flex; gap: 4px; }
.table-row .seats { grid-column: 2; grid-row: 2; }
.seats i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--chair-off); }
.seats i.on { background: var(--chair-on); border-color: var(--chair-on); }

/* ---------- Sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .5); display: grid; place-items: center; padding: 16px; }
.sheet-backdrop[hidden] { display: none; }
.sheet { width: min(500px, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 18px 20px 20px; box-shadow: var(--shadow); animation: rise .2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(-10px); } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 20px; }
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.status-pill.empty { background: var(--empty-fill); color: var(--empty); }
.status-pill.occupied { background: var(--occ-fill); color: var(--occ); }
.status-pill.full { background: var(--full-fill); color: var(--full); }
.status-pill.break { background: rgba(227,167,47,.15); color: var(--warn); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.fact { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.fact span { display: block; font-size: 12px; color: var(--muted); }
.fact b { font-size: 20px; }
.breakdown { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.breakdown li { display: grid; grid-template-columns: 110px 1fr 64px; gap: 10px; align-items: center; font-size: 14px; }
.breakdown .bar { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.breakdown .bar i { display: block; height: 100%; border-radius: 5px; }
.breakdown b { text-align: right; }
.sheet h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 4px 0 10px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; }
.setting-name { font-weight: 650; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-3); font-weight: 650; font-size: 14px; white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) 330px; }
  .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 26px; }
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .staff-list, .table-list { max-height: 520px; }
  .lower-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .brand-sub, .clock-sub { display: none; }
  #speedCtl { display: none; }
}
@media (max-width: 600px) {
  body { padding: 0 10px 10px; }
  .live-chip { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
