:root {
  color-scheme: light;

  --hue: 250;

  --bg: oklch(98.5% 0.004 var(--hue));
  --surface: oklch(100% 0 0);
  --surface-2: oklch(96.5% 0.006 var(--hue));
  --surface-3: oklch(94% 0.008 var(--hue));

  --ink: oklch(22% 0.018 var(--hue));
  --ink-2: oklch(38% 0.018 var(--hue));
  --muted: oklch(55% 0.014 var(--hue));
  --faint: oklch(72% 0.012 var(--hue));

  --line: oklch(91% 0.008 var(--hue));
  --line-strong: oklch(85% 0.012 var(--hue));

  --accent: oklch(48% 0.14 165);
  --accent-ink: oklch(28% 0.09 165);
  --accent-soft: oklch(95% 0.04 165);

  --warn: oklch(58% 0.18 35);
  --warn-soft: oklch(95% 0.04 35);

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 0 oklch(20% 0.02 var(--hue) / 0.04), 0 4px 14px oklch(20% 0.02 var(--hue) / 0.05);
  --shadow-2: 0 1px 0 oklch(20% 0.02 var(--hue) / 0.05), 0 12px 32px oklch(20% 0.02 var(--hue) / 0.08);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 140ms;
  --dur: 220ms;

  font-family: "Inter var", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "ss01", "cv11", "tnum";
}

@supports (font-variation-settings: normal) {
  :root { font-family: "Inter var", Inter, ui-sans-serif, system-ui, sans-serif; }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* Top bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: oklch(100% 0 0 / 0.85);
  backdrop-filter: saturate(140%) blur(10px);
}

.bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 52px;
  padding: 0 24px;
  max-width: 1240px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}

.brand-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  transform: translateY(1px);
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-tag {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.bar-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar-count.is-active { color: var(--ink); }
.bar-count.is-error { color: var(--warn); }

/* Page shell */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 80px;
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Form */

.form {
  padding: 18px 20px 20px;
  display: grid;
  gap: 14px;
}

.panel > .form { padding-top: 14px; }
.panel > .panel-title { padding: 18px 20px 0; }

.row {
  display: grid;
  grid-template-columns: 1fr 220px 200px;
  gap: 12px;
  align-items: end;
}

.row-tight {
  grid-template-columns: 140px 140px 1fr;
}

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

.field.grow { min-width: 0; }
.field.narrow { max-width: 160px; }

.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="search"],
input[type="number"],
select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

input::placeholder { color: var(--faint); }

input:hover,
select:hover { border-color: oklch(78% 0.014 var(--hue)); }

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(78% 0.12 165 / 0.22);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5 6 7.5l3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  white-space: nowrap;
}

.btn:hover { border-color: oklch(72% 0.018 var(--hue)); background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px oklch(78% 0.12 165 / 0.28); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: var(--line-strong); }

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

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.btn-primary:hover {
  background: oklch(28% 0.022 var(--hue));
  border-color: oklch(28% 0.022 var(--hue));
}

.btn-primary:active { background: oklch(18% 0.018 var(--hue)); }
.btn-primary svg { color: oklch(80% 0.014 var(--hue)); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 5px;
  background: oklch(100% 0 0 / 0.18);
  color: oklch(100% 0 0 / 0.85);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
}

/* Results header */

.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.results-headline { display: grid; gap: 6px; }

.status {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
}

.status.is-error { color: var(--warn); }
.status.is-loading { color: var(--muted); }

.results-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.filter {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.filter svg {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
}

.filter input {
  width: 240px;
  height: 36px;
  padding-left: 30px;
}

/* Table */

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 360px);
  min-height: 320px;
}

.data-table {
  width: 100%;
  min-width: 880px;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }

thead th .sort-glyph {
  display: inline-block;
  margin-left: 4px;
  color: var(--faint);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

thead th.is-sorted-asc .sort-glyph { color: var(--ink); transform: rotate(180deg); }
thead th.is-sorted-desc .sort-glyph { color: var(--ink); }

.col-pick { width: 38px; padding-left: 18px; padding-right: 4px; }

tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13.5px;
}

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

tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

tbody tr:hover { background: var(--surface-2); }
tbody tr.is-selected { background: var(--accent-soft); }
tbody tr.is-selected:hover { background: oklch(92% 0.045 165); }

.cell-title {
  display: grid;
  gap: 4px;
  max-width: 460px;
}

.cell-title a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.005em;
}

.cell-title a:hover { color: var(--accent); }

.cell-title a::after {
  content: "↗";
  margin-left: 6px;
  color: var(--faint);
  font-weight: 400;
  transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  display: inline-block;
}

.cell-title a:hover::after { color: var(--accent); transform: translate(2px, -2px); }

.cell-summary {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cell-company { font-weight: 500; }

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.pill.pill-cdi { background: var(--accent-soft); border-color: oklch(86% 0.06 165); color: var(--accent-ink); }
.pill.pill-stage { background: oklch(95% 0.04 65); border-color: oklch(86% 0.07 65); color: oklch(38% 0.1 65); }
.pill.pill-alt { background: oklch(95% 0.04 290); border-color: oklch(86% 0.07 290); color: oklch(38% 0.12 290); }
.pill.pill-cdd { background: oklch(95% 0.035 220); border-color: oklch(86% 0.06 220); color: oklch(38% 0.1 220); }
.pill.pill-freelance { background: oklch(95% 0.04 25); border-color: oklch(86% 0.07 25); color: oklch(40% 0.12 25); }

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

/* Checkbox */

.check {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.check input { position: absolute; opacity: 0; pointer-events: none; }

.check-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  display: inline-grid;
  place-items: center;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.check input:checked + .check-box {
  background: var(--accent);
  border-color: var(--accent);
}

.check input:checked + .check-box::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 1.6px solid #fff;
  border-bottom: 1.6px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.check input:focus-visible + .check-box {
  box-shadow: 0 0 0 3px oklch(78% 0.12 165 / 0.28);
}

/* Empty / loading */

.empty {
  padding: 0 !important;
  border-bottom: none !important;
}

.empty-inner {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 56px 20px;
  color: var(--muted);
}

.empty-inner strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.empty-glyph {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: repeating-linear-gradient(
    45deg,
    var(--surface-2),
    var(--surface-2) 4px,
    var(--surface-3) 4px,
    var(--surface-3) 8px
  );
  margin-bottom: 4px;
}

.skeleton-row td {
  padding: 14px;
}

.skeleton-bar {
  display: block;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-bar.short { width: 40%; }
.skeleton-bar.medium { width: 65%; }
.skeleton-bar.long { width: 85%; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Footer */

.results-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.footnote {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.footnote.is-active { color: var(--ink); font-weight: 500; }

/* Toast */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 30;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-error { background: var(--warn); }

/* Responsive */

@media (max-width: 980px) {
  .row { grid-template-columns: 1fr 1fr; }
  .row .field.grow { grid-column: 1 / -1; }
  .row-tight { grid-template-columns: 1fr 1fr 1fr; }
  .filter input { width: 200px; }
  .table-wrap { max-height: none; }
}

@media (max-width: 720px) {
  .page { padding: 18px 14px 60px; }
  .bar-inner { padding: 0 14px; }
  .row, .row-tight { grid-template-columns: 1fr; }
  .results-header { flex-direction: column; align-items: stretch; }
  .results-tools { flex-direction: column; align-items: stretch; }
  .filter input { width: 100%; }
  .actions { justify-content: stretch; }
  .actions .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
