/* ==========================================================================
   PlayOS design system — black canvas, neon purple accent, fluid motion
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #07050d;
  --bg-2: #0c0916;
  --bg-3: #120d20;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-solid: #141022;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  --accent: #a855f7;
  --accent-2: #d946ef;
  --accent-soft: rgba(168, 85, 247, 0.16);
  --accent-glow: rgba(168, 85, 247, 0.45);
  --cyan: #22d3ee;

  --text: #f3f0fb;
  --muted: #9b93b4;
  --muted-2: #6f688a;

  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;

  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-w: 248px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', var(--font);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(168, 85, 247, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(217, 70, 239, 0.10), transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-glow); color: #fff; }

/* -------------------------------------------------------------- scrollbars */
/* Slim, rounded neon bars: a translucent track and a gradient thumb that
   floats inside it. Keep this global so every panel, table and textarea
   matches the rest of the UI. */
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-track-piece {
  background: transparent;
}
::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background-image: linear-gradient(180deg, rgba(217, 70, 239, 0.9), rgba(139, 92, 246, 0.9));
  background-color: rgba(168, 85, 247, 0.55);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-image: linear-gradient(180deg, #f0abfc, #c084fc);
}
::-webkit-scrollbar-thumb:active {
  background-image: linear-gradient(180deg, #f5d0fe, #d8b4fe);
}
::-webkit-scrollbar-thumb:horizontal {
  background-image: linear-gradient(90deg, rgba(217, 70, 239, 0.9), rgba(139, 92, 246, 0.9));
}
::-webkit-scrollbar-thumb:horizontal:hover {
  background-image: linear-gradient(90deg, #f0abfc, #c084fc);
}
::-webkit-scrollbar-thumb:horizontal:active {
  background-image: linear-gradient(90deg, #f5d0fe, #d8b4fe);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox has no ::-webkit-scrollbar, so give it the closest equivalent. */
@supports (-moz-appearance: none) {
  html {
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.6) transparent;
  }
}

.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.9em; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.accent { color: var(--accent); }
.warn-text { color: var(--warn); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.pad { padding: 1rem 1.25rem; }
.hide-sm { display: inline; }
td.hide-sm, th.hide-sm { display: table-cell; }

/* ---------------------------------------------------------------- layout */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.9rem;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 14, 36, 0.9), rgba(10, 8, 18, 0.92));
  backdrop-filter: blur(18px);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0.5rem 1rem; }
.brand.compact { padding: 0; }
.brand-mark {
  display: block;
  width: 42px; height: 42px; border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 0 24px var(--accent-glow);
  flex: 0 0 auto;
}
.brand-mark.big { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); font-size: 1.05rem; }
.brand-text small { color: var(--muted); font-size: 0.72rem; }

.nav { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.5rem; min-height: 0; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.68rem 0.8rem; border-radius: 12px;
  color: var(--muted); font-weight: 500;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.nav-item svg { width: 18px; height: 18px; stroke-width: 1.8; }
.nav-item:hover { background: var(--panel); color: var(--text); transform: translateX(2px); }
.nav-item.is-active {
  color: #fff;
  background: linear-gradient(90deg, rgba(168,85,247,0.22), rgba(168,85,247,0.06));
  box-shadow: inset 0 0 0 1px rgba(168,85,247,0.28);
}
.nav-item.is-primary {
  margin-top: 0.35rem;
  background: linear-gradient(135deg, rgba(168,85,247,0.9), rgba(217,70,239,0.85));
  color: #fff;
  box-shadow: 0 8px 24px rgba(168,85,247,0.35);
}
.nav-item.is-primary:hover { filter: brightness(1.08); }

.sidebar-foot { margin-top: auto; flex: 0 0 auto; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: 0.6rem; }
.sidebar-switch {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 0.7rem; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 0.82rem;
  background: rgba(168,85,247,0.08); border: 1px solid rgba(168,85,247,0.22);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.sidebar-switch:hover { color: #fff; background: rgba(168,85,247,0.18); }
.sidebar-switch svg { width: 16px; height: 16px; color: var(--accent); flex: 0 0 auto; }
.user-chip { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.35rem; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--muted); font-size: 0.72rem; text-transform: capitalize; }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.avatar.sm { width: 28px; height: 28px; }
.avatar.big { width: 56px; height: 56px; font-size: 1.4rem; }
.avatar-fallback {
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-family: var(--font-display);
}
.inline-flex { display: inline-flex; align-items: center; gap: 0.5rem; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.85rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 5, 13, 0.72);
  backdrop-filter: blur(16px);
}
.page-title { font-size: 1.15rem; }
.topbar-actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
.icon-btn.sidebar-toggle { display: none; }

.content { padding: 1.4rem 1.4rem 3rem; max-width: 1360px; width: 100%; animation: fadeUp 0.45s var(--ease); }

.bottom-nav { display: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------------- cards */

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.card:hover { border-color: var(--line-strong); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem 0.4rem;
}
.card-head h2 { font-size: 1rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.9rem; margin-bottom: 1.1rem; }
.kpi { display: flex; align-items: center; gap: 0.9rem; padding: 1rem 1.1rem; }
.kpi small { color: var(--muted); display: block; font-size: 0.78rem; }
.kpi strong { font-family: var(--font-display); font-size: 1.45rem; letter-spacing: -0.02em; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(168,85,247,0.25);
}
.kpi-icon.alt { background: rgba(255,255,255,0.05); color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--line); }
.kpi-icon svg { width: 20px; height: 20px; }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.dash-grid .span-2 { grid-column: span 2; }

.chart-wrap { padding: 0.5rem 1rem 1.1rem; position: relative; }
.chart-wrap.short { padding-bottom: 0.8rem; }

.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; padding: 0.75rem 1.1rem 1.1rem; }
.quick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem;
  padding: 0.85rem; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); font-weight: 500; font-size: 0.88rem;
  transition: 0.2s var(--ease);
}
.quick svg { width: 18px; height: 18px; color: var(--accent); }
.quick:hover { color: var(--text); border-color: rgba(168,85,247,0.4); transform: translateY(-2px); }

