/* DatasetAPI Core Design System & Console UI (app.css) */
:root,
html[data-theme="dark"] {
  --bg: #070913;
  --bg-elev: #0d1224;
  --surface: #111830;
  --surface-2: #17203f;
  --surface-glass: rgba(17, 24, 48, 0.72);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(0, 229, 255, 0.35);
  --text: #f1f5f9;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.14);
  --violet: #8b5cf6;
  --violet-dim: rgba(139, 92, 246, 0.16);
  --emerald: #10b981;
  --emerald-dim: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.16);
  --danger: #f43f5e;
  --danger-dim: rgba(244, 63, 94, 0.15);
  --accent: #00e5ff;
  --accent-ink: #041019;
  --grad-brand: linear-gradient(135deg, #00e5ff 0%, #6366f1 52%, #a855f7 100%);
  --grad-glow: radial-gradient(640px circle at var(--mx, 50%) var(--my, 20%), rgba(0, 229, 255, 0.10), rgba(139, 92, 246, 0.05) 40%, transparent 70%);
  --shadow-sm: 0 4px 16px rgba(2, 6, 23, 0.35);
  --shadow-lg: 0 22px 60px rgba(2, 6, 23, 0.62);
  --code-bg: #060914;
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-elev: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --surface-glass: rgba(255, 255, 255, 0.84);
  --border: rgba(15, 23, 42, 0.11);
  --border-strong: rgba(79, 70, 229, 0.38);
  --text: #0b1120;
  --text-soft: #1e293b;
  --muted: #475569;
  --faint: #64748b;
  --cyan: #0284c7;
  --cyan-dim: rgba(2, 132, 199, 0.11);
  --violet: #6d28d9;
  --violet-dim: rgba(109, 40, 217, 0.10);
  --emerald: #059669;
  --emerald-dim: rgba(5, 150, 105, 0.11);
  --amber: #d97706;
  --amber-dim: rgba(217, 119, 6, 0.12);
  --danger: #e11d48;
  --danger-dim: rgba(225, 29, 72, 0.10);
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --grad-brand: linear-gradient(135deg, #0284c7 0%, #4f46e5 55%, #7c3aed 100%);
  --grad-glow: radial-gradient(640px circle at var(--mx, 50%) var(--my, 20%), rgba(79, 70, 229, 0.07), rgba(2, 132, 199, 0.04) 40%, transparent 70%);
  --shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 22px 54px rgba(15, 23, 42, 0.11);
  --code-bg: #0b1021;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  line-height: 1.18;
  margin: 0 0 0.55em;
  color: var(--text);
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: inherit; text-decoration: none; }
code, pre, .num, kbd { font-family: var(--font-mono); }
code {
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--cyan-dim);
  color: var(--cyan);
}
pre.code {
  margin: 0;
  padding: 15px 18px;
  border-radius: 11px;
  background: var(--code-bg);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  font-size: 13px;
  line-height: 1.62;
  overflow-x: auto;
}
pre.code code { background: none; padding: 0; color: inherit; font-size: inherit; }

.wrap { width: min(1240px, calc(100% - 40px)); margin-inline: auto; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.lnk { color: var(--cyan); font-weight: 600; transition: opacity .18s; }
.lnk:hover { opacity: .82; text-decoration: underline; }

.skip {
  position: absolute; left: -9999px; top: 8px; z-index: 999;
  padding: 8px 14px; background: var(--accent); color: var(--accent-ink); border-radius: 8px; font-weight: 700;
}
.skip:focus { left: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600; line-height: 1.2;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; transition: transform .16s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .52; cursor: not-allowed; }
.btn.primary {
  background: var(--grad-brand);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 8px 26px rgba(99, 102, 241, 0.34);
}
.btn.primary:hover:not(:disabled) {
  box-shadow: 0 12px 34px rgba(0, 229, 255, 0.36);
}
.btn.ghost { background: rgba(148, 163, 184, 0.08); border-color: var(--border); }
.btn.danger { background: var(--danger-dim); color: var(--danger); border-color: rgba(244, 63, 94, 0.3); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }

/* Brand */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.03em;
}
.brand i {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad-brand); color: #fff;
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.28);
}
.brand i svg { width: 19px; height: 19px; }
.brand em {
  font-style: normal;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Inputs & Forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-soft); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 13px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  font-family: var(--font-sans); font-size: 14.5px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
textarea.input { font-family: var(--font-mono); font-size: 13px; line-height: 1.55; resize: vertical; min-height: 120px; }
.input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
.input.sm { padding: 7px 11px; font-size: 13.5px; border-radius: 8px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; color: var(--text-soft); cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--cyan); }

