:root {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --surface2: #252840;
  --border: #2e3250;
  --accent: #4f7ef8;
  --accent2: #6c63ff;
  --text: #e2e6f0;
  --text-muted: #7b82a0;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 8px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Header ─────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 52px;
}

header .logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-decoration: none;
  flex-shrink: 0;
}

header .logo img {
  width: 100px !important;
  height: auto !important;
  display: block;
}

header .logo .logo-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-left: 1px;
}

header .logo span { color: var(--accent); }

nav { display: flex; gap: 4px; margin-left: auto; }

nav a {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

nav a:hover, nav a.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

nav a.active { color: var(--accent); }

/* ── Layout ─────────────────────────────────── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px;
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); }

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Form ────────────────────────────────────── */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  align-items: flex-end;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-muted); }

input[type="text"], input[type="date"], input[type="time"], select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus, select:focus { border-color: var(--accent); }
input[type="text"]::placeholder { color: var(--text-muted); }
select option { background: var(--surface2); }

.field.flex1 input { width: 240px; }
.field.flex-sm input { width: 120px; }
.field.flex-xs input, .field.flex-xs select { width: 90px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  padding-bottom: 4px;
}

.checkbox-row input[type="checkbox"] { accent-color: var(--accent); }

/* ── Buttons ─────────────────────────────────── */
button {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.85; }
button:disabled { opacity: 0.45; cursor: default; }
button.secondary {
  background: var(--surface2);
  color: var(--text-muted);
}

/* ── Results ─────────────────────────────────── */
#results { margin-top: 4px; }

.result-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.result-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.result-item .title {
  font-weight: 600;
  margin-bottom: 4px;
}

.result-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-item .snippet {
  font-size: 13px;
  color: #bcc3d8;
  border-left: 2px solid var(--border);
  padding-left: 10px;
  margin-top: 8px;
}

/* ── Tables ──────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.025); }

.delay-pos { color: var(--red); }
.delay-zero { color: var(--green); }
.cancelled { color: var(--red); text-decoration: line-through; opacity: 0.6; }

/* ── Score badges ────────────────────────────── */
.score-high { color: var(--green); font-weight: 600; }
.score-mid  { color: var(--yellow); font-weight: 600; }
.score-low  { color: var(--red); font-weight: 600; }

/* ── Spinner / Error ─────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius);
  color: var(--red);
  padding: 12px 16px;
  font-size: 13px;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
  font-size: 13px;
}

/* ── Index page cards ────────────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s, transform 0.1s;
  cursor: pointer;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}

.tool-card .icon { font-size: 28px; margin-bottom: 10px; }
.tool-card .name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.tool-card .desc { font-size: 12px; color: var(--text-muted); }

/* ── Tabs (within a page) ────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  border: none;
  background: none;
  transition: color 0.15s;
}

.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); font-weight: 600; }

/* ── Misc ────────────────────────────────────── */
.tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  padding: 1px 6px;
  color: var(--text-muted);
}

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.link-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
}

.link-btn:hover { background: var(--surface2); }
