/* =====================================================================
   Warfighter Squad Builder — stylesheet
   Mobile-first, military theme
   ===================================================================== */

:root {
  /* Warfighter palette. Neutral warm charcoal for the big areas; muted navy for actions and charts;
     card-art mustard / tan used sparingly (header stripe, title rules, Mission badge);
     "rubber-stamp ink" colours (blue links, red danger, green success) for emphasis. */
  --bg: #151412;
  --surface: #1f1d1a;
  --surface2: #2a2723;
  --border: #433e36;
  --text: #e8e4da;          /* off-white paper */
  --text-muted: #a39d90;    /* faded khaki-grey */
  --accent: #4f6a84;        /* muted navy / field blue */
  --accent-hover: #5f7d99;
  --accent-light: #a9bfd3;
  --on-accent: #fbf8ef;
  --danger: #b04a2f;        /* red stamp */
  --danger-hover: #d9694a;
  --warning: #e29a3c;
  --warning-bg: #2f2412;
  --success: #7fa86a;       /* green stamp */
  --link: #94b4d0;          /* faded blue stamp ink */
  --stripe: #a98a4c;        /* mission-banner mustard, as a thin accent only */
  --olive: #8d863e;
  --kraft: #8d6c3b;         /* tan frame */
  --kraft-dark: #504b42;
  --paper: #e8e0cc;
  --paper-edge: #c2b68c;
  --ink: #2a1f10;
  --font-type: 'Special Elite', 'Courier New', monospace;
  --font-body: 'Roboto Condensed', 'Arial Narrow', system-ui, sans-serif;
  --radius: 3px;
  --header-h: 54px;
  --sidebar-w: 170px;
}

/* ---- Reset --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
input, select, textarea {
  font: inherit;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { resize: vertical; min-height: 60px; }

/* ---- Typography ---------------------------------------------------- */
h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ---- Utility ------------------------------------------------------- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.flex { display: flex; }
.flex-gap { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ---- Buttons ------------------------------------------------------- */
/* Variants: primary (one per view — the main action) · ghost (secondary) · danger-ghost (destructive,
   outlined so it never competes with primary) · danger (filled, for confirmations) · icon (inline row tools).
   Every variant has a 1px border so filled and outlined buttons line up at the same height. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px; line-height: 1.2; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  background: var(--surface2); color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 1px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .35; cursor: default; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger-ghost { background: transparent; border-color: var(--border); color: var(--danger-hover); }
.btn-danger-ghost:hover { background: #3a1a1a; border-color: var(--danger); }
.btn-square { padding: 6px; }
.btn-icon { padding: 6px; background: transparent; border: none; color: var(--text-muted); font-size: 16px; }
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn-icon-danger:hover { color: var(--danger-hover); }
.icon { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-caret { display: inline-flex; margin-left: -2px; opacity: .7; }
.btn-caret .icon { width: 12px; height: 12px; }

/* ---- Page action bar (squad + campaign detail and builders) ---------
   start: navigation (back / cancel, prev-next) · end: secondary | destructive · primary (rightmost) */
.page-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.tb-start, .tb-end { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.tb-end { margin-left: auto; justify-content: flex-end; }
.tb-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }
.tb-pager { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
/* Editor heading (squad + campaign builders), below the action bar */
.page-title { margin-bottom: 12px; }
.tb-pager-pos { min-width: 4em; text-align: center; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  /* Secondary actions collapse to icons (title/aria-label keep the name); the primary keeps its label */
  .tb-end .btn:not(.btn-primary) .btn-label { display: none; }
  .tb-end .btn:not(.btn-primary) { padding: 6px 8px; }
}

/* ---- Header -------------------------------------------------------- */
#app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: #0f1112;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.header-brand {
  font-size: 1rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent-light);
}
#header-auth { display: flex; gap: 8px; align-items: center; }
#header-auth .username { color: var(--text-muted); font-size: 13px; }

/* ---- Layout -------------------------------------------------------- */
#app-layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* Sidebar — desktop */
#sidebar {
  width: var(--sidebar-w);
  background: #0f1112;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: fixed;
  top: var(--header-h); bottom: 0; left: 0;
  overflow-y: auto;
  display: flex; flex-direction: column;
  z-index: 90;
}
#sidebar .nav-link {
  display: block; padding: 10px 20px; white-space: nowrap;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s;
}
#sidebar .nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }
#sidebar .nav-link.active {
  color: var(--accent-light); background: var(--surface);
  border-left-color: var(--accent);
}
/* Nested entry (Builder under Squads / Campaigns) */
#sidebar .nav-link.nav-sub { padding: 6px 20px 6px 36px; font-size: 12px; position: relative; }
#sidebar .nav-link.nav-sub::before {
  content: ''; position: absolute; left: 24px; top: 0; bottom: 50%;
  width: 7px; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.nav-beta {
  display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 99px;
  border: 1px solid var(--accent); color: var(--accent-light);
  font-size: 9px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  vertical-align: 1px; line-height: 14px;
}

/* Main content area */
#app-column {
  flex: 1; min-width: 0; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: calc(100vh - var(--header-h));
}
#app-main {
  flex: 1;
  padding: 24px 16px;
  max-width: 1200px;
  width: 100%;
}
/* Notice: always visible at the bottom of the (fixed) sidebar on desktop; at the end of the page on phones,
   where the sidebar becomes a bottom tab bar */
#sidebar-footer {
  margin-top: auto; padding: 12px 14px 6px; border-top: 1px solid var(--border);
  font-size: 10.5px; line-height: 1.45; color: var(--text-muted);
}
#sidebar-footer p { margin: 0 0 8px; }
#sidebar-footer .footer-gh { display: inline-flex; align-items: center; gap: 6px; color: var(--link); }
#sidebar-footer .footer-gh .icon { width: 14px; height: 14px; flex: none; }
#app-footer {
  display: none;
  margin-top: 24px; padding: 14px 16px; border-top: 1px solid var(--border);
  flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px;
  font-size: 12px; color: var(--text-muted); background: rgba(0, 0, 0, .18);
}
#app-footer p { margin: 0; max-width: 90ch; line-height: 1.5; }
#app-footer .footer-gh { display: inline-flex; align-items: center; gap: 6px; color: var(--link); white-space: nowrap; }
#app-footer .footer-gh .icon { width: 15px; height: 15px; }

/* ---- Tables -------------------------------------------------------- */
.data-table {
  width: 100%; border-collapse: collapse; margin-top: 12px;
}
.data-table th {
  text-align: left; padding: 8px 12px;
  background: var(--surface2); color: var(--text-muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--surface); cursor: pointer; }
