/* ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
   VISUAL SYSTEM (phase 2A of docs/task/rediseno-ux-fase-2-sistema-visual.md) — direction A, "enterprise neutral".
   One definition per component: flat surfaces, thin borders, one primary action (turquoise), own select arrow, sentence case.

   LOAD ORDER: this is the LAST stylesheet (after theme, components, app, ui-kit, page-system, ai-costs, target-profile).
   It restyles the old layers by order and specificity: nothing of them is edited, there is no !important, and every colour is a
   token of theme.css (the only literals are the two chevron data URIs of the select arrow, which CSS variables cannot reach).
   Where an old rule is more specific (html[data-theme="light"] .card, :not(:disabled) hovers, td in zebra rows) the same
   selector is repeated here. Reference: .claude/skills/travco-ui-ux/references/design-system.md §13 and frontend/style-guide.html.

   Scale: control radius 8px (--radius-sm), card radius 14px (--card-radius), pill 999px. Controls: sm 36px, md 40px, lg 44px
   on a fine pointer; 44px for everything on touch (<= 768px or pointer: coarse). Type: --text-xs 13 .. --text-2xl 28, sentence
   case everywhere (only the status micro-labels listed in tests/test_visual_system_frontend.py may stay uppercase).
   ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ */

/* ── 0. Structural tokens (no colours) ──────────────────────────────────────────────────────────────────────────── */
:root {
  --control-h-sm: 2.25rem;
  --control-h: 2.5rem;
  --control-h-lg: 2.75rem;
  --tap: 2.75rem;
  --ease-ui: 150ms ease;
  /* One family: the serif of the old titles becomes the app sans */
  --font-display: var(--font-sans);
}
@media (max-width: 768px), (pointer: coarse) {
  :root { --control-h-sm: 2.75rem; --control-h: 2.75rem; --control-h-lg: 2.75rem; }
}

/* ── 1. Page, shell and typography ──────────────────────────────────────────────────────────────────────────────── */
html, body { background: var(--bg-primary); }
body { font-family: var(--font-sans); }
/* Controls without their own size inherited the UA default (13.33px, off the type scale); :where keeps the specificity at zero so any class wins */
:where(button, input, select, textarea) { font-size: var(--text-sm); }
.app-shell::before { content: none; }
.main-content { background: var(--bg-primary); }

.sidebar {
  width: 15rem; min-width: 15rem; margin: 0;
  border: 0; border-right: 1px solid var(--border); border-radius: 0;
  background: var(--bg-secondary); box-shadow: none; backdrop-filter: none; animation: none;
}
@media (min-width: 769px) { .sidebar { height: 100vh; } }
@media (max-width: 768px) {
  .sidebar { margin: 0; height: auto; box-shadow: var(--shadow-panel); }
  .sidebar:not(.sidebar--open) { box-shadow: none; }
}
html[data-theme="light"] .sidebar, html[data-theme="light"] .topbar { box-shadow: none; }
@media (max-width: 768px) { html[data-theme="light"] .sidebar.sidebar--open { box-shadow: var(--shadow-panel); } }

.topbar {
  height: 3.5rem; min-height: 3.5rem; margin: 0; padding: 0 var(--space-5);
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background: var(--bg-primary); box-shadow: none; backdrop-filter: none; animation: none;
}
@media (max-width: 768px) { .topbar { height: 3.5rem; min-height: 3.5rem; margin: 0; padding: 0 var(--space-3); } }
.topbar__title { font-family: var(--font-sans); font-size: var(--text-lg); font-weight: var(--fw-semibold); letter-spacing: 0; text-transform: none; }
.section-content { padding: var(--space-5); }
@media (max-width: 768px) { .section-content { padding: var(--space-4) var(--space-3); } }

.sidebar__brand { min-height: 3.5rem; padding: 0 var(--space-4); border-bottom: 1px solid var(--border); }
.sidebar__brand-icon { width: 1.75rem; height: 1.75rem; padding: .3rem; border-radius: var(--radius-sm); background: var(--accent-solid); color: var(--on-solid); box-shadow: none; }
.sidebar__brand-name { max-width: none; font-family: var(--font-sans); font-size: var(--text-base); font-weight: var(--fw-semibold); letter-spacing: 0; line-height: 1.2; color: var(--text-primary); text-transform: none; }
.sidebar__brand-version { font-family: var(--font-sans); }
.sidebar__nav { padding: var(--space-3) var(--space-2); }

