/* Shineon Batch console — self-contained, no third-party assets (strict CSP).
   Design system: ported from new-api's shadcn "base-nova" theme (web/src/styles/
   theme.css) so the console reads as part of the same product family. Tokens are
   copied verbatim (oklch); components hand-rolled to the same recipes. */

/* ---------- tokens (new-api light) ---------- */
:root {
  --radius: 1rem;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);

  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --primary: oklch(0.692 0.141 243.716);
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.95 0 0);
  --secondary-foreground: oklch(0.42 0.16 250);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.49 0 0);
  --accent: color-mix(in oklch, var(--primary) 12%, var(--background));
  --accent-foreground: oklch(0.145 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --success: oklch(0.596 0.145 163.225);
  --warning: oklch(0.681 0.162 75.834);
  --info: oklch(0.588 0.158 241.966);
  --border: oklch(0.93 0 0);
  --input: oklch(0.93 0 0);
  --ring: oklch(0.708 0.16 249.003);
  --sidebar: color-mix(in oklch, var(--foreground) 0.5%, var(--background));
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-accent: color-mix(in oklch, var(--primary) 12%, var(--background));
  --sidebar-accent-foreground: oklch(0.579 0.196 255.909);
  --sidebar-border: oklch(0.93 0 0);
  --table-header: color-mix(in oklch, var(--foreground) 1.5%, var(--background));
  --table-hover: color-mix(in oklch, var(--foreground) 3%, var(--background));

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px 0 oklch(0 0 0 / 0.05);
}

/* ---------- tokens (new-api dark: "OpenAI-like charcoal") ---------- */
.dark {
  --background: oklch(0.235 0 0);
  --foreground: oklch(0.965 0 0);
  --card: oklch(0.285 0 0);
  --card-foreground: oklch(0.965 0 0);
  --primary: oklch(0.54 0.142 248.516);
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.335 0 0);
  --secondary-foreground: oklch(0.9 0.05 250);
  --muted: oklch(0.305 0 0);
  --muted-foreground: oklch(0.78 0 0);
  --accent: color-mix(in oklch, var(--primary) 20%, var(--background));
  --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.696 0.17 162.48);
  --warning: oklch(0.769 0.188 70.08);
  --info: oklch(0.613 0.14 239.919);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 17%);
  --ring: oklch(0.554 0.148 250.726);
  --sidebar: oklch(0.225 0 0);
  --sidebar-foreground: oklch(0.95 0 0);
  --sidebar-accent: color-mix(in oklch, var(--primary) 20%, var(--background));
  --sidebar-accent-foreground: oklch(0.9 0.05 250);
  --sidebar-border: oklch(1 0 0 / 11%);
  --table-header: color-mix(in oklch, var(--foreground) 6%, var(--background));
  --table-hover: color-mix(in oklch, var(--foreground) 9%, var(--background));
  --shadow-sm: 0 1px 2px 0 oklch(0 0 0 / 0.3);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--background); color: var(--foreground);
  font: 14px/1.55 var(--font-sans);
  display: grid; grid-template-columns: auto 1fr;
  -webkit-font-smoothing: antialiased;
}
/* Signed out the sidebar is [hidden] and leaves the grid — collapse its column or
   main lands left-aligned in the `auto` track. */
body:has(> aside[hidden]) { grid-template-columns: 1fr; }
/* Author display rules outweigh the UA [hidden] mapping — without this the
   signed-out sidebar keeps showing the last session's nav (see 7d219f1). */
[hidden] { display: none !important; }

h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 16px; }
h2 { font-size: 15px; font-weight: 600; margin: 24px 0 10px; }
.muted { color: var(--muted-foreground); }
.mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
svg.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sidebar shell ---------- */
aside#topbar {
  display: flex; flex-direction: column; width: 232px; min-height: 100vh;
  position: sticky; top: 0; height: 100vh;
  background: var(--sidebar); color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border); padding: 12px;
}
.brand {
  display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; padding: 6px 8px 16px;
}
.brand .logo {
  width: 28px; height: 28px; border-radius: 999px; flex: none;
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-foreground);
  font-size: 13px; font-weight: 700;
}
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted-foreground); font-weight: 500;
  padding: 7px 10px; border-radius: var(--radius-md);
}
nav a:hover { text-decoration: none; background: var(--table-hover); color: var(--foreground); }
nav a.active { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.spacer { flex: 1; }
.side-foot { border-top: 1px solid var(--sidebar-border); padding-top: 10px;
  display: flex; flex-direction: column; gap: 6px; }
#whoami {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px;
  font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis;
}
#whoami::before {
  content: ""; width: 24px; height: 24px; flex: none; border-radius: 999px;
  background: color-mix(in oklch, var(--primary) 24%, var(--background));
  outline: 1px solid var(--border);
}
.side-actions { display: flex; align-items: center; gap: 2px; }

/* ---------- content ---------- */
main { min-width: 0; max-width: 1080px; width: 100%; margin: 0 auto;
  padding: 28px 32px 72px; }

/* ---------- buttons (new-api: h-8, rounded-lg, text-sm medium) ---------- */
button, .btn {
  font: inherit; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--background);
  color: var(--foreground); cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.dark button, .dark .btn { border-color: var(--input);
  background: color-mix(in oklch, var(--input) 30%, transparent); }
button:hover { background: var(--muted); }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}
button.primary { background: var(--primary); border-color: transparent;
  color: var(--primary-foreground); }
button.primary:hover { background: color-mix(in oklch, var(--primary) 85%, var(--foreground) 6%); }
button.danger { background: color-mix(in oklch, var(--destructive) 10%, transparent);
  border-color: transparent; color: var(--destructive); }
