/* RewardsWave admin panel — light, dense, keyboard-friendly. */

:root {
  --bg:        #f2f4f9;
  --surface:   #ffffff;
  --sunken:    #eef1f7;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 2px 8px -1px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(16, 24, 40, 0.04);
  --ink:       #161d2b;
  --ink-soft:  #46516750;
  --muted:     #66718a;
  --rule:      #dde3ee;
  --brand:     #4338ca;
  --brand-dim: #eceafe;
  --good:      #0b7a70;
  --good-dim:  #e0f4f1;
  --warn:      #a15c07;
  --warn-dim:  #fdf0dd;
  --bad:       #c0271f;
  --bad-dim:   #fbeae9;
  --info:      #1f5ec4;
  --info-dim:  #e6eefc;
  --radius:    8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--brand); }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  height: 58px;
  background: linear-gradient(100deg, #161d2b 0%, #1e2740 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-md);
}
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: -0.01em; }
.topbar .brand span {
  font-weight: 500; opacity: 0.55; margin-left: 6px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em;
}
.topbar .env {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  background: #b4690e; padding: 3px 7px; border-radius: 4px;
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: 0.8; }
.topbar .signout { color: #fff; opacity: 0.75; font-size: 13px; }

/* ---------- shell ---------- */

.shell { display: flex; align-items: flex-start; }

.side {
  width: 210px;
  flex: 0 0 210px;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
}
.side a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-size: 14px;
}
.side a:hover { background: var(--sunken); }
.side a.on {
  background: var(--brand); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(67, 56, 202, 0.5);
}
.side a b {
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 20px;
}
.side a.on b { background: rgba(255,255,255,0.25); }

.main { flex: 1; min-width: 0; padding: 20px 24px 60px; }
.main h1 { margin: 4px 0 18px; font-size: 22px; letter-spacing: -0.015em; }
.main h2 { font-size: 16px; margin: 24px 0 10px; }

/* ---------- surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card > h2:first-child { margin-top: 0; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 12px; padding: 15px 17px; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }

/* ---------- tables ---------- */

.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); background: var(--sunken); white-space: nowrap;
}
tbody tr:hover { background: #fafbfe; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); }

/* ---------- bits ---------- */

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill.good  { background: var(--good-dim); color: var(--good); }
.pill.warn  { background: var(--warn-dim); color: var(--warn); }
.pill.bad   { background: var(--bad-dim);  color: var(--bad); }
.pill.info  { background: var(--info-dim); color: var(--info); }
.pill.muted { background: var(--sunken);   color: var(--muted); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.flash.good { background: var(--good-dim); color: var(--good); }
.flash.bad  { background: var(--bad-dim);  color: var(--bad); }

.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }

input[type=text], input[type=search], input[type=password], input[type=number], select, textarea {
  font: inherit; padding: 7px 10px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--ink);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.field input, label.field select, label.field textarea { color: var(--ink); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 6px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; text-decoration: none; display: inline-block;
}
.btn:hover { filter: brightness(1.07); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--rule); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }

.rows { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 14px; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; }

.note { font-size: 13px; color: var(--muted); }
.warnbox { background: var(--warn-dim); color: var(--warn); padding: 10px 14px; border-radius: var(--radius); font-size: 13px; }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login {
  width: 100%; max-width: 340px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 12px; padding: 26px;
}
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p.note { margin: 0 0 18px; }
.login label.field { margin-bottom: 12px; }
.login input { width: 100%; }
.login .btn { width: 100%; text-align: center; }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .side { width: 100%; flex: none; flex-direction: row; overflow-x: auto; position: static; }
  .main { padding: 16px; width: 100%; }
}

/* ---------- charts ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-item i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 110px 1fr max-content; gap: 12px; align-items: center; }
.hbar-label { font-size: 13px; font-weight: 600; }
.hbar-track { background: var(--sunken); border-radius: 4px; height: 14px; overflow: hidden; }
/* 4px rounded data-end, anchored to the baseline at the left. */
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hbar-value { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 560px) {
  .hbar { grid-template-columns: 1fr; gap: 3px; }
  .hbar-value { text-align: left; }
}

/* ---------- payouts ---------- */

.payout-group { padding-bottom: 18px; }
.payout-head {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-start; justify-content: space-between; margin-bottom: 12px;
}
.payout-actions { display: flex; gap: 8px; }
.payout-group table input[type=text] { padding: 5px 8px; font-size: 13px; }
.payout-group input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); }

.paste-block { margin: 12px 0; font-size: 13px; }
.paste-block summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.paste-block textarea { margin: 8px 0; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* ---------- tabs ---------- */

.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--sunken); padding: 4px; border-radius: 10px;
  width: max-content; max-width: 100%; overflow-x: auto;
}
.tab {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
  padding: 7px 16px; border-radius: 7px; white-space: nowrap;
}
.tab.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Checkboxes are load-bearing on the payout and settings pages, so give them a
   real hit target rather than the 13px browser default. */
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .stat:hover { transform: none; }
}

/* ---------- bulk payout ---------- */

/* A row whose purchase Google has not confirmed. Still readable and still
   selectable by hand, but visibly not part of the payable total. */
tr.dim td { opacity: 0.62; }
tr.dim td .pill { opacity: 1; }

.stat .v.good { color: var(--good); }
.stat .v.warn { color: var(--warn); }
