/* Maestro LOS visual layer aligned to Vieglin brand tokens. */

:root {
  color-scheme: dark;
  --bg: #060d2e;
  --bg-deep: #02061a;
  --panel: rgba(2, 6, 26, 0.72);
  --panel-2: rgba(5, 11, 38, 0.72);
  --line: rgba(125, 211, 252, 0.15);
  --line-strong: rgba(125, 211, 252, 0.24);
  --text: #f0f9ff;
  --muted: #c7d8f5;
  --dim: rgba(199, 216, 245, 0.58);
  --accent: #38bdf8;
  --accent-deep: #2563eb;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --brand-grad: linear-gradient(115deg, #7dd3fc, #38bdf8 45%, #3b82f6);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 24px 60px rgba(2, 6, 26, 0.48);
  --font: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Geist Mono', 'Geist', 'Inter', ui-monospace, monospace;
  font-family: var(--font);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(900px 520px at 50% -14%, rgba(56, 189, 248, 0.11), transparent 62%),
    linear-gradient(rgba(56, 189, 248, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, var(--bg-deep) 0%, #050b26 48%, var(--bg) 100%);
  background-size: auto, 48px 48px, 48px 48px, auto;
  background-attachment: fixed;
}
.three-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  opacity: 0.36;
}
::selection { background: rgba(56, 189, 248, 0.32); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

button, select { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.6; }
h1, h2, p { margin: 0; }
button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.55);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* ---------- Top bar ---------- */

#topbar {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 9px 26px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(2, 6, 26, 0.94), rgba(2, 6, 26, 0.78));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
}
.brand { grid-column: 1; display: inline-flex; width: fit-content; }
.brand-logo {
  display: block;
  height: 60px;
  width: auto;
  filter: drop-shadow(0 4px 14px rgba(37, 99, 235, 0.35));
}
.masthead { grid-column: 2; display: grid; justify-items: center; gap: 3px; text-align: center; }
.masthead-eyebrow {
  font-family: var(--font);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(125, 211, 252, 0.72);
  white-space: nowrap;
}
#topbar h1 {
  font-family: var(--font);
  font-size: 1.22rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: #f4f7fb;
}
.auth-action,
.primary-action {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}
.auth-action:hover,
.primary-action:hover {
  border-color: rgba(56, 189, 248, 0.48);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}
.auth-action {
  min-height: 30px;
  padding: 0 10px;
}
.primary-action {
  width: fit-content;
  min-height: 38px;
  padding: 0 14px;
}

