/* ==========================================================================
   Domain manager: plain CSS, no build step. Light theme only.
   1 Tokens  2 Base  3 Controls  4 Shell  5 Components  6 Data grid
   7 Page specifics  8 Responsive  9 Reduced motion
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* surfaces */
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --surface-3: #f7f9fb;
  --border: #d8e0e9;
  --border-subtle: #e8edf2;

  /* ink */
  --ink: #15212e;
  --ink-muted: #4b5b6c;
  --ink-faint: #67778a;

  /* brand: the legacy tab strip */
  --tab-bg: #9ecbf0;
  --tab-ink: #0b2540;
  --tab-hover: #b8d9f5;

  /* action */
  --primary: #1f6fb8;
  --primary-hover: #185a96;
  --primary-soft: #e6f0fa;
  --focus-ring: 0 0 0 3px rgb(31 111 184 / .32);

  /* status triples */
  --danger: #b42318; --danger-bg: #fdf0ef; --danger-border: #f0b9b3;
  --warn: #8a5a00;   --warn-bg: #fff6dc;   --warn-border: #ebd28a;
  --ok: #176b2c;     --ok-bg: #e8f5ec;     --ok-border: #a8d8b6;
  --dirty-bg: #fff3c4;
  --draft-bg: #eef9ee;

  /* space, radius, depth, motion */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-sm: 6px; --r-md: 8px;
  --shadow: 0 1px 2px rgb(16 32 48 / .06), 0 1px 1px rgb(16 32 48 / .04);
  --ease: 120ms ease-out;
  --grid-head-h: 36px;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2367778a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --chev-faint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2367778a' stroke-opacity='.45' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  accent-color: var(--primary);
  caret-color: var(--primary);
}

/* 2. Base and browser surfaces --------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); }
h2 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h3 { font-size: 16px; font-weight: 600; line-height: 1.3; }
h4 { font-size: 13px; font-weight: 600; color: var(--ink-muted); margin-top: var(--s4); }
p { margin: 0; }
::selection { background: #cfe3f6; color: var(--ink); }
a { color: var(--primary); text-underline-offset: .18em; text-decoration-thickness: 1px; }
.table-wrap, .checklist, .drawer { scrollbar-color: #b9c6d3 transparent; scrollbar-width: thin; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon { flex: none; vertical-align: -3px; }
.hint { color: var(--ink-muted); }
small.hint { font-size: 13px; font-weight: 400; margin-left: var(--s1); }
p.hint { margin: var(--s1) 0; }
.small { width: 8rem; }

/* 3. Controls --------------------------------------------------------------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  font: inherit; font-weight: 500; line-height: 1;
  color: var(--ink); text-decoration: none; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}
button:hover, .button:hover { background: var(--surface-3); border-color: #c3cedb; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.danger { color: var(--danger); border-color: var(--danger-border); }
button.danger:hover { background: var(--danger-bg); border-color: var(--danger-border); }
button.sm, .button.sm { height: 26px; padding: 0 8px; font-size: 13px; }
button:disabled, button[data-loading] { opacity: .5; cursor: not-allowed; }

/* Link-style buttons reset the base completely: keep after the base button rules. */
button.link {
  display: inline; height: auto; padding: 0; background: none; border: 0; border-radius: 0;
  color: var(--primary); font-weight: 400; line-height: inherit; white-space: normal;
}
button.link:hover { background: none; text-decoration: underline; text-underline-offset: .18em; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; vertical-align: middle;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--ink-faint); text-decoration: none; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--primary); border-color: transparent; }

input, select, textarea { font: inherit; color: var(--ink); }
input:where(:not([type=checkbox]):not([type=radio]):not([type=range])), select, textarea {
  height: 32px; padding: 0 10px;
  background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
::placeholder { color: var(--ink-faint); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--primary); box-shadow: var(--focus-ring);
}
[aria-invalid="true"] { border-color: var(--danger) !important; }
[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px rgb(180 35 24 / .25); }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 28px;
  background-image: var(--chev); background-repeat: no-repeat; background-position: right 8px center;
}
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0 4px 0 0; vertical-align: -3px; }
input:disabled, select:disabled, textarea:disabled { opacity: .6; }
label { cursor: default; }

