/* All color/surface tokens come from CSS custom properties set by
   `app/branding.py:css_variables()` in <style> at the top of base.html.
   To rebrand, edit branding.json — no CSS changes needed. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }

/* ===== Layout ===== */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; }
.site-nav { display: flex; gap: 0.5rem; }
.site-main { flex: 1; width: 100%; }
.site-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
  display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center;
}
.footer-sep { opacity: 0.5; }
.container { max-width: 64rem; margin: 0 auto; padding: 1.5rem 1.25rem; }
.container-narrow { max-width: 36rem; margin: 0 auto; padding: 1.5rem 1.25rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.04s ease, background 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-lg { padding: 0.9rem 1.75rem; font-size: 1.0625rem; }
.btn-block { display: flex; width: 100%; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card + .card { margin-top: 1rem; }

/* ===== Forms ===== */
.field { margin-bottom: 1rem; }
.field label {
  display: block; font-weight: 600; margin-bottom: 0.375rem; font-size: 0.9375rem;
}
.input, .file-input {
  display: block; width: 100%; padding: 0.7rem 0.9rem;
  font: inherit;
  border: 1px solid var(--border); border-radius: 0.625rem;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .file-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1rem;
  border: 2px dashed var(--border);
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.file-drop:hover, .file-drop.is-drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.file-drop input[type="file"] { display: none; }
.file-drop .file-drop-title { font-weight: 600; margin-bottom: 0.25rem; }
.file-drop .file-drop-sub { color: var(--muted); font-size: 0.875rem; }
.file-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text);
  border-radius: 9999px;
  padding: 0.35rem 0.75rem; font-size: 0.875rem; font-weight: 500;
  margin-top: 0.75rem;
}

/* ===== Hero (landing) ===== */
.hero {
  text-align: center;
  padding: clamp(2rem, 6vw, 5rem) 1.25rem 2rem;
}
.hero h1 { margin-bottom: 0.5rem; }
.hero .lede {
  font-size: clamp(1.0625rem, 2vw, 1.25rem);
  color: var(--muted);
  max-width: 38rem; margin: 0 auto 1.5rem;
}
.hero .cta-row { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* ===== Steps / how-it-works ===== */
.steps {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin-top: 1.5rem;
}
.steps .step .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 9999px;
  background: var(--accent); color: white; font-weight: 700;
  margin-bottom: 0.5rem;
}

/* ===== Tips card ===== */
.tips { padding-left: 0; list-style: none; }
.tips li {
  position: relative; padding-left: 1.75rem; margin-bottom: 0.5rem;
}
.tips li::before {
  content: ""; position: absolute; left: 0; top: 0.45rem;
  width: 0.875rem; height: 0.875rem;
  background: var(--accent); border-radius: 9999px;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3 8.5l3 3 7-7' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3 8.5l3 3 7-7' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/contain no-repeat;
}
.tips.tips-bad li::before {
  background: #DC2626;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 4l8 8M12 4l-8 8' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'/></svg>") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 4l8 8M12 4l-8 8' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'/></svg>") center/contain no-repeat;
}

/* ===== Progress bar (upload + status) ===== */
.progress {
  width: 100%; height: 0.625rem;
  background: var(--border); border-radius: 9999px; overflow: hidden;
}
.progress > .bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.4s ease;
}
.progress-label {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: 0.875rem; color: var(--muted); margin-top: 0.5rem;
}

/* ===== Status step list ===== */
.step-list { list-style: none; padding: 0; margin: 1.25rem 0 0; display: grid; gap: 0.5rem; }
.step-list li {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border); border-radius: 0.625rem;
  background: var(--surface);
  font-size: 0.9375rem;
}
.step-list li .dot {
  width: 0.625rem; height: 0.625rem; border-radius: 9999px; background: var(--border);
  flex-shrink: 0;
}
.step-list li.is-done .dot { background: var(--accent); }
.step-list li.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.step-list li.is-active .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ===== Status / alerts ===== */
.alert {
  padding: 0.875rem 1rem; border-radius: 0.625rem;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.9375rem;
}
.alert-error {
  border-color: #FECACA; background: #FEF2F2; color: #991B1B;
}
.alert-success {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

/* ===== Grid two-col on desktop ===== */
.split {
  display: grid; gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 48rem) {
  .split { grid-template-columns: 1.3fr 1fr; }
}

/* tiny utility */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.text-center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.875em; }
.hidden { display: none !important; }

/* ===== Admin ===== */
.metric-row {
  display: grid; gap: 0.75rem; margin: 1rem 0 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem; padding: 0.875rem 1rem;
}
.metric-num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.metric-lbl { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.filter-bar {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.filter-bar .input { width: auto; min-width: 8rem; padding: 0.5rem 0.75rem; }

.data-table {
  width: 100%; border-collapse: collapse; font-size: 0.9375rem;
}
.data-table th, .data-table td {
  text-align: left; padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  font-weight: 600; font-size: 0.8125rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.875rem; }

.pill {
  display: inline-block; padding: 0.15rem 0.625rem; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; background: var(--border); color: var(--text);
}
.pill-queued     { background: #E2E8F0; color: #334155; }
.pill-processing { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-dark); }
.pill-done       { background: #DCFCE7; color: #166534; }
.pill-failed     { background: #FEE2E2; color: #991B1B; }
.pill-paid       { background: var(--accent); color: white; margin-left: 0.375rem; }
.pill-awaiting_payment { background: #FEF3C7; color: #92400E; }
.pill-payment_claimed  { background: #FED7AA; color: #9A3412; font-weight:700; }

.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 0.4rem 0; vertical-align: top; }
.kv td:first-child { width: 9rem; color: var(--muted); font-size: 0.875rem; }

.action-stack { display: grid; gap: 0.5rem; }
