/*
 * Restrained product palette shared with the other portfolio demos: neutral
 * greys carry the layout, one indigo accent marks what is interactive.
 */
:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #ececef;
  --border: #e6e6ea;
  --border-strong: #d4d4da;
  --text: #17181c;
  --muted: #6b6f78;
  --faint: #9a9ea6;
  --accent: #5b5bd6;
  --accent-soft: rgb(91 91 214 / 0.1);
  --success: #2f8f5b;
  --warning: #b7791f;
  --danger: #d93f3f;
  --shadow: 0 1px 2px rgb(16 17 20 / 0.04);
  --pop: 0 8px 30px rgb(16 17 20 / 0.12), 0 0 0 1px rgb(16 17 20 / 0.06);
  color-scheme: light;
}

.dark {
  --bg: #0c0d0f;
  --surface: #131416;
  --surface-2: #18191c;
  --surface-3: #1f2024;
  --border: #232428;
  --border-strong: #303237;
  --text: #ecedef;
  --muted: #8b8f98;
  --faint: #5f636b;
  --accent: #7c82ee;
  --accent-soft: rgb(124 130 238 / 0.14);
  --success: #4cb782;
  --warning: #e0b24a;
  --danger: #eb6a6a;
  --shadow: none;
  --pop: 0 12px 40px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(255 255 255 / 0.06);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/20px Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.faint { color: var(--faint); font-size: 12px; line-height: 17px; margin: 10px 0 0; }
.faint a { color: var(--muted); }

/* Top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: 48px; padding: 0 16px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--text); color: var(--bg); }
.mark svg { width: 14px; height: 14px; stroke-width: 2.6; }
.run { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.run .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.run.ok .dot { background: var(--success); }
.run.stale .dot { background: var(--warning); }
.top-actions { margin-left: auto; display: flex; gap: 2px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* Page */
.wrap { max-width: 1280px; margin: 0 auto; padding: 28px 28px 32px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
.meta { margin: 2px 0 0; color: var(--muted); }
.meta a { color: var(--muted); text-underline-offset: 2px; }
.seg { display: inline-flex; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); flex: none; }
.seg button { border: 0; border-radius: 4px; padding: 0 12px; background: none; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }

.card { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.card-title { margin: 0 0 10px; font-size: 13px; font-weight: 500; }

/* Pipeline */
.pipeline { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px;
  overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--border); }
.pipeline li { position: relative; padding: 14px 16px; background: var(--surface); }
.pipeline li + li::before { content: ""; position: absolute; left: -5px; top: 50%; width: 8px; height: 8px; border-top: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong);
  background: var(--surface); transform: translateY(-50%) rotate(45deg); }
