:root {
  --bg: #0f1420;
  --bg-soft: #161d2c;
  --surface: #1b2536;
  --surface-2: #212e44;
  --border: #2a3851;
  --text: #e8edf6;
  --muted: #93a1bb;
  --accent: #4f8cff;
  --accent-2: #6f5cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 80% -10%, #1c2740 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(15, 20, 32, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .dot {
  width: 24px; height: 24px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.nav .who { color: var(--muted); }

.container { max-width: 1080px; margin: 0 auto; padding: 28px; }
.container-narrow { max-width: 440px; margin: 0 auto; padding: 28px; }
.grid { display: grid; gap: 20px; }
@media (min-width: 820px) { .grid-2 { grid-template-columns: 1.3fr 1fr; } }

/* ---------- card ---------- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.auth-card { margin-top: 8vh; }
.auth-logo {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.row { display: grid; gap: 14px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }

input, select {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.checkbox { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); }
.checkbox input { width: auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: transform .08s, opacity .15s;
}
.btn:hover { opacity: .92; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid transparent; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------- alerts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-ok { background: var(--green-soft); color: var(--green); }
.alert-info { background: var(--accent-soft); color: var(--accent); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-queued { background: var(--surface-2); color: var(--muted); }
.badge-running { background: var(--accent-soft); color: var(--accent); }
.badge-done { background: var(--green-soft); color: var(--green); }
.badge-failed { background: var(--red-soft); color: var(--red); }
.badge-cancelled { background: var(--amber-soft); color: var(--amber); }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

/* ---------- progress ---------- */
.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; min-width: 120px; }
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s ease;
}
.progress-meta { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

/* ---------- misc ---------- */
.stack > * + * { margin-top: 18px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-request .spin-hide { display: none; }

/* ---------- report ---------- */
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.report-head h1 { margin: 0; font-size: 22px; }
.report-head .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
@media (min-width: 760px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: linear-gradient(180deg, var(--surface), var(--bg-soft)); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi .value.green { color: var(--green); }
.kpi .value.red { color: var(--red); }

.chart-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-bottom: 20px; }
@media (min-width: 820px) { .chart-grid { grid-template-columns: 1fr 1fr; } .chart-wide { grid-column: 1 / -1; } }
.chart-card { background: linear-gradient(180deg, var(--surface), var(--bg-soft)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.chart-card h3 { margin: 0 0 14px; font-size: 14px; }
.chart-card .canvas-wrap { position: relative; height: 260px; }

.table-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.table-tools input { max-width: 280px; }
.table-scroll { overflow-x: auto; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: " ⇅"; opacity: .4; font-size: 11px; }
.grade { font-weight: 600; }
.grade.F { color: var(--red); }
.row-fail td:first-child { box-shadow: inset 3px 0 0 var(--red); }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tab { padding: 9px 14px; cursor: pointer; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.share-url { font-family: monospace; font-size: 12.5px; background: var(--bg); padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); word-break: break-all; }
