/* ProspectIQ web UI. Light and dark themes, no external fonts or assets (works offline).
   The theme comes only from the switch in the header: /static/js/theme.js sets html[data-theme]
   before the first paint, so every page shows the same theme. Rules use the tokens below rather
   than fixed colours, so both themes cover every surface. */

/* Theme-independent tokens. */
:root {
  --radius: 12px;
  --radius-sm: 8px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: 24px;
  --page-max: 1320px;
}

/* Light theme (the default). The dark block below redefines every property of this block. */
:root {
  color-scheme: light;

  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef1f4;
  --border: #e2e6ea;
  --border-strong: #cdd3da;
  --border-hover: #b6bec8;

  --text: #17202b;
  --text-2: #3f4a59;
  --muted: #5f6979;
  --faint: #8a93a1; /* placeholders and empty cells */

  --accent: #0e7c74;
  --accent-strong: #0a5f59;
  --accent-soft: #e6f4f2;
  --accent-track: #d4ebe7;
  --accent-border: #b9ddd8;
  --accent-ring: rgba(14, 124, 116, 0.3);
  --accent-fill: rgba(14, 124, 116, 0.25);
  --on-solid: #fff; /* text and icons on a solid accent, warn or danger fill */

  /* Priority ramp (ordinal, one hue, validated light end 2.35:1 on white). */
  --rank-high: #0a4f4a;
  --rank-medium: #0e7c74;
  --rank-low: #5fb8ad;

  /* States: the colour, its soft background, a border and darker text for use on the soft background. */
  --ok: #18794e;
  --ok-soft: #e7f5ee;
  --ok-border: #c6e6d4;
  --ok-text: #135c3b;
  --warn: #9a5700;
  --warn-soft: #fdf4e3;
  --warn-border: #f1dcb4;
  --warn-text: #6e3f00;
  --warn-track: #f6e3c0;
  --danger: #b42318;
  --danger-strong: #8f1c13;
  --danger-soft: #fdeceb;
  --danger-border: #f5c9c5;
  --danger-text: #8a1c13;
  --danger-track: #f6d0cc;
  --danger-ring: rgba(180, 35, 24, 0.12);
  --info: #2b5fb4;
  --info-soft: #eaf1fb;
  --info-border: #cbdaf3;
  --info-text: #24467e;
  --neutral: #4d5866;
  --neutral-soft: #eef1f4;

  --switch-off: #c3cad3;
  --switch-knob: #fff;
  --code-bg: #0f1720;
  --code-text: #d6e2ee;
  --toast-bg: #17202b; /* the toast is a dark chip in both themes */
  --backdrop: rgba(16, 24, 40, 0.45);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235f6979' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.22);
}

/* Dark theme: text and state colours keep at least 4.5:1 on every surface; solid accent, warn and
   danger fills are light, so the text on them is dark. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1419;
  --surface: #171d24;
  --surface-2: #1d242c;
  --surface-3: #242c35;
  --border: #2c353f;
  --border-strong: #3b4651;
  --border-hover: #4d5966;

  --text: #e6eaef;
  --text-2: #c2c9d2;
  --muted: #96a0ad;
  --faint: #7d8794;

  --accent: #2bb3a6;
  --accent-strong: #5fd0c4;
  --accent-soft: #12302d;
  --accent-track: #1d3f3b;
  --accent-border: #24564f;
  --accent-ring: rgba(43, 179, 166, 0.4);
  --accent-fill: rgba(43, 179, 166, 0.3);
  --on-solid: #0f1419;

  /* Priority ramp: brightest = highest priority on dark surfaces (low end 3.3:1 on --surface). */
  --rank-high: #7fdcd1;
  --rank-medium: #2bb3a6;
  --rank-low: #1d7a72;

  --ok: #4cc38a;
  --ok-soft: #12291e;
  --ok-border: #23573d;
  --ok-text: #8fdcb5;
  --warn: #f0b45b;
  --warn-soft: #2d2312;
  --warn-border: #5c4520;
  --warn-text: #f6cd8f;
  --warn-track: #3d3018;
  --danger: #f2877d;
  --danger-strong: #f6a9a1;
  --danger-soft: #331816;
  --danger-border: #6e302a;
  --danger-text: #f8b3ab;
  --danger-track: #4a221e;
  --danger-ring: rgba(242, 135, 125, 0.25);
  --info: #7fa9ef;
  --info-soft: #172338;
  --info-border: #2e4670;
  --info-text: #b0c9f5;
  --neutral: #a3adba;
  --neutral-soft: #242c35;

  --switch-off: #66717e;
  --switch-knob: #e6eaef;
  --code-bg: #0b0f14;
  --code-text: #d6e2ee;
  --toast-bg: #2b3540;
  --backdrop: rgba(0, 0, 0, 0.6);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2396a0ad' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 16px;
}

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