.nav-item {
  min-height: var(--control-h); margin: 1px 0; padding: 0 var(--space-3); gap: var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: transparent; box-shadow: none;
  color: var(--text-secondary); font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--fw-medium); letter-spacing: 0;
}
.nav-item:hover { border: 0; background: var(--bg-hover); color: var(--text-primary); }
.nav-item--active, html[data-theme="light"] .nav-item--active, .nav-item--active:hover {
  border: 0; border-color: transparent; background: var(--bg-active); box-shadow: none; color: var(--text-primary); font-weight: var(--fw-semibold);
}
.nav-item .nav-icon { width: 1.125rem; height: 1.125rem; opacity: 1; }
.nav-item--active .nav-icon { padding: 0; border-radius: 0; background: none; color: var(--green); }
.nav-group { margin: 0; }
.nav-group__items { gap: 1px; margin: var(--space-1) 0 var(--space-1) var(--space-4); padding-left: var(--space-2); border-left: 1px solid var(--border); }
.nav-subitem {
  min-height: var(--control-h-sm); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--fw-medium); letter-spacing: 0; color: var(--text-secondary);
}
.nav-subitem:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-subitem--active, .nav-subitem--active:hover, .nav-subitem--locked.nav-subitem--active {
  border: 0; background: var(--bg-active); color: var(--text-primary); font-weight: var(--fw-semibold);
}
.nav-item:focus-visible, .nav-subitem:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.sidebar__ws { margin: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--bg-tertiary); font-family: var(--font-sans); text-transform: none; letter-spacing: 0; }
.sidebar__footer { margin: 0 var(--space-3); padding: var(--space-3) 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: transparent; }
.sidebar__avatar { width: 2rem; height: 2rem; background: var(--bg-tertiary); color: var(--text-primary); font-family: var(--font-sans); }
.sidebar__username { font-family: var(--font-sans); font-size: var(--text-sm); }

/* Active alliance block of the sidebar: a plain bordered tile */
.clan-context { margin: var(--space-3) var(--space-3) var(--space-1); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--card-radius); background: var(--bg-card); box-shadow: none; }
.clan-context--empty { border-style: dashed; background: transparent; }
.clan-context__heading { margin-bottom: var(--space-2); font-weight: var(--fw-medium); letter-spacing: 0; text-transform: none; color: var(--text-secondary); }
.clan-context__crest, .topbar-group__crest { border-radius: var(--radius-sm); background: var(--bg-tertiary); color: var(--text-primary); box-shadow: none; }
.topbar-group { min-height: var(--control-h-sm); border-radius: var(--radius-sm); border-color: var(--border-mid); background: var(--bg-card); box-shadow: none; }
.topbar-group:hover { background: var(--bg-tertiary); }
.credit-badge { border-radius: 999px; border-color: var(--border-mid); background: var(--bg-card); font-family: var(--font-sans); }
.topbar__meta > div { font-family: var(--font-sans); }

