/* ============================================================
   GTY Pipeline Control — design system v2
   Dark control-room · GTY teal identity · fully responsive
   Same class contract as v1: all pages re-skin automatically.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* base */
  --bg:        #0A0F16;
  --panel:     #111826;
  --panel-2:   #16202F;
  --card-2:    rgba(255,255,255,.02);
  --border:    #1F2A3A;
  --border-2:  #2C3A4E;
  /* text */
  --text:      #E8EDF4;
  --fg:        #E8EDF4;
  --muted:     #8294A8;
  --dim:       #4A566880;
  /* status */
  --amber:     #F5B84D;
  --green:     #37D99A;
  --red:       #F26D85;
  --blue:      #4EA8DE;
  --violet:    #8B7CF6;
  /* brand */
  --teal:      #00E5C0;
  --teal-dim:  #00E5C022;
  --accent:    #00E5C0;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 10px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.45);
  --sidebar-w: 230px;
  --topbar-h: 54px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100%;
}
::selection { background: var(--teal-dim); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .86em; background: var(--panel-2);
       border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; }
h1 { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: .2px; }
h2 { font-family: var(--display); font-size: 17px; font-weight: 600; }
h3 { font-family: var(--display); font-size: 12px; font-weight: 600; text-transform: uppercase;
     letter-spacing: .12em; color: var(--muted); }

/* ---- scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px;
  border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* ============ SHELL ============ */
.shell { display: flex; min-height: 100vh; }

/* ---- sidebar ---- */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--panel) 0%, #0D1420 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: 40;
}
.brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand .logo { font-family: var(--display); font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 9px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green);
  transition: background .3s, box-shadow .3s; }
.brand .sub { font-family: var(--mono); font-size: 10px; color: var(--dim);
  margin-top: 5px; letter-spacing: .08em; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.nav { padding: 12px 10px; flex: 1; }
.nav .label { font-size: 10px; text-transform: uppercase; letter-spacing: .16em;
  color: var(--dim); padding: 12px 10px 6px; }
.nav .divider { height: 1px; background: var(--border); margin: 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin: 1px 0; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s; text-decoration: none;
  border-left: 2px solid transparent;
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--teal-dim); color: var(--accent);
  border-left-color: var(--accent); }
.nav .ic { width: 16px; height: 16px; flex: 0 0 16px; opacity: .85; }
.sidebar .footer { padding: 14px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); }
.sidebar .footer a { color: var(--muted); }
.sidebar .footer a:hover { color: var(--red); text-decoration: none; }

/* mobile drawer backdrop */
.backdrop { display: none; position: fixed; inset: 0; background: rgba(4,8,14,.6);
  backdrop-filter: blur(2px); z-index: 39; }
.backdrop.show { display: block; }

/* ---- main / topbar ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 30;
}
.menu-toggle { display: none; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  width: 34px; height: 34px; align-items: center; justify-content: center;
  cursor: pointer; }
.page-title { font-family: var(--display); font-weight: 600; font-size: 14px;
  color: var(--muted); letter-spacing: .04em; }
.vitals { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.vital { display: flex; align-items: center; gap: 7px; font-family: var(--mono);
  font-size: 11px; color: var(--muted); }
.vital .k { color: var(--dim); letter-spacing: .06em; }
.vital .bar { width: 52px; height: 5px; background: var(--panel-2);
  border-radius: 3px; overflow: hidden; }
.vital .bar span { display: block; height: 100%; background: var(--accent);
  border-radius: 3px; transition: width .5s ease; }
.vital .bar span.warn { background: var(--amber); }
.vital .bar span.crit { background: var(--red); }
.vital .v { min-width: 30px; color: var(--text); }
.content { padding: 22px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ============ PAGE PRIMITIVES ============ */
.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: 5px; }
.page-head p { color: var(--muted); font-size: 13px; max-width: 760px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, #0F1622 130%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow);
  min-width: 0;
}
.card.pad-lg { padding: 19px 21px; }
.card > h3 { margin-bottom: 4px; }

