/* ===== DESIGN TOKENS ===== */
:root {
  --bg: #f5f3eb;
  --bg-subtle: #efece4;
  --text: #1d2a2f;
  --text-secondary: #556a72;
  --panel: #ffffffcc;
  --panel-solid: #ffffff;
  --line: #c3ced2;
  --accent: #0d6e6e;
  --accent-hover: #1b8f8f;
  --accent-2: #b86e36;
  --danger: #a62f2f;
  --danger-hover: #c43a3a;
  --success: #287d3c;
  --shadow: 0 12px 30px rgba(18, 35, 44, 0.12);
  --shadow-sm: 0 4px 12px rgba(18, 35, 44, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-width: 230px;
  --bottom-nav-height: 64px;
  --transition: 200ms ease;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg: #0f1a1f;
  --bg-subtle: #162228;
  --text: #e0e8ec;
  --text-secondary: #8fa3ad;
  --panel: #1a2930ee;
  --panel-solid: #1a2930;
  --line: #2c3e47;
  --accent: #3db8b8;
  --accent-hover: #4fd4d4;
  --accent-2: #e0965a;
  --danger: #e05555;
  --danger-hover: #f06666;
  --success: #4ec96a;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.40);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a1f;
    --bg-subtle: #162228;
    --text: #e0e8ec;
    --text-secondary: #8fa3ad;
    --panel: #1a2930ee;
    --panel-solid: #1a2930;
    --line: #2c3e47;
    --accent: #3db8b8;
    --accent-hover: #4fd4d4;
    --accent-2: #e0965a;
    --danger: #e05555;
    --danger-hover: #f06666;
    --success: #4ec96a;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.20);
  }
}

/* ===== RESET ===== */
* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ===== BACKGROUND SHAPES ===== */
.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.3;
  pointer-events: none;
}

.bg-shape-a {
  width: 300px;
  height: 300px;
  background: #c3e3dd;
  top: 50px;
  left: 0;
}

.bg-shape-b {
  width: 220px;
  height: 220px;
  background: #f0cead;
  top: 320px;
  right: 0;
}

[data-theme="dark"] .bg-shape { opacity: 0.08; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bg-shape { opacity: 0.08; }
}

/* ===== SIDEBAR (desktop) ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--panel-solid);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  color: var(--accent);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.1;
}

.sidebar-sub {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-group-title {
  margin: 14px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, var(--text-secondary));
  opacity: 0.7;
}

.nav-group-title:first-child {
  margin-top: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  width: 100%;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.sidebar-footer {
  padding: 12px 14px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-session {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sidebar-user {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.sidebar-controls {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.locale-select {
  width: 52px !important;
  padding: 4px 6px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0 !important;
  border-radius: 8px !important;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* Sun/Moon visibility */
.icon-moon { display: none; }
.icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: block; }
  :root:not([data-theme="light"]) .icon-sun { display: none; }
}

.logout-btn {
  width: 100%;
  font-size: 13px;
  padding: 8px 12px;
  color: var(--danger) !important;
  border-color: var(--danger) !important;
}

.logout-btn:hover {
  background: var(--danger) !important;
  color: #fff !important;
}

/* ===== BOTTOM NAV (mobile) ===== */
.bottom-nav {
  display: none;
}

/* ===== MOBILE HEADER ===== */
.mobile-header {
  display: none;
}

/* ===== APP WRAPPER ===== */
.app-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  position: relative;
}

/* ===== LOADING BAR ===== */
.loading-bar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 150;
  overflow: hidden;
  opacity: 1;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.loading-bar.hidden {
  opacity: 0;
}