h1, h2, h3, h4, p, ol, ul, dl, dd {
  margin: 0;
}

a {
  color: var(--accent-strong);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-solid);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

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

.small {
  font-size: 12px;
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- header */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  color: var(--accent);
  flex: none;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

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

.brand-sub {
  font-size: 13px;
  color: var(--muted);
}

.key-badges {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  white-space: nowrap;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neutral);
  flex: none;
}

.badge-label {
  color: var(--text-2);
}

.badge-value {
  font-weight: 650;
}

.badge.tone-ok { border-color: var(--ok-border); background: var(--ok-soft); }
.badge.tone-ok .badge-dot { background: var(--ok); }
.badge.tone-ok .badge-value { color: var(--ok); }
.badge.tone-warn { border-color: var(--warn-border); background: var(--warn-soft); }
.badge.tone-warn .badge-dot { background: var(--warn); }
.badge.tone-warn .badge-value { color: var(--warn); }
.badge.tone-danger { border-color: var(--danger-border); background: var(--danger-soft); }
.badge.tone-danger .badge-dot { background: var(--danger); }
.badge.tone-danger .badge-value { color: var(--danger); }
.badge.tone-info { border-color: var(--info-border); background: var(--info-soft); }
.badge.tone-info .badge-dot { background: var(--info); }
.badge.tone-info .badge-value { color: var(--info); }
.badge.tone-neutral .badge-value { color: var(--neutral); }

/* ---------------------------------------------------------------- banner */

.banner {
  background: var(--info-soft);
  border-bottom: 1px solid var(--info-border);
}

.banner.tone-warn {
  background: var(--warn-soft);
  border-bottom-color: var(--warn-border);
}

.banner-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.banner-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--info);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
  flex: none;
}

.banner.tone-warn .banner-icon {
  border-color: var(--warn);
  border-top-color: transparent;
}

