/* ============================================================
   Reading Academies Lookup — styles
   Tokens + components. One accent (burnt orange, sat <80%),
   slate neutrals, radius rule: panels 12px / controls 8px / badges pill.
   ============================================================ */

/* ---------- Fonts ---------- */
@font-face {
  font-family: 'Inter Var';
  src: url('../fonts/inter-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jbmono-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jbmono-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --font-sans: 'Inter Var', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --accent: #C2410C;
  --accent-hover: #9A3412;
  --accent-soft: #FFF3EC;
  --accent-soft-border: #FBDCCB;
  --accent-ring: rgba(194, 65, 12, 0.35);

  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #EFF2F6;
  --border: #E1E6EE;
  --border-strong: #C9D2DE;

  --text: #101828;
  --text-2: #475467;
  --text-3: #8A94A6;

  --masthead: #0E1E33;
  --masthead-text: #FFFFFF;
  --masthead-sub: #A9B7CC;

  --ok: #15803D;   --ok-bg: #EFFAF2;   --ok-border: #B9E4C6;
  --warn: #B45309; --warn-bg: #FFF8EB; --warn-border: #F2D9A9;
  --bad: #B91C1C;  --bad-bg: #FEF1F1;  --bad-border: #F2BFBF;

  --r-panel: 12px;
  --r-ctrl: 8px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.07);

  --nav-h: 56px;
}

[data-theme="dark"] {
  --accent-soft: rgba(194, 65, 12, 0.16);
  --accent-soft-border: rgba(194, 65, 12, 0.35);

  --bg: #0B1120;
  --surface: #101A2E;
  --surface-2: #16223A;
  --border: #1F2C47;
  --border-strong: #2E3F60;

  --text: #E6EBF3;
  --text-2: #9AA8BE;
  --text-3: #64748B;

  --masthead: #070D19;
  --masthead-sub: #8496B0;

  --ok: #4ADE80;   --ok-bg: rgba(22, 101, 52, 0.22);   --ok-border: rgba(74, 222, 128, 0.35);
  --warn: #FBBF24; --warn-bg: rgba(146, 90, 14, 0.22); --warn-border: rgba(251, 191, 36, 0.35);
  --bad: #F87171;  --bad-bg: rgba(153, 27, 27, 0.22);  --bad-border: rgba(248, 113, 113, 0.35);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Masthead ---------- */
.masthead {
  background: var(--masthead);
  color: var(--masthead-text);
  border-bottom: 3px solid var(--accent);
}
.masthead-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: flex; gap: 14px; align-items: flex-start; }
.brand-mark {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff;
  margin-top: 2px;
}
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand p { color: var(--masthead-sub); font-size: 13px; margin-top: 3px; max-width: 62ch; }

.stat-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--masthead-sub);
  display: flex; align-items: center; gap: 7px;
  white-space: nowrap;
}
.chip b { color: #fff; font-weight: 650; font-family: var(--font-mono); font-size: 12px; }

/* ---------- Nav ---------- */
.nav-wrap {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 4px;
}
.nav button.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  height: 100%;
  padding: 0 14px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
  position: relative;
}
.nav button.tab svg { opacity: 0.75; }
.nav button.tab:hover { color: var(--text); }
.nav button.tab[aria-selected="true"] { color: var(--accent); }
.nav button.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.nav-spacer { flex: 1; }

/* theme toggle */
.theme-toggle {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); width: 34px; height: 34px; border-radius: var(--r-ctrl);
  cursor: pointer; display: grid; place-items: center;
  transition: background 0.12s, border-color 0.12s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.theme-toggle:active { transform: scale(0.96); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.tabpanel { display: none; }
.tabpanel.active { display: block; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-sm);
}

