/* ESP32 Flasher - shared design system (user + admin) */
@font-face {
  font-family: "Inter";
  src: url("/shared/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* Always dark: black background */
:root {
  --bg: #000;
  --bg-2: #07080c;
  --surface: rgba(16, 18, 26, .78);
  --surface-solid: #0e1017;
  --raise: #151822;
  --fg: #eef0f6;
  --fg-2: #c6cbd8;
  --muted: #8a90a2;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --brand: #22d3ee;
  --brand-2: #0ea5e9;
  --grad: linear-gradient(135deg, #0ea5e9 0%, #22d3ee 100%);
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, .14);
  --err: #f87171;
  --err-bg: rgba(239, 68, 68, .14);
  --warn: #fbbf24;
  --warn-bg: rgba(245, 158, 11, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .6), 0 30px 80px rgba(0, 0, 0, .7);
  --glow: 0 8px 28px rgba(34, 211, 238, .25);
  --r: 16px;
  --r-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
::selection { background: rgba(34, 211, 238, .3); }

/* ---------- animated background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.bg::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--line-2) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
}
.blob { position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(110px); opacity: .28; animation: drift 22s var(--ease) infinite alternate; }
.blob.b1 { display: none; }
.blob.b2 { display: none; }
.blob.b3 { display: none; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(80px, 60px) scale(1.12); }
  100% { transform: translate(-60px, 120px) scale(.95); }
}

/* ---------- typography ---------- */
h1, h2, h3 { letter-spacing: -.02em; margin: 0; color: var(--fg); }
h1 { font-size: 24px; font-weight: 750; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); min-height: 1em; margin: 8px 0 0; font-size: 14px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- icons ---------- */
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ico.lg { width: 22px; height: 22px; }
.ico.xl { width: 28px; height: 28px; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card.warn { background: var(--warn-bg); border-color: rgba(245, 158, 11, .35); color: var(--fg); }
.card.warn b { color: var(--warn); }

/* ---------- forms ---------- */
input, select, button, a.btn { font: inherit; }
input, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-solid);
  color: var(--fg);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(34, 211, 238, .15); }
input::placeholder { color: var(--muted); }
label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; font-size: 13px; font-weight: 600; color: var(--fg-2); }
label small { font-weight: 400; }
label.chk { flex-direction: row; align-items: center; gap: 10px; margin: 12px 0; font-weight: 500; font-size: 14px; cursor: pointer; }
label.chk input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.field { position: relative; }
.field .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field input { padding-left: 42px; }

/* ---------- buttons ---------- */
button, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-solid);
  color: var(--fg);
  font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s;
}
button:hover, a.btn:hover { border-color: var(--brand); transform: translateY(-1px); }
button:active { transform: translateY(0) scale(.98); }
button.primary {
  background: var(--grad); background-size: 160% 160%; color: #00141a; border: 0;
  box-shadow: var(--glow); animation: shimmer 6s ease infinite;
}
button.primary:hover { box-shadow: 0 10px 36px rgba(34, 211, 238, .4); }
@keyframes shimmer { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
button.danger, a.btn.danger { color: var(--err); }
button.danger:hover { border-color: var(--err); background: var(--err-bg); }
button.link { border: 0; background: none; color: var(--brand); padding: 6px 8px; box-shadow: none; }
button.link:hover { transform: none; background: rgba(34, 211, 238, .08); }
button.link.danger { color: var(--err); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; transform: none; }
.btn-sm, button.btn-sm, a.btn.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ---------- layout ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > input, .row > select { flex: 1 1 180px; width: auto; }
.row.end { justify-content: flex-end; margin-top: 18px; }
.row.spread { justify-content: space-between; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; }

/* ---------- top bar (user) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--grad); color: #00141a; box-shadow: var(--glow);
}
.logo .ico { width: 20px; height: 20px; }
.logo.big { width: 64px; height: 64px; border-radius: 20px; animation: float 4s ease-in-out infinite; }
.logo.big .ico { width: 34px; height: 34px; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
nav.pills { display: flex; gap: 4px; padding: 4px; background: var(--raise); border: 1px solid var(--line); border-radius: 12px; }
.tab {
  border: 0; background: none; padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; box-shadow: none;
}
.tab:hover { color: var(--fg); transform: none; border: 0; }
.tab.active { background: var(--surface-solid); color: var(--fg); box-shadow: var(--shadow); }
.tab.active .ico { color: var(--brand); }
.userchip { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--raise); border: 1px solid var(--line-2); color: var(--brand);
}

/* ---------- admin shell with sidebar ---------- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px; padding: 22px 16px;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 0 8px 18px; }
.sidebar .brand small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar .tab { justify-content: flex-start; padding: 11px 14px; width: 100%; font-size: 14px; }
.sidebar .tab.active { background: linear-gradient(90deg, rgba(34, 211, 238, .16), rgba(6, 182, 212, .06)); box-shadow: inset 3px 0 0 var(--brand); }
.sidebar .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shell main { max-width: 1240px; width: 100%; padding: 32px 32px 60px; }

/* ---------- auth (login) ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 410px; padding: 36px 32px; text-align: center; box-shadow: var(--shadow-lg); animation: pop .6s var(--ease) both; }
.auth-card .logo.big { margin: 0 auto 18px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card form { text-align: left; margin-top: 26px; display: flex; flex-direction: column; gap: 12px; }
.auth-card button.primary { width: 100%; padding: 13px; margin-top: 6px; font-size: 15px; }
.auth-foot { margin-top: 22px; font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- entrance animations ---------- */
.tabpane:not(.hidden) { animation: rise .45s var(--ease) both; }
.grid > *, .stats > *, #projCards > * { animation: rise .5s var(--ease) both; }
.grid > *:nth-child(2), .stats > *:nth-child(2), #projCards > *:nth-child(2) { animation-delay: .06s; }
.grid > *:nth-child(3), .stats > *:nth-child(3), #projCards > *:nth-child(3) { animation-delay: .12s; }
.grid > *:nth-child(4), .stats > *:nth-child(4), #projCards > *:nth-child(4) { animation-delay: .18s; }
.grid > *:nth-child(n+5), #projCards > *:nth-child(n+5) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- project cards (user) ---------- */
.proj { position: relative; overflow: hidden; margin: 0; padding: 22px; transition: transform .25s var(--ease), box-shadow .25s; }
.proj::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); }
.proj:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.proj-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.proj-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgba(34, 211, 238, .12); color: var(--brand); flex: none; }
.proj-icon .ico { width: 24px; height: 24px; }
.proj .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.proj .notes { min-height: 20px; margin: 12px 0 0; }
.proj button.primary { width: 100%; margin-top: 16px; padding: 13px; font-size: 15px; }
.proj button.primary .ico { transition: transform .3s var(--ease); }
.proj button.primary:hover .ico { transform: scale(1.25) rotate(-8deg); }

