:root {
  --navy: #0b1f3a;
  --navy-2: #12284a;
  --accent: #3b82f6;
  --accent-soft: #dbeafe;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--navy) 0%, #081628 100%);
  color: #dbe4f0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
}

.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.brand-title { font-weight: 700; color: #fff; font-size: 14px; }
.brand-sub { font-size: 11px; color: #93a4bd; }

.signed-in {
  margin: 22px 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #93a4bd;
}
.signed-in strong { color: var(--accent); font-weight: 600; text-transform: none; }

.nav-label {
  margin: 18px 0 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d809c;
}

.nav-link {
  display: block;
  color: #d5deed;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  margin-bottom: 4px;
}
.nav-link.is-active,
.nav-link:hover {
  background: var(--navy-2);
  color: #fff;
}
.nav-link.is-active { border-left-color: var(--accent); }

.sign-out { margin-top: auto; }
.sign-out button {
  width: 100%;
  background: transparent;
  border: 1px solid #2a4060;
  color: #d5deed;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.sign-out button:hover { background: var(--navy-2); }

.main { flex: 1; min-width: 0; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  font-size: 13px;
  color: var(--muted);
}
.topbar a { color: var(--muted); text-decoration: none; }
.content { padding: 28px; }

h1 { margin: 0 0 4px; font-size: 28px; }
h2 { margin: 0 0 16px; font-size: 16px; }
.lede { margin: 0 0 20px; color: var(--muted); }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  margin-bottom: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-grid.compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  border: 1px solid transparent;
}
.stat-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stat-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-card strong { font-size: 22px; }

.filters-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.filters-title { font-weight: 600; font-size: 14px; color: var(--text); }
.panel.filters {
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: visible;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 14px 16px;
  align-items: end;
}
.field { min-width: 0; }
.field label,
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.control,
input,
select {
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select.control,
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
input[type="date"].control {
  min-width: 0;
}
.control:hover,
input:hover,
select:hover {
  border-color: #cbd5e1;
}
.control:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.control.is-invalid,
input.is-invalid {
  border-color: var(--bad);
}
.control.is-invalid:hover,
input.is-invalid:hover,
.control.is-invalid:focus,
input.is-invalid:focus {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px var(--bad-bg);
}
.field-error {
  margin: 6px 0 0;
  color: var(--bad);
  font-size: 12px;
  font-weight: 600;
}
.inline-search { display: flex; gap: 8px; align-items: center; }
.inline-search .control { margin: 0; min-width: 240px; width: 260px; }

.pretty-select { position: relative; }
.pretty-select-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  border: 0;
  padding: 0;
}
.pretty-select-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
  padding-right: 36px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.pretty-select.is-open .pretty-select-toggle {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.pretty-select-menu {
  display: none;
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14);
  padding: 6px;
  max-height: 260px;
  overflow: auto;
}
.pretty-select.is-open .pretty-select-menu { display: block; }
.pretty-select-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--text);
}
.pretty-select-option:hover { background: #f1f5f9; }
.pretty-select-option.is-selected {
  background: var(--accent-soft);
  color: var(--info);
  font-weight: 600;
}

.pretty-date { position: relative; }
.pretty-date-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  border: 0;
  padding: 0;
}
.pretty-date-toggle {
  display: flex;
  align-items: center;
  text-align: left;
  cursor: pointer;
  padding-right: 40px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.pretty-date-toggle.is-placeholder { color: var(--muted); }
.pretty-date.is-open .pretty-date-toggle {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.pretty-date-panel {
  display: none;
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  padding: 12px;
}
.pretty-date.is-open .pretty-date-panel { display: block; }
.pretty-date-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pretty-date-head strong { font-size: 14px; color: var(--text); }
.pretty-date-nav {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.pretty-date-nav:hover { background: var(--accent-soft); color: var(--info); }
.pretty-date-week,
.pretty-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.pretty-date-week {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.pretty-date-day {
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.pretty-date-day:hover { background: #f1f5f9; }
.pretty-date-day.is-today { box-shadow: inset 0 0 0 1px var(--accent); }
.pretty-date-day.is-selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.pretty-date-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.pretty-date-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 0;
}
.pretty-date-link:hover { color: #2563eb; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  height: 40px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-ghost {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f8fafc; color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; font-weight: 500; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.confirm-dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}
.confirm-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.confirm-dialog h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text);
}
.confirm-dialog p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.filter-actions { display: flex; align-items: end; padding-bottom: 0; }

@media (max-width: 1100px) {
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-actions { grid-column: 1 / -1; justify-content: end; }
}

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: 12px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.job-link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}
.job-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--info);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.source-chip svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.source-chip:hover {
  background: #bfdbfe;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.click-row { cursor: pointer; }
.click-row:hover { background: #f8fafc; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}
.badge-muted { background: #e2e8f0; color: #475569; margin-left: 6px; }
.status-completed { background: var(--ok-bg); color: var(--ok); }
.status-running { background: var(--info-bg); color: var(--info); }
.status-partial { background: var(--warn-bg); color: var(--warn); }
.status-failed { background: var(--bad-bg); color: var(--bad); }
.status-skipped_locked { background: #e2e8f0; color: #475569; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.tab.is-active { background: var(--accent); color: #fff; }
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  font-size: 14px;
}
.pager-nav,
.pager-num {
  color: var(--accent);
  text-decoration: none;
}
.pager-nav.is-disabled {
  color: var(--muted);
  cursor: default;
}
.pager-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
}
.pager-num.is-current {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-weight: 600;
}
.pager-ellipsis {
  color: var(--muted);
  letter-spacing: 2px;
}
.empty { color: var(--muted); margin: 0; }
.error-cell { max-width: 320px; }
.error-cell code { display: block; font-size: 12px; }
.error-cell span { color: var(--muted); font-size: 12px; }

.form-error {
  background: var(--bad-bg);
  color: var(--bad);
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0;
  font-size: 13px;
  border: 1px solid #fecaca;
}

.login-body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(59, 130, 246, 0.28), transparent 55%),
    linear-gradient(180deg, #102445 0%, var(--navy) 48%, #071221 100%);
}
.login-wrap {
  width: min(420px, calc(100% - 32px));
}
.login-card {
  width: 100%;
  background: #fff;
  padding: 32px;
  border-radius: 18px;
  display: grid;
  gap: 16px;
  box-shadow: 0 24px 60px rgba(2, 8, 23, 0.35);
}
.login-brand { margin-bottom: 0; }
.login-card .brand-mark {
  width: 42px;
  height: 42px;
  font-size: 14px;
}
.login-card .brand-title { color: var(--text); font-size: 16px; }
.login-card .brand-sub { color: var(--muted); }
.login-lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.login-card .field { display: grid; gap: 0; }
.login-card .control { height: 44px; }
