:root {
    --gold: #c8892b; --gold-soft: #e6b053;
    --ink: #1c1813; --paper: #f6f2ea; --card: #ffffff;
    --line: #e4dccc; --muted: #7c7161; --text: #2a241c;
    --s-pending: #2f6fb0;   --s-pending-bg: #e3eef8;
    --s-approved: #7a5bd0;  --s-approved-bg: #ece6fa;
    --s-issued: #2f8f5b;    --s-issued-bg: #e0f1e7;
    --s-rejected: #c0453e;  --s-rejected-bg: #f8e4e2;
    --shadow: 0 1px 2px rgba(28,24,19,.06), 0 8px 24px rgba(28,24,19,.06);
    --radius: 12px;
    --mono: ui-monospace, "SF Mono", "SFMono-Regular", "Menlo", "Consolas", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  }
  @media (prefers-color-scheme: dark){
    :root{
      --gold:#e0a44d; --gold-soft:#f0c179; --ink:#f4ecdd; --paper:#17140f; --card:#211d16;
      --line:#362f24; --muted:#9a8f7c; --text:#ece3d3;
      --s-pending:#7db6ea; --s-pending-bg:#16283a; --s-approved:#b9a6f0; --s-approved-bg:#251d3a;
      --s-issued:#6cc493; --s-issued-bg:#14291d; --s-rejected:#e88b83; --s-rejected-bg:#331815;
      --shadow:0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.35);
    }
  }
  :root[data-theme="light"]{
    --gold:#c8892b; --gold-soft:#e6b053; --ink:#1c1813; --paper:#f6f2ea; --card:#ffffff;
    --line:#e4dccc; --muted:#7c7161; --text:#2a241c;
    --s-pending:#2f6fb0; --s-pending-bg:#e3eef8; --s-approved:#7a5bd0; --s-approved-bg:#ece6fa;
    --s-issued:#2f8f5b; --s-issued-bg:#e0f1e7; --s-rejected:#c0453e; --s-rejected-bg:#f8e4e2;
    --shadow:0 1px 2px rgba(28,24,19,.06), 0 8px 24px rgba(28,24,19,.06);
  }
  :root[data-theme="dark"]{
    --gold:#e0a44d; --gold-soft:#f0c179; --ink:#f4ecdd; --paper:#17140f; --card:#211d16;
    --line:#362f24; --muted:#9a8f7c; --text:#ece3d3;
    --s-pending:#7db6ea; --s-pending-bg:#16283a; --s-approved:#b9a6f0; --s-approved-bg:#251d3a;
    --s-issued:#6cc493; --s-issued-bg:#14291d; --s-rejected:#e88b83; --s-rejected-bg:#331815;
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.35);
  }

  * { box-sizing: border-box; }
  body { margin:0; background:var(--paper); color:var(--text); font-family:var(--sans); line-height:1.5; -webkit-font-smoothing:antialiased; }
  .wrap { max-width:1080px; margin:0 auto; padding:0 20px 64px; }

  /* ---------- SSO gate ---------- */
  #gate { min-height:100vh; display:grid; place-items:center; padding:32px 20px; }
  .gate-card { width:100%; max-width:440px; text-align:center; }
  .gate-logo { width:56px; height:56px; border-radius:16px; margin:0 auto 18px;
    background:radial-gradient(circle at 34% 30%, var(--gold-soft), var(--gold));
    display:grid; place-items:center; font-size:26px; color:#3a2a08; font-weight:900;
    box-shadow:var(--shadow); }
  .gate-card h1 { font-size:26px; letter-spacing:-.02em; margin:0 0 6px; color:var(--ink); }
  .gate-card p.sub { margin:0 0 22px; color:var(--muted); }
  .sso-btn { width:100%; border:0; border-radius:11px; padding:13px; font:inherit; font-weight:700;
    background:var(--ink); color:var(--paper); cursor:pointer; display:flex; align-items:center; justify-content:center; gap:9px; }
  .sso-btn:hover { filter:brightness(1.1); }
  .gate-divider { display:flex; align-items:center; gap:12px; color:var(--muted); font-size:12px; margin:24px 0 14px; }
  .gate-divider::before, .gate-divider::after { content:""; height:1px; background:var(--line); flex:1; }
  .role-pick { display:grid; gap:10px; }
  .role-pick button { text-align:left; border:1px solid var(--line); background:var(--card); border-radius:11px;
    padding:13px 15px; cursor:pointer; font:inherit; display:flex; gap:12px; align-items:center; box-shadow:var(--shadow); }
  .role-pick button:hover { border-color:var(--gold); }
  .role-pick .rp-ico { width:36px; height:36px; border-radius:9px; background:var(--paper); display:grid; place-items:center; font-size:18px; flex:none; }
  .role-pick .rp-name { font-weight:700; color:var(--ink); }
  .role-pick .rp-desc { font-size:12.5px; color:var(--muted); }

  /* ---------- top bar ---------- */
  header.bar { position:sticky; top:0; z-index:20; background:color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter:blur(8px); border-bottom:1px solid var(--line); }
  .bar-inner { max-width:1080px; margin:0 auto; padding:12px 20px; display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
  .brand { display:flex; align-items:center; gap:10px; font-weight:800; letter-spacing:-.02em; font-size:16px; color:var(--ink); }
  .coin { width:26px; height:26px; border-radius:50%; background:radial-gradient(circle at 34% 30%, var(--gold-soft), var(--gold));
    box-shadow:inset 0 0 0 2px color-mix(in srgb, var(--gold) 60%, #000 12%); display:grid; place-items:center;
    color:#3a2a08; font-weight:900; font-size:14px; flex:none; }
  .role-tag { font-size:12px; font-weight:700; color:var(--gold); background:color-mix(in srgb,var(--gold) 14%, transparent);
    padding:3px 10px; border-radius:999px; }
  .spacer { flex:1; }
  .balance { display:inline-flex; align-items:center; gap:8px; background:var(--card); border:1px solid var(--line);
    border-radius:999px; padding:6px 14px 6px 8px; box-shadow:var(--shadow); font-weight:700; color:var(--ink); }
  .balance .num { font-family:var(--mono); font-variant-numeric:tabular-nums; }
  .balance .lbl { font-size:11px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.07em; }
  .icon-btn { border:1px solid var(--line); background:var(--card); color:var(--text); border-radius:9px; height:34px; min-width:34px;
    padding:0 9px; cursor:pointer; font-size:13px; font-weight:700; box-shadow:var(--shadow); }
  .icon-btn:hover { border-color:var(--gold); }

  /* ---------- intro ---------- */
  .intro { padding:30px 0 6px; }
  .eyebrow { text-transform:uppercase; letter-spacing:.14em; font-size:11px; font-weight:700; color:var(--gold); }
  h1.page { font-size:clamp(24px,4vw,34px); letter-spacing:-.03em; margin:8px 0 6px; color:var(--ink); text-wrap:balance; }
  .intro p { margin:0; color:var(--muted); max-width:62ch; }

  /* ---------- tabs ---------- */
  .tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin:20px 0 24px; flex-wrap:wrap; }
  .tabs button { border:0; background:transparent; color:var(--muted); cursor:pointer; font:inherit; font-weight:600;
    padding:10px 14px; border-bottom:2px solid transparent; margin-bottom:-1px; border-radius:8px 8px 0 0; }
  .tabs button[aria-selected="true"] { color:var(--ink); border-bottom-color:var(--gold); }
  .tabs .count { font-family:var(--mono); font-size:12px; padding:1px 7px; border-radius:999px; margin-left:6px;
    background:var(--s-pending-bg); color:var(--s-pending); }
  .tabs .count.gold { background:color-mix(in srgb,var(--gold) 18%, transparent); color:var(--gold); }

  /* ---------- catalog ---------- */
  .game-head { display:flex; align-items:baseline; gap:10px; margin:26px 0 14px; }
  .game-head h2 { font-size:15px; letter-spacing:.02em; margin:0; color:var(--ink); }
  .game-head .dot { width:9px; height:9px; border-radius:50%; }
  .game-head .meta { font-size:12px; color:var(--muted); }
  .grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px,1fr)); gap:14px; }
  .card { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow);
    display:flex; flex-direction:column; gap:10px; }
  .card .thumb { height:96px; border-radius:8px; display:grid; place-items:center; font-size:34px;
    background:linear-gradient(135deg, color-mix(in srgb, var(--gold) 16%, var(--card)), var(--card)); border:1px solid var(--line); }
  .card h3 { margin:0; font-size:15px; letter-spacing:-.01em; color:var(--ink); text-wrap:balance; }
  .card .desc { margin:0; font-size:12.5px; color:var(--muted); flex:1; }
  .card .foot { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:2px; }
  .price { display:inline-flex; align-items:center; gap:6px; font-family:var(--mono); font-variant-numeric:tabular-nums; font-weight:700; color:var(--ink); }
  .mini-coin { width:16px; height:16px; border-radius:50%; background:radial-gradient(circle at 34% 30%, var(--gold-soft), var(--gold)); flex:none; }

  .btn { border:0; border-radius:9px; cursor:pointer; font:inherit; font-weight:700; font-size:13px; padding:8px 14px;
    background:var(--gold); color:#2a1c04; transition:filter .15s, transform .05s; }
  .btn:hover { filter:brightness(1.05); }
  .btn:active { transform:translateY(1px); }
  .btn:disabled { background:var(--line); color:var(--muted); cursor:not-allowed; }
  .btn.ghost { background:transparent; border:1px solid var(--line); color:var(--text); }
  .btn.sm { padding:6px 10px; font-size:12px; }
  .btn.approve { background:var(--s-issued); color:#fff; }
  .btn.reject { background:transparent; border:1px solid var(--s-rejected); color:var(--s-rejected); }
  @media (prefers-color-scheme: dark){ .btn.approve{ color:#08150d; } }
  .btn.in-cart { background:transparent; border:1px solid var(--gold); color:var(--gold); }

  /* ---------- chips ---------- */
  .chip { display:inline-flex; align-items:center; gap:6px; font-size:11.5px; font-weight:700; padding:3px 9px; border-radius:999px; white-space:nowrap; }
  .chip::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; }
  .chip.pending { color:var(--s-pending); background:var(--s-pending-bg); }
  .chip.approved { color:var(--s-approved); background:var(--s-approved-bg); }
  .chip.issued { color:var(--s-issued); background:var(--s-issued-bg); }
  .chip.rejected { color:var(--s-rejected); background:var(--s-rejected-bg); }
  .role-chip { font-size:11px; font-weight:700; padding:3px 9px; border-radius:999px; background:var(--paper); border:1px solid var(--line); color:var(--muted); }

  /* ---------- panels ---------- */
  .panel { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); overflow:hidden; }
  .panel-head { padding:14px 16px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
  .panel-head h2 { margin:0; font-size:14px; letter-spacing:.01em; color:var(--ink); }
  .panel-head .sub { font-size:12px; color:var(--muted); }
  .rows { display:flex; flex-direction:column; }
  .row { display:grid; grid-template-columns:1fr auto; gap:10px 16px; align-items:center; padding:13px 16px; border-top:1px solid var(--line); }
  .row:first-child { border-top:0; }
  .row .who { font-weight:700; color:var(--ink); font-size:14px; }
  .row .what { font-size:13px; color:var(--muted); }
  .row .what b { color:var(--text); font-weight:600; }
  .row .actions { display:inline-flex; gap:8px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
  .row .amount { font-family:var(--mono); font-variant-numeric:tabular-nums; font-weight:700; color:var(--ink); }

  .cols { display:grid; grid-template-columns:1.3fr 1fr; gap:20px; align-items:start; }
  @media (max-width:760px){ .cols { grid-template-columns:1fr; } }

  /* ---------- cart ---------- */
  .cart-item { display:grid; grid-template-columns:1fr auto auto; gap:12px; align-items:center; padding:13px 16px; border-top:1px solid var(--line); }
  .cart-item:first-child { border-top:0; }
  .qty { display:inline-flex; align-items:center; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
  .qty button { border:0; background:var(--paper); color:var(--text); width:28px; height:28px; cursor:pointer; font:inherit; font-weight:700; font-size:15px; }
  .qty button:hover { background:color-mix(in srgb,var(--gold) 18%, var(--paper)); }
  .qty span { min-width:30px; text-align:center; font-family:var(--mono); font-variant-numeric:tabular-nums; font-weight:700; }
  .cart-summary { padding:16px; border-top:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; }
  .cart-total { font-size:15px; color:var(--ink); font-weight:700; }
  .cart-total .amount { font-family:var(--mono); font-variant-numeric:tabular-nums; }
  .cart-deficit { font-size:12.5px; color:var(--s-rejected); font-weight:600; }
  .order-items { font-size:13px; color:var(--muted); }
  .order-items b { color:var(--text); font-weight:600; }

  /* ---------- form ---------- */
  .form { padding:16px; display:flex; flex-direction:column; gap:12px; }
  .field { display:flex; flex-direction:column; gap:5px; }
  .field label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--muted); }
  .field select, .field input { font:inherit; padding:9px 11px; border-radius:9px; border:1px solid var(--line); background:var(--paper); color:var(--text); }
  .field input:focus, .field select:focus { outline:2px solid var(--gold); outline-offset:1px; }
  .chips-quick { display:flex; gap:6px; flex-wrap:wrap; }
  .chips-quick button { border:1px solid var(--line); background:var(--paper); color:var(--text); border-radius:999px; padding:5px 11px;
    font:inherit; font-size:12px; font-weight:600; cursor:pointer; font-family:var(--mono); }
  .chips-quick button:hover { border-color:var(--gold); }
  .mini-amt { width:82px; padding:7px 9px; border:1px solid var(--line); border-radius:8px; background:var(--paper); color:var(--text);
    font:inherit; font-family:var(--mono); font-variant-numeric:tabular-nums; }
  .mini-amt:focus { outline:2px solid var(--gold); outline-offset:1px; }
  .team-hint { font-size:12px; color:var(--muted); }
  .lead-badge { border-color:var(--gold) !important; color:var(--gold) !important; }

  .empty { padding:30px 16px; text-align:center; color:var(--muted); font-size:13px; }
  .view[hidden], .tabpane[hidden] { display:none; }

  #toast { position:fixed; left:50%; bottom:24px; transform:translateX(-50%) translateY(20px); background:var(--ink); color:var(--paper);
    padding:11px 18px; border-radius:10px; font-weight:600; font-size:13px; box-shadow:var(--shadow); opacity:0; pointer-events:none;
    transition:opacity .2s, transform .2s; z-index:50; max-width:88vw; }
  #toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
  @media (prefers-reduced-motion: reduce){ * { transition:none !important; } }

.login-controls{position:fixed;top:14px;right:16px;display:flex;gap:8px;z-index:30;}

/* ---------- who am I (header) ---------- */
.whoami { font-size:13px; font-weight:700; color:var(--ink); max-width:22ch; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ---------- catalog cart controls ---------- */
.cart-controls { display:inline-flex; gap:6px; align-items:center; }
.btn.qty-minus { padding:6px 10px; background:transparent; border:1px solid var(--gold); color:var(--gold); font-weight:800; line-height:1; }

/* ---------- admin management ---------- */
.row .adm-actions { display:inline-flex; gap:6px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.badge-off { font-size:11px; font-weight:700; padding:3px 9px; border-radius:999px; background:var(--s-rejected-bg); color:var(--s-rejected); }
.badge-on  { font-size:11px; font-weight:700; padding:3px 9px; border-radius:999px; background:var(--s-issued-bg); color:var(--s-issued); }

/* per-user issuance limit + free rewards */
.price-wrap { display:inline-flex; align-items:center; gap:8px; flex-wrap:wrap; }
.price.free { color:var(--s-issued); }
.lim-badge { font-size:11px; font-weight:700; padding:3px 9px; border-radius:999px; background:var(--s-pending-bg,rgba(180,140,0,.14)); color:var(--s-pending,#b48c00); white-space:nowrap; }

/* ---------- modal ---------- */
#modal { position:fixed; inset:0; z-index:60; display:grid; place-items:center; padding:20px; }
#modal[hidden] { display:none; }
.modal-backdrop { position:absolute; inset:0; background:rgba(0,0,0,.45); }
.modal-card { position:relative; width:100%; max-width:460px; max-height:88vh; overflow:auto; background:var(--card);
  border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); }
.modal-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:16px; border-bottom:1px solid var(--line); }
.modal-head h2 { margin:0; font-size:16px; letter-spacing:-.01em; color:var(--ink); }
.modal-body { padding:16px; display:flex; flex-direction:column; gap:12px; }
.modal-foot { padding:14px 16px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px; }
.modal-body .field label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--muted); }
.modal-body .field input, .modal-body .field select, .modal-body .field textarea {
  font:inherit; padding:9px 11px; border-radius:9px; border:1px solid var(--line); background:var(--paper); color:var(--text); width:100%; }
.modal-body .field textarea { resize:vertical; min-height:52px; }
.modal-body .grid2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:520px){ .modal-body .grid2 { grid-template-columns:1fr; } }

/* ---------- login form (gate) ---------- */
#login-form { display:flex; flex-direction:column; gap:10px; margin-bottom:4px; }
#login-form input { font:inherit; padding:11px 13px; border-radius:11px; border:1px solid var(--line); background:var(--card); color:var(--text); }
#login-form input:focus { outline:2px solid var(--gold); outline-offset:1px; }
.sso-alt { background:transparent !important; color:var(--ink) !important; border:1px solid var(--line); }

/* ---------- reward image thumbnail ---------- */
.card .thumb img { width:100%; height:100%; object-fit:cover; border-radius:8px; }

/* ---------- selects & file inputs (unified look) ---------- */
select, .field select {
  font:inherit; padding:9px 34px 9px 11px; border-radius:9px; border:1px solid var(--line);
  background-color:var(--paper); color:var(--text); cursor:pointer;
  appearance:none; -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a8f7c' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 11px center; background-size:12px;
}
select:focus, .field select:focus { outline:2px solid var(--gold); outline-offset:1px; }
#reward-filter { max-width:220px; }

input[type="file"] { font:inherit; font-size:13px; color:var(--muted); max-width:100%; }
input[type="file"]::file-selector-button {
  font:inherit; font-weight:700; font-size:13px; margin-right:10px; padding:8px 14px;
  border:1px solid var(--line); border-radius:9px; background:var(--card); color:var(--text); cursor:pointer;
}
input[type="file"]::file-selector-button:hover { border-color:var(--gold); }

/* ---------- history filters ---------- */
.filters { display:flex; gap:8px; align-items:center; flex-wrap:wrap; padding:12px 16px; border-bottom:1px solid var(--line); }
.filters input[type="date"] { font:inherit; font-size:13px; padding:8px 10px; border-radius:9px; border:1px solid var(--line); background:var(--paper); color:var(--text); }
.filters input[type="date"]:focus { outline:2px solid var(--gold); outline-offset:1px; }
.filters select { font-size:13px; }