.loading-bar-inner {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 2px;
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ===== LAYOUT ===== */
.layout {
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== LOGIN ===== */
.login-panel {
  display: none;
  animation: rise 240ms ease-out;
}

body.logged-out .login-panel {
  display: block;
}

body.logged-out .app-wrapper {
  margin-left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.logged-out .layout {
  max-width: 420px;
  width: 100%;
  padding: 24px;
}

body.logged-out .sidebar,
body.logged-out .bottom-nav,
body.logged-out .mobile-header {
  display: none !important;
}

body.logged-out .loading-bar {
  opacity: 0 !important;
}

body.logged-out .content-section {
  display: none !important;
}

.login-panel h2 {
  font-size: 24px;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px;
}

/* ===== PANELS ===== */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.content-section {
  display: none;
}

.content-section.active-section {
  display: block;
  animation: rise 240ms ease-out;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

h1, h2 {
  margin: 0;
  letter-spacing: 0.3px;
}

/* ===== FORMS ===== */
.stack,
.inline-form {
  display: grid;
  gap: 10px;
}

.form-rows {
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: center;
}

.form-row input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-row label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.slack-alerts-group {
  gap: 8px;
}

.slack-alerts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.slack-alert-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}

.slack-alert-option input[type='checkbox'] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
}

.slack-alert-option span {
  flex: 1;
}

input,
select,
button {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  min-width: 0;
  color: var(--text);
  background: var(--panel-solid);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.12);
}

input, select {
  width: 100%;
}

button {
  width: auto;
}

button {
  background: linear-gradient(145deg, var(--accent), var(--accent-hover));
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: filter var(--transition), transform var(--transition);
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  transform: scale(0.98);
}

button.ghost {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 500;
}

button.ghost:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
}

button.danger-btn {
  background: linear-gradient(145deg, var(--danger), var(--danger-hover));
  color: #fff;
  border: none;
}

/* ===== AUTH FIELDS (collapsible) ===== */
.auth-fields {
  display: grid;
  gap: 12px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 300ms ease, opacity 200ms ease, margin 200ms ease;
  margin: 0;
}

.auth-fields.open {
  max-height: 300px;
  opacity: 1;
  margin-top: 4px;
}

/* ===== PERFORMANCE METRICS ===== */
.speed-factor-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.speed-factor-input-group input[type="number"] {
  width: 100px;
}

.inline-row {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.performance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.performance-table th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid var(--line);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
}

.performance-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.performance-table tr:hover {
  background: var(--bg-subtle);
}

.performance-table .node-name {
  font-weight: 600;
  color: var(--accent);
}

.performance-table .workflow-name {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 4px;
}

.performance-table .ms-value {
  font-weight: 600;
}

.performance-table .warm-color {
  color: var(--success);
}

.performance-table .cold-color {
  color: var(--accent-2);
}

.performance-table .samples-count {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ===== CARDS ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

#overviewCards {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

#analyticsTimingCards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-solid);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.06;
  pointer-events: none;
  border-radius: inherit;
  transition: opacity var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.card:hover::before {
  opacity: 0.10;
}

/* Card status tinting via :has() */
.card:has(.status-success) { border-left-color: var(--success); }
.card:has(.status-success)::before { background: var(--success); }
.card:has(.status-error) { border-left-color: var(--danger); }
.card:has(.status-error)::before { background: var(--danger); }
.card:has(.status-running) { border-left-color: var(--accent); }
.card:has(.status-running)::before { background: var(--accent); }
.card:has(.status-queued) { border-left-color: var(--accent-2); }
.card:has(.status-queued)::before { background: var(--accent-2); }

.card .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.card .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.maintenance-card {
  align-content: start;
}

.maintenance-card h4 {
  margin: 0;
  font-size: 16px;
}

/* ===== PILLS ===== */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  overflow: visible;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--panel-solid);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.pill:hover {
  transform: scale(1.04);
  box-shadow: var(--shadow-sm);
}

.pill.ok {
  border-color: var(--success);
  color: var(--success);
  background: rgba(40, 125, 60, 0.08);
}

.pill.warn {
  border-color: var(--accent-2);
  color: var(--accent-2);
  background: rgba(184, 110, 54, 0.08);
}

.pill.bad {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(166, 47, 47, 0.08);
}

[data-theme="dark"] .pill.ok { background: rgba(78, 201, 106, 0.10); }
[data-theme="dark"] .pill.warn { background: rgba(224, 150, 90, 0.10); }
[data-theme="dark"] .pill.bad { background: rgba(224, 85, 85, 0.10); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill.ok { background: rgba(78, 201, 106, 0.10); }
  :root:not([data-theme="light"]) .pill.warn { background: rgba(224, 150, 90, 0.10); }
  :root:not([data-theme="light"]) .pill.bad { background: rgba(224, 85, 85, 0.10); }
}

