:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-soft: #f9faf8;
  --ink: #1f2421;
  --muted: #626a65;
  --line: #dce1dd;
  --brand: #7a1f36;
  --brand-strong: #64172b;
  --accent: #d78644;
  --success: #18744f;
  --danger: #a53333;
  --focus: #187a91;
  --shadow: 0 8px 24px rgba(31, 36, 33, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, .table-frame:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 65%, white);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  color: white;
  background: var(--brand);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand { color: var(--brand); text-decoration: none; font-size: 20px; display: inline-flex; align-items: center; min-height: 48px; }
.brand img { display: block; width: 174px; height: auto; }

.language-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  background: #edf0ed;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.language-switch button {
  min-width: 48px;
  min-height: 40px;
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
}
.language-switch button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 5px rgba(31, 36, 33, 0.12);
}

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 56px; }
.page-heading, .section-heading, .toolbar, footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.page-heading { margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 32px; line-height: 1.2; font-weight: 760; }
h2 { margin-bottom: 6px; font-size: 21px; line-height: 1.3; font-weight: 720; }
.eyebrow { margin-bottom: 5px; color: var(--brand); font-size: 13px; font-weight: 750; text-transform: uppercase; }
.intro, .state-panel p, footer p { margin-bottom: 0; color: var(--muted); }

.status-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 9px;
  min-height: 44px;
  padding: 9px 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 650;
}
.status-dot { width: 9px; height: 9px; background: #8b928d; border-radius: 50%; }
.status-badge[data-state="loading"] .status-dot { background: var(--accent); }
.status-badge[data-state="ready"] .status-dot { background: var(--success); }
.status-badge[data-state="error"] .status-dot { background: var(--danger); }

.state-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 150px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.state-panel[hidden], [hidden] { display: none !important; }
.state-icon, .spinner {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  color: var(--brand);
  background: #f7ecef;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}
.state-error { border-color: #e5bbbb; }
.state-error .state-icon { color: var(--danger); background: #fff0f0; font-size: 24px; }
.spinner { border: 4px solid #ead8dd; border-top-color: var(--brand); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metric span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
.metric strong { display: block; overflow-wrap: anywhere; font-size: 20px; font-variant-numeric: tabular-nums; }

.toolbar, .records-section {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.toolbar { margin-bottom: 16px; }
.file-summary { min-width: 0; }
.file-summary span, .file-summary small { display: block; color: var(--muted); font-size: 13px; }
.file-summary strong { display: block; max-width: 52ch; overflow-wrap: anywhere; }
.actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.primary-button, .secondary-button, .icon-button {
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.primary-button { color: white; background: var(--brand); border-color: var(--brand); }
.primary-button:hover { background: var(--brand-strong); }
.secondary-button { color: var(--brand); background: var(--surface); border-color: #cdaab4; }
.secondary-button:hover { background: #fbf3f5; }
.icon-button { display: inline-grid; place-items: center; width: 46px; padding: 0; color: var(--ink); background: var(--surface-soft); border-color: var(--line); }
button:disabled { cursor: not-allowed; opacity: 0.46; }

.records-section { padding-bottom: 16px; }
.section-heading { align-items: end; margin-bottom: 14px; }
.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(340px, 100%);
  min-height: 46px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.search-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(24, 122, 145, 0.15); }
.search-field input { width: 100%; min-width: 0; height: 44px; color: var(--ink); background: transparent; border: 0; outline: 0; }
.table-summary { margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.table-frame { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; min-width: 1480px; border-collapse: collapse; font-size: 14px; }
th, td { max-width: 320px; padding: 12px 14px; overflow-wrap: anywhere; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; z-index: 1; color: #424945; background: #f0f3f0; font-size: 12px; font-weight: 750; }
tbody tr:nth-child(even) { background: #fafbfa; }
tbody tr:hover { background: #f6f0f2; }
tbody tr:last-child td { border-bottom: 0; }
.empty-row { padding: 28px; color: var(--muted); text-align: center; }

footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
footer nav { display: flex; gap: 18px; }
footer a { min-height: 44px; padding: 11px 0; color: var(--brand); font-weight: 650; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .site-header { min-height: 64px; padding: 8px 16px; }
  .brand img { width: 148px; }
  .page-shell { width: min(100% - 24px, 1180px); padding: 26px 0 40px; }
  .page-heading, .section-heading, .toolbar, footer { align-items: stretch; flex-direction: column; gap: 14px; }
  h1 { font-size: 27px; }
  .status-badge { align-self: flex-start; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { padding: 16px; }
  .actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 46px; width: 100%; }
  .primary-button, .secondary-button { padding-inline: 10px; }
  .search-field { width: 100%; }
  .records-section { padding: 0; background: transparent; border: 0; }
  .table-frame { overflow: visible; border: 0; }
  table, tbody { display: block; width: 100%; min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  tbody { display: grid; gap: 12px; }
  tbody tr { display: block; overflow: hidden; background: var(--surface) !important; border: 1px solid var(--line); border-radius: 8px; }
  tbody td {
    display: grid;
    grid-template-columns: minmax(108px, 36%) minmax(0, 1fr);
    gap: 12px;
    max-width: none;
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 750; }
  tbody tr:last-child td { border-bottom: 1px solid var(--line); }
  tbody td:last-child { border-bottom: 0 !important; }
  tbody .empty-row { display: block; padding: 28px 16px; text-align: center; }
  tbody .empty-row::before { content: none; }
  footer { width: min(100% - 24px, 1180px); }
}

@media (max-width: 430px) {
  .brand img { width: 132px; }
  .language-switch button { min-width: 44px; padding-inline: 7px; }
  .summary-grid { grid-template-columns: 1fr; }
  .metric { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px; }
  .metric span { margin: 0; }
  .metric strong { font-size: 17px; text-align: right; }
  .state-panel { align-items: flex-start; padding: 20px; }
  .actions { grid-template-columns: 1fr 46px; }
  .actions .primary-button { grid-column: 1 / -1; }
  .records-section { padding: 0; }
}

@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 print {
  body { background: white; }
  .site-header, .language-switch, .actions, .search-field, footer, .status-badge { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .toolbar, .records-section, .metric { border-color: #bbb; box-shadow: none; }
  .table-frame { overflow: visible; }
  table { min-width: 100%; font-size: 9px; }
  th, td { max-width: none; padding: 5px; }
}
