:root {
  color-scheme: light;
  --text: #202124;
  --muted: #5f6368;
  --bg: #ffffff;
  --bg-subtle: #f8f9fa;
  --line: #dadce0;
  --accent: #0f6b75;
  --accent-hover: #0c5860;
  --accent-soft: #e6f3f4;
  --danger: #c5221f;
  --shadow: 0 1px 6px rgba(32, 33, 36, 0.16);
  --shadow-focus: 0 1px 6px rgba(32, 33, 36, 0.22);
  --radius-pill: 28px;
  --radius: 8px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-subtle);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 30;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-weight: 500;
}

.skip-link:focus {
  top: calc(12px + env(safe-area-inset-top, 0px));
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-top: env(safe-area-inset-top, 0px);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent-hover);
}

.brand img {
  display: block;
  border-radius: 6px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-nav a {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.topbar-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.topbar-nav a[aria-current="page"] {
  color: var(--text);
}

.install-btn {
  color: var(--accent);
}

.stats {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px 24px;
  flex: 1;
}

.lead {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 1.05rem;
}

.search-form {
  margin-bottom: 28px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  min-width: 0;
  padding: 4px 6px 4px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(32, 33, 36, 0.04);
  transition:
    box-shadow 0.15s ease,
    border-color 0.15s ease;
}

.search-bar:focus-within {
  border-color: transparent;
  box-shadow: var(--shadow-focus);
}

.search-icon {
  display: flex;
  color: var(--muted);
  flex-shrink: 0;
}

.search-bar input[type="search"] {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  padding: 10px 8px;
  appearance: none;
  -webkit-appearance: none;
}

.search-bar input[type="search"]:focus {
  outline: none;
}

.search-bar input[type="search"]::-webkit-search-decoration,
.search-bar input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-bar input::placeholder {
  color: #80868b;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.search-submit {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 24px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.search-submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

.search-submit:disabled,
.btn-secondary:disabled,
.text-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.progress {
  height: 3px;
  margin: 2px 24px 0;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  animation: progress-slide 1s linear infinite;
}

.search-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 10px;
  min-height: 32px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.text-btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--text);
}

.text-btn[aria-expanded="true"] {
  color: var(--accent);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 14px;
  margin-top: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.filters input,
.filters select {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  min-width: 0;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.filters select {
  min-height: 38px;
}

.filters input:focus,
.filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 117, 0.16);
}

.result-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.state-card {
  margin: 8px 0 28px;
  padding: 28px 20px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.state-msg {
  margin: 0;
  color: var(--muted);
}

.state-card .state-msg {
  max-width: 36rem;
  margin: 0 auto;
}

.state-msg[data-kind="error"] {
  color: var(--danger);
}

.state-card .btn-secondary {
  margin-top: 16px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

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

th,
td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  font-size: 0.925rem;
}

th {
  position: sticky;
  top: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-subtle);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fafafa;
}

.person-name {
  font-weight: 500;
  letter-spacing: -0.01em;
}

.person-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.85rem;
}

.date-cell {
  white-space: nowrap;
  color: var(--text);
}

.row-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px 10px;
  white-space: nowrap;
}

td:last-child {
  width: 1%;
}

.row-actions .text-btn,
.row-actions a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 2px 4px;
}

mark {
  background: var(--accent-soft);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.load-more-wrap .btn-secondary {
  min-width: 180px;
}

.btn-secondary {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.site-footer {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px max(40px, calc(24px + env(safe-area-inset-bottom, 0px)));
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0 0 12px;
}

.admin {
  margin-top: 4px;
}

.admin summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--muted);
}

