/* ==========================================================================
   Local Drive Media — Dashboard v2
   Premium SaaS restyle (same markup, same state classes).
   Brand: ivory field, maroon primary, marigold accent, Baloo 2 display.
   Body/UI face: Inter (tabular numerals, crisp at 13–14px).
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---------- design tokens ---------- */
:root {
  color-scheme: light;

  --bg: #FDF8EF;                 /* ivory field */
  --bg-deep: #F7EFDF;            /* recessed wells */
  --surface: #FFFEFB;            /* card surface */
  --surface-2: #FFFBF3;          /* subtle alt surface */
  --ink: #2B1B12;
  --ink-soft: #8B7355;
  --ink-faint: #B5A28C;

  --primary: #8A2333;            /* maroon */
  --primary-deep: #6E1A28;
  --primary-tint: #F7E9EB;
  --accent: #E9A23B;             /* marigold */
  --accent-deep: #C97F17;
  --accent-soft: #FBF0DC;

  --ok: #1FA855;
  --ok-deep: #178A45;
  --ok-tint: #E4F3E8;
  --danger: #B3261E;
  --danger-tint: #FBEDEB;
  --danger-line: #E8C7C3;

  --line: #EAD9C4;               /* hairline on ivory */
  --line-soft: #F3E8D6;          /* even quieter hairline */

  --side-bg-0: #241318;          /* sidebar gradient stops */
  --side-bg-1: #331B23;
  --side-bg-2: #3D1E28;
  --side-ink: #EEDFD3;
  --side-muted: #A98F80;
  --side-hover: rgba(255, 255, 255, .055);
  --side-active: rgba(233, 162, 59, .13);

  --font-ui: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Baloo 2', var(--font-ui);
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* layered elevation — soft, ambient, never harsh */
  --shadow-1: 0 1px 2px rgba(75, 46, 24, .05), 0 1px 1px rgba(75, 46, 24, .03);
  --shadow-2: 0 1px 2px rgba(75, 46, 24, .05), 0 4px 12px -2px rgba(75, 46, 24, .07);
  --shadow-3: 0 2px 4px rgba(75, 46, 24, .05), 0 12px 32px -8px rgba(75, 46, 24, .14);
  --shadow-pop: 0 4px 8px rgba(43, 27, 18, .08), 0 24px 64px -12px rgba(43, 27, 18, .22);

  --ring: 0 0 0 3px rgba(233, 162, 59, .38);
  --ring-danger: 0 0 0 3px rgba(179, 38, 30, .25);

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --ease: cubic-bezier(.2, .7, .3, 1);
  /* marigold garland — the signature thread */
  --garland: linear-gradient(90deg,
      rgba(233, 162, 59, 0) 0%, #E9A23B 12%, #F6C878 32%,
      #D97A2B 52%, #F6C878 72%, #E9A23B 88%, rgba(233, 162, 59, 0) 100%);
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv05', 'cv11';
}
::selection { background: rgba(233, 162, 59, .32); }

button, input, select { font-family: inherit; }

/* one focus language everywhere */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* quiet, brand-toned scrollbars */
main::-webkit-scrollbar, #feed::-webkit-scrollbar, nav#evNav::-webkit-scrollbar { width: 10px; }
main::-webkit-scrollbar-thumb, #feed::-webkit-scrollbar-thumb {
  background: rgba(139, 115, 85, .26); border-radius: 8px;
  border: 3px solid transparent; background-clip: padding-box;
}
nav#evNav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .14); border-radius: 8px;
  border: 3px solid transparent; background-clip: padding-box;
}
main::-webkit-scrollbar-track, #feed::-webkit-scrollbar-track,
nav#evNav::-webkit-scrollbar-track { background: transparent; }

/* ---------- app shell ---------- */
#app {
  display: grid; height: 100vh;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 60px 1fr;
  grid-template-areas: "side top" "side main";
  transition: grid-template-columns .24s var(--ease);
}
#app.rail { grid-template-columns: 56px 1fr; }

/* ==========================================================================
   SIDEBAR — premium app rail on a deep plum-to-maroon gradient
   ========================================================================== */