.stat { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.stat .num { font-family: var(--display); font-size: 30px; font-weight: 700;
  line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .num.green { color: var(--green); } .stat .num.amber { color: var(--amber); }
.stat .num.red { color: var(--red); }   .stat .num.blue { color: var(--accent); }
.stat .lbl { font-size: 11.5px; color: var(--muted); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px; border: 1px solid; white-space: nowrap; }
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; }
.pill.pending    { color: var(--accent); border-color: #00e5c055; background: #00e5c012; }
.pill.done, .pill.complete { color: var(--green); border-color: #37d99a55; background: #37d99a12; }
.pill.inprogress, .pill.rendering, .pill.assembled, .pill.started, .pill.scripting,
.pill.in-progress { color: var(--amber); border-color: #f5b84d55; background: #f5b84d12; }
.pill.failed, .pill.error { color: var(--red); border-color: #f26d8555; background: #f26d8512; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--display); font-size: 13px; font-weight: 600;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--panel-2);
  color: var(--text); cursor: pointer; transition: all .15s; user-select: none; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04231C; }
.btn.primary:hover { filter: brightness(1.1); color: #04231C; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* forms */
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--border-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 11px; font-size: 13px;
  font-family: var(--sans); transition: border-color .15s, box-shadow .15s;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none;
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--teal-dim); }
textarea { width: 100%; font-family: var(--mono); line-height: 1.55; resize: vertical; }
select { cursor: pointer; }

/* layout helpers */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mb-16 { margin-bottom: 16px; } .mt-16 { margin-top: 16px; }
.mono { font-family: var(--mono); } .small { font-size: 12px; }
.muted { color: var(--muted); }

/* terminal */
.terminal { background: #070B11; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; overflow-y: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.7; }
.terminal .line { display: block; white-space: pre-wrap; word-break: break-word; }
.terminal .line.ok { color: var(--green); }
.terminal .line.err { color: var(--red); }
.terminal .line.warn { color: var(--amber); }
.terminal .line.info { color: #9FB2C8; }
.terminal .line.meta { color: var(--dim); }

/* render banner + pipeline rail (overview) */
.render-banner { display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 17px; margin-bottom: 16px; }
.render-banner .pulse { width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); flex: 0 0 10px; }
.render-banner.active { border-color: #f5b84d55; }
.render-banner.active .pulse { background: var(--amber);
  animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 #f5b84d66; }
  50% { box-shadow: 0 0 0 8px transparent; } }
.render-banner .txt { min-width: 0; }
.render-banner .st { font-weight: 600; font-family: var(--display); }
.render-banner .dt { font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.render-banner .btn { margin-left: auto; flex: 0 0 auto; }

.pipeline { display: flex; align-items: center; gap: 4px;
  margin-bottom: 18px; overflow-x: auto; padding-bottom: 4px; }
.pipeline .stage { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 84px; }
.pipeline .stage::after { content: ''; flex: 1; height: 2px;
  background: var(--border); min-width: 10px; }
.pipeline .stage:last-child::after { display: none; }
.pipeline .node { width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border-2); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10.5px; flex: 0 0 28px;
  background: var(--panel); }
.pipeline .name { font-size: 11px; color: var(--muted); white-space: nowrap; }
.pipeline .stage.done .node { border-color: var(--green); color: var(--green); }
.pipeline .stage.done::after { background: #37d99a55; }
.pipeline .stage.active .node { border-color: var(--amber); color: var(--amber);
  box-shadow: 0 0 10px #f5b84d44; animation: pulse 1.6s infinite; }
.pipeline .stage.active .name { color: var(--amber); }

/* toasts */
.toast-wrap { position: fixed; bottom: 18px; right: 18px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel-2); border: 1px solid var(--border-2);
  border-left: 3px solid var(--accent); color: var(--text);
  padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13px;
  box-shadow: var(--shadow-lg); max-width: 340px; opacity: 1;
  transition: opacity .3s; animation: slidein .25s ease; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* ---- toolbar (search + segmented filters, used by topics/content v2) ---- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  position: sticky; top: var(--topbar-h); z-index: 20;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 10px 12px; margin: 0 -6px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); }
.toolbar .search { flex: 1; min-width: 170px; position: relative; }
.toolbar .search input { width: 100%; padding-left: 32px; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); width: 14px; height: 14px; color: var(--dim); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted);
  font-family: var(--display); font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--teal-dim); color: var(--accent); }
.seg button .n { font-family: var(--mono); font-size: 10px; opacity: .75; margin-left: 4px; }

/* queue rows */
.q-row { display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border); }
.q-row:last-child { border-bottom: 0; }
.q-row .idx { font-family: var(--mono); font-size: 10.5px; color: var(--dim);
  min-width: 26px; padding-top: 2px; }
.q-row .body { flex: 1; min-width: 0; }
.q-row .t { font-size: 13.5px; font-weight: 500; }
.q-row .k { font-size: 11.5px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.q-row .k.open { white-space: normal; }
.q-row.next { background: linear-gradient(90deg, var(--teal-dim), transparent 60%);
  border-radius: var(--radius-sm); }
.q-row.next .idx { color: var(--accent); }
details.adv { border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card-2); margin-top: 16px; }
details.adv > summary { cursor: pointer; padding: 13px 17px;
  font-family: var(--display); font-weight: 600; font-size: 13px;
  color: var(--muted); list-style: none; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: '▸ '; color: var(--dim); }
details.adv[open] > summary::before { content: '▾ '; }
details.adv .inner { padding: 0 17px 17px; }
.empty { text-align: center; color: var(--dim); padding: 32px 10px; font-size: 13px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1120px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 920px) {
  .grid.cols-2 { grid-template-columns: 1fr; }
  .vital .bar { display: none; }
  .content { padding: 16px 14px; }
}
@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg); width: 250px; flex-basis: 250px; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
}
@media (max-width: 560px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .num { font-size: 24px; }
  .page-title { display: none; }
  .vitals { gap: 10px; }
  .vital .k { display: none; }
  .toolbar { top: calc(var(--topbar-h)); }
  .content { padding: 13px 11px; }
  .card, .card.pad-lg { padding: 13px 14px; }
  .row .btn { flex-shrink: 0; }
}