.user-chip {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 6px 13px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.avatar {
  position: relative;
  display: inline-grid;
  padding: 2px;
  border-radius: 50%;
  background: conic-gradient(from 220deg, #7dd3fc, #2563eb, #38bdf8, #7dd3fc);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}
.avatar-core {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: #0a1320;
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #bae6fd;
}
.avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid #0a1320;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.75);
}

.auth-denied[hidden] {
  display: none;
}
.auth-denied {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(248, 113, 113, 0.34);
  border-radius: var(--radius);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
}
.user-meta small, .user-meta strong { display: block; line-height: 1.18; }
.user-meta small { color: var(--muted); font-size: 0.66rem; }
.user-meta strong { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.01em; }

/* ---------- Layout ---------- */

#main { position: relative; z-index: 1; width: min(1440px, calc(100% - 36px)); margin: 0 auto; padding: 24px 0 44px; }

.control-strip {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.field { display: grid; gap: 7px; }
.field > span {
  color: var(--dim);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.select-wrap { position: relative; display: inline-flex; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-68%) rotate(45deg);
  pointer-events: none;
}
#shift-select {
  appearance: none;
  -webkit-appearance: none;
  width: 230px;
  height: 38px;
  padding: 0 34px 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  font-family: var(--font);
  font-size: 0.8rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
#shift-select:hover { border-color: rgba(56, 189, 248, 0.4); }
#shift-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16); }
#shift-select option { background: #0d1524; font-family: var(--font); }

.health-row { display: inline-flex; align-items: center; justify-content: flex-end; gap: 9px; }
.health-summary {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: 0;
}
.api-token-form {
  display: inline-grid;
  grid-template-columns: minmax(136px, 176px) 38px 38px;
  gap: 7px;
  align-items: center;
}
.api-token-input {
  width: 100%;
  height: 38px;
  min-width: 0;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.api-token-input::placeholder { color: var(--dim); font-family: var(--font); }
.api-token-input:focus {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
.has-api-token .api-token-input {
  border-color: rgba(52, 211, 153, 0.32);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 7px rgba(251, 191, 36, 0.7);
}
.status-pill.is-ok { color: #a7f3d0; border-color: rgba(52, 211, 153, 0.28); }
.status-pill.is-ok::before {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.8);
  animation: pulse 2.6s ease-in-out infinite;
}
.status-pill.is-warn { color: #fde68a; border-color: rgba(251, 191, 36, 0.3); }
.status-pill.is-err { color: #fecaca; border-color: rgba(248, 113, 113, 0.34); }
.status-pill.is-err::before {
  background: var(--err);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.78);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  50% { box-shadow: 0 0 0 4px rgba(52, 211, 153, 0); }
}
.refresh-stamp {
  color: var(--dim);
  font-family: var(--font);
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  color: var(--muted);
  transition: border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.icon-button .icon { display: grid; place-items: center; }
.icon-button .icon svg { width: 15px; height: 15px; }
.icon-button:hover { border-color: rgba(56, 189, 248, 0.5); color: #7dd3fc; box-shadow: 0 0 16px rgba(56, 189, 248, 0.18); }
.icon-button.is-loading .icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- KPI cards ---------- */

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  position: relative;
  overflow: hidden;
  min-height: 122px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.kpi-top { display: flex; align-items: center; gap: 9px; }
.kpi-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  background: rgba(56, 189, 248, 0.09);
  color: #7dd3fc;
}
.kpi-icon svg { width: 15px; height: 15px; }
.kpi-label {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.kpi-value {
  font-family: var(--font);
  font-size: 1.92rem;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { color: var(--dim); font-size: 0.74rem; }

/* ---------- Panels ---------- */

.panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel h2 {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.panel-meta {
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.68rem;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}
.control-panel { overflow: hidden; }
.control-panel-head { margin-bottom: 12px; }
.control-tabs {
  display: inline-flex;
  max-width: 100%;
  gap: 5px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(2, 6, 26, 0.46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.control-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.control-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}
.control-tab.is-active {
  border-color: rgba(56, 189, 248, 0.2);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.14), rgba(255, 255, 255, 0.035));
  color: #dbeafe;
}
.control-tab:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.55);
  outline-offset: 2px;
}
.tab-icon,
.tab-icon svg {
  width: 16px;
  height: 16px;
}
.control-pane { display: none; }
.control-pane.is-active { display: block; }

/* ---------- Correction chat ---------- */

.steer-chat {
  display: grid;
  gap: 12px;
  min-height: 360px;
}
.chat-thread {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  padding: 10px 2px 4px;
}
.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  max-width: min(780px, 100%);
}
.chat-message.is-user {
  justify-self: end;
  justify-content: flex-end;
}
.chat-message.is-agent { justify-self: start; }
.chat-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.055);
  color: #cbd5e1;
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 750;
}
.chat-message.is-agent .chat-avatar {
  border-color: rgba(56, 189, 248, 0.24);
  background: rgba(56, 189, 248, 0.09);
  color: #7dd3fc;
}
.chat-bubble {
  max-width: min(620px, calc(100vw - 96px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  color: #e5edf8;
  font-family: var(--font);
  font-size: 0.84rem;
  line-height: 1.45;
}
.chat-message.is-user .chat-bubble {
  border-color: rgba(125, 211, 252, 0.2);
  background: rgba(56, 189, 248, 0.12);
}
.chat-message.is-loading .chat-bubble {
  color: var(--muted);
}
.chat-markdown {
  display: grid;
  gap: 9px;
  max-width: min(760px, calc(100vw - 96px));
}
.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown p,
.chat-markdown ul,
.chat-markdown ol,
.chat-markdown pre {
  margin: 0;
}
.chat-markdown h1,
.chat-markdown h2 {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.25;
}
.chat-markdown h3 {
  color: #dbeafe;
  font-size: 0.9rem;
  line-height: 1.3;
}
.chat-markdown p,
.chat-markdown li {
  color: #d5deec;
}
.chat-markdown ul,
.chat-markdown ol {
  display: grid;
  gap: 5px;
  padding-left: 19px;
}
.chat-markdown strong {
  color: #f8fafc;
  font-weight: 750;
}
.chat-markdown code {
  padding: 1px 5px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 5px;
  background: rgba(2, 6, 23, 0.34);
  color: #bfdbfe;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.chat-markdown pre {
  overflow: auto;
  padding: 9px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(2, 6, 23, 0.42);
}
.chat-markdown pre code {
  padding: 0;
  border: 0;
  background: transparent;
}
.report-html {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  max-width: min(680px, calc(100vw - 112px));
}
.report-html .explain-report {
  display: grid;
  gap: 12px;
}
.report-html h2,
.report-html h3 {
  margin: 0;
  color: var(--text);
}
.report-html p,
.report-html li {
  color: var(--muted);
}
.report-html ul {
  margin: 0;
  padding-left: 18px;
}
.report-plot {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.45);
}
.report-bar {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) minmax(120px, 2fr) 44px;
  gap: 8px;
  align-items: center;
  min-height: 22px;
}
.report-bar i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--amber));
}
.steer-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 9px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.steer-composer textarea {
  min-height: 38px;
  max-height: 120px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.45;
}
.steer-composer textarea::placeholder { color: var(--dim); }
.send-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: #f8fafc;
  color: #06111f;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.send-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.36);
}
.send-button:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.55);
  outline-offset: 2px;
}
.send-button svg {
  width: 17px;
  height: 17px;
}