.pipeline .step { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.pipeline .step svg { width: 14px; height: 14px; color: var(--faint); }
.pipeline b { display: block; margin-top: 6px; font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pipeline small { display: block; color: var(--faint); font-size: 12px; }

/* Grid */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: stretch; }
.side { display: flex; flex-direction: column; gap: 16px; }
.side .card { padding: 14px 16px; }

/* Table card */
/* The table fills the height of the side column and scrolls inside; it never sets the row height itself. */
.table-card { min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); }
.search { position: relative; flex: 1 1 220px; max-width: 320px; }
.search svg { position: absolute; left: 9px; top: 50%; width: 14px; height: 14px; color: var(--faint); transform: translateY(-50%); }
.search input, select { height: 32px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.search input { width: 100%; padding: 0 10px 0 30px; }
.search input::placeholder { color: var(--faint); }
select { padding: 0 8px; max-width: 180px; }
.search input:hover, select:hover { border-color: var(--border-strong); }
.search input:focus, select:focus { outline: none; border-color: var(--accent); }
select[hidden] { display: none; }
.count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.table-box { flex: 1 1 0; min-height: 560px; overflow: auto; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 0 12px; height: 38px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
thead th { position: sticky; top: 0; z-index: 1; height: 34px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; }
td.num, th.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--faint); font-size: 11px; line-height: 14px; }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }
.empty { color: var(--faint); }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 6px 0; }
td.cat { white-space: normal; min-width: 150px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--muted); font-size: 12px; }
.tag.merged { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent); }
.stars { color: var(--warning); letter-spacing: 1px; }
.stars i { color: var(--surface-3); font-style: normal; }
.note { margin: 0; padding: 10px 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

/* Side cards */
.downloads { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow); font-weight: 500; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { flex: 1; border-color: transparent; background: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 90%, black); }
.coverage, .breakdown { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.coverage li, .breakdown li { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; }
.coverage span, .breakdown span { color: var(--muted); }
.coverage em, .breakdown em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.coverage .complete { display: block; color: var(--faint); font-size: 12px; line-height: 17px; }
.coverage .complete span { color: inherit; }
.bar { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease-out; }
.breakdown .bar i { background: var(--border-strong); }
.breakdown button { all: unset; cursor: pointer; color: var(--text); }
.breakdown button:hover { color: var(--accent); }
.breakdown button:focus-visible { outline: 2px solid var(--accent); }

/* How it works */
.how { margin-top: 28px; }
.how ol { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.how li { counter-increment: s; }
.how li::before { content: counter(s); display: grid; place-items: center; width: 20px; height: 20px; margin-bottom: 8px; border: 1px solid var(--border-strong); border-radius: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
.how b { display: block; font-weight: 500; }
.how li span { display: block; margin-top: 2px; color: var(--muted); }
.foot { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }
.foot a { color: var(--muted); }

/* Record dialog */
dialog { width: min(480px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--pop); }
dialog[open] { animation: pop .14s ease-out; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
@keyframes pop { from { opacity: 0; transform: scale(.98); } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 48px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dl { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; margin: 0; padding: 16px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
dd code { font: 12px ui-monospace, "JetBrains Mono", monospace; color: var(--muted); }
dd a { color: var(--accent); }

@media (max-width: 1000px) {
  .grid { grid-template-columns: 1fr; }
  .table-box { flex: none; max-height: 70vh; min-height: 0; }
  .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .how ol { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .wrap { padding: 20px 16px 28px; }
  .head { flex-direction: column; align-items: stretch; }
  .seg { align-self: flex-start; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .pipeline li + li::before { display: none; }
  .pipeline li:last-child { grid-column: 1 / -1; }
  .run { display: none; }
  .count { margin-left: 0; width: 100%; }
  select { flex: 1; max-width: none; }
  .how ol { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Leads: e-mail status, socials, score, changes */
.mail { word-break: break-all; }
.net { margin-right: 8px; font-size: 12px; }
.sub .tag { margin-right: 6px; }
.st-personal { color: #15803d; border-color: #86efac; }
.st-role { color: var(--muted); }
.st-free-mail { color: #a16207; border-color: #fde68a; }
.st-disposable, .st-invalid { color: #b91c1c; border-color: #fca5a5; }
.score { display: inline-block; min-width: 30px; padding: 1px 6px; border-radius: 6px; font-weight: 600; text-align: center; margin-right: 6px; }
.score.hi { background: #dcfce7; color: #166534; }
.score.mid { background: #fef9c3; color: #854d0e; }
.score.lo { background: #fee2e2; color: #991b1b; }
.dark .score.hi { background: #14532d; color: #bbf7d0; }
.dark .score.mid { background: #713f12; color: #fef08a; }
.dark .score.lo { background: #7f1d1d; color: #fecaca; }
.ch-new { color: #1d4ed8; border-color: #93c5fd; }
.ch-changed { color: #a16207; border-color: #fde68a; }
.deltas { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 8px; }
.deltas button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); }
.closed { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.downloads #crm { flex-basis: 100%; }
td .score + .tag { vertical-align: middle; }
#table td:last-child { min-width: 132px; }

/* Search button, language switch and command palette */
.kbd-btn { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.kbd-btn:hover { background: var(--surface-2); color: var(--text); }
.kbd-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.kbd-btn kbd, .palette kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font: 11px/16px inherit; color: var(--faint); }
.lang-btn { width: auto; padding: 0 7px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
@media (max-width: 640px) { .kbd-btn .kbd-label, .kbd-btn kbd { display: none; } .kbd-btn { border: 0; padding: 0 6px; } }
.palette { width: min(560px, calc(100% - 32px)); margin-top: 12vh; padding: 0; }
.palette::backdrop { background: rgb(0 0 0 / .45); }
.pal-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.pal-search svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.pal-search input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 14px; }
#pal-list { max-height: 52vh; overflow-y: auto; margin: 0; padding: 6px; list-style: none; }
#pal-list [role=option] { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
#pal-list [role=option] span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pal-list [role=option] small { color: var(--faint); font-size: 11.5px; white-space: nowrap; }
#pal-list [aria-selected=true] { background: var(--accent-soft); }
.pal-group { padding: 8px 10px 4px; color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.pal-empty { padding: 24px; text-align: center; color: var(--muted); }
.pal-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 8px 12px; border-top: 1px solid var(--border); color: var(--faint); font-size: 11px; }
