:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Light Theme */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #cbd5e1;
  --border-light: #e2e8f0;

  --accent-color: #2563eb;
  --accent-light: #dbeafe;
  --spread-positive: #15803d;
  --spread-positive-bg: #dcfce7;

  --status-ok: #15803d;
  --status-suspicious: #b45309;
  --status-invalid: #b91c1c;

  --banner-error-bg: #fee2e2;
  --banner-error-text: #991b1b;
  --banner-error-border: #f87171;

  --banner-clock-bg: #fef3c7;
  --banner-clock-text: #92400e;
  --banner-clock-border: #fcd34d;

  --th-bg: #e2e8f0;
  --row-hover-bg: #f8fafc;
  --row-invalid-bg: #fff1f2;
  --row-suspicious-bg: #fffbeb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #090d16;
    --bg-surface: #111827;
    --bg-surface-subtle: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --border-light: #1f2937;

    --accent-color: #60a5fa;
    --accent-light: #1e3a8a;
    --spread-positive: #4ade80;
    --spread-positive-bg: #064e3b;

    --status-ok: #4ade80;
    --status-suspicious: #fbbf24;
    --status-invalid: #f87171;

    --banner-error-bg: #450a0a;
    --banner-error-text: #fca5a5;
    --banner-error-border: #991b1b;

    --banner-clock-bg: #451a03;
    --banner-clock-text: #fde68a;
    --banner-clock-border: #92400e;

    --th-bg: #1f2937;
    --row-hover-bg: #1e293b;
    --row-invalid-bg: #2d1217;
    --row-suspicious-bg: #2c210e;
  }
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  background: var(--accent-light);
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
}

.banner {
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.banner[hidden] {
  display: none;
}

.error-banner {
  background: var(--banner-error-bg);
  color: var(--banner-error-text);
  border-color: var(--banner-error-border);
}

.clock-banner {
  background: var(--banner-clock-bg);
  color: var(--banner-clock-text);
  border-color: var(--banner-clock-border);
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.control-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.input-text, .select-input {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-surface-subtle);
  color: var(--text-main);
}

.input-text:focus, .select-input:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: -1px;
}

.checkboxes {
  gap: 0.75rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-light);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.table-container {
  flex: 1;
  overflow-x: auto;
  max-width: 100%;
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: left;
}

.board-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--th-bg);
  color: var(--text-main);
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
}

.board-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.board-table thead th.sortable:hover {
  background: var(--border-color);
}

.board-table tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.board-table tbody tr:hover {
  background: var(--row-hover-bg);
}

.board-table tbody tr.row-invalid {
  background: var(--row-invalid-bg);
  color: var(--text-muted);
}

.board-table tbody tr.row-suspicious {
  background: var(--row-suspicious-bg);
}

.positive-spread {
  color: var(--spread-positive);
  font-weight: 600;
}

.status-ok {
  color: var(--status-ok);
  font-weight: 500;
}

.status-suspicious {
  color: var(--status-suspicious);
  font-weight: 500;
}

.status-invalid {
  color: var(--status-invalid);
  font-weight: 500;
}

.loading-cell, .empty-cell {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.footer {
  padding: 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-line {
  margin-bottom: 0.25rem;
}

.footer-line:last-child {
  margin-bottom: 0;
}
