/* Lucky Wheel admin. A quiet working tool: neutral panels, one red accent taken from the wheel. */
:root {
  --bg: #f5f4f7; --panel: #ffffff; --ink: #1c1a22; --muted: #67626f; --line: #e5e1ea; --soft: #f1eef4;
  --accent: #c8102e; --accent-ink: #ffffff; --focus: #2457d6;
  --ok: #0f7a4d; --ok-bg: #e2f4eb; --warn: #8f5300; --warn-bg: #fff0d4; --bad: #b42318; --bad-bg: #fde7e5;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131117; --panel: #1c1a21; --ink: #eeebf3; --muted: #a39dad; --line: #2e2a36; --soft: #25222c;
    --accent: #ff5468; --accent-ink: #1c0006; --focus: #8eb2ff;
    --ok: #4bd394; --ok-bg: #11301f; --warn: #ffc56e; --warn-bg: #33270e; --bad: #ff8d84; --bad-bg: #3a1613;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 20px 0 10px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
code { background: var(--soft); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }
pre { margin: 0; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
small { color: var(--muted); font-weight: 400; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.empty { color: var(--muted); margin: 4px 0 12px; }
.crumbs { margin: 0 0 6px; color: var(--muted); font-size: 13px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-left, 0px)); background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.brand span:last-child { color: var(--muted); font-weight: 600; }
.env-badge { padding: 3px 9px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.logo { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #ffcc4d;
  background: conic-gradient(#d4111b 0 36deg, #ffae1a 0 72deg, #d4111b 0 108deg, #ffae1a 0 144deg, #d4111b 0 180deg, #ffae1a 0 216deg, #d4111b 0 252deg, #ffae1a 0 288deg, #d4111b 0 324deg, #ffae1a 0); }
nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
nav a:hover { color: var(--ink); }
nav a[aria-current] { background: var(--soft); color: var(--ink); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }

main { max-width: 1220px; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 60px max(16px, env(safe-area-inset-left, 0px)); }
main.narrow { max-width: 440px; }

/* panels and tiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.panel > p.muted { max-width: 820px; }
details.panel > summary { cursor: pointer; font-weight: 600; }
details.panel[open] > summary { margin-bottom: 14px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.head h1, .head h2 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tile span { color: var(--muted); font-size: 13px; font-weight: 600; }
.tile b { display: block; font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }

/* tables */
.scroll { overflow-x: auto; container-type: inline-size; }
.nowrap { white-space: nowrap; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; vertical-align: bottom; }
th.num, td.num { text-align: right; }
tbody tr:last-child td, tbody tr:nth-last-child(2):has(+ tr.edit-row[hidden]) td { border-bottom: 0; }
td { font-variant-numeric: tabular-nums; }
td code { display: inline-block; margin-top: 2px; white-space: nowrap; }
td.actions { width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.row-actions form { display: contents; }
tr.edit-row > td { background: var(--soft); padding: 16px; }
/* The edit form stays in view when a wide table scrolls sideways. */
tr.edit-row form { position: sticky; left: 16px; max-width: min(820px, calc(100cqw - 32px)); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; vertical-align: middle; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.neutral { background: var(--soft); color: var(--muted); }

/* forms */
/* Forms are two columns of fields, tops aligned, so help text under one field never pushes its neighbour down.
   .wide fields and the .form-actions button row take a whole line. */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; align-items: start; }
form.grid { max-width: 820px; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid > .wide, .grid > .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid.filters { max-width: none; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: end; }
.grid.filters > .form-actions { grid-column: auto; min-height: 40px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
label > small { line-height: 1.4; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--ink); font-size: 14px; font-weight: 500; }
label.check > input { flex: none; margin: 2px 0 0; }
label.check small { display: block; line-height: 1.4; }
fieldset.checks { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
fieldset.checks legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:not([type="checkbox"]), select { height: 40px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); padding: 0; }
input[type="color"] { padding: 4px; width: 100%; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 5px; }
input[readonly] { background: var(--soft); }
textarea { min-height: 80px; font-family: var(--mono); font-size: 13px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.sm { min-height: 32px; padding: 4px 11px; font-size: 13px; }
.btn:hover, .btn[aria-expanded="true"] { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* messages */
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.secret-box { border: 2px solid var(--accent); }
.secret { display: flex; gap: 10px; align-items: flex-start; background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.secret code, .secret pre { flex: 1; background: none; padding: 0; font-size: 14px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
/* sign-in and other single-card pages: the card sits in the middle of the window */
main.narrow { max-width: none; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 400px; margin: 0; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login > .brand { justify-content: center; }
.login > h1 { justify-content: center; text-align: center; margin: 0 0 4px; }
.login .flash { margin: 0; }
.login .stack .btn { margin-top: 4px; }

/* wheel editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
@media (max-width: 1200px) { .editor { grid-template-columns: minmax(0, 1fr); } }
.preview { position: sticky; top: 72px; }
.preview lucky-wheel { max-width: 320px; --lw-font: "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; }
table.prizes th { padding: 6px 4px; letter-spacing: .02em; }
table.prizes td { padding: 6px 4px; }
table.prizes input:not([type="checkbox"]), table.prizes select { width: 100%; height: 34px; padding: 5px 7px; }
table.prizes .label-input { min-width: 110px; }
table.prizes .id-input { min-width: 84px; font-family: var(--mono); font-size: 12px; }
table.prizes .num { width: 68px; }
table.prizes select { min-width: 96px; }
table.prizes th.center, table.prizes td.center { text-align: center; }
.order-box { margin-top: 14px; }
.totals { font-size: 13px; font-weight: 600; }
.totals .bad { color: var(--bad); }
.totals .good { color: var(--ok); }
.warnings { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.warnings li { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.warnings li.bad { background: var(--bad-bg); color: var(--bad); }
.save-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 -6px 18px -12px rgba(0, 0, 0, .25); }
@media (max-width: 900px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.filters > .form-actions { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .grid, .grid.cols-3, .grid.filters { grid-template-columns: minmax(0, 1fr); }
  .top { gap: 6px 12px; }
  nav { order: 3; flex-basis: 100%; margin: 0 -12px; }
  .who { margin-left: auto; }
  .who span { display: none; }
  th, td { padding: 8px 6px; }
  .login { padding: 22px 18px; }
  .save-bar { gap: 6px 12px; padding: 10px 12px; }
  .save-bar .muted { font-size: 12px; }
}