.stock-list { padding: 0.25rem 0.5rem 0.9rem; }
.stock-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.75rem; border-radius: 12px; }
.stock-row:hover { background: var(--panel); }
.stock-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.stock-name strong { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--accent)); box-shadow: 0 0 10px var(--dot, var(--accent)); flex: 0 0 auto; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.62rem 1rem; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.92rem; cursor: pointer; white-space: nowrap;
  background: var(--panel); color: var(--text);
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), filter 0.2s;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 26px rgba(168,85,247,0.35);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 12px 32px rgba(168,85,247,0.5); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); background: var(--panel); }
.btn-danger { background: rgba(248,113,113,0.14); color: var(--danger); border-color: rgba(248,113,113,0.3); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.82rem; border-radius: 10px; }
.btn-lg { padding: 0.85rem 1.3rem; font-size: 1rem; border-radius: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.btn-row.end { justify-content: flex-end; }
.stack { display: grid; gap: 0.75rem; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; transition: 0.2s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--panel); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.1); }
.icon-btn svg { width: 17px; height: 17px; }
.link { color: var(--accent); font-weight: 500; display: inline-flex; align-items: center; gap: 0.3rem; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------- form controls */

.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.8rem; color: var(--muted); font-weight: 500; }

.permalink-input {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.permalink-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.16);
}
.permalink-input input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-height: 42px;
}
.permalink-input input:focus,
.permalink-input input:focus-visible { outline: none; box-shadow: none; }
.permalink-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.7rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-2);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Any text-like control. The :not() list deliberately catches <input> with no
   type attribute — otherwise those silently fall back to the browser's white
   default and break the dark design system. :where() keeps specificity at 0 so
   every intentional variant (.sort-input, .select.sm, textarea, …) wins over it. */
:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
  select,
  textarea
) {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
  select,
  textarea
):hover {
  border-color: var(--line-strong);
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(168, 85, 247, 0.65);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(168, 85, 247, 0.16), 0 0 20px rgba(168, 85, 247, 0.14);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: rgba(248, 113, 113, 0.6); }
input:user-invalid:focus, select:user-invalid:focus, textarea:user-invalid:focus {
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(248, 113, 113, 0.18);
}
/* Chrome paints autofill white — pin it to the dark system colors. */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus,
textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--panel-solid) inset;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  caret-color: var(--text);
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}
textarea { resize: vertical; min-height: 70px; }
.select.sm {
  min-height: 0;
  padding: 0.4rem 1.9rem 0.4rem 0.7rem;
  font-size: 0.85rem;
  width: auto;
}

/* ---- design-system dropdown (JS wraps every <select>; native popup can't be
   themed, so the popup is our own fixed-position listbox) ---- */

.dd { position: relative; width: 100%; min-width: 0; }
.dd.sm { width: auto; }
.dd > select.dd-select { display: none; }

.dd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.dd-btn:hover { border-color: var(--line-strong); }
.dd-btn[aria-expanded="true"], .dd-btn:focus-visible {
  outline: none;
  border-color: rgba(168, 85, 247, 0.65);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(168, 85, 247, 0.16), 0 0 20px rgba(168, 85, 247, 0.14);
}
.dd-btn .dd-val {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dd-btn::after {
  content: "";
  flex: 0 0 auto;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}
.dd-btn[aria-expanded="true"]::after { border-top-color: var(--accent); transform: rotate(180deg); }
.dd-btn.sm {
  min-height: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.dd-menu {
  position: fixed;
  z-index: 120;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 85, 247, 0.35);
  background: var(--panel-solid);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 34px rgba(168, 85, 247, 0.14);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: ddIn 0.15s var(--ease);
}
@keyframes ddIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
.dd-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.dd-opt:hover, .dd-opt.is-active {
  background: rgba(168, 85, 247, 0.14);
  color: var(--text);
}
.dd-opt.is-selected {
  background: rgba(168, 85, 247, 0.1);
  color: var(--accent);
  font-weight: 600;
}
.dd-opt.is-selected::after {
  content: "";
  margin-left: auto;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.8);
}
.dd-opt:disabled { opacity: 0.4; cursor: default; }
.dd-opt:focus-visible { outline: none; background: rgba(168, 85, 247, 0.2); color: var(--text); }

input[type="file"] {
  width: 100%;
  min-height: 0;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: var(--panel);
  box-shadow: none;
  color: var(--muted);
  font-size: 0.85rem;
}
input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s var(--ease);
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

.check { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; cursor: pointer; }
.check input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: none;
  cursor: pointer;
  position: relative;
  transition: 0.15s var(--ease);
}
.check input:hover { border-color: var(--accent); }
.check input:checked {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.4l2.9 2.9 6.1-6.9' fill='none' stroke='%23fff' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 13px 13px;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.45);
}
.check input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.22);
}

.perk-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.perk-line svg { width: 15px; height: 15px; color: var(--accent); flex: 0 0 auto; }

