/* TeaBrothers brand system
   Purple-led palette (sampled #a32fac / #9463ae) with gold accents. */

:root {
  --brand: #8e2c9e;
  --brand-600: #a32fac;
  --brand-700: #7c2189;
  --brand-900: #3f1049;
  --brand-050: #faf5fd;
  --brand-100: #f2e6f9;
  --brand-200: #e4cff0;

  --gold: #e1a700;
  --gold-soft: #fff4d1;

  --ink: #2a1b33;
  --ink-soft: #4a3a55;
  --muted: #5d4f68;
  --line: #e9ddf2;
  --bg: #fbf8fd;
  --surface: #ffffff;

  --ok: #1f7a55;
  --ok-soft: #e6f5ee;
  --warn: #8a5a00;
  --warn-soft: #fff6e0;
  --danger: #b3261e;
  --danger-soft: #fdecea;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(58, 22, 74, .06);
  --shadow: 0 6px 24px rgba(58, 22, 74, .08);
  --shadow-lg: 0 18px 48px rgba(58, 22, 74, .16);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1100px 420px at 15% -180px, #f3e3fb 0%, rgba(243, 227, 251, 0) 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0 0 4px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
p { margin: 0 0 10px; }
a { color: var(--brand-700); }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }

/* ── Header ─────────────────────────────────────────────── */
header.tb {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px;
  color: #fff;
  background: linear-gradient(120deg, var(--brand-900) 0%, var(--brand-700) 45%, var(--brand-600) 100%);
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #ffd766, var(--gold));
  color: #4a2b00; font-weight: 800; font-size: .82rem; letter-spacing: .02em;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
header.tb h1 { font-size: 1.08rem; margin: 0; font-weight: 650; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.admin-menu { display: flex; gap: 4px; flex-wrap: wrap; margin: 0; padding: 0; }
.admin-menu a {
  display: inline-block; padding: 7px 11px; border-radius: 999px;
  text-decoration: none; color: #f4e8fb; font-size: .9rem; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.admin-menu a:hover { background: rgba(255,255,255,.16); color: #fff; }
.admin-menu a.active { background: #fff; color: var(--brand-700); font-weight: 650; }

.who {
  margin-left: auto; display: inline-flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  padding: 5px 8px 5px 9px; border-radius: 999px; font-size: .82rem;
}
.who .avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: var(--brand-700); font-weight: 700; font-size: .74rem;
}
.who a { color: #fff; text-decoration: none; border-left: 1px solid rgba(255,255,255,.3); padding-left: 10px; }
.who a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */
main { max-width: 1080px; margin: 30px auto 56px; padding: 0 20px; }
.stack > * + * { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.grid-2 > .card + .card { margin-top: 0; }
.grid-2, .kpi-grid { margin-bottom: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card.narrow { max-width: 460px; margin: 26px auto; }
.card.hero { padding: 0; overflow: hidden; }
.card.hero .hero-band {
  padding: 20px 22px; color: #fff;
  background: linear-gradient(120deg, var(--brand-900), var(--brand-600));
}
.card.hero .hero-band h2 { color: #fff; }
.card.hero .hero-body { padding: 22px; }

/* ── Forms ──────────────────────────────────────────────── */
label { display: block; font-size: .8rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-soft); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #cdb9e0; border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: #a99cb4; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 4px var(--brand-100);
}
.hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; padding: 12px 20px; border: 0; border-radius: 999px;
  font: inherit; font-weight: 650; cursor: pointer;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff; text-decoration: none;
  box-shadow: 0 4px 14px rgba(124, 33, 137, .28);
  transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover, button:hover { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(124, 33, 137, .34); }
.btn:active, button:active { transform: translateY(1px); }
.btn[disabled], button[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn.secondary, button.secondary { background: var(--brand-100); color: var(--brand-700); box-shadow: none; }
.btn.secondary:hover, button.secondary:hover { background: var(--brand-200); filter: none; }
.btn.ghost, button.ghost { background: transparent; color: var(--brand-700); box-shadow: none; border: 1px solid var(--brand-200); }
.btn.block, button.block { width: 100%; }
.btn.lg, button.lg { padding: 15px 26px; font-size: 1.05rem; }
button.small { padding: 8px 14px; font-size: .85rem; margin-top: 0; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin: 12px 0; font-size: .93rem; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe3d2; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: #f0dca6; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: #f5c6c2; }

/* ── Pills ──────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  letter-spacing: .01em; white-space: nowrap;
}
.pill.available { background: var(--ok-soft); color: var(--ok); }
.pill.redeemed { background: var(--brand-100); color: var(--brand-700); }
.pill.blocked { background: var(--danger-soft); color: var(--danger); }
.pill.gold { background: var(--gold-soft); color: #6b4b00; }

/* ── KPI cards ──────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 860px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.kpi .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.kpi .value { font-size: 1.9rem; font-weight: 750; margin-top: 6px; color: var(--brand-900); }
.kpi .sub { font-size: .82rem; color: var(--muted); }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; background: #fff; }
th, td { text-align: left; padding: 12px 14px; vertical-align: middle; }
thead th {
  position: sticky; top: 0;
  background: var(--brand-050); color: var(--brand-900);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800;
  border-bottom: 1px solid var(--line);
}
tbody tr + tr td { border-top: 1px solid #f2ebf8; }
tbody tr:hover { background: #fcf8ff; }
.code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--brand-050); border: 1px solid var(--brand-100);
  padding: 2px 7px; border-radius: 7px; font-size: .86rem; color: var(--brand-900);
}
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ── Branch picker ──────────────────────────────────────── */
.branch-list { display: grid; gap: 10px; margin-top: 14px; }
.branch-option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.branch-option:hover { border-color: var(--brand-200); background: var(--brand-050); }
.branch-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-600); }
.branch-option strong { display: block; font-size: .95rem; }
.branch-option .sub { font-size: .8rem; color: var(--muted); }
.branch-option:has(input:checked) { border-color: var(--brand-600); background: var(--brand-050); box-shadow: 0 0 0 3px var(--brand-100); }

/* ── Redemption ─────────────────────────────────────────── */
.search-hero { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.search-hero input { flex: 1 1 260px; font-size: 1.12rem; padding: 15px 18px; border-radius: 999px; }
.search-hero button { margin-top: 0; padding: 15px 26px; }

.result-card {
  margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; background: #fff; box-shadow: var(--shadow-sm);
}
.result-card.available { border-color: #bfe3d2; background: linear-gradient(180deg, #f7fdfa, #fff); }
.result-card.redeemed { border-color: var(--brand-200); background: linear-gradient(180deg, var(--brand-050), #fff); }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.result-name { font-size: 1.2rem; font-weight: 700; margin: 0; }
.result-meta { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.result-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.weekmeter { height: 8px; border-radius: 999px; background: var(--brand-100); overflow: hidden; margin: 14px 0 6px; }
.weekmeter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-600), var(--brand-700)); }
.success-mark { font-size: 2rem; line-height: 1; }

/* ── Utilities ──────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }
.inline-form { display: inline; margin: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input { max-width: 320px; }

@media (max-width: 1120px) {
  /* Deliberate two-row header: brand + account on top, menu below. */
  .who .who-name { display: none; }
  .who a { border-left: 0; padding-left: 2px; }
  .who { margin-left: auto; }
  .admin-menu {
    order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto;
    padding-bottom: 2px; scrollbar-width: none;
  }
  .admin-menu::-webkit-scrollbar { display: none; }
  .admin-menu a { padding: 6px 10px; font-size: .86rem; }
}
