:root {
  --bg: #1e1e1e;
  --bg-elevated: #252526;
  --bg-row-alt: #2a2d2e;
  --text: #e0e0e0;
  --text-muted: #9e9e9e;
  --border: #3c3c3c;
  --accent: #569cd6;
  --accent-hover: #6aa9e0;
  --btn-primary-fg: #111;
  --error: #f48771;
}

html[data-theme='light'] {
  --bg: #f4f4f5;
  --bg-elevated: #ffffff;
  --bg-row-alt: #ececf0;
  --text: #1a1a1a;
  --text-muted: #5c5c5c;
  --border: #d0d0d7;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --btn-primary-fg: #fff;
  --error: #b91c1c;
}

.theme-bar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}

.page-upload {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.upload-card {
  max-width: 36rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
}

.upload-card h1 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.lead {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.file-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  cursor: pointer;
}

.file-label-text {
  font-weight: 500;
}

input[type='file'] {
  color: var(--text-muted);
}

.btn-primary,
.btn-secondary {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent);
  color: var(--btn-primary-fg);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
}

.theme-toggle .theme-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1rem;
  color: var(--accent);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
}

.btn-link:hover {
  text-decoration: underline;
}

.hint {
  margin: 1.5rem 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.hint code {
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.page-results {
  padding: 1rem 1rem 2rem;
}

.results-header {
  margin-bottom: 1rem;
}

.title-block h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-top: 1rem;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 12px;
  color: var(--text-muted);
}

.toolbar select {
  min-width: 10rem;
  padding: 0.4rem 0.5rem;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: calc(100vh - 180px);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.results-table thead th {
  text-align: left;
  padding: 0.5rem 0.45rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
}

.results-table thead th.num {
  text-align: right;
}

.results-table thead th:hover {
  color: var(--accent);
}

.results-table tbody td {
  padding: 0.4rem 0.45rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.results-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.results-table tbody tr:nth-child(even) {
  background: var(--bg-row-alt);
}

.results-table tbody tr.row-disq {
  opacity: 0.55;
}

.error {
  color: var(--error);
  margin-top: 1rem;
}

@media print {
  .no-print {
    display: none !important;
  }

  th.col-print-skip,
  td.col-print-skip {
    display: none !important;
  }

  body.page-results {
    background: #fff;
    color: #111;
    padding: 0.5cm;
    font-size: 9pt;
  }

  .table-wrap {
    border: none;
    overflow: visible;
  }

  .results-table {
    font-size: 8pt;
  }

  .results-table thead th {
    background: #f0f0f0 !important;
    color: #111 !important;
    border-bottom: 1px solid #999;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .results-table tbody td {
    border-bottom: 1px solid #ccc;
    color: #111;
  }

  .results-table tbody tr:nth-child(even) {
    background: #f9f9f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .results-table tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .results-table thead {
    display: table-header-group;
  }

  .title-block h1 {
    color: #111;
    font-size: 14pt;
  }

  .subtitle {
    color: #333;
  }

  @page {
    margin: 1cm;
  }
}
