:root {
  color-scheme: dark;
  --bg: #0C1115;
  --surface: #131A21;
  --surface-2: #1A2530;
  --divider: #1F2A33;
  --text: #FFFFFF;
  --text-2: #E4ECF2;
  --muted: #C4D1D9;
  --dim: #7A8A95;
  --gold: #C9A85C;
  --green: #66BB6A;
  --red: #EF5350;
}

* { box-sizing: border-box; }
/* Block any later `display: …` rule from silently overriding the HTML `hidden`
 * attribute. Without this, `.modal { display: grid }` wins over the UA's
 * `[hidden] { display: none }` and the modal captures every click on the page. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  min-height: 100vh;
}

main { max-width: 900px; margin: 0 auto; padding: 18px 20px 48px; }
h1 { color: var(--gold); margin: 0; font-size: 20px; letter-spacing: 0.04em; }
h2 { color: var(--text-2); font-size: 14px; margin: 28px 0 10px; letter-spacing: 0.04em; text-transform: uppercase; }
h2:first-of-type { margin-top: 12px; }
.sub { color: var(--dim); font-size: 12px; margin: 4px 0 16px; }
.sub.small { font-size: 11px; }
code { color: var(--gold); font-family: inherit; }
strong { color: var(--text-2); font-weight: bold; }

/* ---- Setup ---- */
#setup { max-width: 480px; }
.setup-form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.setup-form label { display: block; }
.setup-form label span {
  display: block;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.setup-form input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
}
.setup-form input:focus { outline: none; border-color: var(--gold); }
button {
  font: inherit; font-size: 13px;
  padding: 10px 16px;
  background: var(--surface-2); border: 1px solid var(--divider);
  border-radius: 4px;
  color: var(--text-2);
  cursor: pointer;
}
button.primary {
  background: var(--gold); color: #0C1115;
  font-weight: bold;
  border-color: var(--gold);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.msg { min-height: 1.4em; font-size: 12px; color: var(--red); margin: 0; }
.msg.ok { color: var(--green); }

/* ---- Top bar ---- */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.who {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
}
.who #who-name { color: var(--text-2); }
.who .balance {
  background: var(--surface-2);
  border: 1px solid var(--divider);
  color: var(--gold);
  padding: 4px 10px; border-radius: 3px;
  font-weight: bold;
}
.who #who-logout {
  background: none; border: none;
  color: var(--dim); font-size: 18px; padding: 0 4px;
  cursor: pointer;
}
.who #who-logout:hover { color: var(--red); }

/* ---- Hero summary ---- */
.hero {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 4px;
}
.hero-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.hero-cell .lbl {
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.hero-cell .val {
  color: var(--gold);
  font-size: 20px;
  font-weight: bold;
  margin-top: 4px;
}
.hero-cell .val.muted { color: var(--text-2); font-size: 16px; font-weight: normal; }
.hero-note {
  color: var(--dim);
  font-size: 11px;
  margin-top: 8px;
  min-height: 1.3em;
}

/* ---- Catalog ---- */
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.badge-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.badge-card .glyph { font-size: 40px; line-height: 1; margin-bottom: 6px; }
.badge-card .name { color: var(--text-2); font-weight: bold; font-size: 13px; }
.badge-card .desc { color: var(--dim); font-size: 11px; margin: 4px 0 8px; min-height: 2.4em; }
.badge-card .price { color: var(--gold); font-weight: bold; font-size: 14px; margin-bottom: 8px; }
.badge-card .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: 100%; }
.badge-card .actions button { font-size: 11px; padding: 6px 10px; flex: 1; min-width: 70px; }
.badge-card .credit-meta { color: var(--dim); font-size: 10px; margin-top: 6px; }

/* ---- Credits / transactions ---- */
.row-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.row-card .row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.row-card .title { color: var(--text-2); font-weight: bold; font-size: 13px; }
.row-card .amount { color: var(--gold); font-weight: bold; font-size: 13px; }
.row-card .meta { color: var(--dim); font-size: 11px; margin-top: 4px; }
.row-card .desc { color: var(--text-2); font-size: 11px; margin-top: 6px; white-space: pre-wrap; }
.row-card .status {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 6px;
}
.row-card .status.pending  { background: rgba(201,168,92,0.18); color: var(--gold); }
.row-card .status.approved { background: rgba(102,187,106,0.18); color: var(--green); }
.row-card .status.rejected { background: rgba(239,83,80,0.18); color: var(--red); }
.row-card .status.expired  { background: rgba(122,138,149,0.18); color: var(--dim); }
.row-card .status.closed   { background: rgba(102,187,106,0.18); color: var(--green); }
.row-card .status.overdue  { background: rgba(239,83,80,0.22); color: var(--red); }

.row-card .progress-wrap {
  background: var(--surface-2);
  border-radius: 4px;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
}
.row-card .progress { height: 100%; background: var(--gold); }
.row-card .progress.reserved { background: var(--red); }

/* ---- Modal (purchase pending + decline) ---- */
/* Selector excludes the [hidden] state — otherwise `display: grid` would
 * override the browser UA's `[hidden] { display: none }` (equal specificity,
 * later wins) and the modal would silently capture every click on the page. */
.modal:not([hidden]) { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(8,12,16,0.85);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 20px 24px;
  width: min(420px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}
.modal-content h2 {
  margin-top: 0; margin-bottom: 8px;
  color: var(--text); font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
}
.modal-actions {
  display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end;
}
.pending-line {
  font-size: 13px; color: var(--gold);
  font-weight: bold; margin: 6px 0;
  text-align: center;
}
.pending-line .timer { font-family: ui-monospace, monospace; }