/* Hamburger: a real 44px target on phones */
.hamburger { width: var(--tap); height: var(--tap); padding: 0; border-radius: var(--radius-sm); color: var(--text-primary); }
.hamburger:hover { background: var(--bg-hover); }
.hamburger:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Icons of the own sprite (<svg class="icon"><use href="#i-..."/></svg>): they follow the text colour and need no font */
.icon { width: 1.125rem; height: 1.125rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon--sm { width: 1rem; height: 1rem; }
.icon--md { width: 1.25rem; height: 1.25rem; }
.icon--lg { width: 2rem; height: 2rem; stroke-width: 1.5; }

/* ── 2. Sentence case: buttons, titles, table heads and field labels lose the uppercase and the tracking ─────────── */
.group-timezone__option-group-label,
.card__title,
.stat-card__label,
.section-title,
.metric-card__lbl,
.bot-panel__tab,
.tools-meta-item__lbl,
.billing-balance-hero__label,
.pack-card__name,
.settings-section__title,
.map-filter-group legend,
.map-quadrant-filter legend,
.clan-context__heading,
.defensive-intel-drawer__eyebrow,
.map-capital-detail__facts dt,
.tech-card__title,
.tech-hero-gear__slot,
.tech-facts dt,
.tech-table td::before,
.btn--pack,
.btn--tool-excel,
.field__label,
.modal__title,
.map-hovercard__row dt,
.def-ai-label,
.def-units-picker__group legend,
.br-section__title,
.br-band__title,
.import-count__title,
.op-detail__title,
.def-type {
  text-transform: none; letter-spacing: 0;
}
.map-tag-label, .map-detail__tag, .map-card-badge, .map-capital-severity, .br-village__role {
  letter-spacing: .04em; /* micro status labels (<= 13px) keep their capitals and a light tracking */
}

/* Titles: one family, semibold */
.card__title, .settings-section__title, .section-title, .tech-card__title, .target-intel-sync-card__title, .def-plan__title, .def-context__title { font-weight: var(--fw-semibold); }
.page-header__title, .tech-intel__title, .def-view-head__title, .alliance-overview__title, .target-intel-workspace h2 { font-weight: var(--fw-semibold); letter-spacing: 0; }
.tech-card__title { color: var(--text-primary); font-size: var(--text-lg); }
.page-header__title { font-size: var(--text-xl); }
.pg-title { font-size: var(--text-xl); }

/* Labels of fields and table heads: quiet, sentence case */
.field__label { font-size: var(--text-xs); font-weight: var(--fw-medium); color: var(--text-secondary); }
.stat-card__label, .def-stat__label, .metric-card__lbl, .tools-meta-item__lbl, .billing-balance-hero__label, .pack-card__name { font-weight: var(--fw-medium); color: var(--text-secondary); }

/* ── 3. Surfaces: flat, one thin border, no gradients and no coloured edges on normal cards ────────────────────── */
.card, .stat-card, .settings-section, .bot-status-bar, .metric-card, .pack-card, .chart-card, .billing-balance-hero, .tools-meta-item, .tech-card,
.target-intel-sync-card, .bot-panel, .def-panel, .def-stat, .collapsible {
  background: var(--bg-card); background-image: none; border: 1px solid var(--border); border-radius: var(--card-radius); box-shadow: none; animation: none;
}
html[data-theme="light"] .card, html[data-theme="light"] .stat-card, html[data-theme="light"] .metric-card, html[data-theme="light"] .bot-status-bar,
html[data-theme="light"] .pack-card { box-shadow: none; }
.card--soft { background: var(--bg-secondary); }
.pack-card--featured { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.card__header, .settings-section__title { border-bottom-color: var(--border); }
.section-title::after { background: var(--border); }
.collapsible { overflow: hidden; }
.def-stat { border-radius: var(--card-radius); }
.pg-kpi, .dash-kpi { box-shadow: none; }

/* Floating surfaces keep an elevation (the only place that has one) */
.modal, .pg-drawer, .pg-menu__list, .toast, .map-hovercard { box-shadow: var(--shadow-panel); }
.modal { background: var(--bg-card); border: 1px solid var(--border-mid); border-radius: var(--card-radius); }
.modal-overlay { background: var(--scrim); backdrop-filter: none; }
.pg-drawer__scrim { background: var(--scrim); opacity: 1; }
.pg-drawer { border-left-color: var(--border-mid); animation-duration: 150ms; }
.modal__title { color: var(--text-primary); font-size: var(--text-lg); font-weight: var(--fw-semibold); }

/* KPI tiles: sober figures */
.stat-card__value, .def-stat__value, .billing-balance-hero__amount, .tools-meta-item__val { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* ── 4. Buttons: primary (one per view) / secondary / tertiary / danger ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-4);
  border: 1px solid var(--border-mid); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-primary); box-shadow: none;
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--fw-medium); line-height: 1.25; letter-spacing: 0; text-transform: none; text-decoration: none;
  transition: background-color var(--ease-ui), border-color var(--ease-ui), color var(--ease-ui);
}
.btn:hover:not(:disabled), .btn--start:hover:not(:disabled), .btn--primary:hover:not(:disabled), .btn--stop:hover:not(:disabled), .btn--randomize:hover:not(:disabled),
.btn--sm:hover:not(:disabled), .btn--theme:hover:not(:disabled), .btn--danger:hover:not(:disabled), .btn--tool-excel:hover:not(:disabled) {
  transform: none; box-shadow: none; filter: none; background: var(--bg-tertiary); border-color: var(--border-strong); color: var(--text-primary);
}
.btn:active:not(:disabled) { background: var(--bg-active); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.btn--sm, .btn--theme, .btn--preset { min-height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-sm); letter-spacing: 0; background: var(--bg-card); border-color: var(--border-mid); color: var(--text-primary); }
.btn--preset { font-family: var(--font-sans); font-weight: var(--fw-medium); }
.btn--preset:hover { background: var(--bg-tertiary); border-color: var(--border-strong); color: var(--text-primary); }
.btn--lg { min-height: var(--control-h-lg); padding-inline: var(--space-5); }
.btn__icon, .btn .icon { flex: none; }