.section-head { margin: 0 0 14px; }
.section-head h2 { font-size: 17px; }
.section-head p { color: var(--text-2); font-size: 13px; margin-top: 3px; max-width: 72ch; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  font-size: 13.5px; font-weight: 600;
  border-radius: var(--r-ctrl);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border-color: transparent; height: 32px; padding: 0 10px; font-size: 13px;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, select.input, textarea.input {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-ctrl);
  padding: 9px 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder { color: var(--text-3); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
textarea.input { resize: vertical; min-height: 120px; font-family: var(--font-mono); font-size: 13px; line-height: 1.5; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Search panel ---------- */
.search-card { padding: 20px; }
.search-row { display: grid; grid-template-columns: 1fr 300px auto; gap: 12px; align-items: end; }
.search-row .field { min-width: 0; }
.search-options { display: flex; align-items: center; gap: 18px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Results ---------- */
.results-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 22px 0 10px;
}
.results-count { font-size: 13px; color: var(--text-2); }
.results-count b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.results-spacer { flex: 1; }

table.grid {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
table.grid th {
  text-align: left; font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky; top: 0;
}
table.grid td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr:last-child td { border-bottom: 0; }
.tbl-name { font-weight: 600; color: var(--text); }
.tbl-provider { color: var(--text-2); }
.tbl-num { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); }

.table-scroll { overflow-x: auto; border-radius: 0 0 var(--r-panel) var(--r-panel); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 650;
  border-radius: var(--r-pill);
  padding: 2.5px 9px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-ok   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-border); }
.badge-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.badge-bad  { color: var(--bad);  background: var(--bad-bg);  border-color: var(--bad-border); }
.badge-soft { color: var(--text-2); background: var(--surface-2); border-color: var(--border); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 14px; flex-wrap: wrap; }
.pager button.page {
  appearance: none; cursor: pointer;
  min-width: 32px; height: 32px; padding: 0 6px;
  border-radius: var(--r-ctrl);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px; font-family: var(--font-mono);
  transition: background 0.1s, border-color 0.1s;
}
.pager button.page:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.pager button.page[aria-current="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.pager button.page:disabled { opacity: 0.4; cursor: default; }
.pager .page-ellipsis { color: var(--text-3); padding: 0 2px; font-family: var(--font-mono); }

/* ---------- Empty / error states ---------- */
.state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-2);
}
.state .state-icon {
  width: 44px; height: 44px; margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-3);
}
.state h3 { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.state p { font-size: 13px; max-width: 46ch; margin: 0 auto; }

/* ---------- Skeleton ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 6px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }

/* ---------- Providers tab ---------- */
.providers-grid { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.provider-list { max-height: 640px; overflow-y: auto; }
.provider-list .pl-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.provider-item {
  width: 100%; text-align: left; appearance: none; cursor: pointer; border: 0; background: transparent;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
}
.provider-item:hover { background: var(--surface-2); }
.provider-item[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.provider-item .p-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.provider-item .p-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }

.provider-detail { padding: 20px; min-height: 420px; }
.provider-detail .pd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.provider-detail h3 { font-size: 17px; }
.provider-detail .pd-sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.provider-detail .pd-sub b { font-family: var(--font-mono); color: var(--text); }

/* ---------- Bulk tab ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.step-card { padding: 18px; position: relative; }
.step-num {
  position: absolute; top: 14px; right: 16px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  color: var(--text-3);
}
.step-card h3 { font-size: 14.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.step-card p { font-size: 12.5px; color: var(--text-2); }
.step-card .btn { margin-top: 12px; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-panel);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  background: var(--surface);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { color: var(--text-3); margin-bottom: 8px; display: inline-block; }
.dropzone strong { font-size: 13.5px; }
.dropzone p { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.dropzone .dz-file { margin-top: 10px; font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); }

.progress-wrap { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.progress-bar {
  flex: 1; height: 8px; border-radius: var(--r-pill);
  background: var(--surface-2); overflow: hidden;
}
.progress-bar > div {
  height: 100%; width: 0%;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width 0.15s;
}
.progress-label { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); min-width: 90px; text-align: right; }

.summary-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.sum-box {
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 10px 16px;
  background: var(--surface);
}
.sum-box .s-num { font-family: var(--font-mono); font-size: 20px; font-weight: 600; }
.sum-box .s-label { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.sum-box.ok .s-num { color: var(--ok); }
.sum-box.warn .s-num { color: var(--warn); }
.sum-box.bad .s-num { color: var(--bad); }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 24px;
}
.footer-inner {
  max-width: 1180px; margin: 0 auto; padding: 24px;
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-3);
}
.footer-inner .f-note { max-width: 68ch; }
.footer-inner .f-meta { text-align: right; font-family: var(--font-mono); font-size: 11.5px; line-height: 1.8; }
.footer a { color: var(--text-2); }
.footer a:hover { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--masthead); color: var(--masthead-text);
  padding: 11px 18px; border-radius: var(--r-ctrl);
  font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 100;
  max-width: min(92vw, 520px);
  border-left: 3px solid var(--accent);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-left-color: var(--bad); }

/* ---------- Load overlay (data load) ---------- */
.load-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  transition: opacity 0.25s;
}
.load-overlay.done { opacity: 0; pointer-events: none; }
.load-overlay .lo-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
}
.load-overlay h2 { font-size: 16px; }
.load-overlay p { font-size: 13px; color: var(--text-2); font-family: var(--font-mono); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .search-row { grid-template-columns: 1fr; align-items: stretch; }
  .providers-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .masthead-inner { flex-direction: column; }
  .stat-chips { justify-content: flex-start; }
}
@media (max-width: 640px) {
  main { padding: 20px 14px 48px; }
  .nav { padding: 0 10px; gap: 0; }
  .nav button.tab { padding: 0 10px; font-size: 13px; }
  .brand h1 { font-size: 17px; }
  .search-card { padding: 14px; }
  .btn { height: 36px; }
}

/* ---------- Harvest status banner ---------- */
.harvest-banner {
  background: #FFF3EC;
  border-bottom: 1px solid #FBDCCB;
  color: #1E293B;
}
.hb-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.hb-icon { font-size: 1rem; flex: none; }
.hb-text { flex: 1; margin: 0; font-size: 0.85rem; line-height: 1.45; }
.hb-close {
  flex: none; background: none; border: none; color: inherit;
  opacity: 0.6; font-size: 0.9rem; cursor: pointer;
  padding: 0.25rem 0.4rem; border-radius: 6px;
}
.hb-close:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
[data-theme="dark"] .harvest-banner {
  background: #3A241A;
  border-bottom-color: #5C3A26;
  color: #FDEADF;
}
[data-theme="dark"] .hb-close:hover { background: rgba(255, 255, 255, 0.08); }
