@font-face { font-family: "Manrope"; src: url("/manrope-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("/unbounded-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }

/* Night (default) */
:root, [data-theme="dark"] {
  --bg: #121430;
  --rail: #0E1028;
  --surface: #1A1D42;
  --surface-2: #22265255;
  --raise: #232858;
  --line: #2E3368;
  --line-strong: #40468A;
  --text: #ECEEFF;
  --text-2: #A3A8D4;
  --text-3: #7479AC;
  --star: #FFC53D;
  --on-star: #241900;
  --link: #8CC8FF;
  --pending: #FFC53D;   --pending-bg: #FFC53D1F;
  --processing: #6CB8FF; --processing-bg: #6CB8FF1F;
  --completed: #4FD08F;  --completed-bg: #4FD08F1F;
  --rejected: #FF7A85;   --rejected-bg: #FF7A851F;
  --refunded: #C19BFF;   --refunded-bg: #C19BFF1F;
  --shadow: 0 18px 50px #00000066;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #EEF0F7;
  --rail: #14163A;
  --surface: #FFFFFF;
  --surface-2: #F5F6FB;
  --raise: #F0F2FA;
  --line: #DCDFEC;
  --line-strong: #C3C7DC;
  --text: #171A3A;
  --text-2: #4F547E;
  --text-3: #7D82A6;
  --star: #E9A100;
  --on-star: #1D1400;
  --link: #1F6FC5;
  --pending: #A86A00;   --pending-bg: #FFC53D33;
  --processing: #1F6FC5; --processing-bg: #6CB8FF2E;
  --completed: #137A48;  --completed-bg: #4FD08F2E;
  --rejected: #C2283A;   --rejected-bg: #FF7A852B;
  --refunded: #6B3FC0;   --refunded-bg: #C19BFF33;
  --shadow: 0 18px 50px #171A3A26;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 500 14.5px/1.5 "Manrope", system-ui, sans-serif; font-feature-settings: "tnum" 1; }
a { color: var(--link); text-underline-offset: 3px; }
h1, h2, h3 { letter-spacing: -0.015em; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: 650 13.5px/1 "Manrope", sans-serif; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--raise); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--star); border-color: var(--star); color: var(--on-star); }
.btn-primary:hover { background: var(--star); filter: brightness(1.08); }
.btn-danger { color: var(--rejected); border-color: color-mix(in srgb, var(--rejected) 45%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--raise); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; height: 42px; }
input, select, textarea { font: 500 14px "Manrope", sans-serif; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; padding: 0 11px; height: 36px; min-width: 0; }
textarea { height: auto; padding: 9px 11px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 25%, transparent); }
label { font-weight: 650; font-size: 12.5px; color: var(--text-2); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(70% 50% at 50% 0%, #2A2F7A55, transparent), var(--bg); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 10px 0 8px; font-size: 22px; }
.login-card input { height: 42px; margin-bottom: 6px; }
.login-brand { display: flex; align-items: center; gap: 10px; font: 600 16px "Unbounded", sans-serif; }
.login-brand svg, .rail-brand svg { width: 24px; height: 24px; fill: var(--star); }
.form-error { color: var(--rejected); margin: 0; font-weight: 600; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: #D4D7F5; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.rail-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 600 15px "Unbounded", sans-serif; padding: 4px 10px 18px; }
.rail nav { display: grid; gap: 2px; }
.rail nav a { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; color: #B9BDE6; text-decoration: none; font-weight: 600; }
.rail nav a:hover { background: #FFFFFF0F; color: #fff; }
.rail nav a.is-active { background: #FFFFFF17; color: #fff; box-shadow: inset 3px 0 0 #FFC53D; }
.rail-group { margin: 16px 10px 4px; font-size: 12px; color: #7E83B8; font-weight: 600; }
.count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: #FFC53D; color: #241900; font-size: 11.5px; font-weight: 800; display: inline-grid; place-items: center; }
.rail-foot { margin-top: auto; border-top: 1px solid #FFFFFF14; padding: 12px 10px 0; }
.whoami { margin: 0 0 8px; display: grid; }
.whoami b { color: #fff; }
.whoami span { font-size: 12.5px; color: #8D92C5; text-transform: capitalize; }
.rail-actions { display: flex; gap: 6px; }
.rail .btn-ghost { color: #B9BDE6; }
.rail .btn-ghost:hover { background: #FFFFFF14; color: #fff; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 6px; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 750; }
.topbar-flags { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.flag { font-size: 12.5px; font-weight: 700; padding: 5px 10px; border-radius: 999px; }
.flag-stop { background: var(--rejected-bg); color: var(--rejected); }
.flag-shadow { background: var(--processing-bg); color: var(--processing); }
.flag-paused { background: var(--pending-bg); color: var(--pending); }
.menu-btn { display: none; }
#page { padding: 14px 28px 48px; outline: none; }

/* ---------- blocks ---------- */
.section { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 18px; }
.section-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 750; margin-right: auto; }
.section-body { padding: 16px; }
.muted { color: var(--text-2); }
.nowrap { white-space: nowrap; }
[tabindex="-1"]:focus { outline: none; }
.faint { color: var(--text-3); }
.empty { padding: 28px 16px; text-align: center; color: var(--text-2); }

/* KPI strip: one bordered strip with dividers, not a row of floating cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 18px; overflow: hidden; }
.kpi { padding: 16px 18px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi p { margin: 0; color: var(--text-2); font-weight: 600; font-size: 13px; }
.kpi strong { display: block; font: 650 26px/1.2 "Unbounded", sans-serif; letter-spacing: -0.03em; margin-top: 6px; }
.kpi small { color: var(--text-3); font-size: 12.5px; }
.kpi-star strong { color: var(--star); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }

.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { padding: 11px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.alerts li:last-child { border-bottom: 0; }
.alerts li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); background: var(--processing); }
.alerts li.lv-warn::before { background: var(--pending); }
.alerts li.lv-error::before { background: var(--rejected); }

.integ { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0; }
.integ > div { padding: 14px 16px; border-right: 1px solid var(--line); }
.integ > div:last-child { border-right: 0; }
.integ h3 { margin: 0 0 4px; font-size: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--text-3); }
.dot-ok { background: var(--completed); } .dot-warn { background: var(--pending); } .dot-bad { background: var(--rejected); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--text-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--raise); }
td.num, th.num { text-align: right; }
.mono { font-family: "Unbounded", sans-serif; font-weight: 400; font-size: 12px; letter-spacing: .03em; }
.user { font-weight: 700; }
.stars { font-weight: 750; }
.stars::after { content: " ★"; color: var(--star); }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; text-transform: capitalize; white-space: nowrap; }
.pill-pending { background: var(--pending-bg); color: var(--pending); }
.pill-processing { background: var(--processing-bg); color: var(--processing); }
.pill-completed { background: var(--completed-bg); color: var(--completed); }
.pill-rejected { background: var(--rejected-bg); color: var(--rejected); }
.pill-refunded { background: var(--refunded-bg); color: var(--refunded); }
.pill-off { background: var(--raise); color: var(--text-3); }

/* Order queue status tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--text-2); font: 650 13px "Manrope", sans-serif; cursor: pointer; }
.tab:hover { background: var(--raise); }
.tab.is-active { background: var(--raise); border-color: var(--line-strong); color: var(--text); }
.tab b { margin-left: 4px; font-weight: 800; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { width: 260px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.form-grid > div { display: grid; gap: 5px; }
.form-grid input, .form-grid select { width: 100%; }

/* Codes: stacked status bar per batch */
.bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--raise); min-width: 140px; }
.bar span { display: block; height: 100%; }
.b-unused { background: var(--text-3); }
.b-reserved { background: var(--pending); }
.b-delivered { background: var(--processing); }
.b-redeemed { background: var(--completed); }
.b-dead { background: var(--rejected); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.counts { font-size: 12.5px; color: var(--text-2); margin-top: 5px; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Switch rows */
.switch-row { display: flex; gap: 16px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row div { flex: 1; }
.switch-row h3 { margin: 0 0 3px; font-size: 14.5px; }
.switch-row p { margin: 0; color: var(--text-2); font-size: 13.5px; }
.toggle { position: relative; width: 46px; height: 26px; border-radius: 13px; border: 0; background: var(--line-strong); cursor: pointer; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle[aria-checked="true"] { background: var(--completed); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }
.toggle.is-danger[aria-checked="true"] { background: var(--rejected); }
.toggle:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: #05061599; z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--line); z-index: 50; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; margin-right: auto; }
.drawer-body { padding: 18px; overflow-y: auto; }
.big-user { display: flex; align-items: center; gap: 10px; padding: 14px; background: var(--raise); border-radius: 12px; margin-bottom: 14px; }
.big-user strong { font-size: 19px; flex: 1; word-break: break-all; }
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; margin: 0 0 16px; }
.facts dt { color: var(--text-2); font-size: 13px; }
.facts dd { margin: 0; font-weight: 600; word-break: break-word; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.actions .btn-primary { flex: 1; min-width: 180px; height: 40px; }
.timeline { list-style: none; margin: 0 0 14px; padding: 0; }
.timeline li { padding: 0 0 12px 18px; position: relative; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.timeline li::after { content: ""; position: absolute; left: 3.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .note { background: var(--raise); border-radius: 8px; padding: 7px 10px; margin-top: 4px; white-space: pre-wrap; }
.drawer h3 { font-size: 13.5px; margin: 0 0 10px; color: var(--text-2); }

/* ---------- dialog & toasts ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: #05061599; }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog p { margin: 0 0 14px; color: var(--text-2); }
dialog label { display: block; margin-bottom: 5px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: 10px; font-weight: 650; box-shadow: var(--shadow); animation: slide .18s; }
.toast-error { background: var(--rejected); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 60; width: 250px; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .rail.is-open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .topbar, #page { padding-left: 16px; padding-right: 16px; }
  .filters input[type=search] { width: 100%; }
  .hide-sm { display: none; }
  .flag-shadow { display: none; }
  .topbar h1 { font-size: 19px; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