aside {
  grid-area: side;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(233, 162, 59, .10), transparent 55%),
    linear-gradient(168deg, var(--side-bg-1) 0%, var(--side-bg-0) 46%, var(--side-bg-2) 100%);
  color: var(--side-ink);
  display: flex; flex-direction: column; overflow: hidden;
  position: relative;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06);
}
/* faint top sheen so the rail reads as lacquered, not flat */
aside::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 120px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), transparent);
  pointer-events: none;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 16.5px; letter-spacing: .01em; color: #fff;
  white-space: nowrap; position: relative;
}
.brand .cam-ico {
  font-size: 17px; flex: none;
  width: 32px; height: 32px; display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(233, 162, 59, .28), rgba(233, 162, 59, .10));
  border: 1px solid rgba(233, 162, 59, .35);
  border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}

.side-tools { padding: 2px 12px 12px; position: relative; }
#newEvBtn {
  width: 100%; padding: 9px 12px; border: none; border-radius: var(--r-md);
  cursor: pointer;
  background: linear-gradient(180deg, #F2B04E, var(--accent) 55%, #DE9126);
  color: #45280A; font-weight: 700; font-size: 13.5px;
  font-family: var(--font-display); letter-spacing: .01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 6px rgba(0, 0, 0, .28);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .12s;
}
#newEvBtn:hover { filter: brightness(1.05); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 4px 12px rgba(0,0,0,.32); }
#newEvBtn:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2); }

#evSearch {
  width: 100%; margin-top: 10px; padding: 8px 11px; font-size: 13px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, .28);
  color: var(--side-ink);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#evSearch::placeholder { color: var(--side-muted); }
#evSearch:hover { border-color: rgba(255, 255, 255, .2); }
#evSearch:focus, #evSearch:focus-visible {
  border-color: var(--accent);
  background: rgba(0, 0, 0, .34);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25), 0 0 0 3px rgba(233, 162, 59, .22);
}

nav#evNav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 2px 10px 12px; position: relative; }
.navhead {
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--side-muted); padding: 14px 8px 6px; white-space: nowrap;
}
.evitem {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 9px; border: none; border-radius: var(--r-sm); cursor: pointer;
  text-align: left; background: none; color: var(--side-ink);
  font-size: 13.5px; margin-bottom: 2px; position: relative;
  transition: background .14s var(--ease), color .14s;
}
/* active marker: a marigold jewel on the left edge instead of a fat border */
.evitem::before {
  content: ""; position: absolute; left: -4px; top: 50%;
  width: 3px; height: 0; border-radius: 3px;
  background: linear-gradient(180deg, #F6C878, var(--accent));
  transform: translateY(-50%);
  transition: height .18s var(--ease);
}
.evitem:hover { background: var(--side-hover); }
.evitem.sel {
  background: var(--side-active);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(233, 162, 59, .22);
}
.evitem.sel::before { height: 60%; }
.evitem:focus-visible { box-shadow: inset 0 0 0 1px rgba(233,162,59,.22), var(--ring); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.on { background: #3ECC74; box-shadow: 0 0 0 3px rgba(62, 204, 116, .16); }
.dot.off { background: #6B5A50; }
.evmeta { min-width: 0; }
.evmeta .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .005em; }
.evmeta .sub2 { font-size: 11px; color: var(--side-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.collapse-btn {
  margin: 10px 12px 12px; padding: 8px; border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--r-sm); cursor: pointer;
  background: rgba(255, 255, 255, .05); color: var(--side-muted); font-size: 13px;
  transition: background .14s, color .14s, border-color .14s;
}
.collapse-btn:hover { background: rgba(255, 255, 255, .1); color: var(--side-ink); border-color: rgba(255, 255, 255, .18); }

#app.rail .brand span, #app.rail .side-tools, #app.rail .navhead,
#app.rail .evmeta { display: none; }
#app.rail .brand { justify-content: center; padding: 18px 0 14px; }
#app.rail .evitem { justify-content: center; padding: 11px 0; }
#app.rail .evitem::before { left: 2px; }
#app.rail .collapse-btn { margin: 10px 8px 12px; }

/* ==========================================================================
   TOP BAR — airy, with the marigold garland signature underneath
   ========================================================================== */
header#top {
  grid-area: top; display: flex; align-items: center; gap: 16px;
  background: rgba(253, 248, 239, .86);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  position: relative; z-index: 20;
}
/* the garland: a warm gradient thread under the bar */
header#top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--garland);
  opacity: .85; pointer-events: none;
}
#topName {
  font-family: var(--font-display); font-size: 19px; font-weight: 700;
  color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .005em;
}
.codechip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  background: var(--accent-soft); color: #7A5410;
  padding: 3px 9px; border-radius: 6px;
  border: 1px solid rgba(217, 160, 66, .35);
  letter-spacing: .04em;
}
.rolechip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 20px;
  background: var(--accent-soft); color: #7A5410;
  border: 1px solid rgba(217, 160, 66, .35);
}
#renameBtn { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--ink-soft); border-radius: 6px; padding: 2px 4px; transition: color .12s, background .12s; }
#renameBtn:hover { color: var(--primary); background: var(--primary-tint); }