/* Primary: filled accent. A compact (.btn--sm) button keeps the secondary look, as before */
.btn--primary:not(.btn--sm), .btn--start:not(.btn--sm) { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-solid); font-weight: var(--fw-semibold); }
.btn--primary:hover:not(:disabled):not(.btn--sm), .btn--start:hover:not(:disabled):not(.btn--sm) { background: var(--accent-solid-hover); border-color: var(--accent-solid-hover); color: var(--on-solid); }
.btn--primary:active:not(:disabled):not(.btn--sm), .btn--start:active:not(:disabled):not(.btn--sm) { background: var(--accent-solid-hover); }
.btn--start.btn--sm { color: var(--text-primary); }

/* Danger: outlined (destructive row action) or filled (stop) */
.btn--danger { background: var(--bg-card); border-color: var(--border-mid); color: var(--err-fg); }
.btn--danger:hover:not(:disabled) { background: var(--err-bg); border-color: var(--err-fg); color: var(--err-fg); }
.btn--stop { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--on-danger-solid); font-weight: var(--fw-semibold); }
.btn--stop:hover:not(:disabled) { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--on-danger-solid); filter: brightness(1.08); }
.btn--randomize { background: var(--warn-solid); border-color: var(--warn-solid); color: var(--on-warn-solid); font-weight: var(--fw-semibold); }
.btn--randomize:hover:not(:disabled) { background: var(--warn-solid); border-color: var(--warn-solid); color: var(--on-warn-solid); filter: brightness(1.08); }

/* Tertiary / ghost: text or icon only; icon-only buttons are square */
.btn--ghost, .pg-menu__btn, .pg-drawer__close { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled), .pg-menu__btn:hover:not(:disabled), .pg-drawer__close:hover:not(:disabled) { background: var(--bg-tertiary); border-color: transparent; color: var(--text-primary); }
.btn--icon, .pg-menu__btn, .pg-drawer__close { width: var(--control-h-sm); min-width: var(--control-h-sm); padding: 0; }
.btn--tool-excel, .btn--pack { font-size: var(--text-sm); font-weight: var(--fw-medium); background: var(--bg-card); border-color: var(--border-mid); color: var(--text-primary); font-family: var(--font-sans); }
.btn--pack--featured { border-color: var(--green); }
.btn--tool-excel:disabled { opacity: .5; }
.btn--theme { min-width: 3.5rem; font-weight: var(--fw-medium); }
.btn--quick { box-shadow: none; }