.input-icon { position: relative; display: flex; align-items: center; min-width: 0; flex: 1; }
.input-icon svg { position: absolute; left: 0.8rem; width: 17px; height: 17px; color: var(--muted-2); pointer-events: none; }
.input-icon input { padding-left: 2.35rem; padding-right: 2.35rem; }
.input-icon:focus-within svg { color: var(--accent); }
.input-icon .icon-btn { position: absolute; right: 0.35rem; width: 34px; height: 34px; border-radius: 10px; }
.input-icon .icon-btn svg { width: 17px; height: 17px; position: static; color: var(--muted); pointer-events: none; }
.input-icon .icon-btn:hover svg { color: var(--accent); }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.chip-row.scroll-x { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.3rem; scrollbar-width: none; }
.chip-row.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.38rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 0.83rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: 0.2s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.is-on, .chip-toggle.is-on {
  background: var(--accent-soft); color: #fff; border-color: rgba(168,85,247,0.5);
  box-shadow: 0 0 16px rgba(168,85,247,0.25);
}
code.chip { cursor: default; font-family: ui-monospace, monospace; }

.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 13px; background: rgba(0,0,0,0.3); border: 1px solid var(--line); }
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 0.45rem 0.85rem; border-radius: 10px; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem;
  transition: 0.2s var(--ease);
}
.seg-btn svg { width: 15px; height: 15px; }
.seg-btn.is-on { background: linear-gradient(135deg, rgba(168,85,247,0.9), rgba(217,70,239,0.85)); color: #fff; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted-2); font-weight: 600; padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 0.8rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: rgba(255,255,255,0.03); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td small { display: block; }
.table .num { text-align: right; }

.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text); }
.table th.is-sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table th.is-sortable::after { content: '↕'; margin-left: 0.35rem; font-size: 0.85em; opacity: 0.35; }
.table th.is-sorted { color: var(--text); }
.table th.is-sorted::after { opacity: 1; color: #c084fc; }
.table th.is-sorted[aria-sort='ascending']::after { content: '↑'; }
.table th.is-sorted[aria-sort='descending']::after { content: '↓'; }

.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.22rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  background: rgba(255,255,255,0.06); color: var(--muted);
  border: 1px solid var(--line);
}
.pill-ok { background: rgba(52,211,153,0.14); color: var(--ok); border-color: rgba(52,211,153,0.3); }
.pill-warn { background: rgba(251,191,36,0.14); color: var(--warn); border-color: rgba(251,191,36,0.3); }
.pill-danger { background: rgba(248,113,113,0.14); color: var(--danger); border-color: rgba(248,113,113,0.3); }
.pill-muted { opacity: 0.7; }
.pill-tier { background: var(--accent-soft); color: #e9d5ff; border-color: rgba(168,85,247,0.35); }

.empty-state { display: grid; place-items: center; gap: 0.6rem; padding: 2rem 1rem; text-align: center; color: var(--muted); }
.empty-state svg { width: 34px; height: 34px; color: var(--accent); opacity: 0.85; }
.empty-state.compact { padding: 1.4rem 0.8rem; }

/* --------------------------------------------------------- page utilities */

.page-toolbar { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; flex: 1; min-width: 0; }
.filter-row .input-icon { max-width: 340px; }

.banner {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1rem; border-radius: 14px; margin-bottom: 1rem;
  background: var(--accent-soft); border: 1px solid rgba(168,85,247,0.3);
  font-size: 0.9rem;
}
.banner svg { width: 18px; height: 18px; color: var(--accent); flex: 0 0 auto; }
.banner.warn { background: rgba(251,191,36,0.1); border-color: rgba(251,191,36,0.3); }
.banner.warn svg { color: var(--warn); }
.banner.ok { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); }
.banner.ok svg { color: var(--ok); }
.banner.info { background: rgba(34,211,238,0.08); border-color: rgba(34,211,238,0.25); }
.banner.info svg { color: var(--cyan); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.span-2 { grid-column: span 2; }
.form-pad { padding: 0.5rem 1.25rem 1.25rem; }
.form-pad-top { padding: 0 1.25rem 1.25rem; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 1rem; align-items: start; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; padding: 0 1.25rem 0.9rem; }
.stat { background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 14px; padding: 0.6rem 0.7rem; }
.stat small { color: var(--muted); display: block; font-size: 0.72rem; }
.stat strong { font-family: var(--font-display); font-size: 1.05rem; }

.member-hero { display: flex; align-items: center; gap: 0.85rem; }

.timeline { list-style: none; margin: 0; padding: 0.4rem 1rem 1rem; }
.timeline li { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.2rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
.timeline li:last-child { border-bottom: 0; }
.timeline div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.tl-dot.alt { background: var(--cyan); box-shadow: 0 0 10px rgba(34,211,238,0.5); }

.rank-list { list-style: none; margin: 0; padding: 0.4rem 1rem 1rem; display: grid; gap: 0.35rem; }
.rank-list li { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.4rem; border-radius: 12px; }
.rank-list li:hover { background: var(--panel); }
.rank {
  width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.8rem; flex: 0 0 auto;
}
.rank-body { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.rank-body strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.def-list { display: grid; gap: 0.5rem; margin: 0; }
.def-list div { display: grid; grid-template-columns: 200px 1fr; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.def-list dt { color: var(--muted); font-size: 0.85rem; }
.def-list dd { margin: 0; word-break: break-all; }

.check-list { margin: 0; padding-left: 1.1rem; color: var(--muted); display: grid; gap: 0.35rem; }
.role-title { margin-bottom: 0.6rem; }

.save-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; padding: 1rem 0 0; margin-top: 1rem; }

/* ----------------------------------------------------------------- modals */

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 2, 10, 0.72); backdrop-filter: blur(6px); animation: fadeIn 0.2s ease; }
.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: linear-gradient(180deg, #1a1330, #100c1d);
  border: 1px solid rgba(168,85,247,0.28);
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.6), 0 0 60px rgba(168,85,247,0.12);
  animation: popIn 0.28s var(--ease);
}
.modal-card.narrow { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.05rem 1.2rem 0.6rem; }
.modal-head h3 { font-size: 1.05rem; }
.modal-body { padding: 0.6rem 1.2rem 1rem; display: grid; gap: 0.8rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.9rem 1.2rem 1.2rem; border-top: 1px solid var(--line); }