/* ---------- Sequence list ---------- */

.sequence-list { display: grid; gap: 10px; }
.os-card {
  position: relative;
  display: grid;
  grid-template-columns: 30px 44px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  min-height: 74px;
  padding: 12px 16px 12px 19px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.os-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15px;
  bottom: 15px;
  width: 3px;
  border-radius: 3px;
  background: var(--os-accent, var(--accent));
  box-shadow: 0 0 12px color-mix(in srgb, var(--os-accent, var(--accent)) 55%, transparent);
}
.os-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--os-accent, var(--accent)) 32%, rgba(148, 163, 184, 0.2));
  box-shadow: 0 14px 34px rgba(2, 6, 16, 0.42);
}
.os-card.is-checked {
  border-color: color-mix(in srgb, var(--ok) 30%, var(--line));
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.055), rgba(255, 255, 255, 0.012));
}
.os-check {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
}
.os-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.os-check span[aria-hidden="true"] {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid color-mix(in srgb, var(--os-accent, var(--accent)) 38%, var(--line));
  border-radius: 7px;
  background: rgba(2, 6, 26, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.os-check span[aria-hidden="true"]::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #021018;
  border-bottom: 2px solid #021018;
  opacity: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0.78);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.os-check:hover span[aria-hidden="true"] {
  border-color: color-mix(in srgb, var(--os-accent, var(--accent)) 70%, white);
  transform: translateY(-1px);
}
.os-check input:focus-visible + span[aria-hidden="true"] {
  outline: 2px solid rgba(56, 189, 248, 0.55);
  outline-offset: 2px;
}
.os-check input:checked + span[aria-hidden="true"] {
  border-color: transparent;
  background: linear-gradient(135deg, #7dd3fc, var(--ok));
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.24);
}
.os-check input:checked + span[aria-hidden="true"]::after {
  opacity: 1;
  transform: rotate(-45deg) translate(1px, -1px) scale(1);
}
.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;
}
.os-rank {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  border: 1px solid color-mix(in srgb, var(--os-accent, var(--accent)) 30%, transparent);
  background: color-mix(in srgb, var(--os-accent, var(--accent)) 9%, transparent);
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--os-accent, var(--accent)) 72%, white);
}
.os-card.is-next .os-rank {
  background: linear-gradient(135deg, color-mix(in srgb, var(--os-accent, var(--accent)) 80%, white), var(--os-accent, var(--accent)));
  border-color: transparent;
  color: #051018;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--os-accent, var(--accent)) 45%, transparent);
}
.os-body { min-width: 0; }
.os-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.os-picker {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.next-tag {
  flex: none;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--os-accent, var(--accent)) 42%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--os-accent, var(--accent)) 13%, transparent);
  color: color-mix(in srgb, var(--os-accent, var(--accent)) 75%, white);
  font-size: 0.56rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.os-tag {
  margin-right: 6px;
  color: var(--dim);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.os-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2.5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.028);
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}
.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--os-accent, var(--accent));
  box-shadow: 0 0 6px color-mix(in srgb, var(--os-accent, var(--accent)) 70%, transparent);
}
.os-owner { display: grid; gap: 6px; justify-items: end; text-align: right; min-width: 0; }
.os-ref {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 500;
  color: #cbd5e1;
}
.call-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3.5px 10px;
  border: 1px solid rgba(56, 189, 248, 0.26);
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.09);
  color: #7dd3fc;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}