#topStats { display: flex; gap: 18px; font-size: 12.5px; color: var(--ink-soft); margin-left: auto; white-space: nowrap; letter-spacing: .01em; }
#topStats b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

.health {
  display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-soft);
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow-1);
}
#healthDot { width: 7px; height: 7px; border-radius: 50%; background: #C9BBA8; flex: none; }
#healthDot.ok { background: var(--ok); animation: pulse 2.2s infinite; }
#healthDot.bad { background: var(--danger); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31, 168, 85, .4); }
  50%      { box-shadow: 0 0 0 5px rgba(31, 168, 85, 0); }
}

#logout {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: var(--r-sm); padding: 6px 13px; font-size: 12.5px; font-weight: 550;
  cursor: pointer; box-shadow: var(--shadow-1);
  transition: color .14s, border-color .14s, box-shadow .14s;
}
#logout:hover { color: var(--primary); border-color: rgba(138, 35, 51, .35); box-shadow: var(--shadow-2); }

/* ==========================================================================
   MAIN + TABS
   ========================================================================== */
main { grid-area: main; overflow-y: auto; padding: 0 28px 48px; scroll-behavior: smooth; }

.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  margin: 0 -28px; padding: 6px 28px 0;
  position: sticky; top: 0; z-index: 10;
  background: rgba(253, 248, 239, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tab {
  padding: 11px 15px 12px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; letter-spacing: .01em; color: var(--ink-soft);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  position: relative;
  transition: color .14s, background .14s;
}
.tab::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2.5px;
  border-radius: 3px 3px 0 0; background: var(--primary);
  transform: scaleX(0); transform-origin: center;
  transition: transform .18s var(--ease);
}
.tab:hover { color: var(--ink); background: rgba(138, 35, 51, .05); }
.tab.on { color: var(--primary); }
.tab.on::after { transform: scaleX(1); }
.tab:focus-visible { box-shadow: var(--ring); }
.tab.dngr { color: var(--primary); opacity: .7; margin-left: auto; }
.tab.dngr:hover { opacity: 1; background: var(--danger-tint); color: var(--danger); }
.tab.dngr.on { opacity: 1; color: var(--danger); }
.tab.dngr.on::after { background: var(--danger); }

.panel { display: none; padding-top: 20px; }
.panel.on { display: block; animation: panelin .22s var(--ease); }
@keyframes panelin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-2);
}
h3 { font-size: 13px; font-weight: 700; margin-bottom: 12px; color: var(--ink); letter-spacing: .01em; }
.hintline { font-size: 12px; color: var(--ink-soft); font-weight: 400; letter-spacing: 0; }

/* ==========================================================================
   STAT CARDS — big tabular numerals, marigold tick, quiet luxury
   ========================================================================== */
.statrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-2);
  transition: box-shadow .18s var(--ease), transform .18s var(--ease), border-color .18s;
}
.stat::before {
  content: ""; position: absolute; top: 0; left: 18px; width: 26px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--accent), #F6C878);
  opacity: .9;
}
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-3); border-color: #E2CDB0; }
.stat .lbl {
  font-size: 10.5px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .09em; color: var(--ink-soft);
}
.stat .val {
  font-family: var(--font-display);
  font-size: 34px; font-weight: 700; line-height: 1.15;
  font-variant-numeric: tabular-nums;
  margin-top: 3px; letter-spacing: -.01em;
  display: inline-block; padding: 0 5px; margin-left: -5px;
  border-radius: 7px;
  transition: background .5s, color .5s;
}
.stat .val.bump { background: var(--accent-soft); color: var(--accent-deep); }
#lastUpd { font-size: 11.5px; color: var(--ink-faint); margin: 8px 2px 16px; font-variant-numeric: tabular-nums; }

.ovgrid { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
@media (max-width: 1100px) {
  .ovgrid { grid-template-columns: 1fr; }
  .statrow { grid-template-columns: repeat(2, 1fr); }
  main { padding: 0 20px 40px; }
  .tabs { margin: 0 -20px; padding: 6px 20px 0; }
}

/* ==========================================================================
   LIVE ACTIVITY FEED
   ========================================================================== */
#feedCard { padding: 0; overflow: hidden; }
#feedHead {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), transparent);
}
.livepill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 800; letter-spacing: .1em;
  padding: 3px 10px; border-radius: 20px;
  background: var(--ok-tint); color: var(--ok-deep);
  border: 1px solid rgba(31, 168, 85, .25);
  transition: background .2s, color .2s, border-color .2s;
}
.livepill .dot2 { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: pulse 2.2s infinite; }
.livepill.paused { background: var(--bg-deep); color: var(--ink-soft); border-color: var(--line); }
.livepill.paused .dot2 { background: #B5A28C; animation: none; }

#newPill {
  display: none; margin-left: auto;
  font-size: 11px; font-weight: 700;
  background: linear-gradient(180deg, #F2B04E, var(--accent));
  color: #45280A; border: none; border-radius: 20px;
  padding: 4px 11px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), var(--shadow-1);
  transition: filter .12s, transform .12s;
}
#newPill:hover { filter: brightness(1.05); transform: translateY(-1px); }

