/* ------------------------------------------------------------------
   Edusav DevPanel — shadcn/ui-flavored design system (dark, hand-rolled)
   Single stylesheet. Tokens → reset → typography → components → utilities.
   ------------------------------------------------------------------ */

:root {
  /* base palette — neutral zinc, OKLCH */
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);

  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);

  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);

  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);

  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);

  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);

  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);

  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.985 0 0);

  --success: oklch(0.74 0.15 162);
  --success-foreground: oklch(0.145 0 0);

  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);

  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-lg: calc(var(--radius) + 4px);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.18);
  --shadow:    0 1px 3px 0 rgb(0 0 0 / 0.22), 0 1px 2px -1px rgb(0 0 0 / 0.18);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.28), 0 2px 4px -2px rgb(0 0 0 / 0.22);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* reset */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, blockquote, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; border-spacing: 0; }
a { color: inherit; text-decoration: none; }

html, body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@supports (font-variation-settings: normal) {
  html, body { font-family: "Inter var", var(--font-sans); }
}

/* typography */
.h1 { font-size: 1.5rem;   font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.h2 { font-size: 1.25rem;  font-weight: 600; letter-spacing: -0.02em;  line-height: 1.3; }
.h3 { font-size: 1.0625rem;font-weight: 600; letter-spacing: -0.015em; line-height: 1.35; }
.h4 { font-size: 0.9375rem;font-weight: 600; line-height: 1.4; }
.lead { font-size: 0.9375rem; color: var(--muted-foreground); }
.text-xs   { font-size: 0.75rem; }
.text-sm   { font-size: 0.8125rem; }
.text-base { font-size: 0.875rem; }
.text-muted { color: var(--muted-foreground); }
.text-destructive { color: var(--destructive); }
.text-success { color: var(--success); }
.mono { font-family: var(--font-mono); font-size: 0.85em; }

code, kbd, .code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 4%);
}

/* layout */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.main { padding-block: 2rem; }

.stack    > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: 0.5rem; }
.stack-lg > * + * { margin-top: 1.5rem; }
.stack-xl > * + * { margin-top: 2rem; }

.row         { display: flex; align-items: center; gap: 0.5rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.row-end     { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; }
.wrap        { flex-wrap: wrap; }
.grow        { flex: 1 1 auto; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.page-header p  { color: var(--muted-foreground); font-size: 0.875rem; margin-top: 0.25rem; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklch, var(--background) 80%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--foreground);
}
.brand-logo {
  height: 1.75rem;
  width: auto;
  display: block;
}
.nav {
  display: flex; align-items: center; gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.nav a {
  transition: color 150ms ease;
  position: relative;
  padding: 0.25rem 0;
}
.nav a:hover { color: var(--foreground); }
.nav a.active { color: var(--foreground); }
.nav-sep { width: 1px; height: 1.25rem; background: var(--border); }
.nav form { margin: 0; }

/* button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  height: 2.25rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-foreground);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease,
              border-color 150ms ease, opacity 150ms ease,
              box-shadow 150ms ease, transform 150ms ease;
  user-select: none;
}
.btn:hover { background: color-mix(in oklch, var(--primary) 90%, transparent); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.btn-secondary:hover { background: color-mix(in oklch, var(--secondary) 80%, transparent); }

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}
.btn-destructive:hover { background: color-mix(in oklch, var(--destructive) 88%, transparent); }

.btn-sm   { height: 2rem;    padding: 0 0.75rem; font-size: 0.8125rem; border-radius: calc(var(--radius) - 2px); }
.btn-xs   { height: 1.625rem;padding: 0 0.5rem;  font-size: 0.75rem;   border-radius: calc(var(--radius) - 2px); }
.btn-lg   { height: 2.625rem;padding: 0 1.25rem; font-size: 0.9375rem; }
.btn-block { width: 100%; }
.btn-icon { width: 2.25rem; padding: 0; }

/* input */
.input {
  display: flex;
  align-items: center;
  height: 2.25rem;
  width: 100%;
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background: transparent;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  color: var(--foreground);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.input::placeholder { color: var(--muted-foreground); }
.input:hover { border-color: oklch(1 0 0 / 22%); }
.input:focus-visible, .input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 30%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--destructive); }
.input-sm { height: 2rem; font-size: 0.8125rem; padding: 0 0.625rem; border-radius: calc(var(--radius) - 2px); }

/* select — minimal native restyle */
select.input {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted-foreground) 50%),
    linear-gradient(135deg, var(--muted-foreground) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 50%,
    calc(100% - 9px)  50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

/* label */
.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}
.field { display: block; }
.field-hint { margin-top: 0.375rem; font-size: 0.75rem; color: var(--muted-foreground); }

/* card */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.card-title { font-size: 1rem;  font-weight: 600; letter-spacing: -0.01em; }
.card-description { font-size: 0.8125rem; color: var(--muted-foreground); }
.card-content { padding: 1.25rem 1.5rem; }
.card-header + .card-content { padding-top: 0; }
.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem;
}