button.danger:hover { background: color-mix(in oklch, var(--destructive) 20%, transparent); }
button.ghost { border-color: transparent; background: none; color: var(--muted-foreground); }
button.ghost:hover { background: var(--table-hover); color: var(--foreground); }
button.icon { width: 32px; padding: 0; }
button:disabled { opacity: .5; pointer-events: none; }

/* ---------- forms ---------- */
input, select {
  font: inherit; font-size: 14px; height: 36px;
  border: 1px solid var(--input); border-radius: var(--radius-md);
  padding: 0 12px; background: var(--background); color: var(--foreground);
  width: 100%; transition: border-color .12s, box-shadow .12s;
}
.dark input, .dark select { background: color-mix(in oklch, var(--input) 30%, transparent); }
input[type="file"] { padding: 6px 12px; height: auto; }
input::placeholder { color: var(--muted-foreground); }
select { appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 500; }

/* ---------- cards / panels ---------- */
.panel {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}

/* ---------- tables ---------- */
.panel:has(> table) { padding: 6px 8px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 9px 12px; }
th { color: var(--muted-foreground); font-weight: 500; font-size: 12.5px;
  background: var(--table-header); border-bottom: 1px solid var(--border); }
th:first-child { border-top-left-radius: var(--radius-md); }
th:last-child { border-top-right-radius: var(--radius-md); }
td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td, tbody tr:hover td { background: var(--table-hover); }

/* ---------- badges (shadcn soft variants) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--muted); color: var(--muted-foreground);
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px;
  background: currentColor; }
.badge.b-running, .badge.b-submitting {
  background: color-mix(in oklch, var(--info) 12%, transparent); color: var(--info); }
.badge.b-success {
  background: color-mix(in oklch, var(--success) 12%, transparent); color: var(--success); }
.badge.b-partial, .badge.b-expired {
  background: color-mix(in oklch, var(--warning) 14%, transparent); color: var(--warning); }
.badge.b-failure, .badge.b-cancelled {
  background: color-mix(in oklch, var(--destructive) 12%, transparent); color: var(--destructive); }

/* ---------- alerts ---------- */
.error-box {
  background: color-mix(in oklch, var(--destructive) 8%, var(--background));
  border: 1px solid color-mix(in oklch, var(--destructive) 25%, transparent);
  color: var(--destructive);
  border-radius: var(--radius-md); padding: 10px 14px; margin: 12px 0;
  white-space: pre-wrap; font-size: 13.5px;
}
.note-box {
  background: color-mix(in oklch, var(--info) 8%, var(--background));
  border: 1px solid color-mix(in oklch, var(--info) 25%, transparent);
  border-radius: var(--radius-md); padding: 12px 16px; margin: 12px 0;
}

/* ---------- stats ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; }
.stat { background: var(--muted); border-radius: var(--radius-md); padding: 12px 16px; }
.panel.statgrid { background: transparent; border: none; box-shadow: none; padding: 0; }
.panel.statgrid .stat { background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); border-radius: var(--radius-lg); padding: 14px 18px; }
.stat .v { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat .k { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }

/* ---------- misc ---------- */
.actions { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.field-row { display: flex; gap: 12px; align-items: end; }
.field-row > div { flex: 1; }
.keysecret {
  font-family: var(--mono); font-size: 13.5px; background: var(--muted);
  border: 1px solid var(--border);
  padding: 10px 12px; border-radius: var(--radius-md); word-break: break-all;
  user-select: all; margin-top: 8px;
}
.steps .step { opacity: .45; }
.steps .step.on { opacity: 1; }

/* ---------- login (new-api auth-layout: brand top-left, centered column) ---------- */
.login-wrap { grid-column: 1 / -1; min-height: 100vh; display: grid; }
.login-brand { position: absolute; top: 24px; left: 28px;
  display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; }
.login-brand .logo { width: 32px; height: 32px; border-radius: 999px;
  display: grid; place-items: center; background: var(--primary);
  color: var(--primary-foreground); font-size: 14px; font-weight: 700; }
.login-box { width: 100%; max-width: 420px; margin: auto; padding: 24px; }
.login-box h1 { font-size: 22px; margin: 0 0 4px; }
.login-box .panel { padding: 24px; }
.login-actions { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }

/* ---------- responsive: sidebar becomes a top bar ---------- */
@media (max-width: 768px) {
  body { grid-template-columns: 1fr; }
  aside#topbar {
    position: sticky; top: 0; z-index: 5; width: 100%; height: auto; min-height: 0;
    flex-direction: row; align-items: center; gap: 4px;
    border-right: none; border-bottom: 1px solid var(--sidebar-border);
    padding: 8px 10px; overflow-x: auto;
  }
  .brand { padding: 0 6px; }
  .brand .name { display: none; }
  nav { flex-direction: row; gap: 2px; }
  nav a { padding: 6px 9px; white-space: nowrap; }
  nav a .nav-label { display: none; }
  nav a svg.ic { width: 18px; height: 18px; }
  .side-foot { border-top: none; padding-top: 0; flex-direction: row; align-items: center; }
  #whoami { display: none; }
  /* Icon-only sign-out on the narrow bar; the svg keeps its own size. */
  #signout { font-size: 0; gap: 0; width: 32px; padding: 0; }
  main { padding: 16px 12px 48px; }
  /* Tables pan inside their card — the page itself must never scroll sideways. */
  .panel { overflow-x: auto; }
  .panel table { min-width: 560px; }
  th, td { white-space: nowrap; }
  .login-brand { top: 16px; left: 16px; }
}