#feed { max-height: 520px; overflow-y: auto; overscroll-behavior: contain; }
.fitem {
  display: flex; gap: 11px; padding: 9px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px; line-height: 1.5; align-items: baseline;
  transition: background .14s;
}
.fitem:last-child { border-bottom: none; }
.fitem:hover { background: var(--surface-2); }
.fitem.fresh { animation: slidein .28s var(--ease); background: var(--accent-soft); transition: background 1.2s; }
@keyframes slidein { from { transform: translateY(-7px); opacity: 0; } to { transform: none; opacity: 1; } }
.fico {
  flex: none; width: 22px; height: 22px;
  display: grid; place-items: center; align-self: center;
  font-size: 12px; border-radius: 7px;
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
}
.ftext { flex: 1; min-width: 0; overflow-wrap: break-word; }
.ftime { flex: none; font-size: 10.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.fitem.err { background: var(--danger-tint); }
.fitem.err .ftext { color: var(--danger); font-weight: 600; }
.fitem.err .fico { background: #F6DCD9; border-color: var(--danger-line); }

/* ==========================================================================
   PROCESSING QUEUE
   ========================================================================== */
.qrow { display: flex; gap: 16px; font-size: 13px; flex-wrap: wrap; align-items: center; }
.qrow b { font-variant-numeric: tabular-nums; font-weight: 650; }
.qfail { margin-top: 10px; font-size: 13px; }
.qfail .fr {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin-top: 4px;
  color: var(--danger); border-radius: var(--r-sm);
  background: var(--danger-tint);
  border: 1px solid var(--danger-line);
}
.qfail .fr span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- mini buttons ---------- */
.mini {
  display: inline-block; padding: 6px 12px; font-size: 12.5px; font-weight: 600;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; letter-spacing: .01em;
  box-shadow: var(--shadow-1);
  transition: border-color .14s, box-shadow .14s, background .14s, color .14s, transform .1s;
}
.mini:hover { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(233,162,59,.25), var(--shadow-2); }
.mini:active { transform: translateY(1px); box-shadow: none; }
.mini.wa {
  background: linear-gradient(180deg, #26B75F, var(--ok) 60%, var(--ok-deep));
  border-color: var(--ok-deep); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), var(--shadow-1);
}
.mini.wa:hover { filter: brightness(1.06); border-color: var(--ok-deep); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), var(--shadow-2); }
.mini.red { color: var(--danger); border-color: var(--danger-line); background: var(--surface); }
.mini.red:hover { border-color: var(--danger); background: var(--danger-tint); box-shadow: 0 0 0 1px rgba(179,38,30,.15), var(--shadow-1); }

/* ==========================================================================
   COUNTER QR CARDS
   ========================================================================== */
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.counterbox {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 12px 14px; text-align: center;
  background: linear-gradient(180deg, #FFFFFF, var(--surface-2));
  box-shadow: var(--shadow-1);
  transition: box-shadow .18s var(--ease), transform .18s var(--ease), border-color .18s;
}
.counterbox:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: #E2CDB0; }
.counterbox h4 {
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  margin-bottom: 8px; color: var(--primary); letter-spacing: .01em;
}
.counterbox canvas {
  width: 132px; height: 132px; image-rendering: pixelated;
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: 0 0 0 1px var(--line-soft), 0 0 0 6px #fff, 0 0 0 7px var(--line);
  margin: 4px 0 2px;
}
.counterbox .cnt { font-size: 12px; color: var(--ink-soft); margin: 10px 0 10px; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   UPLOAD DROPZONE
   ========================================================================== */
#drop {
  border: 1.5px dashed rgba(217, 160, 66, .75);
  border-radius: var(--r-md);
  padding: 26px 16px;
  text-align: center; color: var(--ink-soft); cursor: pointer;
  background:
    radial-gradient(70% 120% at 50% 0%, rgba(251, 240, 220, .7), transparent 70%),
    #FFFFFF;
  transition: background .16s, border-color .16s, box-shadow .16s, transform .16s var(--ease);
}
#drop b { color: var(--primary); font-weight: 700; }
#drop:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(233, 162, 59, .2);
}
#drop.hot {
  background: var(--accent-soft);
  border-color: var(--accent-deep);
  border-style: solid;
  box-shadow: inset 0 0 0 2px rgba(233, 162, 59, .35), var(--shadow-2);
  transform: scale(1.005);
}
#upStatus { margin-top: 10px; font-size: 13px; min-height: 1em; color: var(--ink-soft); }

/* ==========================================================================
   PHOTOS & RESULTS
   ========================================================================== */
.photo-tools {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
  font-size: 13px; flex-wrap: wrap; color: var(--ink-soft);
  padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.photo-tools label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.photo-tools select {
  background: var(--surface); color: var(--ink); cursor: pointer;
  box-shadow: var(--shadow-1);
}
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.ph { min-width: 0; }
.ph a { display: block; border-radius: var(--r-md); }
.ph img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-deep);
  box-shadow: var(--shadow-1);
  transition: box-shadow .18s var(--ease), transform .18s var(--ease);
}
.ph a:hover img { box-shadow: var(--shadow-3); transform: translateY(-2px); }
.ph .cap { font-size: 11.5px; color: var(--ink-soft); margin-top: 7px; line-height: 1.5; }
.ph .cap .fname {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em;
}
.ph .cap b { color: var(--ink); font-weight: 650; }
.mockscore { color: var(--accent-deep); }
#loadMore { margin: 18px auto 0; display: none; }

/* ==========================================================================
   GUESTS TABLE
   ========================================================================== */
.tbl-tools {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), transparent);
}
.tbl-tools .sp { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  text-align: left; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line);
}
td {
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
  height: 44px; vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .02em; }
