:root {
  --bg: #0d0d0f;
  --panel: #17171b;
  --panel-2: #1f1f25;
  --line: #2c2c34;
  --text: #f4f4f6;
  --muted: #9a9aa6;
  --accent: #e2231a;      /* New Balance red */
  --accent-2: #c99a3f;    /* Boutiqaat gold */
  --green: #1faa59;
  --amber: #d9962a;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1a1a22 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); }

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.brand .x { color: var(--accent); }
.brand small { display:block; font-size: 11px; color: var(--muted); font-weight:600; letter-spacing:.14em; }

.container { max-width: 1080px; margin: 0 auto; padding: 16px; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---- Login ---- */
.login-box { width: 100%; max-width: 380px; padding: 28px 24px; }
.login-box h1 { font-size: 20px; margin: 18px 0 4px; }
.login-box p.sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

label { display:block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; letter-spacing:.02em; }
input, select, textarea {
  width: 100%; padding: 12px 14px; font-size: 15px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); }
textarea { min-height: 120px; resize: vertical; font-family: inherit; }

.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  width: 100%; padding: 13px 16px; margin-top: 18px;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing:.02em;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--panel-2); border:1px solid var(--line); color: var(--text); }
.btn.gold { background: var(--accent-2); color:#1a1400; }
.btn.ghost { background: transparent; border:1px solid var(--line); color: var(--text); }
.btn.sm { width:auto; padding: 8px 12px; margin:0; font-size: 13px; }
.btn.danger { background: transparent; border:1px solid var(--accent); color: var(--accent); }

.err { color: #ff8a82; font-size: 13px; margin-top: 12px; min-height: 16px; }
.ok  { color: #7fe0a0; font-size: 13px; margin-top: 12px; }

/* ---- Top bar ---- */
.topbar {
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top:0; background: rgba(13,13,15,.92); backdrop-filter: blur(8px); z-index: 20;
}
.topbar .who { font-size: 13px; color: var(--muted); }

/* ---- Tabs ---- */
.tabs { display:flex; gap: 6px; padding: 12px 16px 0; flex-wrap: wrap; }
.tab { padding: 9px 14px; border-radius: 10px 10px 0 0; cursor:pointer; color: var(--muted); font-weight:600; font-size:14px; border:1px solid transparent; border-bottom:none; }
.tab.active { background: var(--panel); color: var(--text); border-color: var(--line); }

/* ---- Stat tiles ---- */
.stats { display:grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 16px 0; }
.stat { padding: 16px; text-align:center; }
.stat .num { font-size: 30px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); text-transform:uppercase; letter-spacing:.08em; margin-top:4px; }
.stat.green .num { color: var(--green); }
.stat.amber .num { color: var(--amber); }

/* ---- Section header with +New ---- */
.section-head { display:flex; align-items:center; justify-content:space-between; margin: 8px 0 12px; gap: 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 16px; margin: 0; }
.section-head .actions { display:flex; gap: 8px; }
.search { max-width: 240px; margin:0; padding:9px 12px; }

/* ---- Table / list ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing:.06em; font-weight:600; }
tr:hover td { background: rgba(255,255,255,.02); }
.table-wrap { overflow-x: auto; }

.pill { display:inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight:700; }
.pill.pending { background: rgba(217,150,42,.15); color: var(--amber); }
.pill.done { background: rgba(31,170,89,.15); color: var(--green); }
.size-badge { display:inline-block; min-width: 34px; text-align:center; padding: 4px 8px; border-radius: 8px; background: var(--panel-2); border:1px solid var(--line); font-weight:700; }

.team-tag { display:inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight:700;
  background: rgba(201,154,63,.14); color: var(--accent-2); border:1px solid rgba(201,154,63,.25); }

/* per-team progress on dashboard */
.team-progress { display:grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 12px; margin: 4px 0 20px; }
.tp-card { padding: 14px 16px; }
.tp-head { display:flex; justify-content:space-between; align-items:baseline; margin-bottom: 8px; }
.tp-name { font-weight: 800; font-size: 14px; }
.tp-count { font-size: 12px; color: var(--muted); }
.tp-bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow:hidden; }
.tp-fill { height: 100%; background: linear-gradient(90deg, var(--green), #35c977); border-radius:999px; transition: width .4s; }

.row-actions { display:flex; gap: 6px; }
.icon-btn { background: var(--panel-2); border:1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 8px; cursor:pointer; font-size: 13px; }
.icon-btn:hover { border-color: var(--accent-2); }

/* ---- Drawer ---- */
.drawer-scrim { position: fixed; inset:0; background: rgba(0,0,0,.55); opacity:0; pointer-events:none; transition: opacity .2s; z-index: 40; }
.drawer-scrim.open { opacity:1; pointer-events:auto; }
.drawer {
  position: fixed; top:0; right:0; height:100%; width: 420px; max-width: 92vw;
  background: var(--panel); border-left:1px solid var(--line);
  transform: translateX(100%); transition: transform .25s ease; z-index: 50;
  display:flex; flex-direction:column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display:flex; align-items:center; justify-content:space-between; padding: 18px 20px; border-bottom:1px solid var(--line); }
.drawer-head h3 { margin:0; font-size: 17px; }
.drawer-body { padding: 20px; overflow-y: auto; }
.close-x { background:none; border:none; color: var(--muted); font-size: 22px; cursor:pointer; }

/* ---- QR modal ---- */
.modal-scrim { position: fixed; inset:0; background: rgba(0,0,0,.7); display:none; place-items:center; z-index:60; padding:16px; }
.modal-scrim.open { display:grid; }
.qr-card { background:#fff; color:#111; border-radius:16px; padding: 22px; width: 320px; max-width:92vw; text-align:center; }
.qr-card img { width: 240px; height: 240px; }
.qr-card h3 { margin: 6px 0 2px; }
.qr-card .qsize { color:#555; font-size: 14px; }

/* ---- Scanner ---- */
.scan-wrap { max-width: 480px; margin: 0 auto; padding: 16px; }
#reader { width: 100%; border-radius: 14px; overflow: hidden; border:1px solid var(--line); }
#reader video { border-radius: 14px; }
.result-card { padding: 22px; margin-top: 18px; text-align:center; }
.result-card .rname { font-size: 24px; font-weight: 800; margin: 6px 0; }
.result-card .rsize { font-size: 15px; color: var(--muted); }
.result-card .big-size { font-size: 46px; font-weight: 900; margin: 10px 0; letter-spacing:.02em; }
.result-card .status-line { margin: 14px 0; font-size: 15px; }
.banner { border-radius: 12px; padding: 14px; margin: 14px 0; font-weight: 700; }
.banner.done { background: rgba(31,170,89,.14); color: #86e6ab; border:1px solid rgba(31,170,89,.3); }
.banner.already { background: rgba(226,35,26,.14); color: #ff9a94; border:1px solid rgba(226,35,26,.3); }
.hint { color: var(--muted); font-size: 13px; text-align:center; margin-top: 10px; }

.manual { display:flex; gap:8px; margin-top: 14px; }
.manual input { margin:0; }
.manual .btn { margin:0; width:auto; padding: 12px 16px; }

.empty { text-align:center; color: var(--muted); padding: 40px 16px; }
.spinner { display:inline-block; width:18px; height:18px; border:2px solid rgba(255,255,255,.3); border-top-color:#fff; border-radius:50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .stat .num { font-size: 22px; }
  .search { max-width: 150px; }
  th, td { padding: 10px 8px; }
}

/* ---- Print cards sheet ---- */
#printSheet { display: none; }
#printSheet .print-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap: 10mm; }
#printSheet .print-card { border:1px dashed #999; border-radius: 10px; padding: 8mm; text-align:center; break-inside: avoid; color:#111; }
#printSheet .print-card img { width: 45mm; height: 45mm; }
#printSheet .print-card .pn { font-weight:800; font-size: 14pt; margin-top: 4mm; }
#printSheet .print-card .ps { font-size: 11pt; color:#444; }
#printSheet .print-card .pc { font-size: 8pt; color:#888; font-family: monospace; margin-top: 2mm; }

@media print {
  body { background:#fff !important; color:#000; }
  body > *:not(#printSheet) { display: none !important; }
  #printSheet { display: block !important; }
}