@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.inline-form .inline-row { display: flex; gap: 0.45rem; align-items: center; margin-bottom: 0.8rem; }
.inline-form .inline-row input[type="text"], .inline-form .inline-row input:not([type]) { flex: 1; }
.sort-input { width: 70px; }
input[type="color"] { width: 46px; min-height: 0; height: 40px; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); box-shadow: none; cursor: pointer; }
.cat-list { display: grid; gap: 0.3rem; }
.cat-row { display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.4rem; border-radius: 10px; }
.cat-row:hover { background: var(--panel); }
.cat-row strong { flex: 1; }

.result-list { display: grid; gap: 0.35rem; max-height: 320px; overflow-y: auto; overflow-x: hidden; }
.result-item {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left;
  padding: 0.65rem 0.75rem; border-radius: 13px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  transition: 0.18s var(--ease);
}
.result-item:hover { border-color: rgba(168,85,247,0.5); }
.result-item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.result-item .meta small { color: var(--muted); }
.result-item .pts { font-family: var(--font-display); color: var(--accent); font-weight: 700; }

.quick-points, .quick-cash { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.change-row { display: flex; justify-content: space-between; align-items: center; padding: 0.7rem 0.9rem; border-radius: 13px; background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.25); }
.change-row strong { font-family: var(--font-display); font-size: 1.15rem; color: var(--ok); }
.pay-due { text-align: center; padding: 0.9rem; border-radius: 16px; background: var(--accent-soft); border: 1px solid rgba(168,85,247,0.3); }
.pay-due small { color: var(--muted); display: block; }
.pay-due strong { font-family: var(--font-display); font-size: 2rem; letter-spacing: -0.02em; }

.success-card { text-align: center; padding: 1.6rem 1.3rem 1.4rem; }
.success-burst { width: 66px; height: 66px; margin: 0 auto 0.7rem; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 40px var(--accent-glow); }
.success-burst svg { width: 30px; height: 30px; }
.success-total { font-family: var(--font-display); font-size: 2rem; margin: 0.2rem 0; }

/* ----------------------------------------------------------------- toasts */

#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 120; display: grid; gap: 0.5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.75rem 0.95rem; border-radius: 14px;
  background: rgba(20, 15, 34, 0.96); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); font-size: 0.9rem;
  animation: toastIn 0.3s var(--ease);
}
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; }
.toast-success { border-color: rgba(52,211,153,0.4); }
.toast-success svg { color: var(--ok); }
.toast-error { border-color: rgba(248,113,113,0.45); }
.toast-error svg { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ auth screen */

.page-auth { display: grid; place-items: center; min-height: 100vh; position: relative; overflow: hidden; padding: 1.2rem; }
.auth-wrap { position: relative; z-index: 2; width: min(440px, 100%); }
.auth-orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55; pointer-events: none; }
.auth-orb-1 { width: 420px; height: 420px; background: rgba(168,85,247,0.55); top: -120px; left: -100px; animation: float 9s ease-in-out infinite; }
.auth-orb-2 { width: 360px; height: 360px; background: rgba(34,211,238,0.28); bottom: -140px; right: -110px; animation: float 11s ease-in-out infinite reverse; }
@keyframes float { 0%,100% { transform: translate(0,0); } 50% { transform: translate(24px, -18px); } }

.auth-card {
  background: linear-gradient(180deg, rgba(26,19,48,0.92), rgba(14,10,26,0.95));
  border: 1px solid rgba(168,85,247,0.25);
  border-radius: 26px;
  padding: 2rem 1.7rem 1.4rem;
  box-shadow: 0 40px 100px rgba(0,0,0,0.6), 0 0 80px rgba(168,85,247,0.12);
  text-align: center;
  animation: popIn 0.5s var(--ease);
}
.auth-brand h1 { font-size: 1.9rem; margin-top: 0.8rem; }
.auth-brand p { margin: 0.2rem 0 0; font-size: 0.9rem; }
.auth-actions { margin-top: 1.6rem; display: grid; justify-items: center; gap: 0.9rem; }
/* Google's button iframe paints a white box when it inherits our dark
   color-scheme — force light so its canvas stays transparent here. */
#gbtn { color-scheme: light; }
.auth-hint { font-size: 0.82rem; max-width: 300px; margin: 1.1rem auto 0; }
.auth-foot { margin-top: 1.4rem; font-size: 0.75rem; }

.access-choice { display: grid; gap: 0.6rem; margin-top: 1.2rem; }
.access-card {
  display: flex; align-items: center; gap: 0.75rem; width: 100%;
  padding: 0.85rem 0.9rem; border-radius: 16px; text-align: left; cursor: pointer;
  background: rgba(0,0,0,0.3); border: 1px solid var(--line); color: var(--text);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}