.call-pill svg { width: 11px; height: 11px; }

.called-stage {
  display: grid;
  gap: 9px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}
.called-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  color: var(--muted);
}
.called-stage-head span {
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.called-stage-head small {
  color: var(--dim);
  font-family: var(--font);
  font-size: 0.68rem;
}
.called-list { display: grid; gap: 7px; }
.called-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--ok) 18%, var(--line));
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.055), rgba(255, 255, 255, 0.012));
}
.called-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, #7dd3fc, var(--ok));
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.18);
}
.called-mark::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #021018;
  border-bottom: 2px solid #021018;
  transform: rotate(-45deg) translate(1px, -1px);
}
.called-body { display: grid; gap: 3px; min-width: 0; }
.called-body strong,
.called-body span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.called-body strong {
  color: #dbeafe;
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 650;
}
.called-body span {
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.68rem;
}
.called-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.confirm-button,
.restore-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.07);
  color: #7dd3fc;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.confirm-button {
  border-color: rgba(52, 211, 153, 0.24);
  background: rgba(52, 211, 153, 0.09);
  color: #86efac;
}
.confirm-button:hover {
  transform: translateY(-1px);
  border-color: rgba(134, 239, 172, 0.46);
  background: rgba(52, 211, 153, 0.14);
}
.restore-button:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 211, 252, 0.42);
  background: rgba(56, 189, 248, 0.12);
}
.confirm-button:focus-visible,
.restore-button:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.55);
  outline-offset: 2px;
}
.confirm-button svg,
.restore-button svg { width: 15px; height: 15px; }

/* ---------- Picker Gantt ---------- */

.gantt-card { min-height: 190px; }
.picker-gantt {
  --gutter: 112px;
  min-width: 0;
}
.picker-gantt-window {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--dim);
  font-size: 0.68rem;
}
.picker-gantt-window strong {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.picker-gantt-window span:last-child { text-align: right; }
.picker-gantt-axis {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 18px;
  margin-left: var(--gutter);
  background: linear-gradient(180deg, rgba(6, 13, 46, 0.96), rgba(6, 13, 46, 0.82));
  color: var(--dim);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}
.picker-gantt-axis-svg {
  display: block;
  width: 100%;
  height: 18px;
  overflow: visible;
}
.picker-gantt-axis-text {
  fill: rgba(199, 216, 245, 0.62);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.picker-gantt-viewport {
  position: relative;
  max-height: 470px;
  overflow: auto;
  padding: 4px 6px 4px 0;
  scrollbar-width: thin;
}
.picker-gantt-scroll {
  position: relative;
  min-width: 760px;
  width: var(--timeline-width, 300%);
}
.picker-gantt-scroll.is-window-3h { width: 300%; }
.picker-gantt-scroll.is-window-6h { width: 600%; }
.picker-gantt-scroll.is-window-10h { width: 960%; }
.picker-gantt-scroll.is-window-12h { width: 1200%; }
.picker-gantt-body { position: relative; }
.picker-gantt-overlay {
  position: absolute;
  inset: 4px 6px 4px var(--gutter);
  pointer-events: none;
}
.picker-gantt-gridline {
  stroke: rgba(148, 163, 184, 0.16);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.picker-gantt-grid-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.picker-gantt-rows {
  position: relative;
  display: grid;
  gap: 10px;
}
.picker-gantt-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 42px;
}
.picker-gantt-label {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 0;
  padding: 4px 10px 4px 0;
  background: linear-gradient(90deg, rgba(6, 13, 46, 0.96) 0%, rgba(6, 13, 46, 0.88) 82%, transparent);
}
.picker-gantt-label strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-gantt-label span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--dim);
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-gantt-track {
  position: relative;
  height: 34px;
  border: 1px solid rgba(148, 163, 184, 0.11);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.024);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.picker-gantt-track-svg {
  display: block;
  width: 100%;
  height: 34px;
  overflow: hidden;
}
.picker-gantt-svg-bar {
  fill: #7dd3fc;
  stroke: rgba(125, 211, 252, 0.58);
  stroke-width: 1;
  filter: drop-shadow(0 3px 5px rgba(56, 189, 248, 0.22));
  vector-effect: non-scaling-stroke;
}
.picker-gantt-svg-bar.is-congelado {
  fill: #7dd3fc;
  stroke: rgba(56, 189, 248, 0.62);
}
.picker-gantt-svg-bar.is-resfriado {
  fill: #34d399;
  stroke: rgba(16, 185, 129, 0.62);
}
.picker-gantt-svg-bar.is-seco {
  fill: #fbbf24;
  stroke: rgba(180, 83, 9, 0.68);
}
.picker-gantt-svg-bar.is-interval {
  fill: rgba(148, 163, 184, 0.42);
  stroke: rgba(203, 213, 225, 0.5);
  stroke-dasharray: 4 3;
  filter: none;
}
.picker-gantt-svg-bar.is-warmup {
  fill: rgba(14, 165, 233, 0.5);
  stroke: rgba(186, 230, 253, 0.78);
  stroke-dasharray: 2 2;
}
.picker-gantt-svg-bar.is-break {
  fill: rgba(100, 116, 139, 0.5);
  stroke: rgba(203, 213, 225, 0.5);
  stroke-dasharray: 5 3;
}
.picker-gantt-svg-label {
  fill: rgba(240, 249, 255, 0.96);
  font-size: 6.6px;
  font-weight: 750;
  pointer-events: none;
}
.picker-gantt-svg-label.ink-dark { fill: rgba(4, 13, 24, 0.92); }
.picker-gantt-svg-label.ink-light,
.picker-gantt-svg-label.is-interval { fill: rgba(240, 249, 255, 0.96); }
.picker-gantt-svg-label.is-warmup { fill: rgba(240, 249, 255, 0.98); }
.picker-gantt-svg-label.is-break { fill: rgba(226, 232, 240, 0.92); }

/* ---------- Empty state & toasts ---------- */

.empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 24px;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.014);
  color: var(--muted);
  text-align: center;
}
.empty svg { width: 26px; height: 26px; color: var(--dim); }