.reveal { cursor: pointer; border-bottom: 1px dashed var(--ink-faint); transition: color .12s, border-color .12s; }
.reveal:hover { color: var(--primary); border-bottom-color: var(--primary); }
td .rowact { white-space: nowrap; }
td .rowact .mini { margin-right: 4px; }

/* ==========================================================================
   DANGER ZONE — GitHub-style, red-bordered, calm until touched
   ========================================================================== */
.dz {
  border: 1px solid var(--danger-line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  background: var(--surface);
}
.dzrow {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #F3E0DD;
  background: var(--surface);
}
.dzrow:last-child { border-bottom: none; }
.dzrow .tx { flex: 1; min-width: 0; }
.dzrow .tx b { display: block; margin-bottom: 3px; font-weight: 650; letter-spacing: .005em; }
.dzrow .tx span { font-size: 12.5px; color: var(--ink-soft); line-height: 1.55; }

.btn-red {
  padding: 9px 16px; border-radius: var(--r-md);
  border: 1px solid var(--danger-line);
  background: var(--surface); color: var(--danger);
  font-weight: 700; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
  flex: none;
}
.btn-red:enabled:hover {
  background: var(--danger); border-color: var(--danger); color: #fff;
  box-shadow: 0 4px 12px -2px rgba(179, 38, 30, .35);
}
.btn-red:enabled:focus-visible { box-shadow: var(--ring-danger); }
.btn-red:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

#delConfirm { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#delConfirm input {
  padding: 9px 13px; border: 1px solid var(--danger-line); border-radius: var(--r-sm);
  font-size: 13.5px; width: 240px; background: #fff;
  font-family: var(--font-mono); letter-spacing: .03em;
  transition: border-color .14s, box-shadow .14s;
}
#delConfirm input:focus, #delConfirm input:focus-visible {
  border-color: var(--danger); box-shadow: var(--ring-danger); outline: none;
}
#delConfirm input::placeholder { font-family: var(--font-ui); letter-spacing: 0; color: var(--ink-faint); }

/* ==========================================================================
   EMPTY STATES, LOGIN, FORMS, TOAST
   ========================================================================== */
.empty { text-align: center; color: var(--ink-soft); padding: 36px 12px; font-size: 13.5px; }

/* full-screen login — the first impression */
#loginWrap {
  display: none; /* JS switches to flex */
  position: fixed; inset: 0; z-index: 100;
  align-items: center; justify-content: center; flex-direction: column; gap: 4px;
  background:
    radial-gradient(52% 44% at 50% 0%, rgba(233, 162, 59, .16), transparent 70%),
    radial-gradient(60% 50% at 50% 108%, rgba(138, 35, 51, .12), transparent 70%),
    var(--bg);
}
#loginWrap .card {
  width: 380px; max-width: calc(100vw - 40px);
  padding: 28px 28px 26px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: rgba(255, 254, 251, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-pop);
  position: relative; overflow: hidden;
  animation: loginin .35s var(--ease);
}
/* garland across the top of the login card */
#loginWrap .card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--garland);
}
@keyframes loginin { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
#loginWrap h3 { font-size: 19px; margin-bottom: 2px; }
#loginWrap input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  margin-bottom: 12px; background: #fff;
  box-shadow: inset 0 1px 2px rgba(75, 46, 24, .04);
  transition: border-color .14s, box-shadow .14s;
}
#loginWrap input:focus, #loginWrap input:focus-visible {
  border-color: var(--accent); box-shadow: var(--ring); outline: none;
}

.btn {
  padding: 11px 20px; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, #9A2C3E, var(--primary) 55%, var(--primary-deep));
  border: none; border-radius: var(--r-md); cursor: pointer;
  font-family: var(--font-display); letter-spacing: .015em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 2px 8px -1px rgba(110, 26, 40, .4);
  transition: filter .12s, transform .12s var(--ease), box-shadow .12s;
}
.btn:hover { filter: brightness(1.08); box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 5px 14px -2px rgba(110, 26, 40, .45); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .25); }
.btn:focus-visible { box-shadow: var(--ring); }