/* empty dates: hide the mm/dd/yyyy noise until focused */
input[type=date].is-empty:not(:focus) { color: transparent; }
input[type=date].is-empty:not(:focus)::-webkit-datetime-edit { color: transparent; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
input[type=date].is-empty:not(:focus):not(:hover)::-webkit-calendar-picker-indicator { opacity: 0; }
input[type=date]:hover::-webkit-calendar-picker-indicator { opacity: 1; }

/* 4. Shell ------------------------------------------------------------------ */
.top {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 52px; padding: 0 var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.top h1 {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 17px; font-weight: 650; letter-spacing: -.01em;
}
.top h1 .icon { width: 20px; height: 20px; color: var(--primary); }
.who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-muted); }
.who strong { font-weight: 600; color: var(--ink); }
.who form { display: inline-flex; margin: 0; }
.who-sep { color: var(--ink-faint); }
.who button.link { font-size: 13px; }

.tabs { display: flex; flex-wrap: wrap; background: var(--tab-bg); }
.tabs a {
  display: inline-flex; align-items: center; height: 40px; padding: 0 14px;
  font-size: 14px; font-weight: 500; color: var(--tab-ink); text-decoration: none;
  transition: background-color var(--ease);
}
.tabs a:hover { background: var(--tab-hover); }
.tabs a.active, .tabs a[aria-current=page] { background: var(--surface); }
.tabs a:focus-visible { outline: 2px solid var(--tab-ink); outline-offset: -2px; }

main { padding: var(--s4); }
main > * { min-width: 0; }

/* 5. Components ------------------------------------------------------------- */
.card, .panel, .tile, .advanced, .run {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow);
}
.card { max-width: 360px; margin: var(--s5) auto; padding: var(--s5); display: grid; gap: 14px; }
.card h2 { font-size: 18px; }
.card label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-muted); }
.card input:not([type=checkbox]):not([type=radio]) { width: 100%; height: 40px; font-size: 14px; color: var(--ink); }
.card.wide { max-width: 520px; }
.card fieldset { border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--s3); margin: 0; }
.card legend { font-size: 13px; font-weight: 600; padding: 0 var(--s1); }
.card label.check { display: block; font-size: 14px; font-weight: 400; color: var(--ink); }
.card label.check.inline { display: inline-block; margin-left: .6rem; }
.card .windows { margin-top: .4rem; }
.card .buttons { display: flex; gap: .6rem; flex-wrap: wrap; }
.card button:not(.link) { height: 40px; }
.prefs .card { margin: var(--s4) auto; }
.err {
  display: flex; align-items: center; gap: 6px; margin: 0;
  color: var(--danger); font-size: 13px;
}
.err .icon { width: 14px; height: 14px; }
.panel { padding: var(--s4); }
.panel > h3 { margin-bottom: var(--s3); }
.panel table.grid { margin: 0 -4px; width: calc(100% + 8px); }

.toast, .row-error, .merge-prompt, .filter-note {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3); border-radius: var(--r-sm); border: 1px solid;
}
.toast { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); margin-bottom: var(--s4); }
.grid-page > .toast { margin-bottom: 0; }
.row-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.merge-prompt { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); flex-wrap: wrap; }
.merge-prompt button { margin-left: .5rem; }
.filter-note { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); flex-wrap: wrap; }
.filter-note button { margin-left: auto; }
.toast .icon, .row-error .icon, .filter-note .icon { width: 16px; height: 16px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.4;
  background: var(--primary-soft); color: #1d5a94;
}
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.panel h3 .badge { margin-left: var(--s2); vertical-align: 1px; }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid transparent;
  font-size: 12px; font-weight: 600; line-height: 1.5; font-variant-numeric: tabular-nums;
}
.pill-bad { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.pill-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.pill-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }
td.last-check .warn { color: var(--warn); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }

details.advanced { padding: 0; }
details.advanced > summary {
  display: flex; align-items: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s3);
  font-weight: 500; cursor: pointer; list-style: none; user-select: none;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary .icon { transition: transform var(--ease); color: var(--ink-faint); }
details.advanced[open] > summary .icon { transform: rotate(90deg); }
details.advanced[open] > summary { border-bottom: 1px solid var(--border); }
.advanced .lists {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s4); padding: var(--s3);
}
.advanced fieldset { border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--s3); margin: 0; min-width: 0; }
.advanced legend { font-size: 13px; font-weight: 600; padding: 0 var(--s1); }
.advanced fieldset > label { display: inline-block; margin-right: var(--s3); }
.advanced fieldset > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--s2); }
.advanced input.small { height: 28px; }
.checklist { max-height: 12rem; overflow: auto; display: grid; margin-top: var(--s2); }
.checklist label { display: block; white-space: nowrap; padding: 2px 0; }
details.picker summary { cursor: pointer; color: var(--primary); }
details.picker label { display: block; white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.tile { padding: var(--s3) var(--s4); display: grid; gap: 2px; align-content: start; }
.tile .n { font-size: 28px; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 13px; color: var(--ink-muted); }
.tile .sub { font-size: 13px; font-weight: 600; color: var(--ink); }
.tile.warn { background: var(--danger-bg); border-color: var(--danger-border); }
.tile.warn .n { color: var(--danger); }
.tile.warn .l { color: var(--danger); display: flex; align-items: center; gap: 6px; }
.tile.warn .l .icon { width: 14px; height: 14px; }
/* A tile that links somewhere: the link covers the tile, and an info button sits on top in the corner. */
.tile-linked { position: relative; }
.tile-link { display: grid; gap: 2px; color: inherit; text-decoration: none; }
.tile-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.tile-link:focus-visible { outline: none; }
.tile-linked:has(.tile-link:focus-visible) { box-shadow: var(--focus-ring); }
.tile-linked:hover { border-color: #c3cedb; }
.tile-linked .info-btn { position: absolute; top: var(--s2); right: var(--s2); z-index: 1; }

/* Info button and its explanation card (native popover, centred, closes on Escape or a click outside). */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); color: var(--ink-muted); cursor: pointer;
}
.info-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--surface); }
.info-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.info-pop {
  width: min(380px, calc(100vw - 32px)); padding: 0; margin: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: 0 12px 32px rgb(16 32 48 / .18), 0 2px 6px rgb(16 32 48 / .08);
}
.info-pop::backdrop { background: rgb(16 32 48 / .12); }
.info-pop-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s3) var(--s2) var(--s4); border-bottom: 1px solid var(--border); }
.info-pop-body { padding: var(--s3) var(--s4) var(--s4); font-size: 14px; line-height: 1.5; }
.info-pop-body p { margin: 0 0 var(--s2); }
.info-pop-body p:last-child { margin-bottom: 0; }
.info-pop[popover]:popover-open { animation: info-pop-in .14s ease-out; }
@keyframes info-pop-in { from { opacity: 0; transform: translateY(4px); } }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s4); margin: var(--s1) 0 var(--s3); }
.facts dt { font-size: 13px; font-weight: 500; color: var(--ink-muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.timeline .when { font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.timeline .field { font-weight: 600; margin-right: .4rem; }
.timeline .old { text-decoration: line-through; color: var(--danger); }
.timeline .new { color: var(--ok); }

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgb(15 30 50 / .35);
  transition: opacity 220ms ease-out;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21;
  width: min(440px, 100vw); padding: 0 20px 16px; overflow: auto;
  background: var(--surface); box-shadow: -8px 0 24px rgb(16 32 48 / .18);
  transition: transform 220ms cubic-bezier(.16, 1, .3, 1);
}
@starting-style {
  .drawer { transform: translateX(100%); }
  .drawer-backdrop { opacity: 0; }
}
.drawer header {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3);
  padding: var(--s4) 0 var(--s3); margin-bottom: var(--s2);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.drawer header .link { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--ink-muted); }
.drawer header .link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.drawer h3 { overflow-wrap: anywhere; }
.drawer > button { margin-top: var(--s3); }

/* 6. Data grid -------------------------------------------------------------- */
/* minmax(0, 1fr): without it the single column grows to its widest child and the page scrolls sideways on phones */
.grid-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
.global-search, .actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.global-search input[type=search] { flex: 1 1 320px; max-width: 480px; min-width: 0; width: auto; }
.global-search .help-link { margin-left: auto; }
.actions label { display: inline-flex; align-items: center; gap: var(--s2); color: var(--ink-muted); }
.actions .count { margin-left: auto; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.actions .hint { margin: 0; }

.table-wrap {
  overflow: auto; max-height: max(360px, calc(100dvh - 220px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
}
.edit-domain .table-wrap { max-height: none; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td {
  padding: 0 var(--s2); border-bottom: 1px solid var(--border-subtle);
  text-align: left; white-space: nowrap;
}
table.grid td { height: 34px; padding: 0 4px; background: var(--row-bg, var(--surface)); }
.panel table.grid td { height: 32px; padding: 0 4px; }
.dashboard .panel table.grid td:first-child { white-space: normal; overflow-wrap: anywhere; } /* long domain names wrap on phones instead of widening the panel */
.panel table.grid tr:last-child td { border-bottom: 0; }
table.grid td.num { text-align: right; }
table.grid td.last-check { white-space: nowrap; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; height: var(--grid-head-h);
  background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--ink-muted);
}
table.grid thead tr.filters th { top: var(--grid-head-h); background: var(--surface-3); font-weight: 400; padding: 4px; height: auto; }
table.grid thead th button.link { color: var(--ink-muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
table.grid thead th[aria-sort] button.link { color: var(--ink); }
table.grid thead th button.link .icon { width: 14px; height: 14px; vertical-align: -2px; margin-left: 2px; }
table.grid thead tr.filters input { height: 28px; }
table.grid input:not([type=checkbox]), table.grid select { width: 100%; min-width: 6rem; }
table.grid tbody input:not([type=checkbox]), table.grid tbody select {
  height: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: 4px;
  background-color: transparent; box-shadow: none;
}
table.grid tbody select { padding-right: 24px; background-image: var(--chev-faint); }
table.grid tbody input:hover, table.grid tbody select:hover { border-color: var(--border); background-color: var(--surface); }
table.grid tbody input:focus, table.grid tbody select:focus {
  border-color: var(--primary); box-shadow: var(--focus-ring); background-color: var(--surface);
}
table.grid tbody input[list] { width: calc(100% - 0px); }
table.grid input.dirty, table.grid select.dirty { background-color: var(--dirty-bg); border-color: var(--warn-border); }
table.grid input.dirty:focus, table.grid select.dirty:focus { border-color: var(--primary); background-color: var(--dirty-bg); }
table.grid td:nth-child(2) input { min-width: 12rem; }
table.grid td:last-child input { min-width: 16rem; }
.edit-domain table.grid td:nth-child(2) input, .edit-domain table.grid td:last-child input { min-width: 0; }

/* row states, lowest priority first (all set --row-bg, so source order decides) */
table.grid tbody tr:where(:hover) { --row-bg: var(--surface-3); }
table.grid tbody tr:where(:has(> td:first-child input[type=checkbox]:checked)) { --row-bg: var(--primary-soft); }
table.grid tbody tr:where(.draft) { --row-bg: var(--draft-bg); }
table.grid tbody tr:where(.has-error) { --row-bg: var(--danger-bg); }
table.grid tbody tr.draft td.draft-mark { font-size: 12px; font-weight: 600; color: var(--ok); white-space: nowrap; }

/* domains grid: pinned identity columns */
table.grid-domains th:nth-child(1), table.grid-domains td:nth-child(1) {
  position: sticky; left: 0; z-index: 1; width: 64px; min-width: 64px; max-width: 64px;
}
table.grid-domains th:nth-child(2), table.grid-domains td:nth-child(2) {
  position: sticky; left: 64px; z-index: 1; box-shadow: inset -1px 0 0 var(--border);
}
table.grid-domains thead th:nth-child(-n+2) { z-index: 3; }
table.grid-domains tbody td:nth-child(1) { white-space: nowrap; }
table.grid-domains tbody td:nth-child(2) input { font-weight: 500; }
table.grid-domains tbody td:nth-child(1) input[type=checkbox] { margin: 0 2px 0 4px; }
.open-link { color: var(--ink-faint); }
.icon-btn.open-link { width: 28px; height: 28px; }

.hist { color: var(--ink-muted); }
button.hist.link {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 4px;
  background: var(--surface-2); border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
}
table.grid td:has(> button.hist) > :is(input, select, .pick-or-type) { width: calc(100% - 38px); min-width: 7.5rem; }
/* x-pick-or-type: the dropdown and its "add new" text box fill the wrapper as a bare control would fill the cell */
.pick-or-type { display: inline-block; width: 100%; vertical-align: middle; }
.pick-or-type > :is(select, input) { width: 100%; }
button.hist.link:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }

/* links on dashboard tables read as content, not a wall of blue */
.dashboard table.grid a { color: var(--ink); font-weight: 500; text-decoration-color: transparent; }
.dashboard table.grid a:hover { color: var(--primary); text-decoration-color: currentColor; }

/* pagination (Laravel's Tailwind view, no Tailwind loaded) */
nav[role=navigation] { font-size: 13px; color: var(--ink-muted); }
nav[role=navigation] > div:first-child { display: none; }
nav[role=navigation] > div:last-child { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
nav[role=navigation] p { margin: 0; }
nav[role=navigation] .relative.z-0, nav[role=navigation] span.relative { display: inline-flex; gap: var(--s1); flex-wrap: wrap; }
nav[role=navigation] a, nav[role=navigation] span[aria-current] > span, nav[role=navigation] span[aria-disabled] > span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 var(--s2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 500;
}
nav[role=navigation] a:hover { background: var(--surface-3); border-color: #c3cedb; }
nav[role=navigation] span[aria-current] > span { background: var(--primary); border-color: var(--primary); color: #fff; }
nav[role=navigation] span[aria-disabled] > span { opacity: .5; }
nav[role=navigation] svg { width: 16px; height: 16px; }

/* 7. Page specifics ---------------------------------------------------------- */
/* login */
body.guest main {
  min-height: 100dvh; padding: var(--s5) var(--s4);
  display: grid; justify-items: center; align-content: center; gap: var(--s4);
}
body.guest .card { width: min(100%, 360px); margin: 0; }
.brand { display: flex; align-items: center; gap: var(--s2); font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.brand .icon { width: 24px; height: 24px; color: var(--primary); }
.card .field-error { display: grid; gap: 6px; }
.with-toggle { position: relative; display: block; }
.with-toggle input { padding-right: 44px; }
.with-toggle .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
.card button.primary[type=submit], .card > button.primary { width: 100%; }

/* dashboard */
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
.dashboard > section > h3 { margin-bottom: var(--s3); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: var(--s4); }
.changes { margin: var(--s1) 0 var(--s2); padding-left: 1.1rem; }
.changes li { padding: 4px 0; }
.changes .hist { margin-left: .5rem; font-size: 13px; }
.dashboard .panel h4:first-of-type { margin-top: 0; }

/* edit page */
.edit-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.edit-head > a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; text-decoration: none; }
.edit-head > a:hover { text-decoration: underline; }
.edit-head h2 { overflow-wrap: anywhere; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: var(--s3) 0 var(--s4); overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs button {
  height: 40px; padding: 0 14px; background: none; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--ink-muted); font-weight: 500; margin-bottom: -1px;
}
.subtabs button:hover { color: var(--ink); background: none; border-bottom-color: transparent; }
.subtabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.subtabs button:focus-visible { outline-offset: -2px; }
.edit-domain > .actions { margin-bottom: var(--s3); }

.detail-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 20px; padding: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow);
}
.detail-form label { display: grid; gap: 6px; align-content: start; font-size: 13px; font-weight: 500; color: var(--ink-muted); min-width: 0; }
.detail-form label.wide, .detail-form .wide { grid-column: 1 / -1; }
.detail-form input, .detail-form select, .detail-form textarea { width: 100%; font-size: 14px; font-weight: 400; color: var(--ink); }
.with-button { display: flex; gap: 6px; }
.with-button input { flex: 1; min-width: 0; }
.with-button button { white-space: nowrap; }
.buttons.wide { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.buttons.wide button.danger { margin-left: auto; }
.detail-form > .buttons.wide {
  position: sticky; bottom: 0; z-index: 2; margin: 4px -20px -20px; padding: 12px 20px;
  background: rgb(255 255 255 / .96); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-md) var(--r-md);
}

/* other pages */
.lookup h2 { margin: .2rem 0; }
/* Lookup tables use the full width; the checkbox and Domains-count columns stay narrow so text columns get the room. */
.lookup table.grid { width: 100%; min-width: 40rem; }
.lookup table.grid :is(th, td):first-child { width: 1%; white-space: nowrap; }
.lookup table.grid :is(th, td).num { width: 1%; white-space: nowrap; text-align: right; }
.run { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: var(--s2) var(--s3); box-shadow: none; }
.run progress { width: 14rem; max-width: 100%; height: 8px; border-radius: 999px; accent-color: var(--primary); }

/* 8. Responsive --------------------------------------------------------------- */
@media (max-width: 768px) {
  main { padding: var(--s3); }
  input:not([type=checkbox]):not([type=radio]), select, textarea,
  .detail-form input, .detail-form select, .detail-form textarea,
  .card input:not([type=checkbox]):not([type=radio]),
  table.grid tbody input:not([type=checkbox]), table.grid tbody select,
  table.grid thead tr.filters input { font-size: 16px; }

  .top { flex-wrap: wrap; justify-content: flex-start; padding: var(--s2) var(--s3); gap: 2px var(--s3); }
  .who { display: contents; }
  .top h1 { order: 0; }
  .who form { order: 1; margin-left: auto; }
  .top::after { content: ""; order: 2; flex-basis: 100%; height: 0; }
  .who-viewing, .who-user { order: 3; font-size: 12px; }
  .who-sep, .who-label, .who-role { display: none; }
  .who-viewing, .who-user { color: var(--ink-muted); }
  .who-viewing { margin-right: var(--s3); }

  .tabs {
    flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
    padding-right: 24px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: none; scroll-snap-align: center; }

  .edit-domain table.grid td:last-child input { min-width: 0; }
  .detail-form > .buttons.wide { margin: 4px -20px -20px; }
}

@media (max-width: 480px) {
  .global-search { flex-wrap: wrap; }
  .global-search strong { flex: 1 0 100%; }
  .global-search input[type=search] { flex: 1 1 0; max-width: none; }
  .grid-page > .actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-page > .actions button { white-space: normal; height: auto; min-height: 32px; padding-top: 4px; padding-bottom: 4px; line-height: 1.2; }
  .global-search label { white-space: nowrap; }
  .grid-page > .actions button.danger { grid-column: 1 / -1; }
  .grid-page > .actions .count { margin-left: 0; align-self: center; }
  .grid-page > .actions label { justify-content: space-between; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: var(--s2); }
  .drawer { width: 100vw; }
  .detail-form { padding: var(--s4); gap: 12px; }
  .detail-form > .buttons.wide { margin: 4px calc(-1 * var(--s4)) calc(-1 * var(--s4)); padding: 10px var(--s4); gap: var(--s2); }
  table.grid-domains tbody td:nth-child(2) input, table.grid-domains td:nth-child(2) input { min-width: 9rem; }
}

@media (pointer: coarse) {
  button, .button { min-height: 40px; }
  button.sm, .button.sm { min-height: 36px; }
  button.link, button.hist.link { min-height: 0; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 40px; }
  table.grid tbody input:not([type=checkbox]), table.grid tbody select { min-height: 36px; height: 36px; }
  table.grid td { height: 44px; }
  .icon-btn, .icon-btn.open-link { width: 36px; height: 36px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .tabs a { height: 44px; }
}

/* 9. Reduced motion ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
[x-cloak]{display:none !important}
.import-page,.export-page{display:grid;grid-template-columns:minmax(0,1fr);gap:1rem}
.import-page h2,.export-page h2,.import-page h3,.export-page h3,.import-page h4,.export-page h4{margin:.2rem 0}
.upload-form{display:grid;gap:.7rem;max-width:520px}
.upload-form fieldset{border:1px solid #dde3ea;border-radius:4px}
.summary{display:flex;gap:.5rem;flex-wrap:wrap}
.chip{background:#eaf3fb;border:1px solid #b9d6ef;border-radius:999px;padding:.1rem .7rem}
.chip.ok{background:#e6f4ea;border-color:#9bd3ae}
.chip.bad{background:#fdf1f1;border-color:#e4a1a1;color:#8a1c1c}
.chip.warn{background:#fff7d6;border-color:#e6cf7a}
td.wrap{white-space:normal;min-width:18rem;max-width:44rem}
.old{text-decoration:line-through;color:#8a4b4b}
.new{color:#176b2c}
.export-layout{display:grid;grid-template-columns:minmax(220px,300px) 1fr;gap:1rem;align-items:start}
@media (max-width:760px){.export-layout{grid-template-columns:1fr}}
.report-list{display:grid;gap:.2rem}
.report-list button{text-align:left;background:#fff;border:1px solid #dde3ea;border-radius:4px;padding:.45rem .7rem;cursor:pointer}
.report-list button.active{background:#eaf3fb;border-color:#9ecbf0;font-weight:600}
.report-inputs{display:flex;gap:1rem;flex-wrap:wrap;align-items:end;margin:.4rem 0}
.report-inputs label{display:grid;gap:.2rem;font-weight:600}
.registrar-sync{display:grid;grid-template-columns:minmax(0,1fr);gap:1rem}
.registrar-sync h2,.registrar-sync h3,.registrar-sync h4{margin:.2rem 0}
.account-form{display:grid;gap:.6rem;max-width:480px;margin-top:1rem}
.account-form label{display:grid;gap:.2rem;font-weight:600}
td.actions-cell{white-space:nowrap}
a.tile{text-decoration:none;color:inherit}
.api-docs{max-width:60rem;background:#fff;border:1px solid #dde3ea;border-radius:6px;padding:1rem 1.4rem}
.api-docs pre{background:#f4f8fc;border:1px solid #dde3ea;border-radius:4px;padding:.6rem .8rem;overflow:auto}
.api-docs code{font-size:.92em}
.api-docs table{border-collapse:collapse}
.api-docs th,.api-docs td{border:1px solid #dde3ea;padding:.25rem .5rem;text-align:left;vertical-align:top}
.new-token{display:grid;gap:.4rem;background:#fff7d6;border:1px solid #e6cf7a;border-radius:4px;padding:.6rem .8rem}
.new-token input{font-family:ui-monospace,monospace}
.token-form{display:flex;gap:.6rem;flex-wrap:wrap;align-items:end}
.token-form label{display:grid;gap:.2rem;font-weight:600}
.saved-views{display:flex;flex-wrap:wrap;gap:.6rem 1rem;align-items:center;background:#fff;border:1px solid #dde3ea;border-radius:6px;padding:.4rem .8rem}
.saved-views label{display:flex;gap:.4rem;align-items:center;font-weight:600}
.saved-views .save-view{display:flex;flex-wrap:wrap;gap:.4rem;align-items:center;min-width:0}
.saved-views .export-links{margin-left:auto}
.columns-picker .lists{display:flex;flex-wrap:wrap;gap:.4rem 1.2rem}

/* Skip link: off-screen until a keyboard user tabs to it. */
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--primary); color: #fff; border-radius: 4px; }
.skip-link:focus { top: 8px; }
main:focus { outline: none; }