/* ---------- chips / badges / status ---------- */
.chip, .badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--raise); border: 1px solid var(--line-2); color: var(--fg-2);
}
.chip { background: rgba(6, 182, 212, .1); border-color: rgba(6, 182, 212, .3); color: #67e8f9; }
.badge .ico { width: 13px; height: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; letter-spacing: .02em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.SUCCESS, .OK { color: var(--ok); background: var(--ok-bg); }
.FAILED, .WRONG { color: var(--err); background: var(--err-bg); }
.STARTED { color: var(--warn); background: var(--warn-bg); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px -22px; padding: 0 22px 8px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(34, 211, 238, .05); }
tbody tr:last-child td { border-bottom: 0; }
td .chk.inl { white-space: nowrap; }

/* ---------- switches (toggle look for on/off checkboxes) ---------- */
input.sw, input[data-active], input[data-canflash], input[data-pactive] {
  appearance: none; -webkit-appearance: none;
  width: 40px !important; height: 22px !important; border-radius: 999px; padding: 0; margin: 0;
  background: var(--line-2); border: 0; position: relative; cursor: pointer; flex: none;
  transition: background .25s var(--ease);
}
input.sw::after, input[data-active]::after, input[data-canflash]::after, input[data-pactive]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .25s var(--ease);
}
input.sw:checked, input[data-active]:checked, input[data-canflash]:checked, input[data-pactive]:checked { background: var(--ok); }
input.sw:checked::after, input[data-active]:checked::after, input[data-canflash]:checked::after, input[data-pactive]:checked::after { transform: translateX(18px); }

/* ---------- access chips (project <-> user checkboxes) ---------- */
label.chk.inl:has(input[data-uproj]), label.chk.inl:has(input[data-puser]) {
  display: inline-flex; margin: 3px 6px 3px 0; padding: 5px 12px 5px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface-solid); font-size: 13px; transition: all .2s;
}
label.chk.inl:has(input[data-uproj]:checked), label.chk.inl:has(input[data-puser]:checked) {
  border-color: var(--brand); background: rgba(34, 211, 238, .12); color: var(--brand);
}
label.chk.inl input[data-uproj], label.chk.inl input[data-puser] { width: 15px; height: 15px; }