.data-table .clickable { cursor: pointer; }
/* Squad list: long names truncate with … on one line (full name in the tooltip) */
.squad-name-cell { white-space: nowrap; }
.data-table .squad-edit-cell { width: 28px; padding-left: 6px; padding-right: 0; text-align: center; }
.squad-edit-btn {
  background: none; border: none; padding: 0 2px; cursor: pointer;
  line-height: 0; color: var(--text-muted);
}
.squad-edit-btn:hover { color: var(--text); }
.squad-name-cell .ellipsis {
  display: inline-block; max-width: 280px; vertical-align: bottom;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Chips --------------------------------------------------------- */
.chip {
  display: inline-block; padding: 2px 8px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
  background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip-soldier { background: #1b2a3a; color: #7fb0d8; border-color: #2f4d6b; }
.chip-weapon  { background: #3a1e1e; color: #bf6d6d; border-color: #5c2e2e; }
.chip-equipment { background: #1e2e3a; color: #6d9bbf; border-color: #2e4a5c; }
.chip-skill   { background: #2e1e3a; color: #9b6dbf; border-color: #4a2e5c; }
.chip-mission { background: #3a2e1e; color: #bf9b6d; border-color: #5c4a2e; }
.chip-custom  { background: #2e2a3a; color: #b3a6e0; border-color: #4a425c; margin-left: 6px; vertical-align: middle; cursor: help; }
.chip-hostile { background: #3a1e1e; color: #bf6d6d; border-color: #5c2e2e; }
.chip-ps  { background: #1e3340; color: #68b5d4; }
.chip-nps { background: #332211; color: #c9a45a; }

/* ---- Filter bar ---------------------------------------------------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.filter-bar input[type=text] { min-width: 200px; flex: 1; }
.filter-bar select { min-width: 120px; }

/* ---- Pagination ---------------------------------------------------- */
.pagination {
  display: flex; gap: 6px; align-items: center; justify-content: center;
  margin-top: 16px;
}
.pagination .page-info { color: var(--text-muted); font-size: 13px; }

/* ---- Cards (detail view) ------------------------------------------- */
.card-detail-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  align-items: start;
}
.card-image-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: center;
}
.card-image-panel img {
  width: 100%; height: auto; display: block;
  cursor: zoom-in;
}
.card-image-placeholder {
  width: 100%; padding-top: 140%;
  background: var(--surface2);
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.card-image-placeholder::after {
  content: '🃏';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px; opacity: 0.2;
}
.card-stats-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header-bar {
  font-size: 12px; color: var(--text-muted); margin-bottom: 6px;
}
.card-name { font-size: 1.6rem; font-weight: 700; margin-bottom: 12px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.stat-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
}
.stat-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); }
.stat-value { font-size: 1.1rem; font-weight: 700; }
.card-notes {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px; font-size: 13px;
  white-space: pre-line;
  margin-top: 12px;
}

/* ---- Budget / Loadout bars ----------------------------------------- */
.bar-wrapper { margin: 6px 0; }
.bar-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.bar-track {
  height: 8px; background: var(--surface2);
  border-radius: 4px; overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.3s, background 0.3s;
  background: var(--success);
}
.bar-fill.warn { background: var(--warning); }
.bar-fill.over { background: var(--danger); }

/* ---- Builder layout ------------------------------------------------ */
.builder-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  height: calc(100vh - var(--header-h) - 48px);
}
.builder-left {
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.builder-right {
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.builder-bottom-actions { display: none; }
.builder-section { margin-bottom: 16px; }
.builder-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.07em;
  margin-bottom: 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.soldier-slot {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.soldier-slot-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.soldier-slot-name { font-weight: 600; font-size: 13px; }
.soldier-slot-cost { color: var(--text-muted); font-size: 12px; }
.gear-list { padding-left: 8px; margin-top: 4px; }
.gear-item {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; padding: 2px 0;
  border-bottom: 1px solid var(--border);
}
.gear-item:last-child { border-bottom: none; }
.picker-card-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
.picker-card-row:hover { background: var(--surface2); }
.picker-card-name { font-weight: 500; }
.picker-card-meta { font-size: 11px; color: var(--text-muted); }
.picker-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 0; border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* ---- Squad detail -------------------------------------------------- */
.squad-header { margin-bottom: 16px; }
.squad-title { font-size: 1.4rem; font-weight: 700; }
.squad-meta { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.squad-info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.squad-mission-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.squad-mission-box.mission-primary {
  border-left: 3px solid var(--accent);
}
.squad-box-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.09em;
  margin-bottom: 8px;
}
.mission-name {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  margin-bottom: 2px; line-height: 1.3;
}
.mission-meta-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px; min-height: 18px;
}
.mission-subtitle {
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.03em; margin-bottom: 10px;
}
.mission-rp-track {
  height: 4px; background: var(--surface2);
  border-radius: 2px; margin-bottom: 4px;
}
.mission-rp-fill {
  height: 100%; border-radius: 2px;
  background: var(--accent); transition: width 0.3s;
}
.mission-rp-fill.over { background: var(--danger); }
.mission-rp-row {
  display: flex; justify-content: space-between;
  font-size: 12px; font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}
.mission-attrs {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.mission-attr {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 8px;
  font-size: 11px; color: var(--text-muted);
}
.mission-attr strong { color: var(--text); font-weight: 600; }
.obj-type-badge {
  display: inline-block;
  color: #fff;
  border-radius: 3px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-right: 6px;
}
.obj-type-badge[title] { cursor: help; }
.soldiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.soldier-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.soldier-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 8px;
}
.soldier-name { font-weight: 700; font-size: 15px; }
.soldier-number { font-size: 12px; color: var(--text-muted); }
.soldier-stats { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.soldier-stats span { white-space: nowrap; }
.gear-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin: 8px 0 4px;
}
.gear-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.gear-table td { padding: 3px 6px; }
.gear-table tr { border-bottom: 1px solid var(--border); }
.gear-table tr:last-child { border-bottom: none; }
.nps-gear-note {
  font-size: 11px; color: var(--warning); font-style: italic; margin-bottom: 4px;
}
.default-gear-section {
  margin-top: 6px; padding: 5px 8px;
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.default-gear-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.06em; margin-bottom: 4px;
}
.gear-item-default {
  opacity: 0.65; font-style: italic;
}
.gear-item-default .gear-qty {
  background: var(--surface2); border-radius: 3px;
  padding: 0 4px; font-size: 10px; font-style: normal;
  color: var(--text-muted); margin-right: 4px;
}

/* ---- Like button --------------------------------------------------- */
/* Like: a toolbar button (btn btn-ghost); outlined heart + count, filled red when liked */
.like-btn.liked { border-color: var(--danger); color: var(--danger-hover); }
.like-btn.liked .icon { fill: currentColor; }
.like-btn.liked:hover { background: #3a1a1a; }
.like-btn:disabled { opacity: 0.5; }
#likes-count { font-variant-numeric: tabular-nums; }

/* ---- Hostile spawn table ------------------------------------------- */
.spawn-table-wrap {
  display: table;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.spawn-table-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.spawn-table {
  border-collapse: collapse;
  font-size: 12px;
}
.spawn-table thead tr { border-bottom: 1px solid var(--border); }
.spawn-table thead .spawn-rp,
.spawn-table thead .spawn-count {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding-top: 4px;
  padding-bottom: 4px;
}
.spawn-table tbody tr:not(:last-child) { border-bottom: 1px solid var(--border); }
.spawn-rp    { padding: 3px 10px 3px 8px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.spawn-count { padding: 3px 8px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Hardy markers ------------------------------------------------- */
.hardy-badge {
  display: inline-block;
  margin: 6px 6px 0 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--hardy-color, var(--text-muted));
}

/* ---- Picker selected row ------------------------------------------- */
tr.picker-row-selected { background: color-mix(in srgb, var(--accent) 10%, transparent); }
tr.picker-row-selected td:first-child { font-weight: 600; }
tr.picker-row-selected td:first-child::before { content: '✓ '; color: var(--accent); }

/* ---- Compact objective row ----------------------------------------- */
.obj-compact-row { padding: 3px 0; }

/* ---- Required modules (inline in the squad subtitle, after the nation) */
.required-modules { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: 6px; vertical-align: middle; }

/* ---- Export menu ----------------------------------------------------- */
.export-menu { position: relative; display: inline-block; }
.export-menu-list {
  position: absolute; top: calc(100% + 4px); right: 0;
  z-index: 60; min-width: 240px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.export-menu-list[hidden] { display: none; }
.export-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  padding: 7px 10px; border: none; border-radius: 4px; background: transparent;
  color: var(--text); text-align: left; cursor: pointer;
}
.export-item:hover, .export-item:focus-visible { background: var(--surface2); }
.export-item-label { font-size: 13px; font-weight: 500; }
.export-item-tip { font-size: 11px; color: var(--text-muted); }

/* ---- Author notes -------------------------------------------------- */
.squad-author-notes { margin-top: 28px; }

/* ---- Comments ------------------------------------------------------ */
.comments-section { margin-top: 24px; }
.comment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 8px;
}
.comment-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.comment-author { font-weight: 600; font-size: 13px; }
.comment-date { font-size: 11px; color: var(--text-muted); }
.comment-body { font-size: 13px; white-space: pre-line; }
.comment-actions { display: flex; gap: 6px; margin-top: 6px; }
.comment-form { margin-top: 12px; }
.comment-form textarea { width: 100%; }
.comment-form .form-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }

/* ---- Profile ------------------------------------------------------- */
.profile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.profile-section h2 { margin-bottom: 12px; }
.form-field { margin-bottom: 10px; }
.form-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.form-field input { width: 100%; max-width: 360px; }
.module-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px; max-height: 420px; overflow-y: auto;
  margin-top: 8px;
}
.module-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 13px; }
.module-item input[type=checkbox] { accent-color: var(--accent); }
.module-actions { display: flex; gap: 8px; margin-bottom: 8px; }

/* ---- Auth forms ---------------------------------------------------- */
.auth-form-wrapper {
  max-width: 360px; margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.auth-form-wrapper h1 { margin-bottom: 20px; }
.auth-form-wrapper .form-field input { width: 100%; }
.auth-form-wrapper .form-footer { margin-top: 16px; text-align: center; font-size: 13px; }

/* ---- Alerts / flash ------------------------------------------------ */
.alert {
  padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 12px; font-size: 13px;
}
.alert ul { margin: 4px 0 0; padding-left: 20px; }
.alert-error { background: #2e1010; border: 1px solid var(--danger); color: #f08080; }
.alert-success { background: #102e18; border: 1px solid var(--success); color: #80f0a0; }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning); }
.alert-info { background: #102030; border: 1px solid #3a7fa0; color: #80c0e0; }

/* ---- Spinner ------------------------------------------------------- */
.spinner-wrap { display: flex; justify-content: center; padding: 32px; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Card Thumbnail Tooltip ---------------------------------------- */
#card-thumb {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  width: min(260px, 45vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
#card-thumb img { width: 100%; height: auto; display: block; }

/* ---- Lightbox ------------------------------------------------------ */
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
}
.lightbox-overlay img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface); color: var(--text);
  border: none; border-radius: 50%; width: 36px; height: 36px;
  font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ---- Quick filter pill --------------------------------------------- */
/* ---- Tabs ---------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.badge-ok { background: #1a3a1a; color: var(--success); border: 1px solid var(--success); border-radius: 4px; padding: 1px 6px; font-size: 11px; }
.badge-cx { background: #2a2200; color: var(--warning); border: 1px solid var(--warning); border-radius: 4px; padding: 1px 6px; font-size: 11px; font-style: normal; margin-left: 4px; }
.badge-xp { background: #1a2a3a; color: var(--link); border: 1px solid var(--link); border-radius: 4px; padding: 1px 6px; font-size: 11px; font-style: normal; margin-left: 4px; }

.quick-filter {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 12px; cursor: pointer; color: var(--text-muted);
  transition: background 0.15s;
}
.quick-filter:hover { background: var(--border); color: var(--text); }
.quick-filter.active { background: #3a1a1a; border-color: var(--danger); color: var(--danger); }
.quick-filter.active-accent { background: #222a33; border-color: var(--accent); color: var(--accent-light); }
.quick-filter.active-purple { background: #2a1a3a; border-color: #9b59b6; color: #c39bd3; }
.quick-filter.active-blue { background: #14263a; border-color: #3498db; color: #85c1e9; }

/* ---- Divider ------------------------------------------------------- */
.divider {
  border: none; border-top: 1px solid var(--border); margin: 16px 0;
}

/* ---- Responsive ---------------------------------------------------- */
@media (max-width: 767px) {
  #sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: 56px; flex-direction: row;
    border-right: none; border-top: 1px solid var(--border);
    padding: 0; overflow: visible;
  }
  #sidebar .nav-link {
    flex: 1; text-align: center; padding: 8px 4px;
    border-left: none; border-top: 3px solid transparent;
    font-size: 11px;
  }
  #sidebar .nav-link.active { border-top-color: var(--accent); border-left: none; }
  #sidebar .nav-link.nav-sub { padding: 8px 4px; font-size: 11px; }
  #sidebar .nav-link.nav-sub::before { display: none; }
  #nav-campaign-builder { display: none !important; }   /* bottom bar: reach it from Campaigns → New */
  .nav-beta { display: none; }
  #app-column { margin-left: 0; }
  #app-main { padding-bottom: 16px; }
  #app-footer { display: flex; padding-bottom: 72px; }      /* clear the fixed bottom tab bar */
  #sidebar-footer { display: none; }
  .card-detail-layout { grid-template-columns: 1fr; }
  .builder-layout { grid-template-columns: 1fr; height: auto; }
  .builder-right { order: -1; }
  .builder-bottom-actions { display: flex; gap: 8px; margin-top: 8px; }
  .builder-bottom-actions .btn { flex: 1; justify-content: center; }
  .data-table th:nth-child(n+4), .data-table td:nth-child(n+4) { display: none; }
  /* squads table has a leading edit column: keep name, nation, mission */
  .squads-table th:nth-child(4), .squads-table td:nth-child(4) { display: table-cell; }
  /* fit the phone width: fixed layout, names and missions wrap onto several rows instead of widening the table */
  .squads-table { table-layout: fixed; width: 100%; }
  .squads-table th, .squads-table td { padding: 8px 6px; font-size: 13px; overflow-wrap: anywhere; }
  .squads-table th:nth-child(1), .squads-table td:nth-child(1) { width: 30px; }
  .squads-table th:nth-child(2), .squads-table td:nth-child(2) { width: 42%; }
  .squads-table th:nth-child(3), .squads-table td:nth-child(3) { width: 18%; }
  .squads-table .squad-name-cell { white-space: normal; }
  .squads-table .squad-name-cell .ellipsis { display: inline; max-width: none; white-space: normal; overflow: visible; }
}

/* ---- Sortable table headers ----------------------------------------- */
.sort-header { cursor: default; user-select: none; white-space: nowrap; }
.sort-header.sortable { cursor: pointer; }
.sort-header.sortable:hover { color: var(--accent-light); }
.sort-header.sort-active { color: var(--accent-light); }

/* ---- Horizontal scroll wrapper for wide tables --------------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Draft badge ---------------------------------------------------- */
.badge-draft {
  display: inline-block;
  background: var(--warning);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

/* ---- Picker table (compact) ---------------------------------------- */
.picker-table th, .picker-table td { font-size: 12px; padding: 5px 8px; }
.picker-table tr.clickable:hover { background: var(--surface2); }

/* ---- Custom tooltip (1.5s delay) ----------------------------------- */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  transition-delay: 0s;
  z-index: 200;
}
[data-tooltip]:hover::after { opacity: 1; transition-delay: 0.5s; }

/* =====================================================================
   Card Detail — redesigned (.cd-*)
   ===================================================================== */

/* Wrapper: sets type-accent custom properties */
.cd-wrap {
  --cd-accent: var(--accent);
  --cd-accent-bg: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

/* Type color themes — match existing chip palette */
.cd-t-soldier    { --cd-accent: #7fb0d8; --cd-accent-bg: #182634; }
.cd-t-weapon     { --cd-accent: #bf6d6d; --cd-accent-bg: #2c1818; }
.cd-t-equipment  { --cd-accent: #6d9bbf; --cd-accent-bg: #18242e; }
.cd-t-skill      { --cd-accent: #9b6dbf; --cd-accent-bg: #22182c; }
.cd-t-sr         { --cd-accent: #8a9099; --cd-accent-bg: #1e2025; }
.cd-t-mission    { --cd-accent: #bf9b6d; --cd-accent-bg: #2c2218; }
.cd-t-objective  { --cd-accent: #c4906a; --cd-accent-bg: #2c2018; }
.cd-t-situation  { --cd-accent: #7ea8bf; --cd-accent-bg: #18262e; }
.cd-t-hostile    { --cd-accent: #bf6d6d; --cd-accent-bg: #2c1818; }

/* Nav bar */
.cd-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.cd-nav-pos { font-size: 12px; color: var(--text-muted); }

/* Header strip */
.cd-header {
  background: var(--cd-accent-bg);
  border-bottom: 2px solid var(--cd-accent);
  padding: 16px 20px 18px;
}

/* Eyebrow: type chip · subtype · nation · module · #number */
.cd-eyebrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.cd-eyebrow-sub    { color: var(--cd-accent); font-weight: 600; }
.cd-eyebrow-sep    { color: var(--border); }
.cd-eyebrow-nation { font-weight: 500; }
.cd-eyebrow-module { font-size: 11px; }
.cd-eyebrow-num    { margin-left: auto; font-size: 11px; opacity: 0.5; font-variant-numeric: tabular-nums; }

.cd-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
}
.cd-theater-tag { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.cd-name {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.12;
  color: var(--text);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* Two-column body */
.cd-body {
  display: grid;
  grid-template-columns: 1fr 220px;
}
.cd-main  { padding: 20px; border-right: 1px solid var(--border); min-width: 0; }
.cd-aside { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

/* Card image */
.cd-image-wrap {
  border-radius: calc(var(--radius) - 1px);
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.cd-has-image { cursor: zoom-in; }
.cd-image { width: 100%; height: auto; display: block; transition: opacity 0.18s; }
.cd-has-image:hover .cd-image { opacity: 0.88; }
.cd-image-placeholder {
  padding-top: 140%;
  background: var(--surface2);
  position: relative;
}
.cd-image-placeholder::after {
  content: '🃏';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px; opacity: 0.12;
}

/* Content sections */
.cd-section { margin-bottom: 22px; }
.cd-section:last-child { margin-bottom: 0; }
.cd-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cd-accent);
  margin-bottom: 10px;
}

/* Sub-labels within a section: single 16px gap (blocks above carry no bottom margin) */
.cd-section-label:not(:first-child) { margin-top: 16px; }
/* Drop the trailing margin of a section's last block so section gaps are uniform */
.cd-section > :last-child { margin-bottom: 0; }

/* Vitals grid — HP / Move / Cover / Loadout / etc. */
.cd-vitals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cd-vital {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  text-align: center;
  min-width: 60px;
}
.cd-vital-val {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 3px;
}
.cd-vital-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* CX / XP experience badges */
.cd-xp-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.cd-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.cd-badge-cx { background: #182634; color: #8fc1dd; border: 1px solid #2f4d6b; }
.cd-badge-xp { background: #19192e; color: #7d7dbf; border: 1px solid #2e2e4e; }



/* Data tables: weapon range/mode, spawn, health/actions, default gear */
.cd-table-wrap {
  display: block;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}
.cd-table {
  width: auto;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cd-table th {
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface2);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.cd-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.cd-table tbody tr:last-child td { border-bottom: none; }
.cd-table tbody tr.clickable:hover { background: var(--surface2); cursor: pointer; }
.cd-assoc-table tbody tr.clickable:hover { background: var(--surface2); cursor: pointer; }
.cd-assoc-num { font-size: 11px; color: var(--text-muted); }

/* Field notes */
.cd-notes {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cd-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-line;
  color: var(--text-muted);
}

/* Responsive: stack image below on narrow screens */
@media (max-width: 640px) {
  .cd-body { grid-template-columns: 1fr; }
  .cd-main { border-right: none; border-bottom: 1px solid var(--border); }
  .cd-aside { padding: 12px; }
  .cd-name  { font-size: 1.4rem; }
}

/* ---- i18n ------------------------------------------------------------ */
.lang-select { padding: 3px 6px; font-size: 12px; }
.tr-marker { margin-left: 6px; font-size: 11px; cursor: help; }
.tr-marker.tr-missing { color: var(--text-muted); }
.tr-marker.tr-draft { color: var(--warning); }
.cd-original { margin-top: 10px; }
.cd-original summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }
.cd-original .cd-notes { margin-top: 6px; opacity: .8; }

/* Translation editor (owner only) */
.tr-badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.tr-badge-missing  { background: var(--surface2); color: var(--text-muted); }
.tr-badge-stale    { background: #3a1d1a; color: #f08a7e; }
.tr-badge-draft    { background: var(--warning-bg); color: var(--warning); }
.tr-badge-reviewed { background: #13301f; color: #5fd08a; }
.tr-progress { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface2); }
.tr-progress-reviewed { background: #2f9e5c; }
.tr-progress-draft    { background: var(--warning); }
.tr-progress-stale    { background: #d0604f; }
.tr-progress-missing  { background: transparent; }
.tr-progress-legend { margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.tr-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin-top: 12px; }
.tr-editor-source h2 { margin: 4px 0 10px; }
.tr-editor-image { max-width: 220px; margin-top: 14px; border-radius: var(--radius); }
.tr-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 4px; }
.tr-glossary { margin-top: 14px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.tr-editor-target textarea { font-family: inherit; line-height: 1.5; }
@media (max-width: 800px) { .tr-editor { grid-template-columns: 1fr; } }

/* ---- Smart search help ---------------------------------------------- */
.smart-help { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 10px; font-size: 12px; }
.smart-help code { background: var(--surface2); padding: 0 4px; border-radius: 3px; }
.smart-help-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px; margin: 8px 0; color: var(--text-muted); }
.smart-help-keys code { color: var(--accent-light); }
.smart-errors { color: var(--warning); margin-left: 8px; }
#picker-errors { font-size: 12px; margin-bottom: 4px; }

/* ---- Modal / import-export --------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; width: min(640px, 100%); max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 6px; }
.custom-mission-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 8px; }
.custom-mission-form .cm-wide { grid-column: 1 / -1; }
.custom-mission-form .form-field input, .custom-mission-form .form-field select { width: 100%; max-width: none; }
@media (max-width: 480px) { .custom-mission-form { grid-template-columns: 1fr; } }
.squad-based-on { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.squad-based-on a { color: var(--link); }

/* ---- Card mentions ----------------------------------------------------- */
.card-mention { color: var(--accent-light); border-bottom: 1px dotted var(--accent); text-decoration: none; }
.card-mention:hover { color: var(--text); }
.card-mention-missing { color: var(--text-muted); }
.mention-box { position: relative; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 2px; max-height: 240px; overflow: auto; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.mention-item { padding: 5px 10px; cursor: pointer; font-size: 13px; }
.mention-item.active, .mention-item:hover { background: var(--surface2); }
.mention-hint { font-size: 11px; margin: 2px 0 6px; }
.mention-hint code, .builder-section code { background: var(--surface2); padding: 0 4px; border-radius: 3px; }

/* ---- Campaigns (spec/09_campaigns.md) ------------------------------ */
.campaign-detail { max-width: 920px; }
.campaign-summary { font-size: 15px; margin: 8px 0; }
.campaign-section { margin-top: 22px; }
.campaign-section h2 { font-size: 16px; margin-bottom: 8px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.campaign-section h3 { font-size: 13px; margin: 12px 0 4px; }
.campaign-intro { font-size: 14px; line-height: 1.55; }
.campaign-text { white-space: pre-wrap; font-size: 13px; line-height: 1.5; }
.campaign-carry { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; margin: 6px 0; }
.campaign-mission { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-top: 10px; scroll-margin-top: 12px; }
.campaign-mission-head { display: flex; align-items: center; gap: 10px; }
.campaign-mission-head h3 { margin: 0; font-size: 15px; }
.campaign-mission-code { min-width: 28px; padding: 2px 8px; border-radius: 6px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 12px; text-align: center; }
.campaign-mission-card, .campaign-mission-meta { margin-top: 6px; font-size: 13px; }
.campaign-mission h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 10px 0 2px; }
.campaign-branches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.campaign-branch { font-size: 12px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); text-decoration: none; color: inherit; }
.campaign-branch.cond-success { border-color: #2e5c44; color: #6dbf8f; }
.campaign-branch.cond-failure { border-color: #5c2e2e; color: #bf6d6d; }
.campaign-branch.cond-choice  { border-color: #4a425c; color: #b3a6e0; }
.chip-entry { background: #1b2a3a; color: #7fb0d8; border-color: #2f4d6b; }

.campaign-editor { max-width: 980px; }
.ce-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.ce-section h2 { font-size: 15px; margin-bottom: 8px; }
.ce-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; }
.ce-grid .ce-wide, .ce-section > .ce-wide { grid-column: 1 / -1; }
.ce-section input[type=text], .ce-section input[type=number], .ce-section select, .ce-section textarea { width: 100%; max-width: none; }
.ce-section textarea { resize: vertical; }
.ce-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ce-check { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; color: var(--text); }
.ce-rule, .ce-outcome { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.ce-rule textarea, .ce-outcome textarea { margin-top: 4px; }
.ce-outcome { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; }
.ce-outcome textarea { grid-column: 1 / -1; }
.ce-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 10px; }
.ce-flow-opt { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 12px; }
.ce-flow-opt input { display: none; }
.ce-flow-opt.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ce-mission { border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; }
.ce-mission.open { border-color: var(--accent); }
.ce-mission-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; flex-wrap: wrap; }
.ce-mission-body { padding: 4px 12px 10px; }
.ce-links { display: flex; flex-direction: column; gap: 6px; }
.ce-link-row { display: grid; grid-template-columns: 150px auto 1fr 1fr auto; gap: 6px; align-items: center; }
.cp-results { max-height: 50vh; overflow: auto; margin-top: 8px; }
.cp-row { padding: 6px 8px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.cp-row:hover { background: var(--surface-2, rgba(255,255,255,.04)); }
@media (max-width: 640px) {
  .ce-link-row { grid-template-columns: 1fr auto 1fr; }
  .ce-link-row input, .ce-link-row button { grid-column: auto; }
  .ce-outcome { grid-template-columns: 1fr auto; }
}

/* Search boxes: ✕ to clear (static/search_clear.js) */
.search-input { padding-right: 28px; }
.search-input:not(:placeholder-shown) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a9099' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}
.search-input.search-clear-hover {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23dde1e7' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}
.badge-lang { font-size: 10px; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--border); color: var(--text-muted); vertical-align: middle; }


/* =====================================================================
   Warfighter theme — game look (charcoal, navy, kraft paper, parchment labels,
   typewriter text, rubber stamps). Overrides the base rules above.
   ===================================================================== */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(79, 106, 132, .10), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(160, 122, 74, .05), transparent 50%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 5px);
  background-attachment: fixed;
}
::selection { background: var(--kraft); color: var(--ink); }
* { scrollbar-color: var(--kraft-dark) var(--bg); }

/* Typewriter headings */
h2, h3, .card-name, .cd-name, .header-brand, .modal h2,
.builder-section-title, .picker-title, .spawn-table-title, .squad-box-label {
  font-family: var(--font-type);
  font-weight: 400;
  letter-spacing: .02em;
}
h1 { font-size: 1.55rem; }

/* Page titles: plain condensed caps with a kraft rule */
h1.page-title, .squad-title, #app-main > h1, #app-main > .flex > h1, .auth-form-wrapper h1 {
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--paper);
  padding-bottom: 4px;
  border-bottom: 3px solid var(--kraft);
  display: inline-block;
}

/* Header: dark charcoal with a thin mustard stripe */
#app-header {
  background: linear-gradient(180deg, #3d382f 0%, #2b2721 100%);
  border-bottom: 3px solid var(--stripe);
  box-shadow: 0 2px 0 var(--kraft-dark), 0 4px 12px rgba(0, 0, 0, .5);
}
.header-brand .brand-link { color: inherit; text-decoration: none; }
.header-brand { color: var(--paper); font-size: 1.15rem; text-shadow: 1px 1px 0 rgba(0, 0, 0, .55); }
#header-auth .username { color: var(--paper-edge); }
#app-header .btn-ghost, #app-header select { border-color: rgba(236, 226, 198, .35); background: rgba(0, 0, 0, .18); color: var(--paper); }

/* Sidebar: dark charcoal with stencil nav */
#sidebar {
  background: linear-gradient(180deg, #161513, #0f0e0d);
  border-right: 2px solid var(--kraft-dark);
}
#sidebar .nav-link {
  font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
}
#sidebar .nav-link.nav-sub { font-size: 11.5px; letter-spacing: .06em; }
#sidebar .nav-link:hover { color: var(--paper); background: rgba(255, 255, 255, .05); }
#sidebar .nav-link.active {
  color: var(--paper); background: #2f2b25;
  border-left-color: var(--kraft);
}

/* Rubber stamps: beta / draft / language */
.nav-beta, .badge-draft {
  border: 1.5px solid var(--danger); color: #e07a5c; background: transparent;
  border-radius: 2px; font-family: var(--font-type); font-weight: 400; letter-spacing: .08em;
  transform: rotate(-4deg);
}
.badge-draft { padding: 0 5px; }
.badge-lang { font-family: var(--font-type); border-color: var(--kraft); color: var(--kraft); border-radius: 2px; }

/* Buttons */
.btn { border-radius: var(--radius); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; font-size: 12.5px; }
.btn-sm { font-size: 11.5px; }
.btn-primary {
  background: linear-gradient(180deg, #4f6a84, #3b5167); color: var(--on-accent); font-weight: 700;
  border: 1px solid #2b3b4b; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 1px 0 rgba(0, 0, 0, .4);
}
.btn-primary:hover { background: linear-gradient(180deg, #587590, #415b73); }
.btn-ghost { border-color: var(--kraft-dark); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, .06); border-color: var(--text-muted); }
.btn-danger { background: var(--danger); color: var(--paper); }
.btn-icon { text-transform: none; }
.page-toolbar { border-bottom-color: var(--kraft-dark); }

/* Inputs */
input, select, textarea { background: #0f0e0d; border-color: var(--border); color: var(--text); }
input::placeholder, textarea::placeholder { color: #6f6852; }
input:focus, select:focus, textarea:focus { outline-color: var(--kraft); }

/* Panels: kraft-bordered field cases */
.ce-section, .modal, .squad-mission-box, .soldier-card, .soldier-slot, .profile-section, .auth-form-wrapper,
.card-stats-panel, .cd-wrap, .builder-left, .builder-right, .comment-item, .spawn-table-wrap, .export-menu-list {
  border-color: var(--kraft-dark);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .35);
}
.ce-section h2, .profile-section h2 {
  color: var(--paper); border-bottom: 1px dashed var(--kraft-dark); padding-bottom: 6px;
}
.modal { background: linear-gradient(180deg, #26231f, var(--surface)); border-width: 2px; }
.modal h2 { color: var(--paper); }
.stat-item, .mission-attr { border-color: var(--kraft-dark); }

/* Tables: dark olive header strip */
.data-table th {
  background: #2f2b25;
  color: var(--accent-light); text-transform: uppercase; font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  border-bottom: 2px solid var(--kraft-dark);
}
.data-table th.sortable:hover, .data-table .sort-header.sortable:hover { color: var(--paper); }
.data-table .sort-header.sort-active { color: var(--link); }
.data-table td { border-bottom-color: rgba(107, 82, 51, .45); }
.data-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, .015); }
.data-table tbody tr:hover { background: rgba(79, 106, 132, .10); }

/* Quick filters and tabs */
.quick-filter { border-radius: 2px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; font-size: 11.5px; }
.tab-btn { text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.tab-btn.active { color: var(--paper); border-bottom-color: var(--kraft); }

/* Card detail header: typewriter name */
.cd-name { font-size: 1.6rem; }
.cd-section-label { font-family: var(--font-type); letter-spacing: .06em; }

/* Alerts as field telegrams */
.alert { border-radius: 2px; border-left-width: 4px; }

/* Spinner in kraft */
.spinner { border-color: var(--border); border-top-color: var(--kraft); }

@media (max-width: 768px) {
  h1.page-title, .squad-title, #app-main > h1, #app-main > .flex > h1 { font-size: 1.2rem; }
}

/* Card-type colours in the game palette (detail header + chips) */
.cd-t-soldier    { --cd-accent: #8fb7d8; --cd-accent-bg: #1b2835; }
.cd-t-weapon     { --cd-accent: #e58a8a; --cd-accent-bg: #311a1c; }
.cd-t-equipment  { --cd-accent: #6fb7ad; --cd-accent-bg: #172829; }
.cd-t-skill      { --cd-accent: #b58ad6; --cd-accent-bg: #231a2e; }
.cd-t-sr         { --cd-accent: #a9adb3; --cd-accent-bg: #25262a; }
.cd-t-mission    { --cd-accent: #dbb768; --cd-accent-bg: #2e2510; }
.cd-t-objective  { --cd-accent: #eda05b; --cd-accent-bg: #33200f; }
.cd-t-situation  { --cd-accent: #9fb0a6; --cd-accent-bg: #1e2421; }
.cd-t-hostile    { --cd-accent: #d8664f; --cd-accent-bg: #2e1510; }
.chip-soldier   { background: #1b2835; color: #8fb7d8; border-color: #34506b; }
.chip-weapon    { background: #311a1c; color: #e58a8a; border-color: #6b3434; }
.chip-equipment { background: #172829; color: #6fb7ad; border-color: #2f5a56; }
.chip-skill     { background: #231a2e; color: #b58ad6; border-color: #4a3a63; }
.chip-mission   { background: #2e2510; color: #dbb768; border-color: #5c4a20; }
.chip-hostile   { background: #2e1510; color: #d8664f; border-color: #5c2a20; }
.chip-ps  { background: #1b2835; color: #b9d3ea; }
.chip-nps { background: #33200f; color: #eda05b; }

@media (max-width: 600px) {
  /* full title; it only gets cut (…) when it would run into the language selector / user menu */
  .header-brand { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; margin-right: 8px; }
  #header-auth { flex: none; }
}

/* ---- Squad metrics (squad detail) ---------------------------------- */
.squad-metrics { margin-top: 28px; }
.metrics-badge {
  font-family: var(--font-type); font-size: 11px; font-weight: normal; letter-spacing: .06em;
  text-transform: uppercase; color: var(--warning); border: 1px solid var(--kraft-dark);
  border-radius: var(--radius); padding: 1px 6px; vertical-align: middle; margin-left: 6px;
}
.metrics-body {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
}
.metrics-radar { width: 280px; max-width: 100%; flex: 0 0 auto; overflow: visible; }
.mr-ring { fill: none; stroke: var(--border); stroke-width: 1; }
.mr-spoke { stroke: var(--border); stroke-width: 1; }
.mr-shape { fill: rgba(79, 106, 132, .40); stroke: var(--accent-light); stroke-width: 1.5; stroke-linejoin: round; }
.mr-dot { fill: var(--accent-light); }
.mr-label { fill: var(--text-muted); font-size: 9.5px; font-family: var(--font-body); }
.metrics-list-wrap { flex: 1 1 280px; min-width: 240px; }
.metrics-list { list-style: none; margin: 0; padding: 0; }
.metric-head, .metric-row {
  display: grid; grid-template-columns: 112px 1fr 34px 46px; align-items: center; gap: 8px; padding: 4px 0;
}
.metric-head { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.metric-row { border-top: 1px solid var(--border); cursor: help; }
.metric-name { font-size: 13px; }
.metric-bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.metric-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.metric-val { text-align: right; font-weight: bold; font-size: 13px; }
.metric-raw { text-align: right; font-size: 12px; color: var(--text-muted); }
.metrics-note { font-size: 12px; margin: 8px 0 0; }

/* ---- Squad generator (view: static/generator.js) -------------------- */
.gen-page { max-width: 1280px; }
.gen-head { margin-bottom: 12px; }
.gen-sub { color: var(--text-muted); margin: 6px 0 0; max-width: 70ch; }
.gen-collection {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius);
}
.gen-collection-ico { display: inline-flex; color: var(--accent-light); }
.gen-collection-ico .icon { width: 18px; height: 18px; }
.gen-collection-text { flex: 1 1 260px; font-size: 14px; }
.gen-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .gen-layout { grid-template-columns: 1fr; } }

.gen-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px;
  position: sticky; top: calc(var(--header-h) + 12px); max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto;
}
@media (max-width: 960px) { .gen-form { position: static; max-height: none; } }
.gen-brief-title {
  font-family: var(--font-type); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--text);
  border-bottom: 2px solid var(--kraft); padding-bottom: 6px; margin-bottom: 12px;
}
.gen-field select, .gen-field input[type=text], .gen-field input[type=number], .gen-field input[type=search] { width: 100%; max-width: none; }
.gen-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.gen-go { width: 100%; justify-content: center; font-size: 16px; padding: 11px 14px; margin-top: 4px; gap: 8px; text-transform: uppercase; letter-spacing: .06em; }
.gen-go .icon { width: 20px; height: 20px; }
.gen-go-sub { text-align: center; font-size: 12px; color: var(--text-muted); margin: 6px 0 12px; }
.gen-reset { margin-top: 10px; }

.gen-sec { border-top: 1px solid var(--border); }
.gen-sec summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none;
  padding: 10px 2px; user-select: none;
}
.gen-sec summary::-webkit-details-marker { display: none; }
.gen-sec summary::before { content: '▸'; color: var(--kraft); margin-right: 6px; transition: transform .12s; }
.gen-sec[open] summary::before { transform: rotate(90deg); }
.gen-sec-title { flex: 1; font-family: var(--font-type); font-size: 13px; letter-spacing: .07em; text-transform: uppercase; color: var(--text); }
.gen-sec-badge { font-size: 11px; color: var(--warning); border: 1px solid var(--kraft-dark); border-radius: var(--radius); padding: 0 6px; }
.gen-sec-body { padding: 2px 2px 8px; }

.gen-seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.gen-seg-item { flex: 1; margin: 0 !important; cursor: pointer; }
.gen-seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.gen-seg-item span {
  display: block; text-align: center; padding: 7px 6px; font-size: 13px; color: var(--text-muted);
  background: var(--surface2); border-right: 1px solid var(--border);
}
.gen-seg-item:last-child span { border-right: 0; }
.gen-seg-item input:checked + span { background: var(--accent); color: var(--on-accent); font-weight: bold; }
.gen-seg-item input:focus-visible + span { outline: 2px solid var(--link); outline-offset: -2px; }
.gen-val { color: var(--text); font-weight: bold; margin-left: 4px; }
.gen-field input[type=range] { width: 100%; accent-color: var(--accent); }
.gen-range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.gen-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gen-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.gen-check { display: inline-flex !important; align-items: center; gap: 5px; font-size: 13px !important; color: var(--text) !important; margin: 0 !important; cursor: pointer; }
.gen-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 5px; }
.gen-chip { display: inline-flex; align-items: center; gap: 4px; }
.gen-chip-x { background: none; border: 0; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.gen-chip-x:hover { color: var(--danger-hover); }
.gen-pick-results { display: flex; flex-direction: column; margin-top: 4px; }
.gen-pick-item {
  display: flex; justify-content: space-between; gap: 8px; text-align: left; font-size: 13px; cursor: pointer;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-top: 0; padding: 6px 8px;
}
.gen-pick-item:first-child { border-top: 1px solid var(--border); }
.gen-pick-item:hover { background: #34302a; }

.gen-result { min-width: 0; }
.gen-empty {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 24px; color: var(--text-muted); max-width: 560px;
}
.gen-empty-title { font-family: var(--font-type); font-size: 20px; color: var(--text); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.gen-empty ol { margin: 10px 0 0 18px; line-height: 1.7; }
.gen-result-head { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; }
.gen-head-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.gen-fit {
  font-family: var(--font-type); font-size: 15px; letter-spacing: .06em; text-transform: uppercase; padding: 3px 10px;
  border-radius: var(--radius); border: 1px solid currentColor; cursor: help;
}
.gen-fit small { font-size: 12px; opacity: .85; margin-left: 4px; }
.gen-fit-strong { color: var(--success); } .gen-fit-solid { color: var(--accent-light); }
.gen-fit-risky { color: var(--warning); } .gen-fit-unfit { color: var(--danger-hover); }
.gen-brief-line { display: grid; gap: 3px; font-size: 14px; margin-bottom: 10px; }
.gen-k { display: inline-block; min-width: 74px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.gen-rpbar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.gen-rpfill { height: 100%; background: var(--accent); }
.gen-rpfill.over { background: var(--danger); }
.gen-rpline { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; margin-top: 5px; align-items: center; }
.gen-keep { margin-top: 8px; }
.gen-h2 { margin: 22px 0 10px; }
.gen-count { font-size: 14px; }
.gen-rp { display: inline-flex; align-items: center; gap: 4px; }
.gen-lock { opacity: .55; }
.gen-lock:hover, .gen-lock.on { opacity: 1; }
.gen-lock.on { color: var(--warning); }
.gen-lock .icon { width: 15px; height: 15px; }
.gen-lock-cell { width: 28px; text-align: right; }
.gen-lock-hint { font-size: 12px; margin-top: 8px; }
.gen-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 22px; }
.gen-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.gen-box h3 { font-family: var(--font-type); font-size: 13px; letter-spacing: .07em; text-transform: uppercase; margin: 0 0 6px; }
.gen-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.gen-list li { padding: 4px 0; border-top: 1px solid var(--border); }
.gen-list li:first-child { border-top: 0; }
.gen-check-row { display: flex; gap: 8px; }
.gen-check-ico { width: 16px; font-weight: bold; }
.gen-check-ok .gen-check-ico { color: var(--success); } .gen-check-weak .gen-check-ico { color: var(--warning); }
.gen-check-missing .gen-check-ico { color: var(--danger-hover); }
.gen-modules { font-size: 12.5px; margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gen-modules .icon { width: 15px; height: 15px; }
.gen-engine { font-size: 12px; margin-top: 4px; }
.gen-save {
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-top: 18px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.gen-save .gen-field { flex: 1 1 100%; }
.gen-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.gen-actions .btn { gap: 6px; }

/* ---- User menu (header) ---------------------------------------------- */
.user-menu-wrap { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 12px; cursor: pointer;
  background: rgba(0, 0, 0, .18); border: 1px solid rgba(232, 224, 204, .3); border-radius: 999px;
  color: var(--paper); font: inherit; font-size: 13px;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .08); border-color: rgba(232, 224, 204, .55); }
.user-avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border); color: var(--paper);
}
.user-avatar .icon { width: 16px; height: 16px; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 210px; z-index: 200; padding: 6px 0;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--stripe);
  border-radius: var(--radius); box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
}
.user-menu[hidden] { display: none; }
.user-menu a, .user-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; background: none; border: 0;
  color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.user-menu a:hover, .user-menu button:hover, .user-menu a:focus-visible, .user-menu button:focus-visible {
  background: rgba(255, 255, 255, .07); outline: none;
}
.user-menu .icon { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
.user-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
@media (max-width: 480px) { .user-btn .username { display: none; } .user-btn { padding: 3px; } }

/* ---- My Expansions ---------------------------------------------------- */
.exp-page { max-width: 1100px; }
.exp-intro { max-width: 70ch; margin: 0 0 14px; }
.exp-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.exp-summary { flex: 1 1 180px; font-size: 14px; }
.exp-search { flex: 1 1 200px; max-width: 320px; }
.exp-filter { flex: 0 0 auto; min-width: 270px; }
.exp-actions { display: flex; gap: 6px; }
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.exp-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; cursor: pointer; opacity: .78;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius);
}
.exp-item.is-owned { opacity: 1; border-left-color: var(--accent); background: var(--surface2); }
.exp-item:hover { border-color: var(--text-muted); }
.exp-item input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.exp-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.exp-name { font-weight: 700; font-size: 14px; }
.exp-facts { font-size: 12px; color: var(--text-muted); }
.exp-nations { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.exp-save-bar {
  position: sticky; bottom: 12px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.exp-save-bar .btn { gap: 8px; }
.nav-short { display: none; }
@media (max-width: 767px) {
  .exp-save-bar { bottom: 68px; }      /* clear the bottom tab bar */
  .nav-long { display: none; }
  .nav-short { display: inline; }
}

/* Phone tab bar: only Cards, Squads, Campaigns and Expansions (the builders and the admin views live on desktop) */
@media (max-width: 767px) {
  #nav-builder, #nav-generator, #nav-translations, #nav-users { display: none !important; }
  /* importing text / CSV / YAML files is a desktop task */
  #import-squad-btn, #builder-import-btn, [data-act="import"] { display: none !important; }
}
@media (max-width: 767px) {
  #sidebar .nav-link, #sidebar .nav-link.nav-sub { letter-spacing: .03em; padding: 8px 2px; font-size: 10.5px; }
}

/* ---- Role chip + user-menu header ------------------------------------- */
.user-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px 6px; }
.user-menu-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; border: 1px solid var(--border); color: var(--text-muted);
}
.role-chip.role-admin { color: var(--stripe); border-color: var(--stripe); }

/* Admin Users view */
.user-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.user-badge-enabled  { background: #13301f; color: #5fd08a; }
.user-badge-pending  { background: var(--warning-bg); color: var(--warning); }
.user-badge-reserved { background: #1f2a3d; color: #8ab4f8; }
.user-badge-disabled { background: #3a1d1a; color: #f08a7e; }
.users-table tbody tr { cursor: default; }
.users-table .user-email { word-break: break-all; }
.users-table .user-date { white-space: nowrap; color: var(--text-muted); }
.users-table .user-actions { white-space: nowrap; text-align: right; }
.users-table .user-actions .btn-icon { padding: 4px; }
.users-table .user-actions .icon { width: 16px; height: 16px; }
.user-link { font-weight: 600; }
.user-detail { max-width: 560px; }
.user-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 18px 0 0; font-size: 13px; }
.user-facts dt { color: var(--text-muted); }
.user-facts dd { margin: 0; }