/* ===== LISTS ===== */
.list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  overflow: visible;
  padding: 4px;
  margin-left: -4px;
  margin-right: -4px;
}

/* Multi-column grid variant for cards (nodes, etc.) */
.list-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-solid);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Node status coloring on items */
.item.node-healthy { border-left-color: var(--success); }
.item.node-degraded { border-left-color: var(--accent-2); }
.item.node-offline {
  border-left-color: var(--danger);
  opacity: 0.6;
}
.item.node-offline:hover { opacity: 0.85; }

.item strong {
  font-size: 14px;
}

.item .meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.item .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.item .actions button {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--text-secondary);
  text-align: center;
  gap: 8px;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  opacity: 0.4;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* ===== STATUS COLORS ===== */
.status-success { color: var(--success); }
.status-error { color: var(--danger); }
.status-running { color: var(--accent); }
.status-queued { color: var(--accent-2); }
.status-cancelled { color: var(--text-secondary); }

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  font-size: 12px;
}

.tip {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== PROMPT EDITOR ===== */
.prompt-editor {
  width: 100%;
  min-height: 200px;
  max-height: 500px;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-solid);
  color: var(--text);
  resize: vertical;
  tab-size: 2;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.prompt-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.12);
}

.prompt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-result {
  margin-top: 16px;
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg-subtle);
  animation: rise 200ms ease-out;
}

.prompt-result.error {
  border-color: var(--danger);
}

.prompt-result h3 {
  margin: 0;
  font-size: 15px;
}

.prompt-result-body {
  margin-top: 10px;
}

.prompt-result-field {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.prompt-result-field:last-child {
  border-bottom: none;
}

.prompt-result-field .pr-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
}

.prompt-result-field .pr-value {
  word-break: break-all;
}

/* ===== NODE QUEUE MODAL ===== */
.queue-section {
  margin-bottom: 14px;
}

.queue-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.queue-item {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-solid);
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}

.queue-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}

/* ===== PAGER ===== */
.pager {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.pager-info {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  text-align: right;
}

/* ===== MODALS ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 22, 28, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 200;
  backdrop-filter: blur(3px);
  animation: fade-in 150ms ease-out;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(980px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  animation: modal-pop 200ms ease-out;
}

.modal-content.modal-narrow {
  width: min(460px, 100%);
}

.modal-content.modal-confirm {
  width: min(380px, 100%);
  text-align: center;
  padding: 28px 24px;
}

@keyframes modal-pop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== CONFIRM DIALOG ===== */
.confirm-icon {
  margin: 0 auto 12px;
  width: 48px;
  height: 48px;
  color: var(--danger);
}

.confirm-icon svg {
  width: 100%;
  height: 100%;
}

.confirm-text {
  font-size: 15px;
  margin: 0 0 20px;
  color: var(--text);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-actions button {
  min-width: 100px;
}

/* ===== JOB DETAIL ===== */
.job-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.job-detail-field {
  padding: 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

.job-detail-field .jd-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.job-detail-field .jd-value {
  font-size: 14px;
  font-weight: 500;
  word-break: break-all;
}

.job-detail-raw {
  margin-top: 8px;
}

.job-detail-raw summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  padding: 6px 0;
  user-select: none;
}

.code-block {
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-subtle);
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.5;
  max-height: 400px;
  overflow: auto;
  color: var(--text);
}

/* ===== COMFY ERROR PRETTY VIEW ===== */
.error-summary {
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 12px;
  font-size: 14px;
}

.node-error-item {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
}

.node-error-head {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}

.node-error-list {
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

.node-error-list li {
  margin-bottom: 4px;
}

.node-error-list small {
  display: block;
  margin-top: 2px;
  font-family: monospace;
  opacity: 0.8;
}

/* ===== TOGGLE BUTTONS ===== */
.toggle-group {
  display: flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  gap: 2px;
}

.toggle-group button {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: all var(--transition);
}

.toggle-group button:hover {
  background: var(--panel-solid);
  color: var(--text);
}

.toggle-group button.active {
  background: var(--panel-solid);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.item img {
  display: block;
}

/* ===== ANALYTICS ===== */
.analytics-wrap {
  margin-top: 20px;
  border-top: 2px solid var(--line);
  padding-top: 18px;
}

.analytics-head {
  margin-bottom: 10px;
}

.analytics-head h3 {
  font-size: 17px;
  letter-spacing: 0.3px;
}

/* Filters: left col (Rango/Estado/SLA) + right col (Nodes full height) */
.analytics-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
  align-items: stretch;
}

.af-left {
  display: grid;
  gap: 10px;
  align-content: start;
}

.af-field {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 10px;
}

.af-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.af-field select,
.af-field input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
}

/* Nodes multi-select: right column, stretches to match left height */
.af-nodes {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0;
}

.af-nodes-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.af-nodes-head label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.af-clear-btn {
  background: none !important;
  border: none !important;
  color: var(--accent) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  padding: 2px 4px !important;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity var(--transition);
}

.af-clear-btn:hover {
  opacity: 1;
  text-decoration: underline;
}

#overviewNodeFilter[multiple] {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-sm);
  padding: 4px;
  font-size: 13px;
}