#newEvForm { display: none; margin-top: 16px; }
#newEvForm .frow { display: flex; gap: 10px; flex-wrap: wrap; }
#newEvForm input {
  flex: 1 1 180px; padding: 11px 13px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(75, 46, 24, .04);
  transition: border-color .14s, box-shadow .14s;
}
#newEvForm input:focus, #newEvForm input:focus-visible {
  border-color: var(--accent); box-shadow: var(--ring); outline: none;
}
#msg { color: var(--ink-soft); }

#toast {
  display: none; position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(43, 27, 18, .96);
  color: #FDF8EF; font-size: 13.5px; font-weight: 500;
  padding: 12px 20px; border-radius: 12px; z-index: 200;
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: toastin .25s var(--ease);
  max-width: min(520px, calc(100vw - 40px));
  text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px; height: 15px; cursor: pointer;
}
select {
  border-radius: var(--r-sm);
  transition: border-color .14s, box-shadow .14s;
}
select:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }

/* ---------- motion respect ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  main { scroll-behavior: auto; }
  .fitem.fresh { animation: none; }
  #healthDot.ok, .livepill .dot2 { animation: none; }
  .stat:hover, .counterbox:hover, .ph a:hover img, #newPill:hover { transform: none; }
}

/* ==========================================================================
   ==========================================================================
   MOBILE LAYER — added 2026-08-16. Purely additive: everything below either
   targets the two new mobile-only elements (#mbMenuBtn / #mbBackdrop) or
   lives inside a max-width:768px media query. Desktop is untouched.
   ==========================================================================
   ========================================================================== */

/* new drawer controls exist in the DOM everywhere — hidden unless mobile */
#mbMenuBtn, #mbBackdrop { display: none; }