/* ── 5. Forms: one control height, own select arrow, calm focus, consistent errors ─────────────────────────────── */
.field__input, .field__select, .lang-select, .field__toggle, textarea.field__input {
  min-height: var(--control-h); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background-color: var(--bg-input); color: var(--text-primary); box-shadow: none;
  font-family: var(--font-sans); font-size: var(--text-md); letter-spacing: 0;
  transition: border-color var(--ease-ui), background-color var(--ease-ui);
}
.field__input, .field__select { padding: .4rem var(--space-3); }
textarea.field__input { min-height: 5rem; padding-block: var(--space-2); }
.lang-select { min-height: var(--control-h-sm); padding: .25rem var(--space-2); font-size: var(--text-sm); }
.field__input:hover, .field__select:hover, .lang-select:hover { border-color: var(--text-secondary); }
.field__input:focus, .field__select:focus, .lang-select:focus { border-color: var(--focus-ring); box-shadow: none; }
.field__input:focus-visible, .field__select:focus-visible, .lang-select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.field__input::placeholder { color: var(--text-muted); opacity: 1; }
.field__input:disabled, .field__select:disabled { background-color: var(--bg-tertiary); color: var(--text-muted); cursor: not-allowed; }
.field__input[aria-invalid="true"], .field__select[aria-invalid="true"] { border-color: var(--err-fg); }
.field__error { color: var(--err-fg); font-size: var(--text-xs); }
.field small, .field p { color: var(--text-secondary); }
input[type="checkbox"], input[type="radio"], .toggle__input { accent-color: var(--accent-solid); }

/* Select: the native arrow is replaced by an own SVG chevron on EVERY select (no JS, no wrapper). The stroke is the
   secondary text colour of each mode, written as a data URI because a CSS variable cannot reach inside one. */
select:not([multiple]):not([size]) {
  -webkit-appearance: none; appearance: none;
  padding-right: 2.25rem; text-overflow: ellipsis;
  background-image: 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='%23c4c5cc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 1rem;
}
html[data-theme="light"] select:not([multiple]):not([size]) {
  background-image: 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='%233f3f46' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
select:not([class]) {
  min-height: var(--control-h); padding-block: .4rem; padding-left: var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background-color: var(--bg-input); color: var(--text-primary); font-family: var(--font-sans); font-size: var(--text-md);
}
select:not([multiple]):not([size]):disabled { opacity: .6; }
option { background: var(--bg-card); color: var(--text-primary); }
.lang-select:not([multiple]):not([size]) { padding-right: 1.9rem; background-position: right .5rem center; background-size: .875rem; }

/* A select that wears the tone of its state (Plan recap outcome): tinted pill, the same pairs as the badges */
.pr-outcome__select { border-left-width: 1px; font-weight: var(--fw-medium); }
.pr-outcome__select--ok { color: var(--ok-fg); background-color: var(--ok-bg); border-color: color-mix(in srgb, var(--ok-fg) 40%, transparent); }
.pr-outcome__select--warn { color: var(--warn-fg); background-color: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-fg) 40%, transparent); }
.pr-outcome__select--err { color: var(--err-fg); background-color: var(--err-bg); border-color: color-mix(in srgb, var(--err-fg) 40%, transparent); }
.pr-outcome__select--info { color: var(--info-fg); background-color: var(--info-bg); border-color: color-mix(in srgb, var(--info-fg) 40%, transparent); }
.pr-outcome__select:hover { border-color: currentColor; }

/* Switch and range */
.toggle__track { border-radius: 999px; border-color: var(--border-strong); background: var(--bg-tertiary); transition: background-color var(--ease-ui), border-color var(--ease-ui); }
.toggle__input:checked + .toggle__track { background: var(--accent-solid); border-color: var(--accent-solid); }
.toggle__input:focus-visible + .toggle__track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.toggle__label { font-size: var(--text-sm); letter-spacing: 0; text-transform: none; }
.field__range { border-radius: 999px; background: var(--border-mid); }
.collapsible__header { font-size: var(--text-sm); font-weight: var(--fw-semibold); letter-spacing: 0; }