.banner-text {
  flex: 1 1 320px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- page */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page-sub {
  margin-top: 4px;
  color: var(--text-2);
  max-width: 70ch;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.side-col {
  min-width: 0;
  align-self: stretch;
}

.side-sticky {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 2px;
  margin: -2px;
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head {
  flex-wrap: wrap;
}

.card-head > div {
  flex: 1 1 220px;
  min-width: 0;
}

.step {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
  margin-top: 1px;
}

.card-title {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.card-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.count-badge {
  flex: none;
  align-self: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.count-badge.is-over {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ---------------------------------------------------------------- form grid */

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

.row + .row,
.row + .toggles,
.toggles + .row,
.toggles + .toggles {
  margin-top: 14px;
}

.row--center {
  align-items: center;
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field > label,
.toggle-text > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.field-error {
  font-size: 12.5px;
  color: var(--danger);
  font-weight: 500;
  line-height: 1.45;
}

.field-error ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]::placeholder,
input[type="number"]::placeholder {
  color: var(--faint);
}

select {
  appearance: none;
  padding-right: 34px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

input[type="text"]:hover,
input[type="number"]:hover,
select:hover {
  border-color: var(--border-hover);
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-ring);
}

input:disabled,
select:disabled {
  background-color: var(--surface-3);
  color: var(--muted);
  cursor: not-allowed;
}

.affix {
  position: relative;
}

.affix-text {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.affix input {
  padding-left: 24px;
}

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.check-line label {
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

input[type="checkbox"]:not(.switch) {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="checkbox"]:disabled + label {
  color: var(--muted);
  cursor: not-allowed;
}

/* switches (still real checkboxes; role="switch") */
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 36px;
  height: 20px;
  margin: 1px 0 0;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--switch-off);
  cursor: pointer;
  transition: background 0.15s;
}

.switch::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25);
  transition: transform 0.15s;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::before {
  transform: translateX(16px);
}

.switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.switch:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

@media (forced-colors: active) {
  .switch {
    appearance: auto;
    -webkit-appearance: checkbox;
    width: 16px;
    height: 16px;
  }
  .switch::before {
    display: none;
  }
}

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

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.toggle--bare {
  padding: 0;
  border: 0;
  background: none;
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toggle-text > label {
  cursor: pointer;
}

.toggle.is-disabled .toggle-text > label {
  color: var(--muted);
  cursor: not-allowed;
}

.cost {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  vertical-align: 1px;
  white-space: nowrap;
}

.tone-ok.cost { background: var(--ok-soft); color: var(--ok); }
.tone-info.cost { background: var(--info-soft); color: var(--info); }
.tone-warn.cost { background: var(--warn-soft); color: var(--warn); }

.advanced,
.guide {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.advanced > summary,
.guide > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  width: max-content;
  max-width: 100%;
}

.advanced[open] > summary,
.guide[open] > summary {
  margin-bottom: 10px;
}

.guide-list {
  padding-left: 18px;
  color: var(--text-2);
  font-size: 13px;
  display: grid;
  gap: 4px;
}

/* notes / hint boxes */
.note-stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.note {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}

.note--compact {
  padding: 8px 11px;
  font-size: 12.5px;
}

.card-note {
  margin: 0 0 14px;
}

.note.tone-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info-text); }
.note.tone-warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.note.tone-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.note.tone-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-text); }
.note.tone-neutral { background: var(--surface-2); }

.note-title {
  font-weight: 650;
  margin-right: 4px;
}

.note .policy {
  margin-right: 6px;
}

.note-foot {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.9;
}

.calc {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
}

.calc:empty {
  display: none;
}

.calc.tone-warn {
  background: var(--warn-soft);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.calc strong {
  font-weight: 650;
  color: var(--text);
}

/* ---------------------------------------------------------------- services (Target tab) */

.services-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.services-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
}

.service-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  border-radius: 10px;
}

.service-list.is-invalid {
  box-shadow: inset 3px 0 0 var(--danger);
  padding-left: 12px;
}

.service-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.service-option:hover {
  border-color: var(--accent);
}

.service-option.is-checked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.service-option:focus-within {
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.service-option input {
  flex: none;
  margin: 0;
  accent-color: var(--accent);
}

/* ---------------------------------------------------------------- chips */

.chips {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 10px;
}

.chips.is-invalid {
  box-shadow: inset 3px 0 0 var(--danger);
  padding-left: 12px;
}

.chip-group-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-wrap {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  max-width: 100%;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.chip-icon {
  font-size: 12px;
  font-weight: 700;
  width: 12px;
  text-align: center;
  flex: none;
}

.chip.is-selected {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.chip.is-flagged {
  border-style: solid;
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-wrap.has-remove .chip {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  padding-right: 9px;
}

.chip-remove {
  min-height: 30px;
  width: 28px;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 999px 999px 0;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.chip-wrap.has-remove .chip.is-selected + .chip-remove {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip-wrap.has-remove .chip.is-flagged + .chip-remove {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-remove:hover {
  color: var(--danger);
}

.add-term {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.add-term input {
  flex: 1;
  min-width: 0;
}

#terms-error,
#term-input-error {
  margin-top: 8px;
}

#terms-hint {
  margin-top: 8px;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-solid);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn--danger {
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn--danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn--danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-solid);
}

.btn--danger-solid:hover:not(:disabled) {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: transparent;
}

.btn--sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn--xs {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn--block {
  width: 100%;
}

.btn-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
}

.btn.is-busy {
  position: relative;
  color: transparent !important;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

.btn--primary.is-busy::after,
.btn--danger-solid.is-busy::after {
  border-color: var(--on-solid);
  border-top-color: transparent;
}

/* ---------------------------------------------------------------- run card */

.run-card .card-title {
  margin-bottom: 12px;
}

.summary {
  display: grid;
  gap: 7px;
  font-size: 13px;
}

.summary > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--surface-3);
  padding-bottom: 6px;
}

.summary > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary dt {
  color: var(--muted);
  flex: none;
}

.summary dd {
  font-weight: 600;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary dd.is-warn {
  color: var(--warn);
}

.summary dd.is-danger {
  color: var(--danger);
}

.gates {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.gates:not(:has(.gate:not([hidden]))):not(:has(.field-error:not([hidden]))) {
  margin-top: 0;
}

.gate {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--warn-border);
  background: var(--warn-soft);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--warn-text);
}

.gate label {
  cursor: pointer;
}

.gate.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-ring);
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.run-note {
  margin-top: 10px;
}

.tips-card .card-title {
  margin-bottom: 10px;
}

.tips {
  padding-left: 20px;
  display: grid;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.45;
}

.tips li::marker {
  color: var(--accent);
  font-weight: 700;
}

.tips:not(.is-expanded) > li:nth-child(n + 5) {
  display: none;
}

.tips-toggle {
  margin-top: 8px;
  margin-left: -12px;
}

/* ---------------------------------------------------------------- panels */

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-head-main {
  min-width: 0;
  flex: 1 1 320px;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-title:focus {
  outline: none;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sub-title {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
}

.sub-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
}

.section {
  margin-top: 20px;
}

.section:first-child {
  margin-top: 0;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.state-box {
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 16px;
  color: var(--text-2);
  background: var(--surface-2);
  font-size: 13px;
}

.state-box strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
}

.state-box.tone-danger {
  border-style: solid;
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-text);
}

.state-box.tone-danger strong {
  color: var(--danger);
}

.state-box.tone-info {
  border-color: var(--info-border);
  background: var(--info-soft);
}

.state-box.tone-ok {
  border-style: solid;
  border-color: var(--ok-border);
  background: var(--ok-soft);
  color: var(--ok-text);
}

.state-box.tone-ok strong {
  color: var(--ok);
}

.issue-list {
  padding-left: 18px;
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

/* pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--neutral);
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill.tone-ok { background: var(--ok-soft); color: var(--ok); }
.pill.tone-warn { background: var(--warn-soft); color: var(--warn); }
.pill.tone-danger { background: var(--danger-soft); color: var(--danger); }
.pill.tone-info { background: var(--info-soft); color: var(--info); }
.pill.tone-neutral { background: var(--neutral-soft); color: var(--neutral); }
.pill.tone-accent { background: var(--accent-soft); color: var(--accent-strong); }

.pill.is-live::before {
  animation: pulse 1.4s ease-in-out infinite;
}

.pill--plain::before {
  display: none;
}

/* stat tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  background: var(--surface);
  min-width: 0;
}

.tile-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile-value {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-top: 1px;
  overflow-wrap: anywhere;
}

.tile-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.tile.is-key {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.tile.is-key .tile-value {
  color: var(--accent-strong);
}

.tile.is-warn .tile-value {
  color: var(--warn);
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

/* meter (same-ramp track) */
.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--accent-track);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.meter.tone-warn { background: var(--warn-track); }
.meter.tone-warn > span { background: var(--warn); }
.meter.tone-danger { background: var(--danger-track); }
.meter.tone-danger > span { background: var(--danger); }

/* thin segmented bar (priority split) */
.segbar {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  margin-top: 10px;
}

.segbar > span {
  display: block;
  height: 100%;
}

.segbar.is-empty {
  background: var(--surface-3);
}

/* tables */
.table-scroll {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.table-scroll.is-tall {
  max-height: 460px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  white-space: nowrap;
}

.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--surface-3);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

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

.table tr.is-current td {
  background: var(--accent-soft);
}

.fill-wrap {
  max-width: 820px;
}

.history-table {
  min-width: 760px;
}

.rows-table td {
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rows-table td.is-empty {
  color: var(--faint);
}

.rows-table th:first-child,
.rows-table td:first-child {
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-main {
  font-weight: 600;
}

.cell-sub {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.cell-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.fill-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.bar {
  width: 140px;
  max-width: 40vw;
  height: 8px;
  border-radius: 2px;
  background: var(--accent-track);
  overflow: hidden;
  flex: none;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.fill-pct {
  width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* key/value chips (report maps) */
.kv {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kv span {
  display: inline-flex;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
}

.kv b {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 20px;
}

.detail-block h4 {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
  margin-bottom: 6px;
}

/* JSON blocks */
.code {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  overflow: auto;
  max-height: 380px;
  white-space: pre;
  tab-size: 2;
}

.run-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.run-details + .run-details {
  margin-top: 8px;
}

.run-details > summary {
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
  list-style: none;
}

.run-details > summary::-webkit-details-marker {
  display: none;
}

.run-details > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex: none;
}

.run-details[open] > summary::before {
  transform: rotate(45deg);
}

.run-details-body {
  padding: 0 12px 12px;
}

.run-title {
  font-weight: 650;
}

.run-meta {
  color: var(--muted);
  font-size: 12.5px;
}

.code-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}

/* steps list (preview) */
.steps {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px 16px;
}

.steps li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  padding: 5px 0;
}

.steps .mark {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.steps li.is-on .mark {
  background: var(--ok-soft);
  color: var(--ok);
}

.steps li.is-off {
  color: var(--muted);
}

.steps li.is-off .mark {
  background: var(--surface-3);
  color: var(--muted);
}

.steps .step-detail {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- job view */

.job-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.4fr);
  gap: 24px;
}

.job-col {
  min-width: 0;
}

.stages {
  list-style: none;
  padding: 0;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  padding: 0 0 12px;
}

.stage:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 24px;
  bottom: 2px;
  width: 2px;
  border-radius: 2px;
  background: var(--border);
}

.stage.is-completed:not(:last-child)::after,
.stage.is-partial:not(:last-child)::after {
  background: var(--accent-border);
}

.stage-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
}

.stage.is-completed .stage-icon {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-solid);
}

.stage.is-partial .stage-icon {
  background: var(--warn);
  border-color: var(--warn);
  color: var(--on-solid);
}

.stage.is-failed .stage-icon {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-solid);
}

.stage.is-skipped .stage-icon {
  border-style: dashed;
  color: var(--muted);
}

.stage.is-running .stage-icon {
  border-color: var(--info);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}

.stage-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.stage-label {
  font-weight: 600;
  font-size: 13.5px;
}

.stage.is-pending .stage-label,
.stage.is-skipped .stage-label {
  color: var(--muted);
  font-weight: 500;
}

.stage-count {
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stage-sub {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.stage-sub .is-error {
  color: var(--danger);
  font-weight: 600;
}

/* "1,234 records scraped" under a finished Google Maps discovery stage */
.stage-note {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border: 1px solid var(--ok-border);
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok-text);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stage-progress {
  margin-top: 5px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent-track);
  overflow: hidden;
}

.stage-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  transition: width 0.3s;
}

.events {
  list-style: none;
  padding: 0;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 12.5px;
}

.events:focus-visible {
  outline-offset: 0;
}

.event {
  display: grid;
  grid-template-columns: 62px 128px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.event:last-child {
  border-bottom: 0;
}

.event time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  padding-top: 1px;
}

.event-stage {
  color: var(--text-2);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-msg {
  overflow-wrap: anywhere;
}

.event.is-warning {
  background: var(--warn-soft);
}

.event.is-error {
  background: var(--danger-soft);
}

.event.is-error .event-msg {
  color: var(--danger-text);
}

.event-level {
  font-weight: 700;
  margin-right: 4px;
}

.events-empty {
  padding: 12px;
  color: var(--muted);
}

.costs .tiles {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.costs .table-scroll {
  margin-top: 10px;
}

.results {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.results-title {
  font-size: 15.5px;
  font-weight: 700;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.files {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
}

.file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
  min-width: 0;
}

.file:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file.is-key {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.file-icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.file.is-key .file-icon {
  background: var(--accent);
  color: var(--on-solid);
}

.file-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.file-label {
  font-weight: 600;
  font-size: 13px;
}

.file-name {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-get {
  margin-left: auto;
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-strong);
}

/* ---------------------------------------------------------------- dialog */

.dialog {
  border: 0;
  padding: 0;
  border-radius: 14px;
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  background: var(--surface);
}

.dialog::backdrop {
  background: var(--backdrop);
}

.dialog-form {
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dialog-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
}

.dialog-extra:empty {
  display: none;
}

.dialog-list {
  display: grid;
  gap: 6px;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.dialog-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.dialog-list dt {
  color: var(--muted);
  flex: none;
  white-space: nowrap;
}

.dialog-list dd {
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px 11px 14px;
  border-radius: 10px;
  background: var(--toast-bg);
  color: #f1f4f7;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--info);
  animation: toast-in 0.18s ease-out;
}

/* Fixed on purpose: the toast stays a dark chip (--toast-bg) in both themes. */
.toast.tone-ok { border-left-color: #3fb37f; }
.toast.tone-warn { border-left-color: #e4a23c; }
.toast.tone-danger { border-left-color: #f07167; }

.toast-msg {
  flex: 1;
  overflow-wrap: anywhere;
}

.toast-close {
  border: 0;
  background: transparent;
  color: #b8c2cd;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.toast-close:hover {
  color: #fff;
}

/* ---------------------------------------------------------------- footer */

.app-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding-top: 4px;
}

/* ---------------------------------------------------------------- motion */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .side-sticky {
    position: static;
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 900px) {
  .job-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  :root {
    --gutter: 16px;
  }
  .page {
    padding-top: 18px;
  }
  .side-sticky {
    grid-template-columns: minmax(0, 1fr);
  }
  .col-3,
  .col-4,
  .col-6,
  .col-8 {
    grid-column: span 12;
  }
  .toggles {
    grid-template-columns: minmax(0, 1fr);
  }
  .card {
    padding: 16px;
  }
  .event {
    grid-template-columns: 58px minmax(0, 1fr);
  }
  .event-stage {
    display: none;
  }
  .bar {
    width: 80px;
  }
}

@media (max-width: 480px) {
  .add-term {
    flex-direction: column;
  }
  .add-term input {
    flex: none;
  }
  .key-badges {
    width: 100%;
  }
  .badge {
    height: 26px;
    font-size: 12px;
  }
}

/* ------------------------------------------------------------------ v1.1 ui-campaign */

.is-view-hidden { display: none !important; }

.app-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: 24px; margin-right: auto; }
.nav-link {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.nav-link:hover { color: var(--accent-strong); background: var(--accent-soft); }
.nav-link[aria-current="page"] { color: var(--accent-strong); background: var(--accent-soft); }
.user-menu { display: flex; align-items: center; gap: 8px; margin-right: 12px; }
.user-name { font-weight: 600; }

.tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--accent-strong); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.tab:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
.tab-num {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 12px;
}
.tab-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.tab.has-error .tab-dot { display: inline-block; }
.tabpanel { display: flex; flex-direction: column; gap: 16px; }
.tabpanel[hidden] { display: none; }
.tabpanel:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 4px; border-radius: 12px; }
.tab-nav { display: flex; justify-content: flex-end; gap: 8px; }
.tab-nav .btn--ghost { margin-right: auto; }

.area-mode { border: 0; padding: 0; margin: 12px 0 0; }
.area-mode legend { font-weight: 600; margin-bottom: 6px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.output-toggles { display: grid; gap: 12px; margin-top: 16px; }
.output-toggles .switch:disabled + .toggle-text { opacity: 0.55; }

.coverage-notice { margin-bottom: 12px; }
.coverage { display: grid; gap: 8px; }
.tiles-svg {
  width: 160px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--accent-soft);
}
.tile-rect { fill: var(--accent-fill); stroke: var(--accent); stroke-width: 1; }

.dc-list, .seg-links { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.dc-list li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.dc-rate { font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 720px) {
  .app-nav { margin-left: 0; width: 100%; order: 3; }
  .user-menu { order: 2; }
  .tab { padding: 6px 8px; }
}
