/* VelaClip Cloud console — dependency-free; themed with the VelaClip design
   system (web-ui/src/index.css in DESIR33/velaclip): near-black "OpusClip"
   dark chrome by default, warm paper light theme, fixed teal-green brand
   accent (#16C2AD), Fraunces headings + Lora body, radii 8/12/18.
   Legacy token names (--surface-1/2/3, --text-*, --status-*) are kept as the
   public contract for app.js and inline SVG charts. */

@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/Lora.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* VelaClip core tokens (dark is the baseline theme) */
  --background: #0A0A0A;
  --surface: #161615;
  --surface-sunken: #050504;
  --foreground: #F4F2ED;
  --muted-foreground: #9A958B;
  --accent: #16C2AD;
  --accent-foreground: #07120E;
  --accent-hover: #3FE0CD;
  --success: #54B36A;
  --warning: #D6A23E;
  --destructive: #D85F54;

  /* Legacy aliases consumed by app.js + charts */
  --surface-1: var(--surface);
  --surface-2: var(--background);
  --surface-3: var(--surface-sunken);
  --border: #2A2A27;
  --text-primary: var(--foreground);
  --text-secondary: #B7B2A8;
  --text-muted: var(--muted-foreground);
  --accent-soft: rgba(22, 194, 173, 0.14);
  --series-1: var(--accent);
  --seq-300: #0E8A7B;
  --seq-450: var(--accent);
  --status-good: var(--success);
  --status-good-soft: rgba(84, 179, 106, 0.16);
  --status-serious: var(--destructive);
  --status-serious-soft: rgba(216, 95, 84, 0.16);
  --status-warning: var(--warning);
  --status-warning-soft: rgba(214, 162, 62, 0.16);
  --status-neutral: #B7B2A8;
  --status-neutral-soft: rgba(183, 178, 168, 0.12);

  /* Type + shape + motion */
  --font-heading: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Lora", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius: var(--radius-sm);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

[data-theme="light"] {
  color-scheme: light;
  --background: #FBFAF7;
  --surface: #FFFFFF;
  --surface-sunken: #F1EEE7;
  --foreground: #1A1916;
  --muted-foreground: #6B6A63;
  --accent: #16C2AD;
  --accent-foreground: #06231D;
  --accent-hover: #0FA796;
  --success: #2E9E52;
  --warning: #B9802A;
  --destructive: #C9483E;

  --border: #E4DFD5;
  --text-secondary: #55534C;
  --accent-soft: rgba(22, 194, 173, 0.14);
  --seq-300: #63D6C6;
  --status-good-soft: rgba(46, 158, 82, 0.13);
  --status-serious-soft: rgba(201, 72, 62, 0.12);
  --status-warning-soft: rgba(185, 128, 42, 0.14);
  --status-neutral: #55534C;
  --status-neutral-soft: rgba(85, 83, 76, 0.10);
  --shadow-sm: 0 1px 2px rgba(20, 20, 18, 0.05), 0 1px 3px rgba(20, 20, 18, 0.08);
  --shadow-md: 0 4px 16px rgba(20, 20, 18, 0.10);
  --shadow-lg: 0 12px 40px rgba(20, 20, 18, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* Chromium skips the UA [hidden] rule for inline <svg> roots */
html, body { margin: 0; padding: 0; }
html {
  background: var(--background);
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out);
}
body {
  font: 14.5px/1.55 var(--font-body);
  background: var(--background);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); letter-spacing: -0.01em; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-foreground); padding: 8px 12px; z-index: 100;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); font-weight: 600;
}
.skip-link:focus { left: 8px; }

.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }

/* Sidebar — Linear/Vercel-style rail per the VelaClip Sidebar component:
   muted by default, sunken highlight + accent icon on the active item. */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; padding: 0 6px 6px; }
.brand img { height: 30px; width: auto; display: block; }
.brand img.logo-light { display: none; }
[data-theme="light"] .brand img.logo-light { display: block; }
[data-theme="light"] .brand img.logo-dark { display: none; }

.workspace-chip {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 2px 14px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.workspace-chip img { width: 22px; height: 22px; }
.workspace-chip .ws-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.workspace-chip .ws-meta { font-size: 11px; color: var(--text-muted); }

.nav-eyebrow {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); padding: 10px 10px 6px;
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  color: var(--text-muted); text-decoration: none; font-size: 13.5px;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.nav-item .nav-icon {
  width: 16px; height: 16px; flex: 0 0 16px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; opacity: 0.85;
}
.nav-item:hover { background: var(--surface-sunken); color: var(--text-primary); }
.nav-item.active { background: var(--surface-sunken); color: var(--text-primary); font-weight: 600; }
.nav-item.active .nav-icon { stroke: var(--accent); opacity: 1; }
.nav-item.is-external { color: var(--text-muted); cursor: not-allowed; opacity: 0.55; }
.nav-sub { padding-left: 34px; font-size: 12.5px; }
.nav-divider { border: 0; border-top: 1px solid var(--border); margin: 12px 6px; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--border); }