/* ---------- admin: stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.stat .stat-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 10px; color: #00141a; background: var(--grad); box-shadow: var(--glow); }
.stat:nth-child(2) .stat-ico { background: linear-gradient(135deg, #3b82f6, #0ea5e9); }
.stat:nth-child(3) .stat-ico { background: linear-gradient(135deg, #10b981, #06b6d4); }
.stat:nth-child(4) .stat-ico { background: linear-gradient(135deg, #f43f5e, #f59e0b); }
.stat b { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: var(--grad); opacity: .07; }

/* ---------- admin: project cards ---------- */
#projCards .card { transition: box-shadow .25s; }
#projCards .card:hover { box-shadow: var(--shadow-lg); }
.inl-h { display: inline; margin: 0; font-size: 18px; }
.files { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin: 18px 0; }
.filebox { border: 1px dashed var(--line-2); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--raise); transition: border-color .2s; }
.filebox:hover { border-color: var(--brand); }
.filebox .fhead { display: flex; gap: 12px; align-items: flex-start; }
.ficon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff; }
.ficon.bin { background: linear-gradient(135deg, #0ea5e9, #3b82f6); }
.ficon.ino { background: linear-gradient(135deg, #06b6d4, #10b981); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .ico { width: 44px; height: 44px; opacity: .5; margin-bottom: 10px; }

/* ---------- dialogs ---------- */
dialog {
  border: 1px solid var(--line-2); border-radius: 20px; padding: 26px;
  background: var(--surface-solid); color: var(--fg);
  width: min(500px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .35s var(--ease) both; }
dialog::backdrop { background: rgba(7, 11, 22, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog h2 { font-size: 19px; }
#askMsg { font-size: 15px; font-weight: 500; margin: 0 0 14px; }

/* ---------- flash progress ---------- */
.bar { height: 14px; background: var(--raise); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin-top: 6px; }
#fdBar {
  height: 100%; width: 0; border-radius: 999px; transition: width .3s var(--ease);
  background-color: var(--brand);
  background-image: linear-gradient(45deg, rgba(255, 255, 255, .25) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .25) 50%, rgba(255, 255, 255, .25) 75%, transparent 75%), var(--grad);
  background-size: 28px 28px, 100% 100%;
  animation: stripes 1s linear infinite;
}
@keyframes stripes { to { background-position: 28px 0, 0 0; } }
#fdStatus { font-weight: 600; margin: 14px 0 0; }
#fdLog { max-height: 200px; overflow: auto; font: 12px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; background: #0b1020; color: #a5f3fc; padding: 12px 14px; border-radius: 12px; white-space: pre-wrap; margin-top: 14px; }
.steps { margin: 10px 0 0; padding-left: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.steps li::before { content: counter(s); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--warn); color: #fff; flex: none; }

/* ---------- motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.filters { margin-bottom: 16px; }

/* =====================================================================
   RESPONSIVE: PC (>1024) / Tablet (641-1024) / Phone (<=640)
   ===================================================================== */
main, .shell main { min-width: 0; }
.lbl-s { display: none; }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  /* admin: icon-only sidebar */
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px; align-items: center; }
  .sidebar .brand { padding: 0 0 16px; }
  .sidebar .brand > div:last-child { display: none; }
  .sidebar .tab { justify-content: center; padding: 12px; width: 52px; height: 48px; }
  .sidebar .tab .lbl, .sidebar .tab .lbl-s { display: none; }
  .sidebar .tab .ico { width: 21px; height: 21px; }
  .sidebar .foot { flex-direction: column; padding-top: 12px; }
  .sidebar .foot .userchip span { display: none; }
  .shell main { padding: 26px 24px 60px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .files { grid-template-columns: 1fr 1fr; }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  main { padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }
  h1, .page-head h1 { font-size: 22px; }
  .page-head { margin-bottom: 16px; align-items: stretch; }
  .page-head > button { width: 100%; }
  .card { padding: 16px; border-radius: 14px; margin-bottom: 14px; }
  .grid, .files { grid-template-columns: 1fr; gap: 14px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat b { font-size: 26px; }
  .stat .stat-ico { width: 36px; height: 36px; border-radius: 11px; margin-bottom: 6px; }
  .stat .muted { font-size: 12px; line-height: 1.3; }
  form .row > input, form .row > select, form .row > button, .filters > * { flex: 1 1 100%; }
  #projCards .card > .row.spread > .row { flex-wrap: nowrap; align-items: center; }
  #projCards .card > .row.spread > .row > label { margin: 0 auto 0 0; }
  .row.end > button { flex: 1 1 0; }
  #projCards .card > .row.spread { flex-direction: column; align-items: stretch; gap: 12px; }
  #projCards .card > .row.spread > .row { justify-content: flex-start; }
  .filebox .row > * { flex: 1 1 auto; }

  /* user top bar + bottom tab bar (blur on a parent would trap position:fixed, so use a solid bar) */
  .topbar, .sidebar { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(5, 6, 10, .94); }
  .topbar { padding: 10px 14px; }
  .topbar .userchip span { display: none; }
  nav.pills, .sidebar nav {
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
    display: flex; flex-direction: row; justify-content: space-around; gap: 2px; padding: 6px;
    background: rgba(14, 16, 23, .92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-lg); width: auto; overflow: visible; order: 0;
  }
  nav.pills .tab, .sidebar nav .tab {
    flex: 1 1 0; min-width: 0; width: auto; height: auto; flex-direction: column; gap: 3px;
    padding: 7px 2px; font-size: 10.5px; border-radius: 12px; box-shadow: none;
  }
  nav.pills .tab .ico, .sidebar nav .tab .ico { width: 20px; height: 20px; }
  nav .tab .lbl { display: none !important; }
  nav .tab .lbl-s { display: block !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  nav .tab.active { background: rgba(34, 211, 238, .12); color: var(--brand); box-shadow: none; }

  /* admin: sidebar becomes a slim top bar */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: auto; z-index: 10; flex-direction: row; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0; }
  .sidebar .brand > div:last-child { display: block; }
  .sidebar .foot { flex-direction: row; margin: 0 0 0 auto; padding: 0; border: 0; }
  .shell main { padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }

  /* tables -> stacked cards */
  .table-wrap { margin: 0; padding: 0; overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; margin-bottom: 10px; background: var(--raise); }
  tbody tr:hover { background: var(--raise); }
  td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); text-align: right; flex-wrap: wrap; }
  tbody tr td:last-child { border-bottom: 0; }
  td::before { content: attr(data-label); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; flex: none; }
  td[colspan] { justify-content: center; }
  td[colspan]::before, td:not([data-label])::before, td[data-label=""]::before { display: none; }
  td .row { justify-content: flex-end; }
  td > label, td > label.chk { flex: 0 0 auto; margin: 0; }
  td:has(label.chk.inl input[data-uproj]) { justify-content: flex-start; text-align: left; }
  td:has(label.chk.inl input[data-uproj])::before { width: 100%; }
  td .userchip { text-align: left; }

  /* dialogs become bottom sheets */
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
  dialog[open] { animation: sheet .35s var(--ease) both; }
  .auth-card { padding: 28px 20px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* very small phones */
@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr; }
  nav .tab .lbl-s { font-size: 9.5px; }
}

/* ---------- product photo on user cards ---------- */
.proj { display: flex; flex-direction: column; }
.proj-photo {
  margin: -22px -22px 16px; aspect-ratio: 16 / 10; overflow: hidden; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(34, 211, 238, .14), transparent 70%), var(--raise);
  border-bottom: 1px solid var(--line); color: var(--brand);
}
.proj-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.proj:hover .proj-photo img { transform: scale(1.05); }
.proj-photo .ico { width: 54px; height: 54px; opacity: .55; }
.proj .notes { flex: 1; }

/* ---------- admin: product photo box ---------- */
.photobox { flex-direction: row; flex-wrap: wrap; align-items: center; }
.photobox .thumb {
  width: 84px; height: 64px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; flex: none;
  background: var(--surface-solid); border: 1px solid var(--line-2); color: var(--muted);
}
.photobox .thumb img { width: 100%; height: 100%; object-fit: cover; }
.photobox > div:nth-child(2) { flex: 1 1 150px; }
.photobox .row { width: 100%; }

/* ---------- flash station ---------- */
dialog.station { width: min(560px, calc(100vw - 32px)); padding: 0; overflow: hidden; }
.st-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--raise); }
.st-photo { width: 58px; height: 58px; border-radius: 14px; overflow: hidden; display: grid; place-items: center; flex: none; background: rgba(34, 211, 238, .1); color: var(--brand); }
.st-photo img { width: 100%; height: 100%; object-fit: cover; }
.st-photo .ico { width: 28px; height: 28px; }
.st-title { flex: 1; min-width: 0; }
.st-title h2 { margin: 0 0 2px; }
.st-lock, #stMain { padding: 20px; }
.st-lock { display: flex; flex-direction: column; gap: 12px; }
.st-step { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px dashed var(--line-2); }
.st-step:last-of-type { border-bottom: 0; }
.st-num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 800;
  background: var(--grad); color: #00141a; margin-top: 2px;
}
.st-grow { flex: 1; min-width: 0; }
.st-grow label.chk { margin: 8px 0 0; }
#portInfo { margin-top: 3px; font-size: 14px; }
#portInfo .ico { color: var(--ok); }
.st-go { width: 100%; padding: 15px; font-size: 17px; }
.st-go .kbd { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: rgba(0, 20, 26, .18); }
.st-run .bar { margin-top: 14px; }
.st-count { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.st-count .link { margin-left: auto; }
#stMain > #fdManualHelp { margin: 4px 0 6px 40px; }
#stMain > #fdLog { margin-top: 6px; }
@media (max-width: 640px) {
  dialog.station { width: 100vw; padding: 0; }
  #stMain > #fdManualHelp { margin-left: 0; }
}