/* Cards, Badges, Chips */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card.pad-0 { padding: 0; overflow: hidden; }
.section { margin-bottom: 20px; }
.grid { display: grid; gap: 16px; }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border);
}
.badge.ok, .badge.done { background: var(--emerald-dim); color: var(--emerald); border-color: rgba(16, 185, 129, 0.32); }
.badge.running, .badge.queued { background: var(--cyan-dim); color: var(--cyan); border-color: rgba(0, 229, 255, 0.32); }
.badge.failed, .badge.canceled { background: var(--danger-dim); color: var(--danger); border-color: rgba(244, 63, 94, 0.32); }
.badge.warn { background: var(--amber-dim); color: var(--amber); border-color: rgba(245, 158, 11, 0.32); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border);
  transition: border-color .16s, background .16s, color .16s;
}
.chip em { font-style: normal; color: var(--muted); font-weight: 500; }
.chip small { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.chip:hover, .chip.on { border-color: var(--cyan); background: var(--cyan-dim); color: var(--cyan); }
.chip.c-task { border-color: rgba(139, 92, 246, 0.3); }
.chip.c-task.on { background: var(--violet-dim); border-color: var(--violet); color: #c4b5fd; }

.q-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  background: var(--emerald-dim); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.28);
  white-space: nowrap;
}
.q-pill svg { width: 13px; height: 13px; }
.mini-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 11.5px;
  background: rgba(148, 163, 184, 0.10); color: var(--muted); border: 1px solid var(--border);
}

.alert {
  padding: 11px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  background: var(--danger-dim); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.35);
}
html[data-theme="light"] .alert { color: #be123c; }
.alert.ok { background: var(--emerald-dim); color: var(--emerald); border-color: rgba(16, 185, 129, 0.35); }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th, table.t td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: rgba(148, 163, 184, 0.05); font-weight: 700; }
table.t th small { display: block; text-transform: none; font-family: var(--font-mono); font-weight: 400; color: var(--faint); margin-top: 2px; }
table.t tbody tr:hover { background: rgba(0, 229, 255, 0.03); }
table.t tr[data-href] { cursor: pointer; }

/* Segmented Tabs */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 18px;
}
.seg button {
  padding: 8px 15px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-family: var(--font-sans); font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .16s, color .16s;
}
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }

/* Upload Dropzone & Progress */
.drop {
  border: 1.5px dashed var(--border-strong); border-radius: 14px; padding: 34px 20px;
  text-align: center; background: rgba(0, 229, 255, 0.03); cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop:hover, .drop.drag { border-color: var(--cyan); background: var(--cyan-dim); }
.drop svg { width: 34px; height: 34px; color: var(--cyan); margin-bottom: 8px; }
.progress { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0%; background: var(--grad-brand); transition: width .2s; }

/* Dashboard Shell (app.html) */
.backdrop {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(700px circle at 15% 0%, rgba(0, 229, 255, 0.07), transparent 60%),
              radial-gradient(700px circle at 90% 10%, rgba(139, 92, 246, 0.08), transparent 60%);
}
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--bg-elev); border-right: 1px solid var(--border);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.side-nav { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.side-nav .item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px; transition: background .16s, color .16s;
}
.side-nav .item svg { width: 18px; height: 18px; }
.side-nav .item:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); }
.side-nav .item.on { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0, 229, 255, 0.25); }
.side .foot { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user img, .avatar-ph {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  background: var(--grad-brand); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.main { padding: 30px 36px; max-width: 1200px; width: 100%; }
.page-head { margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; margin-bottom: 4px; }

.stat-card { padding: 18px 20px; border-radius: 13px; background: var(--surface); border: 1px solid var(--border); }
.stat-card small { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-card b { font-family: var(--font-display); font-size: 26px; letter-spacing: -0.02em; }

/* Auth Pages (login.html, signup.html) */
.auth-wrap {
  position: relative; z-index: 1; min-height: 100vh; display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 480px);
}
.auth-showcase {
  padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(900px circle at 20% 20%, rgba(0, 229, 255, 0.13), transparent 55%),
              radial-gradient(800px circle at 80% 80%, rgba(139, 92, 246, 0.16), transparent 55%),
              #050711;
  border-right: 1px solid rgba(148, 163, 184, 0.14);
  color: #f1f5f9;
}
.auth-panel { display: grid; place-items: center; padding: 32px 24px; background: var(--bg); }
.auth-card { width: min(410px, 100%); }
.or {
  display: flex; align-items: center; gap: 12px; margin: 18px 0;
  color: var(--faint); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.08em;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.empty { padding: 48px 22px; text-align: center; color: var(--muted); }
.spinner {
  display: inline-block; width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--cyan);
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side .foot { border-top: 0; padding-top: 0; margin-left: auto; flex-direction: row; }
  .main { padding: 20px 16px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-showcase { display: none; }
  .grid.g2, .grid.g3, .grid.g4 { grid-template-columns: 1fr; }
}