/* ── 6. Tables of management (.data-table, pg-table): quiet head, comfortable rows, numbers that align ──────────── */
.data-table { font-size: var(--text-sm); border-radius: 0; }
.data-table th, table.pg-table thead th {
  background: var(--bg-head); color: var(--text-secondary); border-bottom: 1px solid var(--border);
  font-size: var(--text-xs); font-weight: var(--fw-medium); letter-spacing: 0; text-transform: none;
}
.data-table td { padding: var(--space-3); border-bottom: 1px solid var(--border); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.data-table tbody tr:nth-child(even) td, .def-panel .data-table tbody tr:nth-child(even) > td { background: transparent; }
.data-table tbody tr:hover td, .def-panel .data-table tbody tr:hover > td, table.pg-table.data-table tbody tr:hover td, table.pg-table.data-table tbody tr:hover th,
table.pg-table.data-table tbody tr:focus-within td, table.pg-table.data-table tbody tr:focus-within th { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.pg-table td, .pg-table tbody th { padding: var(--space-3); border-bottom-color: var(--border); }
.pg-table .pg-num, .data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pg-cell__main { font-weight: var(--fw-medium); }
.pg-link { font-weight: var(--fw-medium); }
.pg-progress__track, .def-meter { box-shadow: none; background: var(--bg-tertiary); }
.pg-foot { border-top-color: var(--border); }
.pg-rowactions { gap: var(--space-1); }

/* ── 7. Badges: one pill per tone, a dot instead of a glyph so nothing needs a font ─────────────────────────────── */
.ui-badge, .status-badge, .badge, .tpl-badge {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: .0625rem var(--space-3);
  border: 0; border-radius: 999px; font-size: var(--text-xs); font-weight: var(--fw-medium); line-height: 1.5; letter-spacing: 0; text-transform: none; white-space: nowrap;
}
.ui-badge::before, .status-badge::before, .badge::before, .tpl-badge::before,
html.has-icons :is(.ui-badge, .status-badge, .badge, .tpl-badge, .ui-badge--ok, .ui-badge--warn, .ui-badge--err, .ui-badge--info, .status-badge--success, .status-badge--warning, .status-badge--error, .badge--ok, .badge--warning, .badge--skipped)::before {
  content: ""; display: inline-block; flex: none; width: .375rem; height: .375rem; margin: 0; border-radius: 50%; background: currentColor; font: inherit;
}
.alliance-badge { border: 0; font-size: var(--text-xs); font-weight: var(--fw-medium); letter-spacing: 0; }
.tech-level, .tech-badge, .tech-chip { border-radius: 999px; font-weight: var(--fw-medium); }
.tpl-badge, .badge { border: 0; }

/* ── 8. Tabs (underline), chips with a count and segmented controls ─────────────────────────────────────────────── */
.ui-tabs, .bot-panel__tabs, .modal__tabs, .login-tabs {
  gap: var(--space-1); padding: 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent;
}
.player-tabs { padding: 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; gap: var(--space-1); }
.ui-tab, .bot-panel__tab, .modal__tab, .login-tab {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-h-lg); padding: 0 var(--space-4);
  border: 0; border-bottom: 2px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0; margin-bottom: -1px;
  background: transparent; box-shadow: none; color: var(--text-secondary);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--fw-medium); letter-spacing: 0; text-transform: none;
  transition: color var(--ease-ui), background-color var(--ease-ui), border-color var(--ease-ui);
}
.ui-tab:hover, .bot-panel__tab:hover, .modal__tab:hover, .login-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.ui-tab[aria-selected="true"], .bot-panel__tab--active, .bot-panel__tab[aria-selected="true"], .modal__tab--active, .login-tab--active {
  background: transparent; border-color: transparent; border-bottom-color: var(--green); color: var(--text-primary); font-weight: var(--fw-semibold); box-shadow: none;
}
.bot-panel__tab--active:hover, .bot-panel__tab[aria-selected="true"]:hover { background: var(--bg-hover); color: var(--text-primary); }
.player-tabs__count { background: var(--bg-tertiary); color: var(--text-primary); }
.player-tabs__tab[aria-selected="true"] .player-tabs__count { background: var(--bg-tertiary); color: var(--text-primary); }
.ui-tab:focus-visible, .bot-panel__tab:focus-visible, .modal__tab:focus-visible, .login-tab:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