/* table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--border);
}
.table { width: 100%; font-size: 0.875rem; }
.table thead th {
  text-align: left;
  padding: 0 1rem;
  height: 2.75rem;
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  background: oklch(1 0 0 / 2%);
}
.table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color 120ms ease; }
.table tbody tr:hover { background: oklch(1 0 0 / 3%); }
.table td.actions { width: 1%; white-space: nowrap; }
.table .td-num { font-variant-numeric: tabular-nums; color: var(--muted-foreground); }

/* badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25;
  border: 1px solid transparent;
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.badge-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--foreground);
}
.badge-muted {
  background: oklch(1 0 0 / 5%);
  color: var(--muted-foreground);
  border-color: var(--border);
}
.badge-primary {
  background: color-mix(in oklch, var(--primary) 18%, transparent);
  color: var(--primary);
  border-color: color-mix(in oklch, var(--primary) 30%, transparent);
}
.badge-destructive {
  background: color-mix(in oklch, var(--destructive) 18%, transparent);
  color: var(--destructive);
  border-color: color-mix(in oklch, var(--destructive) 30%, transparent);
}
.badge-success {
  background: color-mix(in oklch, var(--success) 18%, transparent);
  color: var(--success);
  border-color: color-mix(in oklch, var(--success) 30%, transparent);
}

/* alert */
.alert {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  background: var(--card);
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}
.alert-title { font-weight: 500; }
.alert-body  { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; flex: 1; }
.alert-destructive {
  border-color: color-mix(in oklch, var(--destructive) 50%, transparent);
  background: color-mix(in oklch, var(--destructive) 12%, transparent);
  color: var(--destructive);
}
.alert-success {
  border-color: color-mix(in oklch, var(--success) 45%, transparent);
  background: color-mix(in oklch, var(--success) 12%, transparent);
  color: var(--success);
}
.alert .code,
.alert code {
  background: oklch(1 0 0 / 6%);
  border-color: oklch(1 0 0 / 12%);
  color: var(--foreground);
}

/* separator */
.sep { height: 1px; width: 100%; background: var(--border); border: 0; margin: 0; }

/* modal / dialog */
.modal-backdrop {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 60%);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  animation: modal-fade-in 140ms ease-out;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: modal-scale-in 180ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal-header {
  padding: 1.25rem 1.5rem 0.875rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.modal-title-wrap { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.modal-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.modal-description { font-size: 0.8125rem; color: var(--muted-foreground); }
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem; height: 1.75rem;
  border-radius: 0.375rem;
  color: var(--muted-foreground);
  flex-shrink: 0;
  font-size: 1.125rem;
  line-height: 1;
  transition: background 150ms ease, color 150ms ease;
}
.modal-close:hover { background: var(--accent); color: var(--accent-foreground); }
.modal-body { padding: 0 1.5rem 1.25rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.96) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  gap: 0.5rem;
  color: var(--muted-foreground);
}
.empty .empty-mark {
  width: 2.5rem; height: 2.5rem; border-radius: 0.625rem;
  background: var(--secondary);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 0.25rem;
  font-weight: 700;
  color: var(--secondary-foreground);
}

/* utility */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.w-full { width: 100%; }

/* nav dropdown */
.nav-dropdown { position: relative; }
.nav-trigger {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  height: 2.25rem;
  padding: 0 0.25rem;
  cursor: pointer;
}
.nav-trigger:hover { color: var(--foreground); }
.nav-trigger.active { color: var(--foreground); }
.nav-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 11rem;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.25rem;
  display: none;
  z-index: 50;
}
.nav-dropdown:hover .nav-menu,
.nav-dropdown:focus-within .nav-menu { display: block; }
.nav-menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.nav-menu a + a { margin-top: 2px; }
.nav-menu-right { left: auto; right: 0; }
.nav-user-trigger { display: inline-flex; align-items: center; gap: 0.5rem; }
.nav-menu .nav-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.875rem;
  color: var(--muted-foreground);
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
}
.nav-menu .nav-menu-item:hover { background: var(--accent); color: var(--foreground); }
.nav-menu form + a, .nav-menu a + form { margin-top: 2px; }
.nav-menu a:hover { background: var(--accent); color: var(--foreground); }
.nav-menu a.active { background: var(--accent); color: var(--foreground); }

/* tabs */
.tabs {
  display: inline-flex;
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 0.25rem;
  gap: 0.125rem;
}
.tabs a {
  padding: 0.375rem 0.875rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.tabs a.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

/* progress drawer */
.progress-drawer {
  margin-top: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.progress-drawer .card-header { padding: 0.875rem 1.25rem; }
.progress-events {
  max-height: 22rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.75rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.progress-event {
  display: grid;
  grid-template-columns: 5.5rem 1fr 9rem;
  gap: 0.75rem;
  color: var(--muted-foreground);
}
.progress-event .step { color: var(--foreground); }
.progress-event.success .step { color: var(--success); }
.progress-event.failure .step { color: var(--destructive); }
/* Seed log lines: render the captured stdout/stderr without wrapping in
   a span so long lines preserve whitespace and don't get truncated. */
.progress-event.log .log-line {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--foreground);
}
.progress-event.log.stderr .log-line { color: var(--muted-foreground); }
/* When the progress card is rendered as a full page (Seed flow) the events
   pane should grow with the viewport rather than capping at the drawer height. */
main .progress-drawer { margin-top: 0; }
main .progress-drawer .progress-events { max-height: 70vh; }

/* small text inputs in row */
.row-form { display: flex; gap: 0.375rem; align-items: center; }
.text-tabular { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 0.78rem; }