@media (max-width: 768px) {

  /* ---------- no horizontal page scroll, ever ---------- */
  html, body { overflow-x: hidden; }

  /* ---------- app shell: single column, header can grow to two rows ---------- */
  #app, #app.rail {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "top" "main";
  }

  /* ---------- 1. sidebar becomes an off-canvas drawer ---------- */
  aside {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(300px, 84vw);
    z-index: 60;
    transform: translateX(-103%);
    transition: transform .26s var(--ease);
    visibility: hidden;
  }
  #app.mb-drawer-open aside {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 12px 0 48px rgba(20, 8, 12, .45);
  }
  /* the drawer always shows the FULL sidebar, even if the desktop rail
     (collapsed) state was saved in localStorage */
  #app.rail .brand span { display: inline; }
  #app.rail .side-tools { display: block; }
  #app.rail .navhead { display: block; }
  #app.rail .evmeta { display: block; }
  #app.rail .brand { justify-content: flex-start; padding: 18px 16px 14px; }
  #app.rail .evitem { justify-content: flex-start; padding: 10px 9px; }
  #app.rail .evitem::before { left: -4px; }
  .collapse-btn { display: none; }                 /* rail toggle is desktop-only */
  .evitem { padding: 10px 9px; min-height: 44px; } /* comfy touch rows */

  /* hamburger — fixed 44px touch target, top-left, above everything */
  #mbMenuBtn {
    display: grid; place-items: center;
    position: fixed; top: 8px; left: 10px;
    width: 44px; height: 44px;
    z-index: 70;                    /* above the open drawer, so it stays tappable */
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); color: var(--primary);
    font-size: 19px; line-height: 1; cursor: pointer;
    box-shadow: var(--shadow-2);
  }
  #mbMenuBtn:active { transform: translateY(1px); }

  /* dim backdrop behind the drawer */
  #mbBackdrop {
    display: block;
    position: fixed; inset: 0; z-index: 55;
    background: rgba(30, 15, 10, .52);
    opacity: 0; pointer-events: none;
    transition: opacity .2s var(--ease);
  }
  #app.mb-drawer-open ~ #mbBackdrop { opacity: 1; pointer-events: auto; }

  /* ---------- 2. top bar wraps: name row, then a scrollable stats row ---------- */
  header#top {
    flex-wrap: wrap;
    min-height: 60px; height: auto;
    padding: 8px 12px 8px 62px;     /* room for the fixed hamburger */
    gap: 6px 10px;
  }
  header#top > div:first-child { order: 1; flex: 1 1 auto; }
  .health { order: 2; flex: none; }
  #logout { order: 3; flex: none; min-height: 40px; }
  #topName { font-size: 16px; }
  #topStats {
    order: 4; flex: 1 0 100%;
    margin-left: 0; gap: 14px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;          /* hide the thin scrollbar (Firefox) */
    padding-bottom: 2px;
  }
  #topStats::-webkit-scrollbar { display: none; }  /* hide it (WebKit) */

  /* ---------- main + tabs ---------- */
  main { padding: 0 14px 40px; }
  .tabs {
    margin: 0 -14px; padding: 6px 14px 0;
    flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; min-height: 44px; }

  /* ---------- 9. global touch + iOS-zoom guards ---------- */
  input, select { font-size: 16px !important; }    /* 16px stops iOS auto-zoom;
                                                      !important beats inline styles */
  .mini {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 8px 13px;
  }
  .photo-tools label { min-height: 40px; }
  #renameBtn { min-width: 40px; min-height: 40px; }

  /* ---------- 3. stat cards: 2×2, slightly smaller numerals ---------- */
  .statrow { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px 14px 12px; }
  .stat .val { font-size: 26px; }

  /* ---------- 4. overview: one column; feed scrolls inside itself ---------- */
  .ovgrid { grid-template-columns: 1fr; gap: 14px; }
  #feed { max-height: 320px; }

  /* ---------- 5. counter QR cards: horizontal snap-scroll row ---------- */
  .counters {
    display: flex; gap: 12px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding: 2px 2px 8px;
    scrollbar-width: none;
  }
  .counters::-webkit-scrollbar { display: none; }
  .counterbox {
    flex: 0 0 76%; max-width: 250px;
    scroll-snap-align: center;
  }

  /* ---------- 6. guests table -> stacked cards ----------
     td order is fixed by guests.js:
     1 Guest · 2 WhatsApp · 3 Enrolled · 4 Counter · 5 Photos · 6 Send · 7 Actions */
  #guestTable thead { display: none; }
  #guestTable, #guestTable tbody { display: block; width: 100%; }
  #guestTable tr {
    display: block;
    margin: 12px; padding: 2px 0;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); box-shadow: var(--shadow-1);
  }
  #guestTable td {
    display: block; width: 100%;
    height: auto; padding: 8px 14px;
    border-bottom: 1px solid var(--line-soft);
  }
  #guestTable td:last-child { border-bottom: none; }
  #guestTable td::before {
    display: block;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--ink-soft);
    margin-bottom: 2px;
  }
  #guestTable td:nth-child(1)::before { content: "Guest"; }
  #guestTable td:nth-child(2)::before { content: "WhatsApp"; }
  #guestTable td:nth-child(3)::before { content: "Enrolled"; }
  #guestTable td:nth-child(4)::before { content: "Counter"; }
  #guestTable td:nth-child(5)::before { content: "Photos"; }
  #guestTable td:nth-child(6)::before { content: "Send their gallery"; }
  #guestTable td:nth-child(7)::before { content: "Actions"; }
  #guestTable td .rowact,
  #guestTable td.rowact {
    white-space: normal;
    display: flex; flex-wrap: wrap; gap: 8px;
  }
  #guestTable td.rowact .mini { margin-right: 0; min-height: 40px; }
  .reveal { padding: 4px 0; }       /* bigger tap area for number reveal */

  /* ---------- 7. photos: 2-up grid; tools row already wraps ---------- */
  .pgrid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .photo-tools { gap: 10px 16px; }

  /* ---------- 8. danger zone: stacked, full-width controls ---------- */
  .dzrow { flex-direction: column; align-items: stretch; gap: 12px; }
  .dzrow .btn-red { width: 100%; min-height: 44px; }
  #delConfirm { flex-direction: column; align-items: stretch; }
  #delConfirm input { width: 100%; }
}