.admin summary:hover {
  color: var(--text);
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.job-status {
  min-height: 1.25em;
}

@keyframes progress-slide {
  from {
    background-position: -40% 0;
  }
  to {
    background-position: 140% 0;
  }
}

@media (max-width: 720px) {
  .topbar-inner,
  .container,
  .site-footer {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .topbar-inner {
    flex-wrap: nowrap;
    gap: 10px;
  }

  .container {
    padding-top: 20px;
  }

  .brand {
    min-width: 0;
    font-size: 0.9rem;
    gap: 8px;
  }

  .topbar-nav {
    flex-shrink: 0;
    gap: 10px;
  }

  .topbar-nav a {
    font-size: 0.8125rem;
  }

  .topbar-nav a[aria-current="page"] {
    display: none;
  }

  .stats {
    display: none;
  }

  .search-bar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "icon query clear"
      "submit submit submit";
    align-items: center;
    gap: 4px 2px;
    padding: 8px;
    border-radius: 16px;
  }

  .search-icon {
    grid-area: icon;
    padding-left: 8px;
  }

  .search-bar input[type="search"] {
    grid-area: query;
    font-size: 16px;
  }

  .search-bar .icon-btn {
    grid-area: clear;
  }

  .search-submit {
    grid-area: submit;
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    padding: 0 14px;
  }

  .text-btn {
    min-height: 44px;
    padding: 10px 8px;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .filters input,
  .filters select {
    font-size: 16px;
    min-height: 44px;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  .table-wrap {
    border: 0;
    overflow: visible;
  }

  tbody tr {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
  }

  tbody tr:hover {
    background: var(--bg);
  }

  tbody td {
    padding: 0;
    border: 0;
  }

  tbody td + td {
    margin-top: 10px;
  }

  td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .date-cell {
    display: inline;
  }

  .row-actions {
    flex-direction: row;
    gap: 12px;
    margin-top: 4px;
  }

  .row-actions .text-btn,
  .row-actions a {
    min-height: 44px;
    padding: 8px 4px;
  }

  .job-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .load-more-wrap .btn-secondary {
    min-height: 44px;
    width: 100%;
  }

  .page-title {
    font-size: 1.6rem;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-grid .stat-card:first-child {
    grid-column: 1 / -1;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .gaps-table {
    display: block;
  }

  .gaps-table thead {
    display: none;
  }

  .gaps-table tr {
    display: block;
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
  }

  .gaps-table td {
    display: block;
    padding: 0;
    border: 0;
  }

  .gaps-table td + td {
    margin-top: 8px;
  }

  .bar-row {
    grid-template-columns: 4.6rem minmax(0, 1fr) 3.2rem;
    gap: 6px;
  }
}

.page-title {
  margin: 0 0 8px;
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.stats-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats-section {
  margin-top: 48px;
}

.stats-section h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stats-section h3 {
  margin: 28px 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.stats-section p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 24px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stat-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.bar-chart {
  display: grid;
  gap: 6px;
}

.bar-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) 3.6rem;
  gap: 8px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  min-height: 26px;
}

a.bar-row {
  color: inherit;
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 4px;
  margin: 0 -4px;
}

a.bar-row:hover {
  text-decoration: none;
}

a.bar-row:hover .bar-label,
a.bar-row:focus-visible .bar-label {
  text-decoration: underline;
  text-underline-offset: 2px;
}

a.bar-row:hover .bar-fill {
  background: var(--accent-hover);
}

.bar-row.compact {
  min-height: 22px;
}

.bar-label {
  color: var(--text);
  font-size: 0.8rem;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.bar-row .bar-label {
  color: var(--accent);
}

.bar-track {
  height: 12px;
  background: var(--bg-subtle);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.bar-value {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.gaps-table {
  width: 100%;
  border-collapse: collapse;
}

.gaps-table th,
.gaps-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.gaps-table th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-subtle);
}

.gaps-table .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.retry-btn {
  display: block;
  margin: 12px auto 0;
}

.fine-print {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .progress {
    animation: none;
    background: var(--accent);
  }
}

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px max(64px, env(safe-area-inset-bottom, 0px));
}

.login-card {
  width: 100%;
  max-width: 22rem;
}

.login-card h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.login-error {
  margin: 20px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.9rem;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.login-form input {
  min-height: 44px;
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.login-submit {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
}

.cf-turnstile {
  min-height: 65px;
}

.logout-form {
  display: inline;
  margin: 0;
}
