* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f5f7fa; color: #1a1f2b; line-height: 1.5; font-size: 14px;
}

/* ─── Header / nav ──────────────────────────────────────────────────── */
header {
  display: flex; gap: 16px; align-items: center;
  padding: 10px 16px; background: #1f2937; color: white;
  flex-wrap: wrap;
}
header .brand {
  color: white; text-decoration: none; font-weight: 700; font-size: 18px;
  margin-right: 8px;
}
header .topnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
header .topnav a {
  color: #cbd5e1; text-decoration: none;
  padding: 6px 10px; border-radius: 4px; font-size: 14px;
}
header .topnav a:hover { background: #374151; color: white; }
header .topnav a.active { background: #2563eb; color: white; }
header .logout-form { margin: 0; }
header .link-btn {
  background: none; border: 1px solid #6b7280; color: #cbd5e1;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 13px;
}

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
h1 { margin: 0 0 16px; font-size: 22px; }
h2 { margin: 20px 0 10px; font-size: 16px; color: #334155; }
h3.sub { margin: 12px 0 6px; font-size: 13px; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.05em; }

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; gap: 12px; flex-wrap: wrap;
}

/* ─── Common buttons / chips ─────────────────────────────────────────── */
.btn, .btn-mini {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 4px;
  background: #e5e7eb; color: #1a1f2b; text-decoration: none; border: none;
  cursor: pointer; font-size: 14px; min-height: 36px; line-height: 1.2;
}
.btn-mini { padding: 4px 10px; font-size: 12px; min-height: 28px; }
.btn:hover { background: #d1d5db; }
.btn.primary, .btn-mini.primary { background: #2563eb; color: white; }
.btn.primary:hover, .btn-mini.primary:hover { background: #1d4ed8; }
.btn.danger, .btn-mini.danger { background: #fee2e2; color: #b91c1c; }
.btn.danger:hover, .btn-mini.danger:hover { background: #fecaca; }
.chip {
  background: #eef2f7; border: 1px solid #d6deea; color: #1e3a8a;
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  cursor: pointer; margin: 2px;
}
.chip:hover { background: #dbeafe; }
.chip .meta { color: #64748b; margin-left: 4px; }
.src-chips { margin-top: 8px; display: flex; flex-wrap: wrap; }

/* ─── Cards & layout ────────────────────────────────────────────────── */
.card {
  background: white; border-radius: 8px; padding: 14px;
  box-shadow: 0 1px 3px rgba(20, 30, 50, 0.06);
  border: 1px solid #e7ebf2;
}
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card-title { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; word-break: break-all; }
.card-meta { color: #64748b; font-size: 13px; margin-top: 4px; }
.source-card .src-sched { margin-top: 8px; }
.source-card .actions-row { margin-top: 10px; }

/* ─── Dashboard grid ────────────────────────────────────────────────── */
.dash-grid {
  display: grid; gap: 12px;
  grid-template-columns: 2fr 1fr;
}
.dash-grid .panel-wide { grid-column: 1 / -1; }
.dash-grid .panel { min-width: 0; }
.dash-grid .panel h2 {
  margin-top: 0; font-size: 12px; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.empty-state { color: #94a3b8; font-style: italic; padding: 8px 0; }

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

/* ─── Active job panel innards ──────────────────────────────────────── */
.kv-line { margin: 4px 0; }
.kv-line .label { color: #64748b; font-size: 12px; }
.progress {
  height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden;
  margin: 6px 0;
}
.progress .bar {
  height: 100%; background: linear-gradient(90deg, #2563eb, #60a5fa);
  transition: width 0.4s ease;
}
.log-tail {
  background: #0f172a; color: #cbd5e1;
  padding: 8px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 11px;
  max-height: 100px; overflow: hidden; margin-top: 8px;
  width: 100%; min-width: 0;
}
.log-tail div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Status pills ──────────────────────────────────────────────────── */
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.status-pill.done { background: #dcfce7; color: #166534; }
.status-pill.running { background: #dbeafe; color: #1d4ed8; }
.status-pill.queued { background: #fef3c7; color: #92400e; }
.status-pill.failed { background: #fee2e2; color: #b91c1c; }
.status-pill.interrupted { background: #ffedd5; color: #c2410c; }

.badge {
  display: inline-block; background: #e5e7eb; color: #334155;
  padding: 1px 8px; border-radius: 999px; font-size: 11px;
  margin-left: 4px;
}
.badge.danger { background: #fee2e2; color: #b91c1c; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.dot.on { background: #16a34a; } .dot.off { background: #cbd5e1; }

/* ─── Tables ────────────────────────────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse;
  background: white; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(20,30,50,0.04);
}
.data-table th, .data-table td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid #eef2f7;
  vertical-align: top;
}
.data-table th {
  background: #f1f5f9; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em; color: #475569;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .r { text-align: right; }
.data-table .check { width: 36px; }
.data-table a { color: #2563eb; text-decoration: none; word-break: break-all; }
.data-table a:hover { text-decoration: underline; }
.data-table.compact th, .data-table.compact td { padding: 5px 8px; font-size: 12px; }
.data-table .empty-cell { text-align: center; color: #94a3b8; padding: 16px; }
.ellipsis { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.compact-list { list-style: none; padding: 0; margin: 0; }
.compact-list li { padding: 3px 0; border-bottom: 1px dashed #eef2f7; font-size: 13px; }
.compact-list li:last-child { border-bottom: none; }

.kv { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(20,30,50,0.04); }
.kv th, .kv td { padding: 6px 12px; text-align: left; border-bottom: 1px solid #eef2f7; font-size: 13px; }
.kv th { background: #f8fafc; color: #475569; font-weight: 600; width: 220px; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }

/* ─── Forms ─────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #475569; }
.form label.radio, .form label.checkbox {
  flex-direction: row; align-items: center; gap: 8px; color: #1a1f2b;
}
.form input[type=text], .form input[type=number], .form select, .form input[type=password] {
  padding: 8px 10px; font-size: 14px; border: 1px solid #cbd5e1; border-radius: 4px;
  background: white;
}
.form .inline { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.form .tiny { width: 56px; padding: 4px 6px; }
.form .mono { font-family: ui-monospace, monospace; }
.form fieldset.freq { border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 14px; }
.form fieldset.freq legend { font-size: 12px; color: #64748b; padding: 0 4px; }
.form fieldset.freq label.radio { margin: 4px 0; }
.form-actions { display: flex; gap: 8px; align-items: center; }

.inline-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0;
}
.inline-form input[type=text], .inline-form select {
  padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 14px;
  background: white;
}
.inline-form input[type=text] { min-width: 240px; flex: 1; }
.filters { margin-bottom: 14px; }

input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* ─── Misc ──────────────────────────────────────────────────────────── */
.muted { color: #64748b; }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; }
.empty { padding: 30px; text-align: center; color: #94a3b8; background: white;
  border-radius: 8px; border: 1px dashed #cbd5e1; }

.error {
  color: #b91c1c; background: #fee2e2;
  padding: 10px 14px; border-radius: 6px; margin-bottom: 12px;
}
.error-inline { color: #b91c1c; }
.ok {
  color: #166534; background: #dcfce7;
  padding: 10px 14px; border-radius: 6px; margin-bottom: 12px;
}
.error-pre, .config-pre {
  background: #0f172a; color: #cbd5e1; padding: 10px;
  border-radius: 4px; font-family: ui-monospace, monospace; font-size: 12px;
  overflow: auto; max-height: 320px; white-space: pre-wrap;
}
.config-pre { background: #f8fafc; color: #1a1f2b; }
.log-pre {
  background: #0f172a; color: #cbd5e1; padding: 12px;
  border-radius: 6px; font-family: ui-monospace, monospace; font-size: 12px;
  overflow: auto; max-height: 480px; white-space: pre-wrap;
}

.actions-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 16px 0; }

.breadcrumbs { margin-bottom: 12px; color: #64748b; font-family: ui-monospace, monospace; word-break: break-all; }
.breadcrumbs a { color: #2563eb; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ─── Centered (login / OTP) ────────────────────────────────────────── */
.centered {
  max-width: 360px; margin: 60px auto;
  background: white; padding: 28px; border-radius: 8px;
  box-shadow: 0 1px 4px rgba(20,30,50,0.08);
}
.centered label { display: block; font-size: 13px; margin-bottom: 6px; color: #475569; }
.centered input {
  width: 100%; padding: 10px; font-size: 16px;
  border: 1px solid #cbd5e1; border-radius: 4px; margin-bottom: 14px;
}
.centered button {
  width: 100%; padding: 12px; font-size: 15px; min-height: 44px;
  background: #2563eb; color: white; border: none; border-radius: 4px;
  cursor: pointer;
}
.centered .hint { color: #64748b; font-size: 12px; margin-top: 14px; }

@media (max-width: 600px) {
  main { padding: 10px; }
  .data-table th, .data-table td { padding: 6px 6px; font-size: 13px; }
  header { padding: 8px 10px; }
  .ellipsis { max-width: 140px; }
}