.access-card:hover {
  border-color: rgba(168,85,247,0.45); background: rgba(168,85,247,0.1); transform: translateY(-1px);
}
.access-icon {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 13px;
  background: linear-gradient(135deg, rgba(168,85,247,0.9), rgba(217,70,239,0.85));
  color: #fff; box-shadow: 0 6px 18px rgba(168,85,247,0.3);
}
.access-icon.alt { background: linear-gradient(135deg, rgba(34,211,238,0.85), rgba(168,85,247,0.8)); }
.access-icon svg { width: 19px; height: 19px; }
.access-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; }
.access-text strong { font-size: 0.92rem; }
.access-text small { color: var(--muted); font-size: 0.75rem; }
.access-arrow { width: 16px; height: 16px; color: var(--muted); flex: 0 0 auto; }

.setup-box { text-align: left; margin-top: 1.4rem; padding: 1rem 1.1rem; border-radius: 16px; background: rgba(0,0,0,0.3); border: 1px solid var(--line); }
.setup-box h2 { font-size: 0.95rem; display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.6rem; }
.setup-box h2 svg { width: 16px; height: 16px; color: var(--accent); }
.setup-box ol { margin: 0; padding-left: 1.15rem; display: grid; gap: 0.45rem; font-size: 0.85rem; color: var(--muted); }
.setup-box code { color: var(--text); }

/* ------------------------------------------------------------- POS screen */

.page-pos { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.pos-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.65rem 1.1rem; border-bottom: 1px solid var(--line);
  background: rgba(9, 6, 18, 0.9); backdrop-filter: blur(14px); flex: 0 0 auto; z-index: 40;
}
.pos-topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.cashier-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.75rem; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 0.85rem; color: var(--muted);
}
.cashier-chip svg { width: 15px; height: 15px; color: var(--accent); }

.pos-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 0; }
.pos-catalog { display: flex; flex-direction: column; min-width: 0; padding: 1rem 1.1rem; gap: 0.8rem; overflow: hidden; }
.pos-searchbar { display: flex; align-items: center; gap: 0.8rem; }
.pos-searchbar .input-icon input { padding: 0.8rem 2.4rem 0.8rem 2.4rem; font-size: 1rem; border-radius: 14px; }
.scan-hint { color: var(--muted-2); font-size: 0.8rem; white-space: nowrap; }
kbd {
  font-family: ui-monospace, monospace; font-size: 0.72rem;
  padding: 0.1rem 0.4rem; border-radius: 6px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); color: var(--muted);
}

.product-grid {
  flex: 1; overflow-y: auto; display: grid; gap: 0.7rem; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  padding-bottom: 1rem; padding-right: 0.2rem;
}
.skeleton-grid { display: contents; }
.skeleton { height: 108px; background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); border: 1px solid var(--line); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.product-card {
  position: relative; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 0.3rem;
  padding: 0.85rem 0.85rem 0.8rem; min-height: 108px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  color: var(--text); transition: 0.2s var(--ease);
}
.product-card:hover { transform: translateY(-3px); border-color: rgba(168,85,247,0.5); box-shadow: 0 14px 30px rgba(0,0,0,0.4), 0 0 24px rgba(168,85,247,0.14); }
.product-card:active { transform: scale(0.97); }
.product-card .p-cat { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); font-weight: 700; }
.product-card .p-name { font-weight: 600; font-size: 0.92rem; line-height: 1.25; flex: 1; }
.product-card .p-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.product-card .p-price { font-family: var(--font-display); font-size: 1.05rem; }
.product-card .p-stock { font-size: 0.72rem; color: var(--muted); }
.product-card.is-out { opacity: 0.45; }
.product-card .p-flag { position: absolute; top: 0.55rem; right: 0.55rem; font-size: 0.62rem; padding: 0.12rem 0.4rem; border-radius: 999px; background: rgba(34,211,238,0.14); color: var(--cyan); border: 1px solid rgba(34,211,238,0.3); }

