/* Theme: warm paper + ink, one forest-green accent. Dark mode is warm
   charcoal, not navy. Colours are tokens so both modes share every rule. */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --rule: #e4dfd5;
  --rule-strong: #cfc8ba;
  --ink: #1c1a17;
  --ink-2: #4a463f;
  --muted: #7c766b;
  --accent: #1f6b4a;        /* forest green: links, primary, PHP version */
  --accent-ink: #ffffff;
  --accent-soft: #e3efe8;
  --amber: #9a6a00;
  --amber-soft: #f6ecd2;
  --brick: #a63a2c;
  --brick-soft: #f7e3df;
  --slate-soft: #ecebe6;
  --focus: #1f6b4a55;
  --sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #1e1c19;
    --surface-2: #232120;
    --rule: #34312c;
    --rule-strong: #47433c;
    --ink: #ece8e1;
    --ink-2: #c4bfb5;
    --muted: #8f897e;
    --accent: #5fb98c;
    --accent-ink: #0f1d16;
    --accent-soft: #1f3329;
    --amber: #e0b44f;
    --amber-soft: #3a2f17;
    --brick: #e38273;
    --brick-soft: #3d221d;
    --slate-soft: #2b2925;
    --focus: #5fb98c55;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* buttons & inputs */
button {
  cursor: pointer; font: inherit; font-weight: 600; border: 1px solid var(--accent);
  border-radius: 4px; padding: 8px 16px; background: var(--accent); color: var(--accent-ink);
}
button:hover { filter: brightness(1.08); }
input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: 4px; padding: 8px 10px;
}
input:focus, select:focus { border-color: var(--accent); outline: 3px solid var(--focus); outline-offset: 0; }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 500; padding: 4px 6px; }
.link-btn.small { font-size: 12px; color: var(--muted); }
.link-btn.small:hover { color: var(--accent); }
.btn.ghost {
  padding: 8px 14px; border: 1px solid var(--rule-strong); border-radius: 4px;
  color: var(--ink-2); background: var(--surface); font-weight: 500;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* login */
.login-page {
  display: flex; flex-direction: column; align-items: center;
  min-height: 100vh; min-height: 100dvh; padding: 16px 16px 0;
}
.login-card {
  background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--accent);
  border-radius: 6px; padding: 32px; width: 360px; max-width: 100%; margin: auto 0;
}
.login-card h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.subtitle { color: var(--muted); margin: 4px 0 22px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 10px; }
.login-card button { width: 100%; margin-top: 6px; padding: 10px; }
.alert.error {
  background: var(--brick-soft); border-left: 3px solid var(--brick); color: var(--brick);
  padding: 10px 12px; border-radius: 4px; margin-bottom: 14px;
}

/* layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--rule);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
a.brand:hover { text-decoration: none; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 6px 12px; border: 1px solid var(--rule-strong); border-radius: 4px;
  color: var(--ink-2); background: var(--surface); font-weight: 500; font-size: 13px;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.topbar .link-btn { white-space: nowrap; }
.brand-by { color: var(--muted); font-weight: 400; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 4px; background: var(--accent);
  display: inline-grid; place-items: center; color: var(--accent-ink);
  font: 600 11px/1 var(--mono);
}
main { padding: 8px 24px 48px; max-width: 1240px; margin: 0 auto; }

.stats-banner {
  max-width: 1240px; margin: 16px auto 0; padding: 0 24px;
  color: var(--muted); font-size: 13px; font-family: var(--mono);
}
.stats-banner .hl { color: var(--ink); font-weight: 500; }
.stats-banner .stat + .stat::before { content: '·'; margin: 0 .5em; }

/* tabs: underline, not pills */
.tabs { display: flex; gap: 22px; flex-wrap: wrap; margin: 18px 0 16px; border-bottom: 1px solid var(--rule); }
.tab {
  padding: 8px 0 10px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-weight: 500;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab .count { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-left: 4px; }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters > * { min-width: 0; max-width: 100%; }
.filters input[type="search"] { flex: 1 1 260px; min-width: 0; }
.summary { color: var(--muted); margin: 4px 0 12px; font-size: 13px; }
.summary strong { color: var(--ink); font-family: var(--mono); font-weight: 500; }

/* table */
table.sites {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 6px; overflow: hidden;
}
.sites th, .sites td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
.sites th {
  background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
}
.sites tbody.site:hover td { background: var(--surface-2); }
.sites td.url a { font-family: var(--mono); font-weight: 500; font-size: 13.5px; }
.sites td.contact a { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 36px; }
.evidence-row td {
  padding-top: 0; color: var(--muted); font-size: 12px; font-family: var(--mono);
  line-height: 1.55; word-break: break-word;
}
.sites tr:has(+ .evidence-row) td { border-bottom: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.inline { display: inline; }

.php-ver { color: var(--accent); font-family: var(--mono); font-weight: 500; white-space: nowrap; }
.php-hidden { color: var(--amber); font-family: var(--mono); }
.php-none { color: var(--muted); font-family: var(--mono); white-space: nowrap; }

/* the table scrolls inside its own box on narrow screens, not the page */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; }
.table-wrap table.sites { border: none; border-radius: 0; }

/* tags: squared, tinted */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 500;
  border: 1px solid transparent; line-height: 1.5; white-space: nowrap;
}
.type-et_tld, .type-et_registrant, .type-et_hosted, .type-manual {
  background: var(--slate-soft); color: var(--ink-2); font-family: var(--mono); font-size: 11.5px;
}
.conf-high { background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.conf-medium { background: var(--amber-soft); color: var(--amber); font-size: 11px; }
button.pill { font-weight: 600; padding: 3px 9px; }
.status-resolved { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status-not { background: var(--brick-soft); color: var(--brick); border-color: transparent; }
.status-resolved:hover, .status-not:hover { border-color: currentColor; filter: none; }
.status-none { background: var(--slate-soft); color: var(--muted); font-weight: 600; padding: 3px 9px; }

.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin-top: 22px; color: var(--muted); }
.pager a { font-weight: 500; }

.site-footer {
  text-align: center; color: var(--muted); font-size: 12px; padding: 18px 0 26px;
  border-top: 1px solid var(--rule); max-width: 1240px; margin: 0 auto;
}
.login-page .site-footer { width: 100%; border-top: none; }

/* phones: the table becomes a stack of cards, one per site (each site is its own tbody) */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .topbar {
    position: sticky; top: 0; z-index: 10; padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .brand { font-size: 15px; }
  main { padding: 4px 16px 32px; }

  /* worker status: wrapping chips instead of one long mono line */
  .stats-banner { margin-top: 12px; padding: 0 16px; font-size: 12px; }
  .stats-banner .stats { display: flex; flex-wrap: wrap; gap: 6px; }
  .stats-banner .stat {
    padding: 4px 8px; border-radius: 4px; background: var(--surface); border: 1px solid var(--rule);
  }
  .stats-banner .stat + .stat::before { content: none; }

  /* tabs scroll sideways, edge to edge, rather than wrapping */
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; gap: 20px; margin: 12px -16px 14px; padding: 0 16px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    /* fade the right edge so it's clear more tabs scroll into view */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 10px 0 12px; }

  /* filters: two-column grid, full-size tap targets; 16px text stops iOS zooming in */
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters input[type="search"] { grid-column: 1 / -1; }
  .filters input, .filters select, .filters button, .filters .btn {
    width: 100%; min-height: 44px; font-size: 16px;
  }
  .filters .btn { display: grid; place-items: center; }

  .summary { font-size: 13px; }

  /* cards */
  .table-wrap { overflow: visible; border: none; border-radius: 0; }
  table.sites, .sites tbody, .sites tr, .sites td { display: block; background: none; }
  .sites thead { display: none; }
  .sites tbody {
    background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
    margin-bottom: 12px; overflow: hidden;
  }
  .sites tbody:hover td { background: none; }
  .sites td { border: none; padding: 0; }

  /* flex-wrap rather than grid: the type pills drop to their own line only when they don't fit */
  .sites .site-row {
    display: flex; flex-wrap: wrap; align-items: center; row-gap: 10px;
    padding: 14px 14px 12px;
  }
  /* the basis leaves room for the status pill only, so the PHP line always wraps below */
  .sites td.url { flex: 1 1 calc(100% - 140px); min-width: 0; }
  .sites td.url a { font-size: 15px; overflow-wrap: anywhere; }
  /* status comes after PHP/type in the markup; pull it up beside the domain */
  .sites .site-row td { order: 2; }
  .sites td.url { order: 0; }
  .sites td.status { order: 1; flex: none; padding-left: 12px; }
  .sites td.php { flex: 1 1 auto; }
  .sites td.type { flex: 0 1 auto; margin-left: auto; padding-left: 12px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  .sites td.cms, .sites td.contact { flex: 0 0 100%; min-width: 0; }
  .sites td.cms { padding-top: 12px; border-top: 1px solid var(--rule); }
  .sites td.contact { overflow-wrap: anywhere; }
  .sites td.checked, .sites td.actions { padding-top: 10px; border-top: 1px solid var(--rule); }
  .sites td.checked { flex: 1 1 auto; align-self: stretch; align-items: center; font-family: var(--mono); white-space: nowrap; }
  .sites td.actions { flex: none; padding-left: 12px; }

  /* labelled fields: small caps label on the left */
  .sites td[data-label] { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
  .sites td[data-label]::before {
    content: attr(data-label); flex: 0 0 64px; color: var(--muted); font-size: 11px;
    font-family: var(--sans); font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  }
  .sites td.checked { font-size: 12px; align-items: center; }

  .sites .php-ver, .sites .php-hidden { font-size: 15px; }
  button.pill { padding: 6px 12px; font-size: 12.5px; }
  .sites td.actions .link-btn {
    padding: 7px 14px; border: 1px solid var(--rule-strong); border-radius: 4px;
    font-size: 13px; color: var(--ink-2);
  }

  .sites .evidence-row td {
    padding: 10px 14px 12px; background: var(--surface-2); border-top: 1px solid var(--rule);
    font-size: 11.5px;
  }
  .empty { padding: 32px 16px; }

  .pager { gap: 10px; justify-content: space-between; }
  .pager a {
    padding: 10px 16px; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--surface);
  }
  .pager span { flex: 1; text-align: center; font-size: 13px; }

  .site-footer { padding-bottom: max(26px, env(safe-area-inset-bottom)); }
  .login-card { padding: 24px 20px; }
  .login-card input { font-size: 16px; }
}

/* on-demand domain check (empty search result) */
.lookup { display: grid; justify-items: center; gap: 10px; padding: 8px 0; color: var(--ink-2); }
.lookup-title { margin: 0; font-size: 15px; color: var(--ink); }
.lookup-status { margin: 0; max-width: 560px; color: var(--muted); }
.lookup-hint { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.lookup.busy .lookup-status { color: var(--ink-2); }
.lookup.busy .lookup-status::before {
  content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--rule-strong); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
.lookup button:disabled { opacity: .6; cursor: progress; }
.mono { font-family: var(--mono); }
.type-manual { background: var(--slate-soft); color: var(--ink-2); font-family: var(--mono); font-size: 11.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* small phones: drop the "Checked" label so the date and recheck button share a line */
@media (max-width: 360px) {
  .sites td.checked::before { display: none; }
}

/* phones: with the back button showing, keep only the "ET" mark of the brand */
@media (max-width: 720px) {
  .topbar-left:has(.back-btn) .brand > span:last-child { display: none; }
  .back-btn { padding: 7px 12px; }
}
