:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --text: #1d1d1f;
  --muted: #636366;
  --line: rgba(60, 60, 67, 0.16);
  --accent: #0071e3;
  --accent-strong: #005bb5;
  --green: #2f7d62;
  --amber: #a76000;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  --soft-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 8px;
  --sidebar: 280px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #fbfbfd 0%, #f1f2f4 48%, #eceef2 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: #e9e9ed;
  color: var(--text);
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
  max-width: 100%;
  line-height: 1.2;
}

button:hover {
  background: #dedee3;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.file-button:focus-visible,
tr[tabindex]:focus-visible {
  outline: 3px solid #005bb5;
  outline-offset: 2px;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 113, 227, 0.24);
}

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

button.danger {
  background: #fee4e2;
  color: var(--red);
}

button.ghost {
  background: transparent;
  color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.button-link {
  text-decoration: none;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #fff;
  color: #005bb5;
  box-shadow: var(--shadow);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.boot-screen,
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.boot-card,
.auth-card {
  width: min(780px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  padding: 32px;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  gap: 28px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, #111827, #3b82f6 52%, #34d399);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 12px 22px rgba(0, 0, 0, 0.14);
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 36px;
  line-height: 1.08;
}

h2 {
  font-size: 26px;
  line-height: 1.15;
}

h3 {
  font-size: 18px;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

ul {
  color: var(--muted);
  line-height: 1.5;
  padding-left: 20px;
}

code {
  border-radius: 6px;
  background: #f1f2f4;
  color: #2f3033;
  padding: 2px 5px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f8fa;
  padding: 12px;
}

pre code {
  display: block;
  padding: 0;
  background: transparent;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: rgba(246, 246, 248, 0.78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.sidebar-title h1 {
  display: block;
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.sidebar-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.nav-item {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-radius: var(--radius);
  background: transparent;
  color: #2f3033;
  padding: 0 12px;
}

.nav-item.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--soft-shadow);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 12px 6px 0;
  border-top: 1px solid var(--line);
}

.user-pill {
  min-height: 44px;
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
}

.user-pill strong {
  color: var(--text);
  font-size: 13px;
}

.content {
  min-width: 0;
  max-width: 100%;
  padding: 26px;
}

.page {
  max-width: 1560px;
  min-width: 0;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

.page-kicker {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.toolbar > * {
  min-width: 0;
}

.report-year-field {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.search-field {
  display: grid;
  gap: 3px;
  min-width: min(100%, 240px);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.report-year-field input {
  min-width: 108px;
}

.provenance-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(20px);
  padding: 18px;
  min-width: 0;
}

.panel > .toolbar:first-child:not(:last-child) {
  margin: -2px 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel > h3 + .toolbar {
  padding-top: 2px;
}

.panel.tight {
  padding: 12px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.summary-card {
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.summary-card span {
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-card strong {
  font-size: 1.25rem;
}

.metric {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric strong {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #343437;
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 113, 227, 0.6);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.checkbox-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafafa;
  color: #48484a;
  font-weight: 700;
}

tr:hover td {
  background: #f7fbff;
}

tr.selected td {
  background: #eaf4ff;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  background: #eef2f6;
  color: #465362;
}

.status.ok {
  background: #ecfdf3;
  color: var(--green);
}

.status::before {
  margin-right: 5px;
  font-weight: 800;
  content: "•";
}

.status.ok::before {
  content: "✓";
}

.status.warn::before {
  content: "!";
}

.status.error::before {
  content: "×";
}

.status.warn {
  background: #fff7e8;
  color: var(--amber);
}

.status.error {
  background: #fef3f2;
  color: var(--red);
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: #e9e9ed;
  border-radius: 999px;
  max-width: 100%;
  overflow-x: auto;
}

.segmented button {
  background: transparent;
  min-height: 32px;
  padding: 0 12px;
  box-shadow: none;
}

.segmented button.active {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.status-slot {
  min-height: 48px;
  display: grid;
  align-items: start;
}

.message {
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #edf7ff;
  border: 1px solid #c6e4ff;
  color: #12395d;
}

.message.error {
  background: #fff1f0;
  border-color: #ffccc7;
  color: var(--red);
}

.message.success {
  background: #ecfdf3;
  border-color: #b7ebc6;
  color: var(--green);
}

.meta-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 8px 0 0;
}

.file-control {
  min-width: min(100%, 260px);
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sr-file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-button,
.button-link {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 16px;
  background: #e9e9ed;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
}

.button-link.primary {
  background: var(--accent);
  color: #fff;
}

.file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-control:focus-within .file-button {
  outline: 3px solid #005bb5;
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.download-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(29, 29, 31, 0.28);
  backdrop-filter: blur(12px);
}

.modal-card {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-actions {
  justify-content: flex-end;
}

.split {
  display: grid;
  grid-template-columns: minmax(340px, 0.82fr) minmax(0, 1.18fr);
  gap: 16px;
}

.list {
  display: grid;
  gap: 8px;
}

.list-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  text-align: left;
  line-height: 1.25;
}

.list-item.active {
  border-color: rgba(0, 113, 227, 0.5);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

tr[tabindex] {
  cursor: pointer;
}

tr[tabindex]:focus td {
  background: #edf6ff;
}

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

.small {
  font-size: 12px;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .sidebar {
    position: static;
    height: auto;
    max-width: 100%;
    overflow: hidden;
  }

  .nav-list {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    white-space: nowrap;
  }

  .content {
    padding: 18px;
  }

  .page,
  .panel,
  .split,
  .grid,
  .form-grid,
  .table-wrap {
    min-width: 0;
    max-width: 100%;
  }

  .grid.two,
  .grid.three,
  .summary-grid,
  .form-grid,
  .split,
  .auth-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 12px;
  }

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

  .toolbar {
    align-items: stretch;
  }

  .toolbar > * {
    flex: 1 1 min(100%, 240px);
    max-width: 100%;
  }

  .file-control,
  .download-actions {
    width: 100%;
  }

  .file-button,
  .button-link {
    flex: 0 0 auto;
  }

  button,
  .file-button,
  .button-link {
    min-height: 44px;
  }

  .mobile-card-table {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .mobile-card-table table,
  .mobile-card-table thead,
  .mobile-card-table tbody,
  .mobile-card-table tr,
  .mobile-card-table th,
  .mobile-card-table td {
    display: block;
  }

  .mobile-card-table table {
    min-width: 0;
  }

  .mobile-card-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .mobile-card-table tbody {
    display: grid;
    gap: 10px;
  }

  .mobile-card-table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-solid);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.045);
    overflow: hidden;
  }

  .mobile-card-table tr:hover td,
  .mobile-card-table tr.selected td {
    background: transparent;
  }

  .mobile-card-table tr.selected {
    border-color: rgba(0, 113, 227, 0.5);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
  }

  .mobile-card-table td {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(92px, 0.36fr) minmax(0, 0.64fr);
    gap: 10px;
    align-items: start;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }

  .mobile-card-table td:last-child {
    border-bottom: 0;
  }

  .mobile-card-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .mobile-card-table td > button,
  .mobile-card-table td > .button-link,
  .mobile-card-table td > .status,
  .mobile-card-table td > select,
  .mobile-card-table td > input {
    max-width: 100%;
  }

  .mobile-card-table td > button,
  .mobile-card-table td > .button-link {
    justify-self: stretch;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  button,
  input,
  select,
  textarea,
  .panel,
  .table-wrap,
  .status {
    border: 1px solid CanvasText;
  }

  button:focus-visible,
  a:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  tr[tabindex]:focus-visible {
    outline: 3px solid Highlight;
  }
}