#overviewNodeFilter[multiple] option {
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 1px;
  cursor: pointer;
}

#overviewNodeFilter[multiple] option:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
}

#overviewWorkflowFilter {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
}

@media (max-width: 700px) {
  .analytics-filters {
    grid-template-columns: 1fr;
  }

  #overviewNodeFilter[multiple] {
    min-height: 90px;
  }
}

.analytics-cards {
  margin-bottom: 12px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.analytics-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel-solid);
  transition: box-shadow var(--transition);
}

.analytics-panel:hover {
  box-shadow: var(--shadow-sm);
}

.analytics-panel h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.analytics-status-bars,
.analytics-node-bars {
  display: grid;
  gap: 8px;
}

.analytics-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 8px;
  align-items: center;
}

.analytics-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-radius: inherit;
  transition: width 400ms ease-out;
}

/* Per-status bar colors */
.analytics-bar-fill.status-success { background: linear-gradient(135deg, #287d3c, #34a853); }
.analytics-bar-fill.status-error { background: linear-gradient(135deg, #a62f2f, #d44040); }
.analytics-bar-fill.status-running { background: linear-gradient(135deg, #0d6e6e, #1b8f8f); }
.analytics-bar-fill.status-queued { background: linear-gradient(135deg, #b86e36, #d4924e); }
.analytics-bar-fill.status-cancelled { background: linear-gradient(135deg, #67747c, #8a97a0); }

[data-theme="dark"] .analytics-bar-fill.status-success { background: linear-gradient(135deg, #34a853, #4ec96a); }
[data-theme="dark"] .analytics-bar-fill.status-error { background: linear-gradient(135deg, #d44040, #e05555); }
[data-theme="dark"] .analytics-bar-fill.status-running { background: linear-gradient(135deg, #1b8f8f, #3db8b8); }
[data-theme="dark"] .analytics-bar-fill.status-queued { background: linear-gradient(135deg, #d4924e, #e0965a); }
[data-theme="dark"] .analytics-bar-fill.status-cancelled { background: linear-gradient(135deg, #8a97a0, #a0abb3); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .analytics-bar-fill.status-success { background: linear-gradient(135deg, #34a853, #4ec96a); }
  :root:not([data-theme="light"]) .analytics-bar-fill.status-error { background: linear-gradient(135deg, #d44040, #e05555); }
  :root:not([data-theme="light"]) .analytics-bar-fill.status-running { background: linear-gradient(135deg, #1b8f8f, #3db8b8); }
  :root:not([data-theme="light"]) .analytics-bar-fill.status-queued { background: linear-gradient(135deg, #d4924e, #e0965a); }
  :root:not([data-theme="light"]) .analytics-bar-fill.status-cancelled { background: linear-gradient(135deg, #8a97a0, #a0abb3); }
}

.analytics-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}

.analytics-timeline {
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--bg-subtle);
  overflow-x: auto;
}

.analytics-heatmap {
  display: grid;
  gap: 6px;
}

.heat-row {
  display: grid;
  grid-template-columns: 180px repeat(5, minmax(56px, 1fr));
  gap: 6px;
  align-items: center;
}

.heat-header {
  margin-bottom: 2px;
}

.heat-head,
.heat-node {
  font-size: 12px;
  color: var(--text-secondary);
}

.heat-node {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat-cell {
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

.timeline-col {
  min-width: 26px;
  height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.timeline-bar {
  width: 100%;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  min-height: 6px;
}

.timeline-count {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ===== BANS ===== */
.ban-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
}

.ban-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ban-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.ban-meta strong {
  color: var(--text);
}

.ban-actions {
  display: flex;
  gap: 8px;
}

.ban-actions .small {
  font-size: 12px;
  padding: 4px 10px;
}

@media (max-width: 900px) {
  #overviewCards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #analyticsTimingCards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-row {
    grid-template-columns: 110px 1fr auto;
  }

  .heat-row {
    grid-template-columns: 120px repeat(5, minmax(46px, 1fr));
  }
}

/* ===== WORKFLOW METRICS TABLE ===== */
.wm-row {
  display: grid;
  grid-template-columns: 1fr repeat(4, auto);
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.wm-row:last-child { border-bottom: none; }

.wm-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.wm-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 64px;
}

.wm-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.wm-value {
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 700px) {
  .slack-alerts-grid {
    grid-template-columns: 1fr;
  }

  #overviewCards,
  #analyticsTimingCards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wm-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .wm-cell {
    flex-direction: row;
    gap: 6px;
    justify-content: space-between;
  }
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #12232a;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  max-width: 380px;
  animation: toast-in 200ms ease-out;
}

.toast.error {
  background: var(--danger);
}

.toast.hidden {
  display: none;
}

@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== HIDDEN ===== */
.hidden {
  display: none;
}

/* ===== ANIMATION ===== */
@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===== RESPONSIVE: MOBILE ===== */
@media (max-width: 820px) {
  .sidebar {
    display: none;
  }

  .app-wrapper {
    margin-left: 0;
    padding-bottom: calc(var(--bottom-nav-height) + 8px);
  }

  .loading-bar {
    left: 0;
  }

  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--panel-solid);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .mobile-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-logo {
    width: 24px;
    height: 24px;
    color: var(--accent);
  }

  .mobile-title {
    font-size: 16px;
    font-weight: 700;
  }

  .mobile-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .mobile-logout-btn {
    color: var(--danger) !important;
  }

  .mobile-logout-btn:hover {
    background: var(--danger) !important;
    color: #fff !important;
  }

  .mobile-logout-btn svg {
    width: 20px;
    height: 20px;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--panel-solid);
    border-top: 1px solid var(--line);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  }

  .bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
    min-width: 0;
    flex: 1;
  }

  .bnav-item svg {
    width: 22px;
    height: 22px;
  }

  .bnav-item.active {
    color: var(--accent);
  }

  .bnav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
  }

  .layout {
    padding: 16px;
  }

  .item .actions {
    flex-direction: column;
  }

  .item .actions button {
    width: 100%;
    justify-content: center;
  }

  .toast {
    bottom: calc(var(--bottom-nav-height) + 12px);
    left: 16px;
    right: 16px;
    max-width: none;
  }

  body.logged-out .bottom-nav,
  body.logged-out .mobile-header {
    display: none !important;
  }

  body.logged-out .app-wrapper {
    padding-bottom: 0;
  }

  .panel-head button {
    width: auto;
  }

  .cards {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  #overviewCards,
  #analyticsTimingCards {
    grid-template-columns: 1fr;
  }
}

/* ===== RESPONSIVE: DESKTOP ===== */
@media (min-width: 821px) {
  .form-row {
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 10px;
  }

  .form-row input[type='checkbox'] {
    justify-self: start;
  }

  .panel-head button {
    width: auto;
  }

  .auth-fields .form-row {
    grid-template-columns: 150px 1fr;
  }
}

/* ===== FOCUS VISIBLE ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.15);
}
