/* AI School Admin — house tokens + console layout. */
:root {
  --paper: #f8fafc; --panel: #ffffff; --panel-alt: #f1f5f9;
  --ink: #1e293b; --ink-strong: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --line-strong: #cbd5e1;
  --accent: #6d5ef6; --accent-hover: #5b4ee0; --accent-soft: #eeecff;
  --grad: linear-gradient(120deg, #6d5ef6 0%, #22d3ee 100%);
  --radius-sm: 0.5rem; --radius: 0.75rem; --radius-lg: 1rem;
  --shadow: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px -1px rgba(15,23,42,0.06);
  --shadow-lg: 0 10px 25px -8px rgba(15,23,42,0.15), 0 4px 10px -4px rgba(15,23,42,0.08);
  --font-body: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Fraunces', ui-serif, Georgia, serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 16px;
}
:root[data-theme="dark"] {
  --paper: #0b1020; --panel: #141a30; --panel-alt: #0f1526;
  --ink: #e7eaf5; --ink-strong: #ffffff; --muted: #9aa3c0;
  --line: #252c47; --line-strong: #3a4266;
  --accent: #8b7dff; --accent-hover: #a99dff; --accent-soft: #1a1f3a;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); color: var(--ink); background: var(--paper); line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3 { font-family: var(--font-display); color: var(--ink-strong); letter-spacing: -0.02em; }
a { color: var(--accent); text-decoration: none; }

.bar { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.bar .brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; }
.bar .brand-mark { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
.bar h1 { font-size: 1.05rem; }
.bar .spacer { margin-left: auto; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); cursor: pointer; }
.icon-btn:hover { border-color: var(--line-strong); }

.wrap { max-width: 1000px; margin: 1.5rem auto; padding: 0 1.25rem; }

.gate { max-width: 420px; margin: 4rem auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.8rem; box-shadow: var(--shadow-lg); }
.gate h2 { margin-bottom: 0.3rem; }
.gate p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.2rem; }

.tabs { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 0.6rem 1rem; font-weight: 700; color: var(--muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-family: var(--font-body); font-size: 0.95rem; white-space: nowrap; flex-shrink: 0; }
.tab.active { color: var(--ink-strong); border-bottom-color: var(--accent); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.panel h3 { font-size: 1.1rem; margin-bottom: 1rem; }

label { display: block; font-weight: 700; font-size: 0.82rem; margin-bottom: 0.3rem; color: var(--ink-strong); }
input, select, textarea { width: 100%; padding: 0.55rem 0.7rem; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field { margin-bottom: 0.9rem; }
.grid2 { display: grid; gap: 0.9rem; grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; gap: 0.9rem; grid-template-columns: 1fr 1fr 1fr; }
.check-inline { display: flex; align-items: center; gap: 0.5rem; }
.check-inline input { width: auto; }
.check-inline label { margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.6rem 1.1rem; border-radius: var(--radius-sm); font-weight: 700; font-size: 0.9rem; background: var(--accent); color: #fff; border: 1px solid transparent; cursor: pointer; font-family: var(--font-body); }
.btn:hover { background: var(--accent-hover); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-ghost { background: transparent; color: var(--ink-strong); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--panel-alt); }
.btn-danger { background: transparent; color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; }
td .sub { color: var(--muted); font-size: 0.8rem; }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: var(--panel-alt); border: 1px solid var(--line); color: var(--muted); }
.badge.live { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge.draft { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

.note { padding: 0.7rem 1rem; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 600; margin-bottom: 1rem; }
.note.ok { background: #dcfce7; color: #166534; }
.note.err { background: #fee2e2; color: #991b1b; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.right { text-align: right; }

.bar select { width: auto; padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.userchip { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.banner { border-radius: var(--radius); padding: 0.8rem 1.1rem; font-size: 0.9rem; font-weight: 600; margin-bottom: 1.3rem; border: 1px solid; }
.banner.warn { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.banner.info { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }
:root[data-theme="dark"] .banner.warn { background: #422006; color: #fde68a; border-color: #713f12; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h3 { margin-bottom: 0.4rem; }
@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }

  /* Top bar: wrap, drop secondary text, org switcher on its own full-width row */
  .bar { flex-wrap: wrap; gap: 0.55rem 0.7rem; padding: 0.7rem 1rem; }
  .bar h1 { font-size: 1rem; }
  .bar h1 span { display: none; }
  .userchip { display: none; }
  #org-switcher:not(.hidden) { order: 10; flex-basis: 100%; width: 100%; }
  .icon-btn { width: 40px; height: 40px; }
  .wrap { margin-top: 1rem; padding: 0 1rem; }
  .panel { padding: 1.1rem; }

  /* Tables → stacked cards */
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  tr { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-alt); padding: 0.6rem 0.9rem; margin-bottom: 0.75rem; }
  td { border: none; padding: 0.4rem 0; }
  td[data-label]::before {
    content: attr(data-label); display: block;
    font-weight: 700; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--muted); margin-bottom: 0.15rem;
  }
  td.actions, td.right { justify-content: flex-start; text-align: left; }
  td.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  td.actions .btn { flex: 1; min-width: 44%; }
  td.right select, td select { max-width: 100%; }
}
