@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;

  --primary: #1b3568;
  --primary-dark: #12233f;
  --primary-light: #2c4a82;
  --secondary: #f99920;
  --secondary-dark: #dd8410;
  --secondary-light: #ffb54d;

  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --border: #e3e7ee;
  --text: #17202e;
  --muted: #64748b;

  --success: #157a52;
  --success-bg: #e2f5ec;
  --warning: #a25b00;
  --warning-bg: #fef0da;
  --danger: #b3261e;
  --danger-bg: #fbe6e5;
  --info: #2f5fd6;
  --info-bg: #e8eefc;
  --neutral: #55617a;
  --neutral-bg: #eaedf3;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.16);

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.75rem;
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: var(--shadow-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--secondary-light), var(--secondary-dark));
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 1.5rem;
  margin-right: auto;
}

.site-nav a {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.site-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.site-nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.data-mode-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.site-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.75rem 3rem;
}

/* ---------- Filter card ---------- */

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.search-row {
  position: relative;
}

.search-row svg {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.filter-form input[type="search"] {
  width: 100%;
  padding: 0.65rem 0.9rem 0.65rem 2.6rem;
  font-size: 0.95rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.85rem 0.65rem;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-field label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-field select {
  width: 100%;
}

.filter-form input,
.filter-form select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.filter-form input:hover,
.filter-form select:hover {
  border-color: #c4cbd8;
}

.filter-form input:focus,
.filter-form select:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(249, 153, 32, 0.2);
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.filter-form button {
  padding: 0.6rem 1.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #1a1204;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.filter-form button:hover {
  filter: brightness(1.04);
  box-shadow: var(--shadow-md);
}

.filter-form button:active {
  transform: translateY(1px);
}

.clear-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.clear-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ---------- Result summary ---------- */

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0.1rem 0.85rem;
}

.result-summary {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}

.result-summary strong {
  color: var(--text);
  font-weight: 600;
}

.export-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.export-button svg {
  width: 15px;
  height: 15px;
}

.export-button:hover {
  border-color: var(--secondary);
  background: var(--surface-2);
}

/* ---------- Table ---------- */

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-scroll {
  overflow: auto;
  max-height: 65vh;
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.reports-table th,
.reports-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.reports-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--primary);
  color: #eef2fb;
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: none;
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.reports-table th.sortable {
  padding: 0;
}

.reports-table th.sortable a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.8rem 0.85rem;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.reports-table th.sortable a:hover {
  color: #fff;
  text-decoration: none;
}

.sort-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0.45;
}

.sort-icon::before,
.sort-icon::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}

.sort-icon::before {
  border-bottom: 4px solid currentColor;
}

.sort-icon::after {
  border-top: 4px solid currentColor;
}

.reports-table th.sorted-asc .sort-icon,
.reports-table th.sorted-desc .sort-icon {
  opacity: 1;
}

.reports-table th.sorted-asc .sort-icon::after {
  visibility: hidden;
}

.reports-table th.sorted-desc .sort-icon::before {
  visibility: hidden;
}

.reports-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}

.reports-table tbody tr:last-child {
  border-bottom: none;
}

.reports-table tbody tr:hover {
  background: var(--surface-2);
}

.reports-table a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.reports-table a:hover {
  color: var(--secondary-dark);
  text-decoration: underline;
}

.text-muted {
  color: var(--muted);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-neutral {
  background: var(--neutral-bg);
  color: var(--neutral);
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 1.25rem;
  font-size: 0.88rem;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pagination a:hover {
  border-color: var(--secondary);
  background: var(--surface-2);
}

/* ---------- Detail page ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.back-link:hover {
  color: var(--secondary-dark);
}

.detail-hero {
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
  color: #fff;
  box-shadow: var(--shadow-md);
}

.detail-hero h1 {
  margin: 0 0 0.6rem;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.report-id {
  display: inline-flex;
  align-items: center;
  color: #dfe6f5;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
}

.detail-section h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  margin: 0 0 0.9rem;
  color: var(--secondary-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.detail-section dl {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.field:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.field:first-child {
  padding-top: 0;
}

.detail-section dt {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-section dd {
  margin: 0;
  font-size: 0.92rem;
  word-break: break-word;
}

/* ---------- Overview page ---------- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.3rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  color: var(--primary);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
}

.overview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
}

.overview-panel h2 {
  font-size: 0.78rem;
  margin: 0 0 0.9rem;
  color: var(--secondary-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 35%) 1fr auto;
  align-items: center;
  gap: 0.7rem;
}

.bar-label {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
}

.bar-count {
  min-width: 2ch;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --primary: #4d6fb0;
    --primary-dark: #0d1420;
    --primary-light: #6f8fd1;
    --secondary: #f99920;
    --secondary-dark: #ffab3d;
    --secondary-light: #ffc161;

    --bg: #0c1119;
    --surface: #151c28;
    --surface-2: #1b2431;
    --border: #2a3548;
    --text: #e7ebf3;
    --muted: #93a1b7;

    --success: #4fd39b;
    --success-bg: rgba(79, 211, 155, 0.14);
    --warning: #ffb454;
    --warning-bg: rgba(255, 180, 84, 0.14);
    --danger: #ff8a80;
    --danger-bg: rgba(255, 138, 128, 0.14);
    --info: #7fa4ff;
    --info-bg: rgba(127, 164, 255, 0.14);
    --neutral: #a7b2c6;
    --neutral-bg: rgba(167, 178, 198, 0.14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  }

  .site-header {
    background: linear-gradient(120deg, #1b3568 0%, #0a0f18 100%);
  }

  .brand-mark {
    color: #17202e;
  }

  .filter-form button {
    color: #1a1204;
  }

  .reports-table thead th {
    background: #1b3568;
    color: #eef2fb;
  }

  .detail-hero {
    background: linear-gradient(120deg, #1b3568 0%, #0a0f18 100%);
  }
}
