:root {
  --bg: #f1f5f9;
  --bg-soft: #f8fafc;
  --panel: #0f172a;
  --panel-soft: #1e293b;
  --panel-hover: #334155;
  --surface: #ffffff;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --ink: #0f172a;
  --ink-soft: #64748b;
  --ink-muted: #94a3b8;
  --accent: #0ea5e9;
  --accent-strong: #0284c7;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --ok-fg: #14532d;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --bad-fg: #7f1d1d;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --warn-fg: #78350f;
  --neutral-bg: #f1f5f9;
  --neutral-fg: #475569;
  --running-bg: #ede9fe;
  --running-fg: #4c1d95;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

/* ─── LAYOUT ──────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  background: var(--panel);
  color: #e2e8f0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.brand-wrap {
  padding: 4px 8px;
}

.brand-kicker {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 4px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #475569;
  font-weight: 700;
  padding: 0 8px;
  margin-bottom: 4px;
  margin-top: 4px;
}

.sidebar a {
  color: #94a3b8;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar a .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
}

.sidebar a.active {
  background: rgba(14, 165, 233, 0.15);
  color: #7dd3fc;
}

.sidebar a.active .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding: 8px;
  font-size: 11px;
  color: #475569;
}

/* ─── CONTENT ────────────────────────────────────────────── */
.content {
  padding: 28px 32px 40px;
  min-width: 0;
}

.topbar {
  margin-bottom: 24px;
}

.topbar-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.topbar-subtitle {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

h2 {
  margin: 28px 0 14px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.section-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.sched-head-copy {
  max-width: 680px;
}

.section-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.section-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  max-width: 640px;
  line-height: 1.5;
}

/* ─── STATS GRID ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  border-top: 3px solid var(--line);
  padding: 16px 18px;
}

.stat-card.success {
  border-top-color: var(--ok);
}

.stat-card.fail {
  border-top-color: var(--bad);
}

.metric-label {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
}

.metric-value {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.metric-hint {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
}

/* ─── JOB GRID ───────────────────────────────────────────── */
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.job-card {
  padding: 16px;
}

.dashboard-job-card {
  border-top: 3px solid var(--line);
  transition: box-shadow 0.15s, transform 0.15s;
}

.dashboard-job-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.dashboard-job-card.ok {
  border-top-color: var(--ok);
}

.dashboard-job-card.attention {
  border-top-color: var(--bad);
}

.dashboard-job-card.idle {
  border-top-color: #94a3b8;
}

.dashboard-job-card.off {
  border-top-color: #cbd5e1;
  opacity: 0.75;
}

.job-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.job-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.job-summary {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.job-meta-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.job-meta-line {
  display: flex;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.label {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-width: 60px;
  flex-shrink: 0;
}

.job-meta-value {
  color: var(--ink-soft);
  word-break: break-word;
}

.job-run-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-top: 8px;
  display: inline-block;
}

.job-run-link:hover {
  text-decoration: underline;
}

/* ─── TABLES ─────────────────────────────────────────────── */
.table-modern {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

.table-modern th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table-modern td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink);
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

.table-modern tbody tr:hover td {
  background: #f8fafc;
}

.table-modern td form {
  margin: 0;
}

.table-modern a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.table-modern a:hover {
  text-decoration: underline;
}

.sched-table td {
  vertical-align: top;
}

/* ─── CHIPS / BADGES ─────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.chip.ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.chip.bad {
  background: var(--bad-bg);
  color: var(--bad-fg);
}

.chip.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.chip.neutral {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

.chip.running {
  background: var(--running-bg);
  color: var(--running-fg);
}

/* ─── FORMS & INPUTS ─────────────────────────────────────── */
select,
input[type="time"],
input[type="number"],
input[type="text"] {
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

select {
  min-width: 200px;
}

input[type="text"] {
  min-width: 200px;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  min-height: 34px;
  padding: 7px 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.warn {
  background: var(--bad);
}

button.warn:hover {
  background: #b91c1c;
}

.secondary-btn {
  background: var(--panel-soft);
}

.secondary-btn:hover {
  background: var(--panel-hover);
}

.edit-btn {
  background: #334155;
}

.edit-btn:hover {
  background: #1e293b;
}

.ghost-btn {
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  min-width: 0;
  justify-content: flex-start;
}

.ghost-btn:hover {
  background: var(--line);
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 14px;
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
}

.action-link:hover {
  background: var(--line);
  color: var(--ink);
}

/* ─── INLINE FORMS ───────────────────────────────────────── */
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── SCHEDULE PAGE ──────────────────────────────────────── */
.schedule-mode-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.time-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.time-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 700;
  font-family: "IBM Plex Mono", monospace;
}

.slot-line {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}

.schedule-note {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
}

.modal-overlay.open {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6vh;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  z-index: 2;
  width: min(780px, 94vw);
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.modal-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.modal-close {
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 16px;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--line);
  color: var(--ink);
}

/* ─── SCHEDULE FORM ──────────────────────────────────────── */
.schedule-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.schedule-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  font-weight: 700;
}

.field-help {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.4;
}

.preset-box {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.preset-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-muted);
  font-weight: 700;
}

.schedule-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  grid-column: 1 / -1;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.checkbox-line {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
}

/* ─── RUN DETAIL PAGE ────────────────────────────────────── */
.run-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.history-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.run-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.run-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.run-actions form {
  margin: 0;
}

.run-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  padding: 14px 16px;
}

.metric-number {
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ─── PROGRESS BAR ───────────────────────────────────────── */
.progress-shell {
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  margin-bottom: 16px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: #bae6fd;
}

.progress-bar {
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  animation: run-progress 1.6s ease-in-out infinite;
}

@keyframes run-progress {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(340%); }
}

/* ─── ERROR / CRITICAL BOX ───────────────────────────────── */
.critical-box {
  border-left: 4px solid var(--bad);
  background: #fff5f5;
  margin-bottom: 16px;
}

.critical-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bad);
}

.critical-foot {
  margin-top: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: #b91c1c;
}

/* ─── LOG BOX ────────────────────────────────────────────── */
.log-shell {
  padding: 0;
  overflow: hidden;
}

.log-shell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}

.log-shell-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.log-meta {
  font-size: 11px;
  color: var(--ink-muted);
  font-family: "IBM Plex Mono", monospace;
  word-break: break-all;
}

code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink-soft);
}

.log-box {
  background: #0d1117;
  color: #c9d1d9;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 16px;
  overflow: auto;
  max-height: 68vh;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── STATUS HELPERS ─────────────────────────────────────── */
.status-text-ok {
  color: var(--ok);
  font-weight: 700;
}

.status-text-bad {
  color: var(--bad);
  font-weight: 700;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 220px 1fr;
  }

  .content {
    padding: 20px 20px 32px;
  }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 12px;
  }

  .sidebar nav {
    flex-direction: row;
    gap: 4px;
  }

  .sidebar-footer {
    display: none;
  }

  .content {
    padding: 16px;
  }

  .topbar-title {
    font-size: 22px;
  }

  .run-title-wrap {
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .modal-head h3 {
    font-size: 18px;
  }
}
