/* Looks like the Grand Bonanza Backoffice: indigo accent, white cards on gray
   (light) or GitHub-style layers (dark, the default). */
:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --line: #e5e7eb;
  --text: #1f2937;
  --strong: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-text: #4f46e5;
  --primary-soft: #eef2ff;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --wait: #d97706;
  --wait-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --pink: #db2777;
  --pink-soft: #fdf2f8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
:root.dark {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --line: #30363d;
  --text: #e6edf3;
  --strong: #f0f6fc;
  --muted: #8b949e;
  --primary: #6366f1;
  --primary-text: #818cf8;
  --primary-soft: #1c2240;
  --ok: #4ade80;
  --ok-soft: #0d1f14;
  --wait: #facc15;
  --wait-soft: #1a1508;
  --bad: #f87171;
  --bad-soft: #1f1315;
  --info: #60a5fa;
  --info-soft: #0d1729;
  --pink: #f472b6;
  --pink-soft: #1f0d18;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }
h1 { font-size: 24px; font-weight: 700; color: var(--strong); margin: 4px 0 20px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; color: var(--strong); margin: 0 0 12px; }
.ic { flex-shrink: 0; }

/* ---- Shell: sidebar + top bar ---- */
.side { position: fixed; inset: 0 auto 0 0; width: 256px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; }
.side-logo { display: flex; justify-content: center; padding: 14px 16px 6px; }
.side-logo img { height: 56px; width: auto; }
.side-title { text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .mnav nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--text); font-weight: 500; }
.side-nav a .ic, .mnav nav a .ic { color: var(--muted); }
.side-nav a:hover, .mnav nav a:hover { background: var(--surface-2); text-decoration: none; }
.side-nav a.on, .mnav nav a.on { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.side-nav a.on .ic, .mnav nav a.on .ic { color: var(--primary-text); }
.side-foot { padding: 12px; border-top: 1px solid var(--line); }
.net { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; }
.net b { display: block; color: var(--strong); }
.net span { color: var(--muted); }
.net.test { background: var(--wait-soft); color: var(--wait); }
.net.live { background: var(--ok-soft); color: var(--ok); }

.shell { margin-left: 256px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.clock { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 13px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top-right form { margin: 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border-radius: 9px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.icon-btn:hover { color: var(--strong); background: var(--surface-2); filter: none; }
#theme .ic + .ic, .dark #theme .ic:first-child { display: none; }
.dark #theme .ic + .ic { display: block; }
.user { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.user b { display: block; color: var(--strong); font-size: 13.5px; line-height: 1.2; }
.user span { color: var(--muted); font-size: 12px; }
.avatar { display: inline-flex; width: 36px; height: 36px; border-radius: 50%; align-items: center; justify-content: center; background: var(--surface-2); color: var(--muted); }
.top-logo, .mnav { display: none; }

main { padding: 24px 32px 64px; max-width: 1480px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb span { margin: 0 6px; }
.crumb b { color: var(--strong); font-weight: 500; }

/* ---- Building blocks ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card.narrow { max-width: 560px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h2 { margin: 0; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card-head .end { margin-left: auto; text-align: right; }
.chip { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.wait { background: var(--wait-soft); color: var(--wait); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.primary { background: var(--primary-soft); color: var(--primary-text); }
.chip.pink { background: var(--pink-soft); color: var(--pink); }
.chip.muted { background: var(--surface-2); color: var(--muted); }
.grid2, .grid3 { display: grid; gap: 20px; margin-bottom: 20px; }
.grid2 > .card, .grid3 > .card, .grid-wide > .card { margin-bottom: 0; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.grid-wide { display: grid; gap: 20px; margin-bottom: 20px; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }

.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); color: inherit; }
a.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile .label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.tile .value { font-size: 22px; font-weight: 700; color: var(--strong); margin-top: 10px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value.value-sm { font-size: 17px; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile .ok { color: var(--ok); } .tile .wait { color: var(--wait); } .tile .bad { color: var(--bad); }
.tile .info { color: var(--info); } .tile .primary { color: var(--primary-text); } .tile .pink { color: var(--pink); }

.feed { display: flex; flex-direction: column; gap: 8px; }
.feed-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: inherit; }
a.feed-row:hover { text-decoration: none; border-color: var(--primary); }
.feed-row .chip { width: 32px; height: 32px; border-radius: 8px; }
.feed-row .main { flex: 1; min-width: 0; }
.feed-row .main b { color: var(--strong); font-size: 14.5px; }
.feed-row .main div { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-row .end { text-align: right; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

.rows { display: flex; flex-direction: column; }
.rows > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rows > div:last-child { border-bottom: 0; }
.rows span:first-child { color: var(--muted); }
.rows b { color: var(--strong); font-weight: 600; }

.muted { color: var(--muted); }
.strong { color: var(--strong); font-weight: 600; }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }

.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 16px; border: 1px solid; border-left-width: 4px; }
.flash.ok { background: var(--ok-soft); border-color: var(--ok); }
.flash.bad { background: var(--bad-soft); border-color: var(--bad); }
.invite { margin-top: 8px; padding: 8px; background: var(--bg); border-radius: 8px; }

.badge, .pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge.ok, .pill.ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge.wait, .pill.wait { color: var(--wait); background: var(--wait-soft); border-color: color-mix(in srgb, var(--wait) 30%, transparent); }
.badge.bad, .pill.bad { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge.muted, .pill.muted { color: var(--muted); background: var(--surface-2); border-color: var(--line); }

/* ---- Tables ---- */
.scroll { overflow-x: auto; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
table.list th, table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list th.r, table.list td.r { text-align: right; }
table.list thead th, table.list tr:first-child th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
table.list tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 7px 12px 7px 0; width: 45%; }
table.kv td { padding: 7px 0; color: var(--strong); }

/* ---- Forms ---- */
form.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
form.filters input { flex: 1; min-width: 200px; }
input, select, button { font: inherit; color: var(--text); }
input, select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 0; border-color: var(--primary); }
button { background: var(--primary); color: #fff; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.danger { background: var(--bad); color: #fff; }
.dark button.danger { color: #1f1315; }
button.small { padding: 5px 12px; font-size: 13px; }
button.link { background: none; color: var(--primary-text); padding: 0; font-weight: 500; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label input, label select { color: var(--text); font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
.confirm { display: grid; grid-template-columns: 1fr 150px; gap: 10px; }
form.inline { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
form.inline .confirm { flex: 1; min-width: 280px; }
form.inline > select, form.inline > button { margin-bottom: 12px; }
form.stack { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; min-width: 260px; }
form.stack .confirm { grid-template-columns: 1fr; }
details summary { cursor: pointer; color: var(--primary-text); font-size: 13px; font-weight: 500; }
.switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.switch { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.switch b { color: var(--strong); }
.pager { display: flex; gap: 16px; }
.mt { margin-top: 12px; }
.section { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; }
.section h2 { margin: 0; }
.section .chip { width: 32px; height: 32px; border-radius: 8px; }
.back { display: inline-block; margin-bottom: 6px; font-weight: 500; }
h1.with-badge { display: flex; align-items: center; gap: 12px; }
h1.with-badge .badge { font-size: 13px; }
details.fold summary { font-size: 14px; font-weight: 600; color: var(--strong); }
td.r details { text-align: left; display: inline-block; }
td.r details summary { text-align: right; }
form.stack p { margin: 0 0 6px; color: var(--text); max-width: 320px; }
.card > p { margin: 0 0 14px; }
.timeline { margin: 0 0 16px; padding-left: 18px; }
.timeline li { margin-bottom: 8px; }

/* ---- Sign-in pages ---- */
.auth-page { max-width: none; min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 6vh 16px 40px; }
.auth-net { margin-bottom: 16px; }
.auth-flash { width: 100%; max-width: 420px; }
.auth { width: 100%; max-width: 420px; }
.auth.wide { max-width: 540px; }
.auth-logo { display: block; margin: 0 auto 8px; height: 72px; width: auto; }
.auth h1 { text-align: center; font-size: 20px; margin: 0; }
.auth > p { text-align: center; color: var(--muted); margin: 4px 0 20px; }
.auth form { margin-top: 0; padding: 24px; }
.auth button { width: 100%; margin-top: 6px; padding: 11px 16px; }
.steps { padding-left: 18px; margin-top: 0; }
.steps li { margin-bottom: 10px; }
.qr { background: #fff; display: inline-block; padding: 8px; border-radius: 8px; margin-top: 8px; }
.qr img { display: block; image-rendering: pixelated; }

/* ---- Narrow screens: sidebar becomes a drop-down menu ---- */
@media (max-width: 1100px) {
  .grid-wide { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .side { display: none; }
  .shell { margin-left: 0; }
  .topbar { padding: 0 12px; gap: 10px; }
  .top-logo { display: block; height: 34px; width: auto; }
  .mnav { display: block; position: relative; }
  .mnav summary { list-style: none; display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 9px; color: var(--text); }
  .mnav summary::-webkit-details-marker { display: none; }
  .mnav nav { position: absolute; top: 46px; left: 0; width: 240px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); display: flex; flex-direction: column; gap: 2px; }
  main { padding: 16px 16px 48px; }
}
@media (max-width: 640px) {
  .clock, .user div { display: none; }
  .confirm { grid-template-columns: 1fr; }
  .tile .value { font-size: 20px; }
  h1 { font-size: 21px; }
}
