* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #d7dde6;
  --text: #18202a;
  --text-muted: #5d6877;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --success-soft: #dcfce7;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151d;
  --surface: #18212c;
  --surface-muted: #111923;
  --border: #2d3948;
  --text: #edf2f7;
  --text-muted: #a2afc0;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --accent-soft: rgba(96, 165, 250, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.18);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

body {
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  margin: 0;
  padding: 2rem 1rem 3rem;
  color: var(--text);
}

.page-shell {
  max-width: 1120px;
  margin: 0 auto;
}

.page-header,
header,
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-title,
h1 {
  margin: 0;
  font-size: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.card-wide {
  max-width: 1120px;
}

h2 {
  font-size: 1.1rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.card > header h2,
.section-header h2 {
  margin-top: 0;
  margin-bottom: 0.25rem;
}

.section-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

label,
.theme-control {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.theme-control {
  min-width: 140px;
  margin-bottom: 0;
  color: var(--text-muted);
}

input,
select {
  display: block;
  width: 100%;
  padding: 0.6rem 0.7rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.65rem 1.15rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

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

button.stop {
  background: var(--danger);
}

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

button.link {
  background: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
}

button.link:hover {
  background: none;
  color: var(--accent-strong);
}

.secondary-btn {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.error {
  color: var(--danger);
  min-height: 1.2rem;
  font-size: 0.9rem;
}

.elapsed {
  font-size: 2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.filters,
.inline-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filters label,
.inline-form label {
  margin-bottom: 0;
  min-width: 180px;
  flex: 1 1 220px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--text-muted);
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-badge.is-active {
  color: var(--success);
  background: var(--success-soft);
}

.status-badge.is-inactive {
  color: var(--danger);
  background: var(--danger-soft);
}

tr.is-inactive td {
  color: var(--text-muted);
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-strong);
}

[hidden] { display: none !important; }

@media (max-width: 720px) {
  body {
    padding: 1rem 0.75rem 2rem;
  }

  .card {
    padding: 1.2rem;
  }

  .page-header,
  header,
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: space-between;
  }

  button,
  .secondary-btn {
    width: 100%;
  }

  .row-actions button {
    width: auto;
  }
}