#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 20; }
.toast {
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--ok);
  border-radius: 12px;
  background: rgba(13, 20, 33, 0.94);
  color: var(--text);
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: toast-in 0.22s ease;
}
.toast-err { border-left-color: var(--err); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  #topbar { position: static; grid-template-columns: 1fr auto; }
  .brand { grid-column: 1; }
  .user-chip { grid-column: 2; }
  .masthead { grid-column: 1 / -1; grid-row: 2; justify-items: start; text-align: left; padding-bottom: 6px; }
  #topbar h1 { white-space: normal; }
  .control-strip { align-items: stretch; flex-direction: column; }
  .health-row { align-items: stretch; justify-content: flex-start; }
  .api-token-form { grid-template-columns: minmax(0, 1fr) 38px 38px; width: 100%; }
  #shift-select, .select-wrap { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .os-card { grid-template-columns: 30px 44px minmax(0, 1fr); }
  .os-owner { grid-column: 3; justify-items: start; text-align: left; }
  .picker-gantt { --gutter: 0px; }
  .picker-gantt-axis { margin-left: 0; }
  .picker-gantt-scroll { min-width: 640px; }
  .picker-gantt-row { grid-template-columns: 1fr; gap: 8px; align-items: start; }
  .picker-gantt-label {
    position: static;
    padding-right: 0;
    background: transparent;
  }
  .picker-gantt-overlay { left: 0; opacity: 0.55; }
}

@media (max-width: 560px) {
  #main { width: min(100% - 20px, 1440px); }
  .brand-logo { height: 52px; }
  .user-chip .user-meta { display: none; }
  .health-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    width: 100%;
  }
  .health-summary {
    justify-items: start;
    min-width: 0;
  }
  .status-pill {
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }
  .api-token-form {
    grid-column: 1 / -1;
  }
  .refresh-stamp {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .icon-button {
    grid-column: 2;
    justify-self: end;
    width: 38px;
  }
  .kpi-grid { grid-template-columns: 1fr; }
  .control-tab { padding: 0 8px; font-size: 0.7rem; }
  .steer-chat { min-height: 320px; }
  .chat-thread { min-height: 220px; max-height: 340px; }
  .chat-bubble { max-width: calc(100vw - 96px); }
  .steer-composer { border-radius: 16px; }
  .os-card {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
  }
  .os-rank { grid-column: 1; grid-row: 2; width: 30px; height: 30px; border-radius: 10px; font-size: 0.78rem; }
  .os-body { grid-column: 2; grid-row: 1 / span 2; }
  .os-owner { grid-column: 2; }
  .panel { padding: 14px; }
  .panel-head { align-items: flex-start; flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
