:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #eef2f7;
  --text: #172033;
  --muted: #5e697b;
  --border: #d6dce7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #a53a3a;
  --shadow: 0 18px 50px rgb(23 32 51 / 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 40px clamp(20px, 5vw, 72px) 28px;
  background: #172033;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 8px;
  color: #98d8d0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.header-copy {
  max-width: 760px;
  margin-bottom: 0;
  color: #d6dce7;
  font-size: 1.05rem;
}

.github-link {
  color: #ffffff;
  text-decoration: none;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 8px;
  padding: 10px 14px;
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 56px) 48px;
}

.panel,
.repo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.setup-panel {
  align-self: start;
}

.search-panel {
  align-self: start;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
}

input:focus,
select:focus,
button:focus-visible,
.github-link:focus-visible,
.import-button:focus-within {
  outline: 3px solid rgb(15 118 110 / 0.28);
  outline-offset: 2px;
}

.load-form,
.search-grid {
  display: grid;
  gap: 14px;
}

.search-grid {
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr));
}

.wide {
  min-width: 0;
}

.form-actions,
.toolbar,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.form-actions {
  margin-top: 4px;
}

.filters {
  margin-top: 14px;
}

.filters label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.filters input {
  min-height: auto;
  width: auto;
}

.toolbar {
  margin-top: 16px;
}

button,
.import-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 14px;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button,
.import-button {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary-button:hover,
.import-button:hover {
  background: #e1e7f0;
}

.danger-button {
  color: var(--danger);
}

.import-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.progress {
  margin-top: 16px;
  min-height: 48px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.92rem;
}

.cache-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.results-region {
  grid-column: 1 / -1;
}

.results {
  display: grid;
  gap: 12px;
}

.result-table-shell {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.result-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.result-table th,
.result-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.result-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
}

.result-table tbody tr:hover {
  background: #f2f7f6;
}

.table-sort-button {
  min-height: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.table-sort-button:hover {
  background: transparent;
  color: var(--accent-strong);
}

.table-filter-row th {
  top: 38px;
  padding-top: 0;
}

.table-filter {
  min-height: 34px;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.84rem;
  font-weight: 600;
}

.repo-table-name {
  color: var(--accent-strong);
  font-weight: 850;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.repo-table-name:hover {
  text-decoration: underline;
}

.repo-table-description {
  max-width: 520px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.repo-table-starrank {
  font-weight: 850;
}

.empty-table-cell {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.repo-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 18px;
  padding: 18px;
}

.repo-name {
  color: var(--accent-strong);
  font-size: 1.08rem;
  font-weight: 850;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.repo-name:hover {
  text-decoration: underline;
}

.repo-description {
  margin: 8px 0 12px;
  color: var(--muted);
}

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic {
  padding: 3px 8px;
  border-radius: 999px;
  background: #e5f3f1;
  color: #115e59;
  font-size: 0.8rem;
  font-weight: 800;
}

.insights-panel {
  grid-column: 1 / -1;
}

.insights-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.insights-controls label {
  min-inline-size: min(100%, 360px);
}

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

.insight-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.insight-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.insight-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insight-item {
  display: grid;
  gap: 4px;
}

.insight-title {
  color: var(--accent-strong);
  font-weight: 850;
  text-decoration: none;
}

.insight-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.insight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.insight-action {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 0.82rem;
}

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

.repo-meta {
  display: grid;
  gap: 10px;
  margin: 0;
  color: var(--muted);
}

.repo-meta div {
  display: grid;
  gap: 2px;
}

.repo-meta dt {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.repo-meta dd {
  margin: 0;
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.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;
}

@media (max-width: 960px) {
  .app-header,
  .app-shell,
  .insights-grid,
  .repo-card,
  .search-grid {
    grid-template-columns: 1fr;
  }

  .github-link {
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding-top: 28px;
  }

  h1 {
    font-size: 2.2rem;
  }

  .form-actions,
  .insights-controls,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  button,
  .import-button {
    width: 100%;
    text-align: center;
  }
}