/* Chips with a counter (filters, Past plans / Plan recap) */
.pg-seg__btn {
  min-height: var(--control-h); padding: 0 var(--space-3); border: 1px solid var(--border-mid); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--fw-medium); line-height: 1.2;
}
.pg-seg__btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pg-seg__btn[aria-pressed="true"] { background: var(--bg-active); border-color: var(--green); box-shadow: none; color: var(--text-primary); }
.pg-seg__count { padding: 0 var(--space-2); background: var(--bg-tertiary); color: var(--text-primary); font-weight: var(--fw-medium); }
.pg-seg__btn[aria-pressed="true"] .pg-seg__count { background: var(--bg-card); }
.ui-segmented { padding: 2px; gap: 2px; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); background: var(--bg-tertiary); }
.ui-segmented__btn { min-height: var(--control-h-sm); border-radius: calc(var(--radius-sm) - 2px); font-family: var(--font-sans); font-weight: var(--fw-medium); letter-spacing: 0; text-transform: none; }
.ui-segmented__btn[aria-pressed="true"] { background: var(--bg-card); border-color: var(--border-mid); box-shadow: none; color: var(--text-primary); font-weight: var(--fw-semibold); }
.pg-crumb { font-weight: var(--fw-medium); }

/* ── 9. Banners, empty and loading states ───────────────────────────────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4); border: 1px solid color-mix(in srgb, currentColor 32%, transparent); border-left-width: 1px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); line-height: 1.5;
}
.alert--error, .alert--err, .alert--warn, .alert--warning, .alert--ok, .alert--success { border-left-width: 1px; }
.toast { border: 1px solid var(--border-mid); border-left-width: 1px; border-radius: var(--radius-sm); background: var(--bg-card); letter-spacing: 0; }
.toast--error { background: var(--err-bg); border-color: var(--err-fg); }
.empty-state, .pg-empty { color: var(--text-secondary); }
.pg-empty__ico { color: var(--text-muted); }
.ui-skeleton { border-radius: var(--radius-sm); }

/* ── 10. Motion and focus ───────────────────────────────────────────────────────────────────────────────────────── */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .btn, .ui-tab, .bot-panel__tab, .modal__tab, .field__input, .field__select, .toggle__track, .pg-seg__btn { transition: none; }
}

/* ── 11. Own checkbox (.check): the native <input type="checkbox"> stays (same id, name, events, keyboard and screen reader), but it is
   stretched over the whole label and made transparent, so the touch target is the label (>= 44px) and the box is drawn by the label.
   Markup: <label class="check"><input type="checkbox"> <span>Text</span></label>. The tick is a clipped fill, no image, no colour literal.
   ::before / ::after are placed first with `order` (a pseudo-element after the content would land after the text). */
.check { --check-box: 1.25rem; position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); cursor: pointer; }
.check > input[type="checkbox"] { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
.check::before {
  content: ""; order: -2; flex: none; box-sizing: border-box; width: var(--check-box); height: var(--check-box);
  border: 2px solid var(--border-strong); border-radius: calc(var(--radius-sm) - 2px); background: var(--bg-card);
  transition: background var(--ease-ui), border-color var(--ease-ui);
}
.check:hover::before { border-color: var(--text-secondary); }
.check:has(> input:checked)::before { border-color: var(--accent-solid); background: var(--accent-solid); }
.check:has(> input:checked)::after {
  content: ""; order: -1; flex: none; width: var(--check-box); height: var(--check-box); margin-left: calc(-1 * (var(--check-box) + var(--space-2)));
  background: var(--on-solid); clip-path: polygon(22% 52%, 31% 43%, 43% 56%, 70% 26%, 79% 35%, 43% 76%); pointer-events: none;
}
.check:has(> input:focus-visible)::before { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.check:has(> input:disabled) { cursor: not-allowed; opacity: .6; }
@media (forced-colors: active) {
  .check::before { border-color: ButtonText; background: Canvas; }
  .check:has(> input:checked)::before { border-color: Highlight; background: Highlight; }
  .check:has(> input:checked)::after { background: HighlightText; }
}
@media (prefers-reduced-motion: reduce) { .check::before { transition: none; } }