.pos-cart {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20,14,36,0.95), rgba(10,7,19,0.98));
}
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem 0.5rem; }
.cart-head h2 { font-size: 1rem; }
.member-bar {
  display: flex; align-items: center; gap: 0.65rem; width: calc(100% - 2.2rem); margin: 0 1.1rem;
  padding: 0.65rem 0.8rem; border-radius: 14px; cursor: pointer; text-align: left;
  background: var(--panel); border: 1px dashed rgba(168,85,247,0.35); color: var(--text);
  transition: 0.2s var(--ease);
}
.member-bar:hover { border-color: var(--accent); background: var(--accent-soft); }
.member-bar.has-member { border-style: solid; background: var(--accent-soft); }
.member-bar > svg:first-child { width: 18px; height: 18px; color: var(--accent); }
.member-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.member-bar-text strong { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-bar-text small { font-size: 0.72rem; }
.member-bar .chev { width: 16px; height: 16px; color: var(--muted); }

.cart-lines { flex: 1; overflow-y: auto; padding: 0.7rem 1.1rem; display: flex; flex-direction: column; gap: 0.45rem; }
.cart-line {
  display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.6rem;
  padding: 0.65rem 0.75rem; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
  animation: popIn 0.22s var(--ease);
}
.cart-line .l-name { font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
.cart-line .l-unit { color: var(--muted); font-size: 0.78rem; }
.cart-line .l-total { font-family: var(--font-display); font-weight: 700; align-self: center; }
.qty-ctrl { display: inline-flex; align-items: center; gap: 0.15rem; grid-column: 1 / -1; }
.qty-ctrl button {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; display: grid; place-items: center;
  transition: 0.15s;
}
.qty-ctrl button:hover { border-color: var(--accent); color: var(--accent); }
.qty-ctrl button svg { width: 14px; height: 14px; }
.qty-ctrl input {
  width: 44px; min-height: 0; text-align: center; padding: 0.28rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel);
}
.qty-ctrl .l-remove { margin-left: auto; border: 0; background: transparent; color: var(--muted-2); width: 30px; }
.qty-ctrl .l-remove:hover { color: var(--danger); }

.cart-foot { border-top: 1px solid var(--line); padding: 0.85rem 1.1rem calc(1rem + env(safe-area-inset-bottom)); display: grid; gap: 0.65rem; }
.promo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.totals { margin: 0; display: grid; gap: 0.25rem; }
.totals > div { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.9rem; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .total-row { margin-top: 0.35rem; padding-top: 0.55rem; border-top: 1px dashed var(--line); }
.totals .total-row dt { color: var(--text); font-weight: 600; }
.totals .total-row dd { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; color: #fff; text-shadow: 0 0 22px var(--accent-glow); }

.cart-fab {
  position: fixed; left: 0.8rem; right: 0.8rem; bottom: 0.8rem; z-index: 50;
  display: none; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1.1rem; border-radius: 16px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-weight: 600; box-shadow: 0 16px 40px rgba(168,85,247,0.45);
}
.cart-fab[hidden] { display: none; }
.cart-fab-count { background: rgba(0,0,0,0.28); border-radius: 999px; min-width: 26px; height: 26px; display: grid; place-items: center; font-size: 0.82rem; }
.cart-fab strong { margin-left: auto; font-family: var(--font-display); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 45; backdrop-filter: blur(3px); }
.drawer-backdrop[hidden] { display: none; }

/* --------------------------------------------------------------- receipt */

.page-print { background: #0b0813; min-height: 100vh; padding: 1rem; }
.print-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; gap: 0.6rem;
  max-width: 480px; margin: 0 auto 1rem; padding: 0.5rem 0;
}
.receipt {
  max-width: 480px; margin: 0 auto;
  background: #fdfcff; color: #17122a;
  border-radius: 18px; padding: 1.6rem 1.5rem 1.3rem;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  font-size: 0.92rem;
}
.receipt-head { text-align: center; border-bottom: 2px dashed #d9d4e8; padding-bottom: 0.9rem; }
.receipt-brand { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.receipt-uen { margin: 0.15rem 0 0; color: #6b6484; font-size: 0.78rem; letter-spacing: 0.04em; }
.receipt-head .muted { color: #6b6484; font-size: 0.82rem; }
.receipt-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 1rem; padding: 0.8rem 0; border-bottom: 1px solid #ebe7f5; font-size: 0.84rem; }
.receipt-meta div { display: flex; flex-direction: column; }
.receipt-meta span { color: #6b6484; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.receipt-table { width: 100%; border-collapse: collapse; margin: 0.7rem 0; }
.receipt-table th { text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: #6b6484; padding: 0.4rem 0; border-bottom: 1px solid #ebe7f5; }
.receipt-table td { padding: 0.5rem 0; border-bottom: 1px dashed #eee9f8; vertical-align: top; }
.receipt-table .num { text-align: right; }
.receipt-table small { display: block; color: #8a83a3; }
.receipt-totals { margin: 0.4rem 0 0; display: grid; gap: 0.2rem; font-size: 0.9rem; }
.receipt-totals > div { display: flex; justify-content: space-between; }
.receipt-totals dt { color: #6b6484; }
.receipt-totals dd { margin: 0; font-weight: 600; }
.receipt-totals .grand { margin-top: 0.4rem; padding-top: 0.45rem; border-top: 2px solid #17122a; font-size: 1.1rem; }
.receipt-totals .grand dt, .receipt-totals .grand dd { color: #17122a; font-weight: 700; }
.receipt-points { text-align: center; margin-top: 0.8rem; padding: 0.6rem; border-radius: 12px; background: #f3ecff; border: 1px dashed #d0bbf5; }
.receipt-points p { margin: 0; }
.receipt-foot { margin-top: 1rem; padding-top: 0.7rem; border-top: 2px dashed #d9d4e8; text-align: center; font-size: 0.82rem; }
.receipt-foot .muted { color: #6b6484; }

@media print {
  body.page-print { background: #fff; padding: 0; }
  .no-print, .print-toolbar { display: none !important; }
  .receipt { box-shadow: none; border-radius: 0; max-width: none; padding: 0; }
  @page { margin: 10mm; }
}

/* -------------------------------------------------------------- bottom nav */

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 80; backdrop-filter: blur(3px); }
.sheet-backdrop[hidden], .sheet[hidden] { display: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
  background: linear-gradient(180deg, #1a1330, #0d0a18);
  border-top: 1px solid rgba(168,85,247,0.3);
  border-radius: 22px 22px 0 0; padding: 0.6rem 1rem calc(1.2rem + env(safe-area-inset-bottom));
  animation: sheetUp 0.3s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 42px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 0.3rem auto 0.8rem; }
.sheet h3 { margin-bottom: 0.5rem; }
.sheet-link { display: flex; align-items: center; gap: 0.7rem; padding: 0.85rem 0.6rem; border-radius: 12px; color: var(--muted); font-weight: 500; }
.sheet-link:hover { background: var(--panel); color: var(--text); }
.sheet-link svg { width: 18px; height: 18px; color: var(--accent); }
.sheet-signout { margin: 0.4rem 0 0; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.sheet-signout-btn {
  width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; font: inherit;
}
.sheet-signout-btn:hover { background: rgba(248,113,113,0.1); color: var(--danger); }
.sheet-signout-btn svg { color: var(--danger); }

/* ------------------------------------------------------- customer portal */.page-customer { display: flex; flex-direction: column; min-height: 100vh; position: relative; overflow-x: hidden; }
.page-customer .auth-orb { position: fixed; }

.portal-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 6, 18, 0.82);
  backdrop-filter: blur(16px);
}

.portal-wrap {
  position: relative; z-index: 2;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 1.3rem 1.1rem 3rem;
  display: grid; gap: 1rem;
  animation: fadeUp 0.45s var(--ease);
}

.portal-foot {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  width: min(960px, 100%); margin: 0 auto; padding: 1rem 1.1rem 2rem;
  font-size: 0.82rem;
}
.portal-foot a { color: var(--accent); }

.portal-hero { display: flex; gap: 1.4rem; align-items: center; padding: 1.35rem 1.4rem; flex-wrap: wrap; }
.portal-hero-main { display: flex; gap: 1rem; align-items: center; flex: 1; min-width: 260px; }
.portal-id h1 { font-size: 1.45rem; letter-spacing: -0.02em; }
.portal-id p { margin: 0.15rem 0 0.5rem; font-size: 0.88rem; }
.portal-points {
  text-align: right; padding: 0.8rem 1.1rem; border-radius: 16px; min-width: 150px;
  background: var(--accent-soft); border: 1px solid rgba(168,85,247,0.3);
}
.portal-points small { color: var(--muted); display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.portal-points strong {
  display: block; font-family: var(--font-display); font-size: 2.3rem; line-height: 1.1;
  color: #fff; text-shadow: 0 0 26px var(--accent-glow);
}
.portal-points span { font-size: 0.78rem; }

.portal-qr {
  display: grid; justify-items: center; gap: 0.4rem;
  padding: 0.7rem; border-radius: 16px;
  background: #fff; border: 1px solid var(--line-strong);
  width: 128px;
}
.portal-qr svg { display: block; }
.portal-qr small { color: #55506b; font-size: 0.68rem; text-align: center; }
.portal-qr-fallback { color: #17122a; font-weight: 700; font-size: 0.95rem; }

.portal-stats { margin-bottom: 0; }

.tier-progress .progress-track {
  height: 12px; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,0.35); border: 1px solid var(--line);
}
.tier-progress .progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px var(--accent-glow);
  transition: width 0.8s var(--ease);
}
.tier-progress p { margin: 0.75rem 0 0; font-size: 0.9rem; }
.tier-ladder { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; }
.tier-step {
  padding: 0.45rem 0.85rem; border-radius: 12px; text-align: center; line-height: 1.2;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); color: var(--muted);
}
.tier-step strong { display: block; font-size: 0.85rem; }
.tier-step small { font-size: 0.72rem; }
.tier-step.is-earned { border-color: rgba(168,85,247,0.45); color: var(--text); }
.tier-step.is-current {
  background: var(--accent-soft); border-color: rgba(168,85,247,0.7);
  box-shadow: 0 0 20px rgba(168,85,247,0.28);
}
.tier-step.is-current strong::after { content: ' ●'; color: var(--accent); }
.small-note { font-size: 0.82rem; margin: 0.8rem 0 0; }

/* ------------------------------------------------------------ staff invite */

.invite-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.invite-row input { flex: 1; min-width: 160px; }
.invite-row .select { flex: 0 0 auto; }

/* ------------------------------------------------------- membership signup */

.join-card { width: min(480px, 100%); text-align: left; }
.join-card .auth-brand { text-align: center; }
.join-card .auth-brand h1 { font-size: 1.45rem; }
.join-form { display: grid; gap: 0.85rem; margin-top: 1.3rem; }
.join-form .field small { font-size: 0.75rem; }

.join-photo { display: grid; justify-items: center; gap: 0.35rem; }
.photo-picker { display: grid; justify-items: center; gap: 0.45rem; cursor: pointer; }
.photo-frame {
  position: relative; display: grid; place-items: center; overflow: hidden;
  width: 108px; height: 108px; border-radius: 50%;
  background: rgba(0,0,0,0.35);
  border: 2px dashed rgba(168,85,247,0.55);
  box-shadow: 0 0 26px rgba(168,85,247,0.22);
  transition: 0.2s var(--ease);
}
.photo-picker:hover .photo-frame { border-color: var(--accent); box-shadow: 0 0 34px rgba(168,85,247,0.4); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.photo-frame img[hidden] { display: none; }
.photo-placeholder { color: var(--accent); display: grid; place-items: center; }
.photo-placeholder svg { width: 30px; height: 30px; }
.photo-cta { font-size: 0.82rem; font-weight: 600; color: var(--accent); }
.photo-hint { font-size: 0.74rem; text-align: center; margin: 0; }
#photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.join-identity {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.8rem; border-radius: 13px;
  background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.25);
  font-size: 0.84rem; color: var(--muted); overflow-wrap: anywhere;
}
.join-identity svg { width: 16px; height: 16px; color: var(--ok); flex: 0 0 auto; }
.join-identity strong { color: var(--text); }

/* ----------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .pos-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    height: 100vh;
    height: 100dvh;
    padding-bottom: calc(1.1rem + env(safe-area-inset-bottom));
    transform: translateX(-100%); transition: transform 0.3s var(--ease);
    box-shadow: var(--shadow); z-index: 66;
  }
  body.sidebar-open .sidebar { transform: none; }
  .icon-btn.sidebar-toggle { display: inline-grid; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 65; backdrop-filter: blur(3px); }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .span-2 { grid-column: span 1; }
  .detail-grid { grid-template-columns: 1fr; }
  .content { padding: 1rem 1rem 5.5rem; }

  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; justify-content: space-around; align-items: stretch;
    padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom));
    background: rgba(10, 7, 19, 0.94); backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .bottom-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
    padding: 0.4rem 0.2rem; border: 0; background: transparent; cursor: pointer;
    color: var(--muted-2); font-size: 0.66rem; font-weight: 600; border-radius: 12px;
  }
  .bottom-item svg { width: 20px; height: 20px; }
  .bottom-item.is-active { color: var(--accent); }
  .bottom-item.is-primary { color: #fff; }
  .bottom-item.is-primary svg { color: #fff; filter: drop-shadow(0 0 10px var(--accent-glow)); }
}

@media (max-width: 820px) {
  .page-pos { height: auto; min-height: 100vh; overflow: visible; }
  .pos-layout { display: block; }
  .pos-catalog { padding-bottom: 5.5rem; }
  .pos-cart {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 70;
    max-height: 86vh; border-left: 0; border-top: 1px solid rgba(168,85,247,0.35);
    border-radius: 22px 22px 0 0; box-shadow: 0 -20px 60px rgba(0,0,0,0.6);
    transform: translateY(102%); transition: transform 0.32s var(--ease);
  }
  body.cart-open .pos-cart { transform: none; }
  .cart-fab { display: flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .def-list div { grid-template-columns: 1fr; gap: 0.1rem; }
  .hide-sm, td.hide-sm, th.hide-sm { display: none; }
  .modal-card { border-radius: 20px 20px 0 0; align-self: end; width: 100%; max-height: 90vh; }
  .modal { padding: 0; align-items: end; }
  .modal-card.narrow { width: 100%; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .filter-row .input-icon { max-width: none; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi strong { font-size: 1.2rem; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0.7rem 0.9rem; }
  .page-title { font-size: 1rem; }

  .portal-hero { padding: 1.1rem; }
  .portal-hero-main { flex-wrap: wrap; }
  .portal-points { text-align: left; width: 100%; }
  .portal-qr { width: 112px; }
  .invite-row input { min-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------ points QR codes */

.qr-member-list { display: grid; gap: 0.4rem; margin-top: 0.4rem; }
.qr-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.qr-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.45rem 0.3rem 0.6rem; border-radius: 999px;
  background: rgba(168,85,247,0.14); border: 1px solid rgba(168,85,247,0.3);
  font-size: 0.78rem;
}
.qr-chip strong { font-weight: 600; }
.qr-chip small { color: var(--muted); font-size: 0.7rem; }
.qr-chip-x {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 0.95rem; line-height: 1; padding: 0 0.15rem; border-radius: 50%;
}
.qr-chip-x:hover { color: var(--danger); }
.qr-search-results:empty { display: none; }
.qr-search-results {
  display: grid; gap: 0.25rem; margin-top: 0.4rem;
  max-height: 230px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 0.3rem;
  background: rgba(0,0,0,0.25);
}
.qr-search-item {
  display: flex; flex-direction: column; gap: 0.05rem; text-align: left;
  padding: 0.5rem 0.6rem; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--text); font: inherit;
}
.qr-search-item:hover { background: var(--panel); }
.qr-search-item strong { font-size: 0.85rem; font-weight: 600; }
.qr-search-item small { color: var(--muted); font-size: 0.72rem; }
.qr-canvas { width: min(280px, 100%); margin: 0 auto 0.6rem; }
.paynow-qr {
  width: min(230px, 100%); margin: 0.35rem auto 0.55rem; padding: 0.65rem;
  border-radius: 16px; background: #fff; box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}
.paynow-qr:empty { display: none; }
.paynow-qr svg { width: 100%; height: auto; display: block; }
.paynow-hint { text-align: center; font-size: 0.82rem; margin: 0 0 0.6rem; }
#paynow-missing[hidden] { display: none; }
.qr-redeem { text-align: center; display: grid; gap: 0.35rem; justify-items: center; }
.qr-redeem-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 10px 30px var(--accent-glow); margin-bottom: 0.3rem;
}
.qr-redeem-icon svg { width: 26px; height: 26px; }
.qr-redeem h2 { font-size: 1.5rem; }
.qr-redeem form { margin-top: 0.6rem; }

@media print {
  body.page-main .sidebar, body.page-main .topbar, body.page-main .bottom-nav { display: none !important; }
  #qr-show .modal-backdrop, #qr-show .modal-head button, #qr-show #qr-print { display: none !important; }
  #qr-show { position: static; display: block; padding: 0; }
  #qr-show .modal-card { box-shadow: none; border: 0; background: #fff; color: #111; max-width: none; }
  #qr-code-text { color: #111; }
}

/* ------------------------------------------------------- points QR scanner */

.scan-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.scan-cta-text h2 { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; }
.scan-cta-text h2 svg { width: 18px; height: 18px; color: var(--accent); }
.scan-cta-text p { margin: 0.25rem 0 0; font-size: 0.84rem; }

.scanner {
  position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 46vh;
  border-radius: 16px; overflow: hidden; background: #000;
}
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame {
  position: absolute; inset: 12%; border-radius: 16px;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 0 0 100vmax rgba(0,0,0,0.35);
}

.divider {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

@media (max-width: 520px) {
  .scan-cta { flex-direction: column; align-items: stretch; }
  .scan-cta .btn { width: 100%; }
}