.content { padding: 28px 32px 48px; max-width: 1240px; min-width: 0; }
.content:focus { outline: none; }

/* Screen entrance — VelaClip's screen-in (fade + 6px rise). Re-triggers on
   every route render because #view's children are replaced. */
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
#view > * { animation: screen-in var(--duration-base) var(--ease-out) both; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 15.5px; font-weight: 600; margin: 20px 0 8px; }
.subtitle { color: var(--text-secondary); margin: 0 0 18px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* Execution-mode banner (was inline-styled; now token-driven). */
.mode-banner {
  display: block; margin-bottom: 14px; padding: 9px 14px;
  border-radius: var(--radius-md); font-weight: 600; letter-spacing: 0.03em;
  font-size: 13px; border: 1px solid;
}
.mode-banner.mode-real { background: var(--status-good-soft); color: var(--status-good); border-color: var(--status-good); }
.mode-banner.mode-simulation { background: var(--status-warning-soft); color: var(--status-warning); border-color: var(--status-warning); }
.exec-real { color: var(--status-good); font-weight: 700; }
.exec-sim { color: var(--status-warning); font-weight: 700; }

.btn {
  font: inherit; font-weight: 500; padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-primary); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  user-select: none;
  transition: background-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  text-decoration: none;
}
.btn:hover { background: var(--surface-sunken); color: var(--text-primary); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-foreground); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-foreground); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-sm { padding: 3px 10px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border); padding: 6px 8px; font-weight: 600;
}
table.data td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-sunken); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-body);
  font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 9999px;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.succeeded, .chip.done { color: var(--status-good); background: var(--status-good-soft); }
.chip.failed { color: var(--status-serious); background: var(--status-serious-soft); }
.chip.running, .chip.queued { color: var(--accent); background: var(--accent-soft); }
.chip.cancelled, .chip.skipped, .chip.pending { color: var(--status-neutral); background: var(--status-neutral-soft); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.field-inline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
input, select, textarea {
  font: inherit; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-sunken); color: var(--text-primary);
  max-width: 480px;
  transition: border-color var(--duration-fast) var(--ease-out);
}
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
textarea { font-family: var(--mono); font-size: 12px; min-height: 84px; max-width: 640px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; }

/* Live view pipeline — GitHub-Actions/Databricks-style step list. */
.pipeline { display: flex; flex-direction: column; }
.stage-card { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-sunken); }
.stage-card + .stage-card { margin-top: 0; }
.stage-connector { width: 2px; height: 14px; background: var(--border); margin-left: 26px; }
.stage-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  width: 100%; background: transparent; border: 0; text-align: left;
  font: inherit; color: inherit; cursor: pointer; border-radius: var(--radius-md);
}
.stage-head:hover { background: var(--surface); }
.stage-name { font-weight: 600; flex: 0 0 220px; }
.stage-meta { color: var(--text-secondary); font-size: 12px; display: flex; gap: 14px; flex: 1; flex-wrap: wrap; font-family: var(--mono); }
.stage-body { border-top: 1px solid var(--border); padding: 12px 14px; }
.stage-actions { margin-left: auto; display: flex; gap: 6px; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; word-break: break-word; }

pre.json, pre.log {
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; font-family: var(--mono); font-size: 12px; overflow: auto;
  max-height: 320px; white-space: pre-wrap; word-break: break-word;
}
.log-line { display: block; }
.log-line .lvl-warn { color: var(--status-warning); }
.log-line .lvl-error { color: var(--status-serious); }

/* Tabs — VelaClip underline style: quiet labels, accent underline bar. */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  font: inherit; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px; color: var(--text-muted); cursor: pointer;
  margin-bottom: -1px;
  transition: color var(--duration-fast) var(--ease-out);
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm);
}
.tile .tile-value { font-family: var(--font-heading); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.tile .tile-label { font-size: 12px; color: var(--text-secondary); }

.chart-wrap { overflow-x: auto; }
.chart-tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 9px; font-size: 12px; box-shadow: var(--shadow-md);
}

.diff-added { color: var(--status-good); }
.diff-removed { color: var(--status-serious); text-decoration: line-through; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }

.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 60;
  background: var(--foreground); color: var(--background);
  padding: 10px 16px; border-radius: var(--radius-md); max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.empty { color: var(--text-muted); padding: 22px; text-align: center; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.error-banner {
  background: var(--status-serious-soft); color: var(--status-serious);
  border: 1px solid var(--status-serious); border-radius: var(--radius-md);
  padding: 10px 12px; margin-bottom: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  .sidebar .nav-list { flex-direction: row; flex-wrap: wrap; }
  .sidebar .workspace-chip, .sidebar .nav-eyebrow { display: none; }
  .sidebar-footer { margin-top: 0; flex-direction: row; border-top: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .stage-name { flex-basis: 130px; }
  .content { padding: 20px 16px 40px; }
}
