/* =========================================================================
   WOSB Tracker — refreshed visual layer.
   All existing selectors are preserved; only their styles are refined.
   ========================================================================= */

:root {
  /* base palette */
  --bg:        #0a1020;
  --bg-2:      #0e162a;
  --bg-3:      #131d36;        /* nested row tone */
  --card:      #17223e;        /* elevated surface */
  --card-hi:   #1d2a4b;        /* card hover / inner panel */
  --border:    #243150;        /* default outline (used sparingly) */
  --border-soft: rgba(255,255,255,0.04);

  /* text */
  --text:      #e8eef8;
  --muted:     #8c9bbb;
  --dim:       #5a6885;

  /* accents */
  --accent:        #5ab2ff;
  --accent-strong: #7ec3ff;
  --accent-glow:   rgba(90, 178, 255, 0.18);
  --ok:    #3ed59b;
  --warn:  #f5b840;
  --bad:   #f0625e;
  --nap:   #b39bff;

  /* depth */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-2: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-3: 0 16px 48px rgba(0,0,0,0.55);

  /* spacing scale (informational; used inline) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --radius:  10px;
  --radius-sm: 6px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
::selection { background: var(--accent-glow); color: var(--text); }

/* Default anchor color. Without this, links fall back to the browser
   default (~#0000EE), which is harsh on the dark navy palette and looks
   like blue-on-blue on cards. accent-strong reads cleanly without
   competing with the accent-blue button color. */
a {
  color: var(--accent-strong);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent); text-decoration: underline; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(circle at 12% 0%, rgba(90, 178, 255, 0.06), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(179, 155, 255, 0.05), transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Header / sidebar ------------------------------------------
   Sidebar lives on the left, fixed. Collapsed by default to a 56px icon
   rail; pinning expands it to 220px. On mobile (<= 720px), it becomes a
   slide-in drawer toggled by the hamburger in the header. */
:root {
  --sidebar-w-collapsed: 56px;
  --sidebar-w-expanded: 220px;
  --header-h: 54px;
}

header {
  display: flex; align-items: center;
  padding: 10px 20px;
  background: rgba(10, 16, 32, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 30;
  gap: 14px;
  min-height: var(--header-h);
  box-sizing: border-box;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 {
  font-size: 17px; margin: 0;
  letter-spacing: 0.3px; font-weight: 600;
}
.logo { font-size: 24px; color: var(--accent); filter: drop-shadow(0 0 8px var(--accent-glow)); }
/* Header logo image — sized to fit the header height with a faint glow
   matching the prior anchor icon. The source asset is the full WOSB
   Tools splash (ship + text + tagline); since we ship one image asset
   we just constrain it tightly so only the ship+wave portion reads. */
.brand-logo {
  height: 38px; width: auto;
  border-radius: 6px;
  filter: drop-shadow(0 0 6px rgba(90, 178, 255, 0.25));
  flex-shrink: 0;
  object-fit: cover;
  object-position: center 25%;   /* favor the ship over the text below */
  aspect-ratio: 1 / 1;
}
.header-tag {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-tag:empty { display: none; }

/* Hamburger toggle — visible on mobile, also acts as the desktop pin button.
   Three lines stacked into an X when sidebar is expanded. */
.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; padding: 0;
  transition: background var(--transition), border-color var(--transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.04); border-color: rgba(90,178,255,0.3); }
.sidebar-toggle span {
  display: block; width: 18px; height: 2px;
  background: var(--text); border-radius: 1px;
  transition: transform 0.18s, opacity 0.18s;
}
body.sidebar-pinned .sidebar-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.sidebar-pinned .sidebar-toggle span:nth-child(2) { opacity: 0; }
body.sidebar-pinned .sidebar-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Sidebar — fixed left, full-height under the header. */
.sidebar {
  position: fixed;
  top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-w-collapsed);
  background: rgba(10, 16, 32, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border-soft);
  z-index: 20;
  overflow-x: hidden; overflow-y: auto;
  transition: width 0.18s ease;
  padding: 10px 0;
  box-sizing: border-box;
}
body.sidebar-pinned .sidebar { width: var(--sidebar-w-expanded); }
/* Hover-to-peek: when not pinned, hovering the sidebar expands it
   transiently without persisting state. */
@media (hover: hover) and (pointer: fine) {
  .sidebar:hover { width: var(--sidebar-w-expanded); }
}
/* Hide sidebar entirely when not logged in (renderNav clears innerHTML, but
   keep the rail off-screen so the auth page isn't pushed right). */
.sidebar:empty { display: none; }
.sidebar:empty + .sidebar-scrim { display: none; }

.sidebar ul {
  list-style: none; margin: 0; padding: 0;
}
.sidebar > ul { display: flex; flex-direction: column; gap: 2px; }

.sb-item {
  display: flex; align-items: center;
  width: 100%;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--muted);
  padding: 9px 14px 9px 11px;
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  text-align: left;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  font-family: inherit;
  gap: 12px;
}
.sb-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sb-item.active {
  background: var(--accent-glow); color: var(--accent-strong);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sb-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; min-width: 22px; height: 22px;
  font-size: 16px;
  flex-shrink: 0;
}
/* Icon-image variant for nav entries that use a PNG/SVG instead of an emoji.
   Sized to the same 22-px slot, with object-fit: contain so a non-square
   source preserves its aspect ratio. */
.sb-icon-img {
  width: 22px; height: 22px; object-fit: contain;
  display: block;
}
.sb-label {
  flex: 1;
  opacity: 0;
  transition: opacity 0.12s;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.sidebar-pinned .sb-label,
.sidebar:hover .sb-label { opacity: 1; }
.sb-caret {
  font-size: 10px; color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s, transform 0.18s;
}
body.sidebar-pinned .sb-caret,
.sidebar:hover .sb-caret { opacity: 1; }
.sb-group.open > .sb-item .sb-caret { transform: rotate(180deg); }

.sb-sub {
  max-height: 0; overflow: hidden;
  transition: max-height 0.2s ease;
  background: rgba(0,0,0,0.18);
}
.sb-group.open .sb-sub { max-height: 240px; }
.sb-sub .sb-item {
  padding-left: 45px;
  font-size: 12.5px;
}

.sb-divider {
  height: 1px; background: var(--border-soft);
  margin: 8px 14px;
}

/* Sidebar nav badge — used for the pending-proposals count on Dashboard. */
.sb-item .nav-badge {
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.12s;
}
body.sidebar-pinned .sb-item .nav-badge,
.sidebar:hover .sb-item .nav-badge { opacity: 1; }
/* Keep a small dot visible even when collapsed so the user notices the
   pending count without expanding. */
.sb-item .nav-dot {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--bad);
  border-radius: 50%;
  top: 8px; left: 30px;
  display: none;
}
body.has-pending .sb-item.has-pending-dot { position: relative; }
body.has-pending .sb-item.has-pending-dot .nav-dot { display: block; }
body.sidebar-pinned .sb-item.has-pending-dot .nav-dot,
.sidebar:hover .sb-item.has-pending-dot .nav-dot { display: none; }

/* Scrim — covers main content when the mobile drawer is open so taps
   outside the sidebar close it. */
.sidebar-scrim {
  position: fixed;
  top: var(--header-h); left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 19;
}

/* Main content shifts right to make room for the collapsed rail and
   then fills the remaining viewport width — no fixed max-width so we
   don't leave a dead zone on the right. Auth screen (no sidebar) drops
   the offset and goes flush left. */
main {
  margin-left: var(--sidebar-w-collapsed);
  margin-right: 0;
  padding: 28px 32px;
  transition: margin-left 0.18s ease;
}
body.sidebar-pinned main { margin-left: var(--sidebar-w-expanded); }
body.no-sidebar main { margin-left: 0; }

.site-footer {
  margin-left: var(--sidebar-w-collapsed);
  margin-right: 0;
  padding: 20px 32px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border-soft);
  margin-top: 24px;
  transition: margin-left 0.18s ease;
}
body.sidebar-pinned .site-footer { margin-left: var(--sidebar-w-expanded); }
body.no-sidebar .site-footer { margin-left: 0; }
.site-footer a { color: var(--accent-strong); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
body.map-mode .site-footer { display: none; }

/* ---------- Cards ----------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--transition);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 17px; font-weight: 600; letter-spacing: 0.2px;
  color: var(--text);
}
/* Header row inside a card: title on the left, action button(s) flush right.
   Use it to put primary card actions (Edit, Add, etc.) in the top-right
   corner instead of below the content. */
.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; }
.card-head > .mini-btn,
.card-head > button { margin-left: auto; }
.card h3 {
  margin-top: 0; font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px;
  font-weight: 600;
}

.auth-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 880px; margin: 24px auto; }
@media (max-width: 720px) { .auth-wrap { grid-template-columns: 1fr; } }

.dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dashboard .card:last-child { grid-column: 1 / -1; }
@media (max-width: 720px) { .dashboard { grid-template-columns: 1fr; } }

/* ---------- Forms ----------------------------------------------------- */
form label {
  display: block; margin-bottom: 12px;
  font-size: 12px; color: var(--muted);
  font-weight: 500; letter-spacing: 0.2px;
}
input, textarea, select {
  width: 100%;
  padding: 9px 12px;
  margin-top: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: inherit; font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input[type=checkbox], input[type=radio] {
  width: auto; padding: 0; margin-top: 0;
  background: initial; border: initial;
  accent-color: var(--accent);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Buttons --------------------------------------------------- */
button {
  background: var(--accent); color: #07111f; border: none;
  padding: 9px 16px; border-radius: 7px; cursor: pointer;
  font-weight: 600; font-size: 13px; letter-spacing: 0.1px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
button:hover { background: var(--accent-strong); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }

button.secondary {
  background: rgba(255,255,255,0.04); color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }

button.danger { background: var(--bad); color: #fff; }
button.danger:hover { background: #e85046; }
button.warn { background: var(--warn); color: #07111f; }
button.warn:hover { background: #fac560; }

.err {
  color: var(--bad); font-size: 12px; margin-top: 8px;
  min-height: 16px;
}

/* ---------- Status badges -------------------------------------------- */
.status-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  border: 1px solid transparent;
  line-height: 1.4;
}
.s-allied   { background: rgba(62,213,155,0.12); color: var(--ok);   border-color: rgba(62,213,155,0.4); }
.s-nap      { background: rgba(179,155,255,0.12); color: var(--nap); border-color: rgba(179,155,255,0.4); }
.s-neutral  { background: rgba(140,155,187,0.10); color: var(--muted); border-color: rgba(140,155,187,0.3); }
.s-war      { background: rgba(240,98,94,0.12);  color: var(--bad);  border-color: rgba(240,98,94,0.4); }
.s-proposed { background: rgba(245,184,64,0.12); color: var(--warn); border-color: rgba(245,184,64,0.4); }

/* ---------- Generic row pattern -------------------------------------- */
.rel-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.rel-row:last-child { border-bottom: none; }
.rel-row .left { display: flex; flex-direction: column; gap: 4px; }
.rel-row .name { font-weight: 600; }
/* Guild link inside the row reads as text first, accent on interaction —
   keeps the relationship cards calm instead of two competing blues. */
.rel-row .name a {
  color: var(--text);
  border-bottom: 1px dashed transparent;
  padding-bottom: 1px;
  transition: color var(--transition), border-color var(--transition);
}
.rel-row .name a:hover {
  color: var(--accent-strong);
  border-bottom-color: rgba(126, 195, 255, 0.45);
  text-decoration: none;
}
.rel-row .notes { color: var(--muted); font-size: 12px; }
.rel-row .actions { display: flex; gap: 6px; align-items: center; }

.guild-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: 7px; cursor: pointer;
  transition: background var(--transition);
}
.guild-list-item:hover { background: var(--accent-glow); }
.guild-list-item .tag { color: var(--accent); font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.guild-list-item.is-kos {
  background: rgba(240,98,94,0.06);
  box-shadow: inset 3px 0 0 var(--bad);
}

.history-row {
  padding: 8px 0; font-size: 12.5px; color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
}
.history-row:last-child { border-bottom: none; }
.history-row .when { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--dim); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.back {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border-soft);
  cursor: pointer; padding: 6px 12px;
  border-radius: 7px; font-size: 12px;
  margin-bottom: 14px;
  transition: color var(--transition), border-color var(--transition);
}
.back:hover { color: var(--accent); border-color: rgba(90,178,255,0.3); }

/* ---------- Modal ----------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  min-width: 360px; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-3);
}
.modal h3 {
  margin: -22px -22px 16px;
  padding: 13px 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent);
  border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: move; user-select: none;
  position: sticky; top: -22px; z-index: 2;
  font-size: 15px; font-weight: 600;
  color: var(--text);
}
.modal h3::before { content: "⋮⋮  "; color: var(--dim); font-size: 14px; }

.info-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 8px 18px; font-size: 13px;
}
.info-grid dt { color: var(--muted); font-size: 12px; }
.info-grid dd { margin: 0; color: var(--text); }
.empty {
  color: var(--dim); font-style: italic;
  padding: 14px 0; font-size: 13px;
}

/* ---------- Roster: player + ship ------------------------------------ */
.player-block {
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 14px 16px;
  margin-top: 12px;
  background: var(--bg-3);
}
.player-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.player-head .pname { font-weight: 600; font-size: 15px; }
.player-head .prank { color: var(--accent); font-size: 12px; margin-left: 8px; font-weight: 500; }
.player-head .pnotes { color: var(--muted); font-size: 12px; width: 100%; margin-top: 4px; }

/* Last-seen activity pill — bucketed by days since last Google sign-in. */
.seen-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 10.5px; font-weight: 600;
  line-height: 1.5;
  border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0.2px;
}
.seen-pill.seen-fresh { background: rgba(82, 196, 130, 0.18); color: #6fd99a; }
.seen-pill.seen-warm  { background: rgba(245, 184, 64, 0.18); color: #f5b840; }
.seen-pill.seen-stale { background: rgba(245, 130, 64, 0.20); color: #f58240; }
.seen-pill.seen-cold  { background: rgba(240, 98, 94, 0.20);  color: #f0625e; }

/* ---------- Fleet Battle Planner ---------------------------------------
   In-room view: top toolbar (leave button, status, map picker) above a
   stage area that fills the remaining viewport. The stage div hosts the
   Konva canvas, which auto-fits to its container. */
.bp-room {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--header-h) - 24px);
  gap: 8px;
}
.bp-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.bp-toolbar-spacer { flex: 1; }
.bp-status-inline {
  font-size: 12px;
  color: var(--muted);
  padding: 2px 8px;
}
.bp-status-inline b { color: var(--text); font-weight: 600; }
.bp-map-picker {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.bp-map-picker select {
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.bp-map-readonly {
  font-size: 12px; font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
}
.bp-stage {
  flex: 1;
  /* Themed: var(--bg) stays the same dark navy in dark mode (matches the
     previous hardcoded #0a1020), and flips to parchment cream in light
     mode so the planner doesn't render a black box mid-cream-page. The
     square 1080x1080 virtual canvas means the map fills almost all of
     this area; the visible stage bg is mostly the thin margin around it. */
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 400px;
}
/* Light mode gets a slightly warmer stage tint + warm border so the map
   sits in a "well" rather than blending invisibly into the page. */
body.theme-light .bp-stage {
  background: #e0d4b0;
  border: 1px solid rgba(110, 84, 54, 0.30);
  box-shadow: 0 1px 0 rgba(255, 250, 230, 0.4) inset;
}
/* Konva injects its container with inline styles; just make sure cursor
   feedback works on the canvas surface. */
.bp-stage canvas { cursor: crosshair; display: block; }

/* Tool buttons in the in-room toolbar — a tight pill row. */
.bp-tools {
  display: inline-flex; gap: 4px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
/* Stroke-color swatches for the Draw tool. A horizontal row of round
   buttons whose backgrounds *are* the line color they select. The
   active swatch gets a ring border so it's obvious which color the
   next stroke will use. */
.bp-palette {
  display: inline-flex; gap: 4px;
  padding: 3px 4px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  align-items: center;
}
.bp-swatch {
  width: 20px; height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: outline-color var(--transition), transform var(--transition);
}
.bp-swatch:hover { transform: scale(1.12); }
.bp-swatch.active { outline-color: var(--text); }
body.theme-light .bp-swatch { border-color: rgba(91, 62, 30, 0.4); }
body.theme-light .bp-swatch.active { outline-color: var(--accent); }
.bp-tool {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px; font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.bp-tool:hover:not(.disabled) { background: rgba(255,255,255,0.04); color: var(--text); }
.bp-tool.active {
  background: var(--accent-glow);
  color: var(--accent-strong);
  border-color: rgba(90,178,255,0.3);
}
.bp-tool.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Body splits the in-room view between the Konva stage (left) and the
   roster / squadron panels (right). Min-width 0 on the stage column
   keeps Konva from forcing the page wider than the viewport. */
.bp-body {
  display: flex; gap: 8px;
  flex: 1;
  min-height: 0;
}
.bp-body .bp-stage { flex: 1; min-width: 0; }
.bp-side {
  width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.bp-side-head {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.bp-side-head h3 {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}
.bp-roster {
  overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.bp-roster-row {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
}
.bp-roster-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.bp-status-dot { font-size: 10px; }
.bp-pname { font-weight: 500; }
.bp-role {
  margin-left: 4px;
  padding: 0 6px;
  font-size: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  border-radius: 999px;
}
.bp-assigned { font-size: 12px; margin-top: 2px; }
.bp-assigned-empty { color: var(--dim); font-style: italic; }
.bp-assign-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.bp-assign-row select {
  flex: 1;
  padding: 3px 6px;
  font-size: 11px;
}
.bp-offers {
  margin-top: 6px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.bp-offers-empty { color: var(--dim); font-style: italic; font-size: 11px; }
.bp-offer-tag {
  background: rgba(90,178,255,0.10);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
}

/* Squadron chip on a roster row */
.bp-sq-chip {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

/* Squadrons section */
.bp-squadrons {
  overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.bp-sq-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 0;
  font-size: 12px;
  overflow: hidden;
}
.bp-sq-card.bp-sq-inactive { opacity: 0.55; }
.bp-sq-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 10px;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.02);
  flex-wrap: wrap;
}
.bp-sq-name {
  font-weight: 600;
  flex: 1; min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bp-sq-toggle {
  padding: 2px 8px !important;
  font-size: 10px !important;
  letter-spacing: 0.5px;
}
.bp-sq-card.bp-sq-inactive .bp-sq-toggle {
  background: rgba(240,98,94,0.15);
  color: var(--bad);
  border-color: rgba(240,98,94,0.3);
}
.bp-sq-state {
  padding: 2px 8px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
}
.bp-sq-formation, .bp-sq-formation-readonly {
  font-size: 10.5px;
  padding: 2px 6px;
  width: 100%;
  margin-top: 4px;
}
.bp-sq-formation-readonly {
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  display: inline-block;
}
.bp-sq-members {
  padding: 6px 10px 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.bp-sq-member {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11.5px;
}
.bp-sq-member:last-child { border-bottom: 0; }
.bp-sq-mname { font-weight: 500; }
.bp-sq-mship { color: var(--muted); font-size: 11px; }
.bp-sq-mship-empty { font-style: italic; color: var(--dim); }
.bp-sq-empty {
  font-size: 11px; font-style: italic;
  color: var(--dim);
  padding: 4px 0;
}

@media (max-width: 900px) {
  .bp-body { flex-direction: column; }
  .bp-side { width: auto; max-height: 360px; }
}

/* Public-build "PUBLIC" pill on the build header. */
.public-pill {
  display: inline-block;
  padding: 1px 7px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(90, 178, 255, 0.18);
  color: var(--accent);
  border-radius: 999px;
  vertical-align: middle;
}

/* Public Builds page row layout. */
.public-build-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin-bottom: 8px;
}

.ship-list { margin-top: 12px; padding-left: 0; list-style: none; }
.ship-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 10px 12px;
  background: var(--bg-2);
  box-shadow: inset 3px 0 0 var(--accent);
  margin-bottom: 6px; border-radius: 6px;
  transition: background var(--transition);
}
.ship-row:hover { background: var(--card-hi); }
.ship-thumb {
  width: 76px; height: 56px; border-radius: 5px; object-fit: cover;
  border: 1px solid var(--border-soft); background: var(--bg);
  flex-shrink: 0;
}
.ship-img-preview {
  max-width: 200px; max-height: 130px; margin-top: 6px;
  border-radius: 6px; border: 1px solid var(--border-soft);
}
.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.upload-btn {
  background: transparent; color: var(--accent);
  border: 1px dashed rgba(90,178,255,0.5);
  padding: 7px 14px; font-size: 12px; border-radius: 6px;
  cursor: pointer; font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
}
.upload-btn:hover { background: var(--accent-glow); border-color: var(--accent); }
.upload-status { font-size: 11px; color: var(--muted); }
.upload-status.ok { color: var(--ok); }
.upload-status.err { color: var(--bad); }

.ship-row .sname { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; }
.ship-row .sclass { color: var(--muted); font-size: 12px; }
.ship-row .snotes { color: var(--muted); font-size: 11px; font-style: italic; }

/* ---------- Mini buttons --------------------------------------------- */
.mini-btn {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  padding: 4px 10px; font-size: 11px;
  border-radius: 5px; cursor: pointer; font-weight: 500;
  transition: all var(--transition);
}
.mini-btn:hover {
  border-color: rgba(90,178,255,0.4);
  color: var(--text); background: rgba(255,255,255,0.04);
}
.mini-btn.danger {
  color: var(--bad); background: transparent;
  border-color: rgba(240,98,94,0.3);
}
.mini-btn.danger:hover {
  border-color: var(--bad);
  background: rgba(240,98,94,0.10);
  color: var(--bad);
}
.mini-btn.remove-x {
  width: 26px !important; height: 26px !important; padding: 0 !important;
  display: inline-flex !important; align-items: center !important; justify-content: center !important;
  font-size: 18px !important; font-weight: 900 !important; line-height: 1 !important;
  background: var(--bad) !important; color: #ffffff !important; border-color: var(--bad) !important;
  flex-shrink: 0 !important; font-family: Arial, sans-serif !important;
}
.mini-btn.remove-x:hover { background: #e8504a !important; border-color: #e8504a !important; color: #fff !important; }
.fleet-row-actions { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Map page (iframe) ---------------------------------------- */
.map-page {
  position: fixed; left: 0; right: 0; bottom: 0; top: 51px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 14px 12px;
  background: var(--bg); z-index: 5;
}
.map-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 4px; flex: 0 0 auto;
}
.map-bar .map-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.map-bar .map-link:hover { text-decoration: underline; }
.map-page iframe {
  flex: 1 1 auto; width: 100%;
  border: 1px solid var(--border-soft);
  border-radius: 8px; background: #000; min-height: 0;
}
.map-image-page {
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
}
.map-image-page .map-image {
  max-width: 100%; max-height: 100%;
  object-fit: contain; display: block;
  border-radius: 8px;
}
.map-fallback {
  padding: 14px;
  border: 1px solid rgba(240,98,94,0.4);
  border-radius: 8px; color: var(--bad);
  font-size: 13px; flex: 0 0 auto;
  background: rgba(240,98,94,0.05);
}
body.map-mode { overflow: hidden; }

/* ---------- Battle Map (canvas) -------------------------------------- */
.battlemap-page { display: flex; flex-direction: column; gap: 10px; }
.bm-toolbar {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  box-shadow: var(--shadow-1);
  position: sticky; top: 51px; z-index: 4;
}
.bm-tools, .bm-style, .bm-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bm-tools .bm-tool {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  padding: 5px 12px; font-size: 12px; border-radius: 6px;
  cursor: pointer; transition: all var(--transition);
}
.bm-tools .bm-tool:hover { border-color: rgba(90,178,255,0.3); color: var(--text); }
.bm-tools .bm-tool.active {
  background: var(--accent); color: #07111f;
  border-color: var(--accent); font-weight: 700;
}
.bm-style label {
  font-size: 11.5px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
}
.bm-style input[type=color] {
  width: 36px; height: 28px;
  border: 1px solid var(--border-soft);
  background: var(--bg); padding: 2px; border-radius: 5px; cursor: pointer;
}
.bm-style input[type=range] { width: 110px; accent-color: var(--accent); }
.bm-actions button {
  background: transparent; border: 1px solid var(--border-soft); color: var(--muted);
  padding: 5px 12px; font-size: 12px; border-radius: 6px; cursor: pointer; font-weight: 500;
  transition: all var(--transition);
}
.bm-actions button:hover { border-color: rgba(90,178,255,0.3); color: var(--text); }
.bm-actions button.danger { color: var(--bad); border-color: rgba(240,98,94,0.3); }
.bm-actions button.danger:hover { background: rgba(240,98,94,0.1); border-color: var(--bad); }
.bm-zoom { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-left: 8px; }
.bm-zoom button { padding: 2px 8px; }

.bm-canvas-wrap {
  position: relative; overflow: auto;
  border: 1px solid var(--border-soft); border-radius: 9px;
  background: var(--bg); height: calc(100vh - 200px); min-height: 480px;
  box-shadow: var(--shadow-1);
}
.bm-canvas-wrap.bm-panning { cursor: grabbing; }
.bm-stage { position: relative; transform-origin: 0 0; }
.bm-stage img.bm-img { display: block; user-select: none; pointer-events: none; }
.bm-stage canvas { position: absolute; top: 0; left: 0; cursor: crosshair; touch-action: none; }
.bm-stage .bm-markers {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; pointer-events: none;
}
.bm-stage .bm-markers img { box-shadow: 1px 1px 4px #555; }
.bm-stage .bm-markers .bm-label             { color: goldenrod;   font-size: 20px; font-weight: bold; text-shadow: 0 0 .5em #000; white-space: nowrap; }
.bm-stage .bm-markers .bm-poilabel          { color: green;       font-size: 10px; font-weight: bold; text-shadow: 0 0 .5em #000; white-space: nowrap; }
.bm-stage .bm-markers .bm-portxylabel       { color: yellow;      font-size: 14px; font-weight: bold; text-shadow: 0 0 .5em #000; white-space: nowrap; }
.bm-stage .bm-markers .bm-islandxylabel     { color: greenyellow; font-size: 12px; font-weight: bold; text-shadow: 0 0 .5em #000; white-space: nowrap; }
.bm-stage .bm-markers .bm-productionxylabel { color: cyan;        font-size: 12px; font-weight: bold; text-shadow: 0 0 .5em #000; white-space: nowrap; }
.bm-stage .bm-markers .bm-altarxylabel      { color: magenta;     font-size: 12px; font-weight: bold; text-shadow: 0 0 .5em #000; white-space: nowrap; }
.bm-stage .bm-markers .bm-fortxylabel       { color: violet;      font-size: 12px; font-weight: bold; text-shadow: 0 0 .5em #000; white-space: nowrap; }
.bm-layers {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding-left: 12px;
  border-left: 1px solid var(--border-soft);
  margin-left: 6px;
}
.bm-layers .checkbox-row { font-size: 11px; gap: 4px; }
.bm-layers .checkbox-row input { transform: scale(0.9); }

/* ---------- Guides ---------------------------------------------------- */
.guide-card {
  border: 1px solid var(--border-soft);
  border-radius: 9px; padding: 14px 16px;
  background: var(--bg-3);
  margin-bottom: 10px; cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.guide-card:hover {
  background: var(--card-hi);
  border-color: rgba(90,178,255,0.3);
  transform: translateY(-1px);
}
.guide-title { font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 4px; }
.guide-meta { color: var(--muted); font-size: 11px; }
.guide-cat {
  display: inline-block;
  background: var(--accent-glow); color: var(--accent);
  padding: 1px 7px; border-radius: 3px; font-size: 10px;
  font-weight: 600;
}
.guide-excerpt { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.5; }
.guide-mine {
  background: var(--accent); color: #07111f;
  padding: 2px 9px; border-radius: 999px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0;
}
.guide-header { border-bottom: 1px solid var(--border-soft); padding-bottom: 14px; margin-bottom: 18px; }
.guide-body { line-height: 1.65; font-size: 14px; }
.guide-body h1 { font-size: 22px; margin: 18px 0 8px; font-weight: 600; }
.guide-body h2 { font-size: 18px; margin: 16px 0 6px; font-weight: 600; }
.guide-body h3 { font-size: 15px; margin: 14px 0 4px; font-weight: 600; }
.guide-body p { margin: 8px 0; }
.guide-body ul { margin: 8px 0; padding-left: 22px; }
.guide-body li { margin: 4px 0; }
.guide-body code {
  background: var(--bg); border: 1px solid var(--border-soft);
  padding: 1px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
.guide-body a { color: var(--accent); }
.guide-body .guide-img {
  max-width: 100%; border-radius: 7px;
  border: 1px solid var(--border-soft); margin: 10px 0;
}
.guide-editor-tabs { display: flex; gap: 6px; align-items: center; margin: 12px 0 6px; }
.guide-editor-tabs .tab-btn {
  background: transparent; border: 1px solid var(--border-soft);
  color: var(--muted); padding: 5px 14px; font-size: 12px;
  border-radius: 6px; cursor: pointer; transition: all var(--transition);
}
.guide-editor-tabs .tab-btn:hover { color: var(--text); }
.guide-editor-tabs .tab-btn.active {
  background: var(--accent); color: #07111f; border-color: var(--accent); font-weight: 600;
}
#guide-body {
  width: 100%; font-family: 'JetBrains Mono', monospace;
  font-size: 13px; line-height: 1.6;
}

/* ---------- Leadership / Diplo --------------------------------------- */
.leadership-section {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.leadership-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.leadership-header h3 {
  margin: 0; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600;
}
.leadership-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.leadership-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--bg-3);
  border: 1px solid var(--border-soft);
  border-radius: 7px; font-size: 13px;
  transition: background var(--transition);
}
.leadership-list li:hover { background: var(--card-hi); }
.leader-name { font-weight: 600; color: var(--text); }
.leader-note { color: var(--muted); font-size: 11px; flex: 1; font-style: italic; }
.leader-edit { margin-left: auto; }

.rank-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  background: var(--bg-2); color: var(--muted);
  border: 1px solid var(--border-soft);
  line-height: 1.5;
}
.rank-badge.rank-software-dev {
  background: linear-gradient(135deg, rgba(126,195,255,0.22), rgba(179,155,255,0.22));
  color: var(--accent-strong);
  border-color: rgba(126,195,255,0.55);
  text-shadow: 0 0 6px rgba(126,195,255,0.45);
  letter-spacing: 0.8px;
}
.rank-badge.rank-founder    { background: rgba(245,184,64,0.13);  color: #f5b840; border-color: rgba(245,184,64,0.4); }
.rank-badge.rank-admiral    { background: rgba(240,98,94,0.13);   color: var(--bad); border-color: rgba(240,98,94,0.4); }
.rank-badge.rank-commodore  { background: rgba(255,138,76,0.13);  color: #ff8a4c; border-color: rgba(255,138,76,0.4); }
.rank-badge.rank-officer    { background: rgba(90,178,255,0.13);  color: var(--accent); border-color: rgba(90,178,255,0.4); }
.rank-badge.rank-midshipman { background: rgba(179,155,255,0.13); color: var(--nap); border-color: rgba(179,155,255,0.4); }
.rank-badge.rank-sailor     { background: rgba(62,213,155,0.13);  color: var(--ok); border-color: rgba(62,213,155,0.4); }
.rank-badge.rank-cabin-boy  { background: var(--bg-2); color: var(--muted); }
.rank-badge.rank-diplomat   { background: rgba(179,155,255,0.13); color: var(--nap); border-color: rgba(179,155,255,0.4); }

.checkbox-row {
  display: flex; flex-direction: row !important;
  align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
}
.checkbox-row input[type=checkbox] { margin: 0; }

.dip-row { align-items: center !important; }
.dip-info { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.dip-actions { display: flex; gap: 4px; flex-shrink: 0; }
.dip-handles-inline {
  display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding-left: 8px; border-left: 1px solid var(--border-soft); margin-left: 6px;
}
.dip-handles-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin-right: 2px; }
.dip-target {
  display: inline-block;
  background: var(--accent-glow); color: var(--accent);
  border: 1px solid rgba(90,178,255,0.3);
  padding: 1px 7px; border-radius: 4px;
  font-size: 11px; font-family: 'JetBrains Mono', monospace; font-weight: 600;
}
.dip-target-scouted { background: rgba(179,155,255,0.13); color: var(--nap); border-color: rgba(179,155,255,0.3); }
.dip-empty { color: var(--dim); font-size: 11px; font-style: italic; }
.dip-tag-type { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; padding: 0 4px; }

.dip-pick-section {
  border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 12px;
  margin-bottom: 12px; max-height: 260px;
  overflow-y: auto;
  background: var(--bg);
}
.dip-pick-head {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin: 0 0 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
}
.dip-pick-row {
  display: flex !important; flex-direction: row !important;
  justify-content: space-between !important; align-items: center !important;
  padding: 8px 12px !important; margin: 0 !important;
  font-size: 13px !important; color: var(--text) !important;
  cursor: pointer !important; border-radius: 6px;
  border-left: 3px solid transparent;
  transition: background var(--transition);
}
.dip-pick-row:hover { background: var(--accent-glow); }
.dip-pick-row input[type=checkbox] { margin: 0 !important; }
.dip-pick-row .dip-pick-tag { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.dip-pick-row.dip-pick-checked {
  background: var(--accent-glow);
  border-left-color: var(--accent);
}
.dip-pick-row.dip-pick-checked .dip-pick-tag { color: var(--accent); }

/* ---------- Build-ship modal helpers --------------------------------- */
.cannon-counter { font-size: 11px; font-family: 'JetBrains Mono', monospace; }
input.rank-locked {
  background: var(--accent-glow) !important;
  color: var(--accent) !important; cursor: not-allowed;
}
.rank-auto-hint { color: var(--accent); font-size: 10px; margin-top: 4px; opacity: 0.85; }

.bship-preview-wrap {
  margin: 8px 0 16px;
  border: 1px solid var(--border-soft); border-radius: 8px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  display: flex; align-items: center; justify-content: center;
  min-height: 150px; padding: 10px; overflow: hidden;
}
.bship-preview-wrap img {
  max-width: 100%; max-height: 220px; height: auto;
  display: block; border-radius: 6px;
}
.bship-preview-empty { color: var(--muted); font-size: 12px; font-style: italic; padding: 14px; text-align: center; }

.crew-picker {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px 12px; padding: 10px 12px;
  border: 1px solid var(--border-soft); border-radius: 7px;
  background: var(--bg);
}
.crew-cell { display: flex; align-items: center; gap: 8px; }
.crew-label { font-size: 12px; color: var(--text); flex: 1; margin: 0 !important; font-weight: 500; }
.crew-cell input { width: 76px; padding: 5px 8px !important; font-size: 12px; text-align: right; }
.crew-total { font-size: 11px; color: var(--muted); margin-top: 6px; }
.crew-tag {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; background: rgba(179,155,255,0.13); color: var(--nap);
  border: 1px solid rgba(179,155,255,0.3); margin-right: 4px;
}

.bs-meta { font-size: 10px; color: var(--muted); padding: 0 6px; }
.bs-upgrades { font-size: 11px; color: var(--text); }
.bs-upgrades b { color: var(--warn); margin-right: 4px; }
.upgrade-tag {
  display: inline-block; padding: 2px 7px; margin: 1px 3px 1px 0;
  border-radius: 4px; font-size: 10px;
  background: rgba(245,184,64,0.13); color: var(--warn);
  border: 1px solid rgba(245,184,64,0.4);
}

.upgrade-picker {
  max-height: 320px; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--border-soft); border-radius: 7px;
  background: var(--bg); padding: 10px 12px;
}
.upgrade-group { margin-bottom: 14px; }
.upgrade-group:last-of-type { margin-bottom: 0; }
.upgrade-group h4 {
  margin: 0 0 8px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
}
.upgrade-row {
  display: flex !important; flex-direction: row !important; align-items: center !important;
  gap: 10px; padding: 7px 10px; margin: 0 0 3px !important;
  border-radius: 5px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition);
}
.upgrade-row:hover { background: rgba(245,184,64,0.07); }
.upgrade-row.is-on { background: rgba(245,184,64,0.12); border-left-color: var(--warn); }
.upgrade-row input[type=checkbox] { margin: 0 !important; flex-shrink: 0; }
.upgrade-row .upg-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.upgrade-row .upg-name { font-weight: 600; font-size: 12.5px; color: var(--text); line-height: 1.3; }
.upgrade-row .upg-note { color: var(--muted); font-size: 10.5px; line-height: 1.4; margin-top: 2px; }
.upgrade-custom-label { display: block !important; margin-top: 12px !important; }
.upgrade-custom-label textarea { font-family: inherit !important; font-size: 12px; width: 100%; box-sizing: border-box; }

.bs-special {
  font-size: 11px; color: var(--text);
  padding: 6px 10px;
  background: rgba(179,155,255,0.06);
  box-shadow: inset 2px 0 0 var(--nap);
  border-radius: 5px;
}
.bs-special b { color: var(--nap); display: block; margin-bottom: 3px; }

.bs-ammo {
  font-size: 11px; color: var(--text);
  padding: 6px 10px;
  background: rgba(62,213,155,0.06);
  box-shadow: inset 2px 0 0 var(--ok);
  border-radius: 5px;
}
.bs-ammo b { color: var(--ok); margin-right: 4px; }
.ammo-tag {
  display: inline-block; padding: 2px 7px; margin: 1px 3px 1px 0;
  border-radius: 4px; font-size: 10px;
  background: rgba(62,213,155,0.13); color: var(--ok);
  border: 1px solid rgba(62,213,155,0.4);
}
.bs-inventory {
  font-size: 11px; color: var(--text);
  padding: 6px 10px;
  background: rgba(245,184,64,0.06);
  box-shadow: inset 2px 0 0 var(--warn);
  border-radius: 5px;
}
.bs-inventory b { color: var(--warn); display: block; margin-bottom: 3px; }

.sc-tag {
  display: inline-block; padding: 2px 7px; margin: 1px 3px 1px 0;
  border-radius: 4px; font-size: 10px;
  background: rgba(179,155,255,0.13); color: var(--nap);
  border: 1px solid rgba(179,155,255,0.4);
}
.sc-picker .upgrade-row.is-on { background: rgba(179,155,255,0.12); border-left-color: var(--nap); }
.sc-picker .upgrade-row:hover { background: rgba(179,155,255,0.07); }
.sc-type {
  font-size: 10px; font-weight: 400; color: var(--muted);
  padding: 0 5px;
  border: 1px solid var(--border-soft); border-radius: 3px;
  margin-left: 6px;
}

.cannon-picker-wrap { display: block; }
.cannon-search, .picker-search {
  width: 100%; box-sizing: border-box;
  margin: 4px 0 8px !important;
  padding: 7px 12px !important; font-size: 13px;
}
.cannon-picker-controls { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.cannon-picker-controls .cannon-search { margin: 0 !important; flex: 1; }
.cannon-picker-controls .cannon-clear-all { flex-shrink: 0; }
.cannon-fill-all {
  margin-left: 4px; padding: 4px 10px !important; font-size: 10px;
  background: var(--accent-glow); border-color: rgba(90,178,255,0.3); color: var(--accent);
}
.cannon-fill-all:hover { background: rgba(90,178,255,0.25); border-color: var(--accent); }
.upgrade-picker-wrap { display: block; }

.cannon-picker {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border-soft); border-radius: 7px;
  padding: 10px 12px; background: var(--bg);
}
.cannon-group { margin-bottom: 12px; }
.cannon-group:last-child { margin-bottom: 0; }
.cannon-group h4 {
  margin: 0 0 8px 0; font-size: 11px; text-transform: uppercase;
  color: var(--accent); letter-spacing: 1.2px;
  font-weight: 600;
}
.cannon-row {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 8px;
  padding: 6px 0; font-size: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.cannon-row:last-child { border-bottom: none; }
.cannon-row input[type="number"] {
  width: 52px; padding: 5px 6px; margin: 0;
  text-align: right; font-size: 12px;
}
/* Side-aware inputs: P / S / Bow / Stern columns. Tight grid keeps the
   four labelled cells aligned; the small <span> labels above the inputs
   read top-to-bottom in the row's vertical centre. */
.cannon-side-inputs {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 6px;
  align-items: end;
}
.cannon-side-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cannon-side-cell input[type="number"] { width: 48px; }
@media (max-width: 600px) {
  .cannon-side-inputs { gap: 4px; }
  .cannon-side-cell input[type="number"] { width: 38px; padding: 4px 4px; }
}
.cinfo { display: flex; flex-direction: column; gap: 3px; }
.cname { font-weight: 600; }
.cstat { color: var(--muted); font-size: 10.5px; font-family: 'JetBrains Mono', monospace; }
.cstat b { color: var(--accent); font-weight: 600; }
.cstat-na { color: var(--muted); font-size: 10px; font-style: italic; }
.tier {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-left: 4px;
}
.tier-crafted  { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(90,178,255,0.4); }
.tier-pirate   { background: rgba(240,98,94,0.13); color: var(--bad); border: 1px solid rgba(240,98,94,0.4); }
/* tier-regular is the default — no badge shown. */

.cannon-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.cannon-tag {
  background: rgba(245,184,64,0.10);
  border: 1px solid rgba(245,184,64,0.4);
  color: var(--warn);
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.broadside-summary {
  margin-top: 6px; font-size: 11px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 12px;
}
.broadside-summary b { color: var(--text); }

/* ---------- KoS rows ------------------------------------------------- */
.kos-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px;
  margin-top: 8px;
  background: rgba(240,98,94,0.06);
  box-shadow: inset 4px 0 0 var(--bad);
  border-radius: 7px;
}
.kos-row .left { flex: 1; }
.kos-row .target { font-weight: 600; }
.kos-row .target .kos-type { color: var(--muted); font-size: 11px; margin-left: 6px; font-weight: 400; }
.kos-row .reason { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kos-row .meta { color: var(--dim); font-size: 11px; margin-top: 2px; }

.sev-badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  border: 1px solid transparent; line-height: 1.5;
}
.sev-low    { background: rgba(245,184,64,0.13); color: var(--warn); border-color: rgba(245,184,64,0.4); }
.sev-medium { background: rgba(240,98,94,0.13);  color: var(--bad);  border-color: rgba(240,98,94,0.4); }
.sev-high   { background: var(--bad); color: #fff; border-color: var(--bad); }

.kos-flag {
  display: inline-block; background: var(--bad); color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 3px;
  margin-left: 6px; letter-spacing: 0.5px; text-transform: uppercase;
  vertical-align: middle;
}
.guild-list-item.is-kos { box-shadow: inset 3px 0 0 var(--bad); }

/* ---------- Scouted rows -------------------------------------------- */
.scouted-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 12px;
  margin-top: 8px;
  background: rgba(245,184,64,0.05);
  box-shadow: inset 3px 0 0 var(--warn);
  border-radius: 7px;
}
.scouted-row .sname-line { font-weight: 600; }
.scouted-row .stag { color: var(--warn); font-family: 'JetBrains Mono', monospace; font-size: 12px; margin-left: 6px; }
.scouted-row .sfaction { color: var(--accent); font-size: 12px; margin-left: 6px; }
.scouted-row .snotes-line { color: var(--muted); font-size: 12px; margin-top: 4px; }
.scouted-row .smeta { color: var(--dim); font-size: 11px; margin-top: 4px; }
.scouted-flag {
  display: inline-block; background: var(--warn); color: #07111f;
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 3px;
  margin-left: 6px; letter-spacing: 0.5px; text-transform: uppercase;
  vertical-align: middle;
}

/* ---------- Fleet block (and Fleet Builds reuse this) --------------- */
.fleet-block {
  background: var(--bg-3);
  box-shadow: inset 3px 0 0 var(--accent);
  border-radius: 9px; padding: 16px 18px; margin-top: 14px;
}
.fleet-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.fleet-name { font-weight: 700; font-size: 15px; }
.fleet-notes { color: var(--muted); font-size: 12px; margin-top: 6px; }

.fleet-stats {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; font-size: 13px;
}
.fleet-stats .stat {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  padding: 5px 12px; border-radius: 6px;
  font-size: 12px;
}
.fleet-stats .stat b { color: var(--accent); }
.fleet-stats .stat.hp b  { color: var(--ok); }
.fleet-stats .stat.dps b { color: var(--warn); }

.fleet-ships-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.fleet-ship-row {
  display: grid;
  grid-template-columns: 60px 1fr auto auto auto auto auto;
  gap: 12px; align-items: center;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  font-size: 13px;
  transition: background var(--transition);
}
.fleet-ship-row:hover { background: var(--card-hi); }
.fleet-ship-speed { color: var(--accent); font-weight: 600; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.fleet-ship-thumb {
  width: 56px; height: 40px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border-soft);
  background: var(--card);
}
.fleet-ship-thumb.placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 10px;
}
.fleet-ship-info .owner { color: var(--muted); font-size: 11px; }
.fleet-ship-hp { color: var(--ok); font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.fleet-ship-dps { color: var(--warn); font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.fleet-ship-armor { color: var(--muted); font-size: 11px; font-family: 'JetBrains Mono', monospace; }

.mutual-warn {
  background: var(--bad); color: #fff;
  padding: 9px 14px;
  border-radius: 7px; margin-bottom: 10px;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-1);
}

.cat-total {
  display: inline-block; font-size: 11px;
  color: var(--muted); margin-left: 8px;
}

/* ---------- Scrollbar polish (webkit) -------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 5px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--accent); }

.google-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; padding: 10px 18px;
  background: #fff; color: #3c4043;
  border: 1px solid #dadce0; border-radius: 6px;
  font-weight: 600; font-size: 14px; text-decoration: none;
  font-family: 'Roboto', system-ui, sans-serif;
  transition: box-shadow var(--transition), background var(--transition);
  width: 100%; box-sizing: border-box;
}
.google-btn:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.3); background: #f7f8f8; text-decoration: none; }

.discord-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; padding: 10px 18px;
  background: #5865F2; color: #fff;
  border: 1px solid #4752c4; border-radius: 6px;
  font-weight: 600; font-size: 14px; text-decoration: none;
  font-family: 'Roboto', system-ui, sans-serif;
  transition: box-shadow var(--transition), background var(--transition);
  width: 100%; box-sizing: border-box;
}
.discord-btn:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.3); background: #4752c4; color: #fff; text-decoration: none; }
.auth-discord-btn { padding: 13px 20px !important; font-size: 15px !important; margin-top: 4px; }

/* ---------- Auth hero (single-CTA login) -------------------------- */
.auth-hero {
  min-height: calc(100vh - 80px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 460px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-3);
  text-align: center;
}
.auth-brand { margin-bottom: 26px; }
.auth-logo {
  font-size: 56px; line-height: 1;
  color: var(--accent);
  filter: drop-shadow(0 0 24px var(--accent-glow));
  margin-bottom: 12px;
}
/* Auth-screen splash logo — the full WOSB Tracker branding (ship + text
   + tagline) shown big at the top of the sign-in card. */
.auth-logo-img {
  display: block;
  margin: 0 auto 4px;
  max-width: 220px;
  width: 100%;
  height: auto;
  border-radius: 12px;
  filter: drop-shadow(0 0 24px rgba(90, 178, 255, 0.18));
}
.auth-card h1 {
  font-size: 24px; font-weight: 700;
  margin: 0 0 6px; letter-spacing: 0.2px;
}
.auth-tag {
  color: var(--muted); font-size: 13px;
  margin: 0;
}
.auth-google-btn {
  padding: 13px 20px !important;
  font-size: 15px !important;
  margin-top: 4px;
}
.auth-fineprint {
  color: var(--muted); font-size: 11.5px; line-height: 1.5;
  margin: 12px 0 0;
}
.auth-other {
  margin-top: 28px; padding-top: 20px;
  border-top: 1px solid var(--border-soft);
  text-align: left;
}
.auth-other > summary {
  cursor: pointer; list-style: none;
  color: var(--muted); font-size: 12px;
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
  user-select: none;
}
.auth-other > summary::-webkit-details-marker { display: none; }
.auth-other > summary::before { content: "›  "; display: inline-block; transition: transform var(--transition); }
.auth-other[open] > summary::before { transform: rotate(90deg); }
.auth-other > summary:hover { color: var(--accent); background: rgba(255,255,255,0.03); }
.auth-other-body { margin-top: 14px; }
.auth-other-body h3 {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin: 0 0 8px;
}
.auth-other-body form button[type=submit] {
  width: 100%;
  margin-top: 4px;
}

/* ---------- Guild badge (flag + colored tag) -------------------------- */
.g-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600;
  /* color rides on the inner .g-tag only; the name uses the default text color */
}
.g-badge { line-height: 1.3; }
.g-badge .g-logo {
  width: 20px; height: 20px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
/* In the bigger Your-Guild banner, scale the logo up to match the title. */
.guild-banner .g-logo { width: 36px; height: 36px; border-radius: 6px; }

/* Big banner shown at the top of the dashboard's Your Guild card. The
   guild's color tints the [TAG] via .g-tag; the name stays default-colored. */
.guild-banner {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 22px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

/* Server tag pill — e.g., "NA" / "EU" / "CIS" / "Asia". Visually understated
   so it reads as metadata, not branding. */
.server-chip {
  display: inline-block;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  border: 1px solid var(--border-soft);
  vertical-align: middle;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ---------- Nav badge (counts on nav buttons) ------------------------- */
.nav-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10.5px; font-weight: 700;
  line-height: 1.4;
  background: var(--bad);
  color: #fff;
  border-radius: 999px;
  vertical-align: middle;
}

/* ---------- Pending proposals card (dashboard) ------------------------ */
.pending-card {
  border: 1px solid rgba(245,184,64,0.45);
  background: linear-gradient(180deg, rgba(245,184,64,0.05), var(--card));
  box-shadow: 0 0 0 1px rgba(245,184,64,0.12) inset, 0 4px 14px rgba(0,0,0,0.35);
}
.pending-card .card-head h2 { color: var(--warn); }
.pending-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  background: var(--warn); color: #07111f;
  border-radius: 999px;
  font-size: 12px; font-weight: 800;
}
.pending-list { display: flex; flex-direction: column; gap: 10px; }
.pending-row {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  padding: 10px 14px;
}
.pending-row-main {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 14px;
}
.pending-from { color: var(--muted); font-size: 12px; }
.pending-notes {
  color: var(--text); font-size: 12.5px; font-style: italic;
  margin: 6px 0 0;
}
.pending-actions { margin-top: 8px; display: flex; gap: 8px; }
.pending-actions button { padding: 5px 12px; font-size: 12px; }

/* ---------- Trading page ----------------------------------------------- */
.trading-page { display: block; }
.trading-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.trading-updated {
  color: var(--muted); font-size: 11px;
}
.trading-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}
.trading-tabs button {
  background: transparent; border: none; color: var(--muted);
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.trading-tabs button:hover { color: var(--text); }
.trading-tabs button.active {
  color: var(--accent); border-bottom-color: var(--accent);
}
.trading-toolbar {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.trading-toolbar input[type=search] {
  width: 240px; max-width: 100%;
}
.trading-hint {
  color: var(--muted); font-size: 11.5px; line-height: 1.4;
}
.port-picker {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
}
.port-picker > span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.port-picker select { width: 220px; }

/* ---- Best Routes view ---- */
.route-list { display: flex; flex-direction: column; gap: 8px; }
.route-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.route-card:hover { border-color: rgba(90,178,255,0.3); }
.route-card.open { border-color: rgba(90,178,255,0.4); }
.route-summary {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.7fr 1.6fr 1.6fr 24px;
  gap: 14px; align-items: center;
  width: 100%;
  background: transparent; border: none; color: var(--text);
  padding: 12px 16px; cursor: pointer; text-align: left;
}
.route-summary:hover { background: rgba(255,255,255,0.02); }
.route-good { display: flex; flex-direction: column; gap: 3px; }
.route-name { font-size: 14px; font-weight: 600; }
.rating { color: var(--accent); font-size: 10px; letter-spacing: 1px; }
.rating-dim { color: var(--border-soft); }
.route-profit, .route-ppw { text-align: right; font-variant-numeric: tabular-nums; }
.route-profit b, .route-ppw b { font-size: 16px; color: var(--accent); }
.route-profit-label { color: var(--muted); font-size: 10.5px; }
.route-buy, .route-sell {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11.5px;
}
.route-flag {
  font-size: 10px; font-weight: 700; padding: 2px 6px;
  border-radius: 3px; letter-spacing: 0.5px;
  white-space: nowrap;
}
.route-flag.buy  { background: rgba(106,200,128,0.18); color: var(--ok); }
.route-flag.sell { background: rgba(240,98,94,0.18);   color: var(--bad); }
.port-chip {
  display: inline-block; font-size: 11px;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.port-chip.more { color: var(--muted); border-style: dashed; }
.route-chev { color: var(--muted); font-size: 12px; text-align: right; }
.route-detail {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border-soft);
  background: rgba(0,0,0,0.18);
}
.route-detail-meta {
  font-size: 11.5px; color: var(--muted); margin-bottom: 8px;
}
.route-detail-meta b { color: var(--text); }
.price-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.price-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 3px 8px; border-radius: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums;
}
.price-pill.is-buy  { background: rgba(106,200,128,0.16); border-color: rgba(106,200,128,0.4); }
.price-pill.is-sell { background: rgba(240,98,94,0.16);   border-color: rgba(240,98,94,0.4); }
.price-pill-port { color: var(--muted); }
.price-pill.is-buy  .price-pill-port,
.price-pill.is-sell .price-pill-port { color: var(--text); }
.price-pill-val { font-weight: 700; }
.price-pill.is-buy  .price-pill-val { color: var(--ok); }
.price-pill.is-sell .price-pill-val { color: var(--bad); }

/* ---- By Port view ---- */
.port-table-wrap {
  border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden;
}
.port-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.port-table th, .port-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--border-soft);
}
.port-table thead th {
  background: rgba(255,255,255,0.03);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;
  font-size: 10.5px; font-weight: 600; text-align: left;
}
.port-table tbody tr:last-child td { border-bottom: none; }
.port-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.port-table .num { text-align: right; }
.port-table .muted { color: var(--muted); }
.port-table .cell-good { font-weight: 600; }
.port-table .ppw-pos b { color: var(--ok); }
.port-table .ppw-zero b { color: var(--muted); font-weight: 400; }
.cell-tag {
  display: inline-block; font-size: 9.5px; font-weight: 700;
  padding: 1.5px 6px; border-radius: 3px; margin-left: 6px;
  text-transform: uppercase; letter-spacing: 0.5px; vertical-align: middle;
}
.cell-tag.buy  { background: rgba(106,200,128,0.18); color: var(--ok); }
.cell-tag.sell { background: rgba(240,98,94,0.18);   color: var(--bad); }

/* Arbitrage rank column — small "#1" badge */
.port-table .rank {
  font-size: 10.5px; font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
  width: 36px;
}
.port-table .rank:first-child { padding-left: 14px; }

/* ---------- Bounty board ---------------------------------------------- */
.bounty-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.bounty-toolbar { margin-left: auto; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.bounty-filter { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.bounty-filter input { margin: 0; }

.bounty-group {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.bounty-group.is-resolved { opacity: 0.65; }
.bounty-group-head {
  display: flex; gap: 16px; align-items: baseline;
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border-soft);
}
.bounty-group-target {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.bounty-group-total { margin-left: auto; text-align: right; }
.bounty-pool {
  font-size: 18px; font-weight: 700; color: #f5b840;
  font-variant-numeric: tabular-nums;
}
.bounty-pool-unit { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.bounty-pool-meta { color: var(--muted); font-size: 11.5px; margin-left: 6px; }

.bounty-list { display: flex; flex-direction: column; }
.bounty-item {
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
}
.bounty-item:first-child { border-top: none; }
.bounty-item.is-closed .bounty-reward { opacity: 0.55; }
.bounty-main {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
}
.bounty-reward {
  font-size: 16px; font-weight: 700; color: #f5b840;
  font-variant-numeric: tabular-nums;
}
.bounty-reward-unit { font-size: 10.5px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.bounty-poster {
  font-size: 12.5px; color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-soft);
  border-radius: 4px; padding: 2px 8px;
}
.bounty-meta { color: var(--muted); font-size: 11.5px; }
.bounty-status {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 3px; text-transform: uppercase;
  margin-left: auto;
}
.bounty-status-open      { background: rgba(106,200,128,0.18); color: var(--ok); }
.bounty-status-paid      { background: var(--accent-glow);     color: var(--accent); }
.bounty-status-cancelled { background: rgba(255,255,255,0.05); color: var(--muted); }
.bounty-status-expired   { background: rgba(240,98,94,0.13);   color: var(--bad); }
.bounty-status-pending   { background: rgba(245,196,84,0.16);  color: #f5c454; }
.bounty-status-rejected  { background: rgba(240,98,94,0.13);   color: var(--bad); }

.bounty-reason {
  margin: 6px 0 0; padding-left: 0;
  color: var(--text); font-size: 12.5px; line-height: 1.45;
}
.bounty-paid-note {
  margin: 4px 0 0; color: var(--accent); font-size: 11.5px; font-style: italic;
}
.bounty-actions { margin-top: 8px; display: flex; gap: 8px; }
.bounty-actions button { padding: 4px 10px; font-size: 11.5px; }

.bounty-image {
  display: inline-block;
  margin-top: 8px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  max-width: 100%;
}
.bounty-image img {
  display: block;
  max-width: 320px;
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: cover;
}
.bounty-image:hover { border-color: var(--accent); }

/* Discord-webhook fieldset on the Edit Profile modal — three independent
   webhook slots, each with its own Send-test button + status line. */
.webhook-group {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 14px 14px;
  margin: 10px 0;
}
.webhook-group legend {
  padding: 0 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.4px;
}
.webhook-group label { margin-bottom: 8px; display: block; }
.webhook-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  margin-left: 4px;
}
.webhook-actions {
  display: flex; gap: 8px; align-items: center;
  margin-top: 6px;
}
.webhook-actions .webhook-test {
  padding: 5px 10px;
  font-size: 11.5px;
}
.webhook-state {
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- Mobile-friendly tweaks --------------------------------------
   Targets: phones (<= 720px) and tight phones (<= 480px). The dashboard
   and auth-wrap already collapse to a single column at 720px; everything
   below piggybacks on that breakpoint to keep the rest of the chrome
   usable on narrow screens without rewriting the desktop layout. */
@media (max-width: 720px) {
  /* Header: hamburger + brand on one row, shrink padding. */
  header {
    padding: 8px 12px;
    gap: 10px;
  }
  .brand h1 { font-size: 16px; }
  .header-tag {
    font-size: 12px;
    max-width: 40%;
  }

  /* Mobile sidebar: hidden off-screen by default, slides in as a drawer
     when body.sidebar-open. Hover-peek is disabled (we used a media
     query gate for hover-capable devices, so phones already skip it). */
  .sidebar {
    width: var(--sidebar-w-expanded);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.sidebar-pinned .sidebar { width: var(--sidebar-w-expanded); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  /* Always show labels in the mobile drawer once it's open. */
  body.sidebar-open .sb-label,
  body.sidebar-open .sb-caret,
  body.sidebar-open .sb-item .nav-badge { opacity: 1; }
  body.sidebar-open .sb-item.has-pending-dot .nav-dot { display: none; }

  /* Mobile main: full width, no left offset. Drawer overlays. */
  main { padding: 14px 12px; margin-left: 0; }
  body.sidebar-pinned main { margin-left: 0; }
  .site-footer { margin-left: 0; padding: 14px 12px 24px; }
  body.sidebar-pinned .site-footer { margin-left: 0; }
  .card { padding: 14px 14px; }
  .card h2 { font-size: 15px; }

  /* Modals: never wider than the viewport. */
  .modal-backdrop .modal {
    max-width: calc(100vw - 20px) !important;
    width: calc(100vw - 20px) !important;
  }
  .modal { padding: 16px 14px; }

  /* Trading + bounty toolbars: stack vertically on narrow screens. */
  .trading-toolbar,
  .bounty-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .trading-toolbar input[type=search],
  .port-picker,
  .port-picker select { width: 100%; }
  .trading-hint { font-size: 11px; }

  /* Best Routes cards: collapse the 6-column grid to a stack. */
  .route-summary {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .route-profit, .route-ppw { text-align: left; }
  .route-chev { display: none; }

  /* Bounty group head: stack target + total. */
  .bounty-group-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .bounty-group-total { margin-left: 0; }
  .bounty-main {
    flex-direction: column;
    align-items: flex-start;
  }
  .bounty-status { margin-left: 0; }

  /* Card-head: keep title + action button on one row but allow wrap. */
  .card-head { flex-wrap: wrap; }
}

/* iOS Safari zooms inputs with font-size < 16px on focus. Bump baseline
   on small screens so it doesn't fight the layout. */
@media (max-width: 480px) {
  input, textarea, select {
    font-size: 16px;
  }
  /* But keep the small numeric inputs in cannon/crew pickers compact;
     they're not focused often enough to be a zoom-trigger pain point
     and the 16px min would blow the layout. */
  .cannon-row input[name="cannon-count"],
  .crew-cell input[name="crew-count"],
  .cannon-row input[name="ammo-count"] { font-size: 12px; }
}

/* ---------- Changelog modal ------------------------------------------- */
.changelog-list {
  list-style: none; padding: 0; margin: 8px 0 14px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 400px; overflow-y: auto;
}
.changelog-list li {
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}
.changelog-title { font-weight: 600; font-size: 13px; color: var(--text); }
.changelog-body  { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 3px; }

/* ---------- Events / Calendar ----------------------------------------- */
.event-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.event-card:hover { border-color: rgba(90,178,255,0.4); }
.event-card.is-cancelled { opacity: 0.55; border-left-color: var(--bad); }
.event-card.is-past      { opacity: 0.7;  border-left-color: var(--muted); }
.event-row-main { display: flex; flex-direction: column; gap: 3px; }
.event-when  { font-size: 12px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.event-title { font-size: 15px; font-weight: 600; color: var(--text); }
.event-row-meta {
  margin-top: 6px;
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted);
}
.event-loc { display: inline-flex; align-items: center; gap: 4px; }
.event-cancelled-tag {
  display: inline-block; background: rgba(240,98,94,0.15); color: var(--bad);
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 3px;
  text-transform: uppercase; vertical-align: middle;
}

.rsvp-counts { display: inline-flex; gap: 8px; }
.rsvp-count {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.rsvp-yes   { background: rgba(62,213,155,0.15); color: var(--ok); }
.rsvp-maybe { background: rgba(245,184,64,0.15); color: var(--warn); }
.rsvp-no    { background: rgba(240,98,94,0.13);  color: var(--bad); }

.event-header { padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.event-meta   { color: var(--muted); font-size: 12.5px; }
.event-body   { margin-top: 12px; color: var(--text); font-size: 13.5px; line-height: 1.6; }

.rsvp-form { padding: 8px 0; }
.rsvp-buttons { display: flex; gap: 8px; }
.rsvp-btn {
  flex: 1; padding: 8px 12px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-soft); background: rgba(255,255,255,0.02);
  color: var(--muted); border-radius: 7px; cursor: pointer;
  transition: all var(--transition);
}
.rsvp-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.rsvp-btn.rsvp-yes.active   { background: rgba(62,213,155,0.18); color: var(--ok);  border-color: rgba(62,213,155,0.4); }
.rsvp-btn.rsvp-maybe.active { background: rgba(245,184,64,0.18); color: var(--warn); border-color: rgba(245,184,64,0.4); }
.rsvp-btn.rsvp-no.active    { background: rgba(240,98,94,0.18);  color: var(--bad);  border-color: rgba(240,98,94,0.4); }

.rsvp-list { display: flex; flex-direction: column; gap: 12px; }
.rsvp-bucket {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-soft);
  border-radius: 7px; padding: 8px 12px;
}
.rsvp-bucket-head {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.rsvp-bucket-yes   .rsvp-bucket-head { color: var(--ok); }
.rsvp-bucket-maybe .rsvp-bucket-head { color: var(--warn); }
.rsvp-bucket-no    .rsvp-bucket-head { color: var(--bad); }
.rsvp-bucket-count { background: rgba(255,255,255,0.06); padding: 1px 7px; border-radius: 999px; margin-left: 4px; font-size: 11px; }
.rsvp-bucket-list { display: flex; flex-direction: column; gap: 4px; }
.rsvp-row {
  display: flex; gap: 10px; align-items: baseline;
  font-size: 12.5px; padding: 3px 0;
}
.rsvp-name { font-weight: 600; }
.rsvp-rank { color: var(--muted); font-size: 11px; }
.rsvp-note { color: var(--muted); font-style: italic; font-size: 11.5px; }

/* ---------- Recruitment page ----------------------------------------- */
.recruit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 4px 0;
}
.recruit-tile {
  position: relative;
  display: flex; flex-direction: column;
  aspect-ratio: 1 / 1;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}
.recruit-tile:hover {
  border-color: rgba(90,178,255,0.45);
  transform: translateY(-2px);
}
.recruit-tile-logo,
.recruit-tile-placeholder {
  width: 64px; height: 64px;
  border-radius: 10px;
  margin-bottom: 8px;
  object-fit: cover;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 20px; color: var(--muted);
  letter-spacing: 1px;
}
.recruit-tile-head { font-size: 14px; margin-bottom: 4px; }
.recruit-tile-meta {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 6px; font-size: 11px;
}
.recruit-tile-blurb {
  flex: 1; min-height: 0;
  font-size: 12px; line-height: 1.4; color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.recruit-tile-blurb.empty-blurb { color: var(--muted); font-style: italic; }
.recruit-faction { color: var(--muted); font-size: 12px; }
/* Pop-out modal opened from a recruitment tile. */
.recruit-modal {
  max-width: 480px; width: calc(100vw - 60px);
  text-align: center;
}
.recruit-modal-close {
  position: absolute; top: 8px; right: 12px;
  width: 32px; height: 32px;
  background: transparent; border: none;
  font-size: 22px; line-height: 1; cursor: pointer;
  color: var(--muted);
}
.recruit-modal-close:hover { color: var(--text); }
.recruit-modal-logo,
.recruit-modal-placeholder {
  width: 96px; height: 96px;
  margin: 4px auto 10px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 28px; color: var(--muted);
  letter-spacing: 2px;
}
.recruit-modal-title { margin: 0 0 8px; }
.recruit-modal-meta {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 14px; font-size: 12px;
}
.recruit-modal-blurb {
  text-align: left;
  white-space: pre-wrap;
  font-size: 13px; line-height: 1.55;
  color: var(--text);
  margin-bottom: 14px;
}
.recruit-modal-blurb.empty-blurb { color: var(--muted); font-style: italic; text-align: center; }
.recruit-modal-contact {
  text-align: left;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}
/* ---------- After-Action Report parchment card ---------------------- */
/* Used by both the AAR create/edit modal and the read-only detail
   pop-card. Renders the modal as a cream/beige paper sheet with
   bold dark labels in a left column, values in the right column,
   thin separators between rows, and small dark rivets in each
   corner — matching the design mock. */
.modal.aar-parchment {
  background: linear-gradient(180deg, #f3e3c0 0%, #ead2a3 100%);
  color: #2b1d10;
  border: 1px solid #5a3e1e;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(91, 62, 30, 0.25);
  border-radius: 6px;
  padding: 28px 36px 22px;
  font-family: 'Georgia', 'Times New Roman', serif;
  position: relative;
  max-width: 880px;
}
/* Four corner rivets — rendered as <span class="aar-corner aar-corner-tl">…
   The pseudo-element approach was unreliable for placing all four; explicit
   spans inside the modal work cleanly and let CSS handle each corner. */
.modal.aar-parchment .aar-corner {
  position: absolute;
  width: 10px; height: 10px;
  background: #2b1d10;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(91, 62, 30, 0.5);
}
.modal.aar-parchment .aar-corner-tl { top: 8px;    left: 8px;  }
.modal.aar-parchment .aar-corner-tr { top: 8px;    right: 8px; }
.modal.aar-parchment .aar-corner-bl { bottom: 8px; left: 8px;  }
.modal.aar-parchment .aar-corner-br { bottom: 8px; right: 8px; }
.modal.aar-parchment h3 {
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 18px;
  margin: 0 0 4px;
  color: #2b1d10;
  font-weight: 700;
}
.modal.aar-parchment .aar-rule {
  height: 1px;
  background: rgba(43, 29, 16, 0.45);
  margin: 8px -8px 14px;
}
.modal.aar-parchment .aar-row {
  display: grid;
  grid-template-columns: 200px 1px 1fr;
  align-items: start;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(43, 29, 16, 0.18);
}
.modal.aar-parchment .aar-row:last-of-type { border-bottom: none; }
.modal.aar-parchment .aar-label {
  font-weight: 700;
  color: #2b1d10;
  letter-spacing: 0.2px;
}
.modal.aar-parchment .aar-divider {
  background: rgba(43, 29, 16, 0.35);
  width: 1px;
  align-self: stretch;
}
.modal.aar-parchment .aar-value {
  white-space: pre-wrap;
  color: #2b1d10;
  min-width: 0;
}
.modal.aar-parchment .aar-value-muted { color: #6b513a; font-style: italic; }
.modal.aar-parchment input[type="text"],
.modal.aar-parchment input[type="datetime-local"],
.modal.aar-parchment textarea,
.modal.aar-parchment select {
  width: 100%;
  background: rgba(255, 250, 235, 0.55);
  border: 1px solid rgba(43, 29, 16, 0.35);
  color: #2b1d10;
  padding: 7px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
.modal.aar-parchment input::placeholder,
.modal.aar-parchment textarea::placeholder { color: rgba(43, 29, 16, 0.45); }
.modal.aar-parchment input:focus,
.modal.aar-parchment textarea:focus {
  outline: none;
  border-color: #5a3e1e;
  background: rgba(255, 250, 235, 0.85);
}
.modal.aar-parchment .aar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(43, 29, 16, 0.45);
}
.modal.aar-parchment .aar-actions button {
  padding: 8px 18px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  border-radius: 4px;
  font-family: 'Georgia', 'Times New Roman', serif;
  cursor: pointer;
}
.modal.aar-parchment .aar-actions button.aar-primary {
  background: #f1dcae;
  color: #2b1d10;
  border: 1px solid #5a3e1e;
}
.modal.aar-parchment .aar-actions button.aar-primary:hover { background: #e9cf94; }
.modal.aar-parchment .aar-actions button.aar-secondary {
  background: #2b1d10;
  color: #f3e3c0;
  border: 1px solid #2b1d10;
}
.modal.aar-parchment .aar-actions button.aar-secondary:hover { background: #3d2a18; }
.modal.aar-parchment .aar-actions button.aar-danger {
  background: #6b1f1f;
  color: #f3e3c0;
  border: 1px solid #6b1f1f;
}
.modal.aar-parchment .aar-actions button.aar-danger:hover { background: #832525; }
.modal.aar-parchment .err { color: #832525; margin-top: 8px; }
.modal.aar-parchment .aar-meta {
  text-align: center;
  color: #6b513a;
  font-size: 12px;
  font-style: italic;
  margin: -2px 0 8px;
}
/* Sharing status lines on the (always-cream) parchment card. Fixed colors,
   not theme vars — the card stays parchment in both themes, so a dark sienna
   and an aged-green read on cream regardless of light/dark mode. */
.modal.aar-parchment .aar-meta-ally {
  color: #8a5a28;
  font-style: normal;
  font-weight: 700;
}
.modal.aar-parchment .aar-meta-shared {
  color: #3f6b2e;
  font-style: normal;
  font-weight: 700;
}

/* Dark mode: the parchment card is hardcoded cream above, which looks wrong
   against the dark UI. Dark theme is the default (no body.theme-light), so
   scope a dark "aged document at night" palette here — warm dark surface with
   cream ink. Light mode keeps the cream parchment from the base rules above. */
body:not(.theme-light) .modal.aar-parchment {
  background: linear-gradient(180deg, #241c12 0%, #1a140c 100%);
  color: #ece0c8;
  border-color: #5a3e1e;
}
body:not(.theme-light) .modal.aar-parchment .aar-corner {
  background: #b9863e;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
body:not(.theme-light) .modal.aar-parchment h3 { color: #f0e6cf; }
body:not(.theme-light) .modal.aar-parchment .aar-rule { background: rgba(236, 224, 200, 0.3); }
body:not(.theme-light) .modal.aar-parchment .aar-row { border-bottom-color: rgba(236, 224, 200, 0.14); }
body:not(.theme-light) .modal.aar-parchment .aar-label { color: #f0e6cf; }
body:not(.theme-light) .modal.aar-parchment .aar-divider { background: rgba(236, 224, 200, 0.22); }
body:not(.theme-light) .modal.aar-parchment .aar-value { color: #ece0c8; }
body:not(.theme-light) .modal.aar-parchment .aar-value-muted { color: #b99e74; }
body:not(.theme-light) .modal.aar-parchment input[type="text"],
body:not(.theme-light) .modal.aar-parchment input[type="datetime-local"],
body:not(.theme-light) .modal.aar-parchment textarea,
body:not(.theme-light) .modal.aar-parchment select {
  background: rgba(255, 250, 235, 0.06);
  border-color: rgba(236, 224, 200, 0.25);
  color: #ece0c8;
}
body:not(.theme-light) .modal.aar-parchment input::placeholder,
body:not(.theme-light) .modal.aar-parchment textarea::placeholder { color: rgba(236, 224, 200, 0.4); }
body:not(.theme-light) .modal.aar-parchment input:focus,
body:not(.theme-light) .modal.aar-parchment textarea:focus {
  border-color: #b9863e;
  background: rgba(255, 250, 235, 0.1);
}
body:not(.theme-light) .modal.aar-parchment .aar-actions { border-top-color: rgba(236, 224, 200, 0.3); }
body:not(.theme-light) .modal.aar-parchment .aar-actions button.aar-primary {
  background: #32271a; color: #f0e6cf; border-color: #5a3e1e;
}
body:not(.theme-light) .modal.aar-parchment .aar-actions button.aar-primary:hover { background: #3d3022; }
body:not(.theme-light) .modal.aar-parchment .aar-actions button.aar-secondary {
  background: #3a2e1d; color: #f0e6cf; border-color: #5a3e1e;
}
body:not(.theme-light) .modal.aar-parchment .aar-actions button.aar-secondary:hover { background: #483a28; }
body:not(.theme-light) .modal.aar-parchment .err { color: #f0625e; }
body:not(.theme-light) .modal.aar-parchment .aar-meta { color: #b99e74; }
/* Lighter sharing-status tints so they read on the dark card. */
body:not(.theme-light) .modal.aar-parchment .aar-meta-ally { color: #d9a85a; }
body:not(.theme-light) .modal.aar-parchment .aar-meta-shared { color: #6fcf8e; }

/* ---------- Light theme (parchment / leather + brass) --------------- */
/* Triggered by `body.theme-light` set on init by app.js. Overrides the
   :root CSS variables with a warm, eye-friendly palette inspired by old
   nautical logbooks: soft cream paper, ink-brown text, leather buttons,
   brass accents. Avoids pure black / pure white and any cool blues so
   the whole page reads as warm, low-saturation, low-glare. */
body.theme-light {
  /* Backgrounds: soft cream — slightly desaturated from before so it
     doesn't read as yellow-glare under bright office lights. */
  --bg:          #ebe2c8;          /* page bg — soft warm cream */
  --bg-2:        #f0e8d2;          /* header / cards-on-cards */
  --bg-3:        #e2d6b8;          /* nested-row tone */
  --card:        #f3ecd6;          /* elevated card surface */
  --card-hi:     #f7f1de;          /* hover / inner panel */
  --border:      #6e5436;          /* warm brown — softer than near-black */
  --border-soft: rgba(56, 40, 20, 0.10);

  /* Text: warm dark brown (not near-black) — enough contrast for body
     copy without the eye-strain of pure black on cream. */
  --text:        #3a2d1a;
  --muted:       #7a6748;
  --dim:         #9a8a6b;

  /* Accent: aged brass — warm, low-glare, period-appropriate. Reads as
     a focus / selection / link color without competing with the brown
     text. accent-strong is a slightly lighter brass for hover; the
     strong tone never crosses into "loud" territory. */
  --accent:        #8a5a28;
  --accent-strong: #a66f38;
  --accent-glow:   rgba(138, 90, 40, 0.18);

  /* Status: muted period-appropriate tones, not vivid. */
  --ok:    #4a6a32;                /* aged moss green */
  --warn:  #a07020;                /* burnt amber */
  --bad:   #8b3030;                /* wax-seal red */
  --nap:   #6f5a8a;                /* muted plum */

  /* Shadows: warm umber, low alpha — keeps depth without harsh edges. */
  --shadow-1: 0 1px 2px rgba(56, 40, 20, 0.14);
  --shadow-2: 0 4px 12px rgba(56, 40, 20, 0.16);
  --shadow-3: 0 14px 38px rgba(56, 40, 20, 0.22);
}

/* Body — soft radial wash on top of the cream so the page isn't a flat
   sheet, but no harsh gradient stops. */
body.theme-light {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(110, 84, 54, 0.06), transparent 70%),
    radial-gradient(900px 700px at 100% 100%, rgba(160, 112, 32, 0.06), transparent 70%),
    var(--bg);
  color: var(--text);
}

/* Selection: warm brass tint instead of cool blue glow. */
body.theme-light ::selection { background: rgba(138, 90, 40, 0.22); color: var(--text); }

/* Anchors: brass for state, with a subtle underline-on-hover so links
   stay identifiable on the warm background. */
body.theme-light a       { color: var(--accent); }
body.theme-light a:hover { color: var(--accent-strong); text-decoration: underline; }

/* Header — soft cream gradient, hairline brown bottom border. */
body.theme-light header {
  background: linear-gradient(180deg, #f0e8d2 0%, #e8e0c4 100%);
  border-bottom: 1px solid rgba(110, 84, 54, 0.25);
  box-shadow: 0 1px 0 rgba(255, 250, 230, 0.5) inset;
}
body.theme-light .brand h1 { color: var(--text); }

/* Sidebar — same gradient family as the header so they read as one
   continuous "page edge" rather than two competing surfaces. */
body.theme-light .sidebar {
  background: linear-gradient(180deg, #f3ecd6 0%, #e6dab8 100%);
  border-right: 1px solid rgba(110, 84, 54, 0.25);
}
body.theme-light .sb-item { color: var(--text); }
body.theme-light .sb-item:hover {
  background: rgba(138, 90, 40, 0.08);
  color: var(--text);
}
body.theme-light .sb-item.active {
  background: rgba(138, 90, 40, 0.14);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Cards / modals — warm cream surface with a 1px ink-brown border and
   a soft top highlight for "engraved on paper" feel. */
body.theme-light .card,
body.theme-light .modal,
body.theme-light .guide-card,
body.theme-light .public-build-row,
body.theme-light .fleet-block,
body.theme-light .bp-roster-row,
body.theme-light .bp-sq-card {
  background: var(--card);
  border: 1px solid rgba(110, 84, 54, 0.25);
  box-shadow:
    0 1px 0 rgba(255, 250, 230, 0.7) inset,
    var(--shadow-1);
}
body.theme-light .card-head { border-bottom-color: rgba(110, 84, 54, 0.18); }

/* Inputs / textareas — soft cream fill, warm border. Focus ring is
   brass with a subtle glow rather than a sharp blue line. */
body.theme-light input[type="text"],
body.theme-light input[type="password"],
body.theme-light input[type="email"],
body.theme-light input[type="number"],
body.theme-light input[type="search"],
body.theme-light input[type="datetime-local"],
body.theme-light input[type="date"],
body.theme-light input[type="time"],
body.theme-light input[type="url"],
body.theme-light input[type="tel"],
body.theme-light textarea,
body.theme-light select {
  background: #faf3df;
  border: 1px solid rgba(110, 84, 54, 0.30);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(110, 84, 54, 0.05) inset;
}
body.theme-light input::placeholder,
body.theme-light textarea::placeholder { color: rgba(58, 45, 26, 0.40); }
body.theme-light input:focus,
body.theme-light textarea:focus,
body.theme-light select:focus {
  border-color: var(--accent);
  background: #fdf8e8;
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

/* PRIMARY action buttons — leather brown with cream text. Subtle inset
   highlight on top + soft drop shadow gives the "stamped leather" feel
   without being noisy. Rules out the AAR / sidebar / theme / OAuth
   buttons which have their own visual identity. */
body.theme-light button:not(.aar-primary):not(.aar-secondary):not(.aar-danger):not(.theme-toggle):not(.sidebar-toggle):not(.google-btn):not(.discord-btn):not(.danger):not(.secondary):not(.mini-btn) {
  background: linear-gradient(180deg, #5a3e1e 0%, #4a3018 100%);
  color: #f3ecd6;
  border: 1px solid #382412;
  box-shadow:
    0 1px 0 rgba(255, 240, 210, 0.18) inset,
    0 1px 2px rgba(56, 40, 20, 0.20);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.20);
}
body.theme-light button:not(.aar-primary):not(.aar-secondary):not(.aar-danger):not(.theme-toggle):not(.sidebar-toggle):not(.google-btn):not(.discord-btn):not(.danger):not(.secondary):not(.mini-btn):hover {
  background: linear-gradient(180deg, #6a4a26 0%, #5a3e1e 100%);
  border-color: #2b1d10;
}
body.theme-light button:not(.aar-primary):not(.aar-secondary):not(.aar-danger):not(.theme-toggle):not(.sidebar-toggle):not(.google-btn):not(.discord-btn):not(.danger):not(.secondary):not(.mini-btn):active {
  background: linear-gradient(180deg, #4a3018 0%, #3a2410 100%);
}

/* SECONDARY / mini buttons — quiet, transparent-ish on cream. */
body.theme-light button.secondary,
body.theme-light button.mini-btn:not(.danger) {
  background: rgba(110, 84, 54, 0.06);
  color: var(--text);
  border: 1px solid rgba(110, 84, 54, 0.30);
  box-shadow: none;
}
body.theme-light button.secondary:hover,
body.theme-light button.mini-btn:not(.danger):hover {
  background: rgba(110, 84, 54, 0.14);
  border-color: rgba(110, 84, 54, 0.50);
}

/* DANGER buttons — wax-seal red. Same leathery treatment as primary
   for visual cohesion — "stamped" rather than flat. */
body.theme-light button.danger,
body.theme-light button.mini-btn.danger {
  background: linear-gradient(180deg, #9a3838 0%, #7a2828 100%);
  color: #f3ecd6;
  border: 1px solid #5a1a1a;
  box-shadow:
    0 1px 0 rgba(255, 220, 210, 0.18) inset,
    0 1px 2px rgba(90, 26, 26, 0.25);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
body.theme-light button.danger:hover,
body.theme-light button.mini-btn.danger:hover {
  background: linear-gradient(180deg, #aa4040 0%, #8b3030 100%);
}

/* Modal backdrops — soft umber wash, not a hard black blanket. */
body.theme-light .modal-backdrop { background: rgba(56, 40, 20, 0.32); }

/* Footer — sits gently on the page edge. */
body.theme-light .site-footer {
  background: rgba(110, 84, 54, 0.05);
  border-top: 1px solid rgba(110, 84, 54, 0.18);
  color: var(--muted);
}

/* Pills / badges that hard-coded the old accent now lift from --accent. */
body.theme-light .public-pill {
  background: var(--accent);
  color: #f3ecd6;
}

/* AAR parchment card stays parchment in both themes — it's the design
   anchor the rest of light mode is built around. */

/* ---------- Theme toggle button -------------------------------------- */
.theme-toggle {
  margin-left: auto;
  margin-right: 12px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent);
}
body.theme-light .theme-toggle:hover {
  background: rgba(91, 62, 30, 0.10);
  border-color: var(--accent);
}
.theme-toggle .theme-icon-dark  { display: inline; }
.theme-toggle .theme-icon-light { display: none;   }
body.theme-light .theme-toggle .theme-icon-dark  { display: none;   }
body.theme-light .theme-toggle .theme-icon-light { display: inline; }

/* ---------- SEO pre-render landing ----------------------------------
   Lives inside <main id="app"> so the SPA wipes it on first render
   (appEl.innerHTML = ''). Crawlers indexing the initial HTML response
   see real prose; users on slow connections see a tolerable holding
   page before hydration. */
.seo-landing {
  max-width: 820px;
  margin: 32px auto;
  padding: 24px;
  line-height: 1.55;
  color: var(--text, #e6e6e6);
}
.seo-landing h2 { margin: 0 0 12px; font-size: 28px; line-height: 1.25; }
.seo-landing h3 { margin: 24px 0 8px; font-size: 18px; }
.seo-landing .seo-lede { font-size: 16px; margin: 0 0 8px; }
.seo-landing .seo-features { padding-left: 20px; margin: 8px 0 0; }
.seo-landing .seo-features li { margin-bottom: 6px; }
.seo-landing .seo-cta {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.seo-landing .seo-cta-link {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--border, #2a334a);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text, #e6e6e6);
}
.seo-landing .seo-cta-link:hover { border-color: var(--accent, #8ab4f8); }
.seo-landing .seo-fineprint {
  margin-top: 24px;
  color: var(--muted, #8a93a8);
  font-size: 12px;
}

/* ---------- Trade Map (Trading > Map sub-tab) ------------------------ */
.trade-map-wrap { display: flex; flex-direction: column; gap: 10px; }
.map-setup-banner {
  background: rgba(245,184,64,0.10);
  border-left: 3px solid var(--warn, #f5b840);
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 4px;
}
.trade-map-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted, #8a93a8);
}
.map-copy-feedback { color: var(--ok, #6fc06f); font-weight: 600; font-size: 11px; }
.trade-map-body {
  display: grid; grid-template-columns: 1fr 220px; gap: 12px;
  align-items: start;
}
.trade-map-body:has(.trade-map-canvas-wrap:only-child) { grid-template-columns: 1fr; }
@media (max-width: 720px) {
  .trade-map-body { grid-template-columns: 1fr; }
}
.trade-map-canvas-wrap { display: flex; flex-direction: column; gap: 6px; }
.map-pick-status { font-size: 11px; color: var(--text, #e6e6e6); }
.map-pick-status.muted { color: var(--muted, #8a93a8); }
.trade-map-canvas {
  position: relative; width: 100%;
  border: 1px solid var(--border, #2a334a);
  border-radius: 4px;
  overflow: hidden;
  cursor: crosshair;
}
.trade-map-img { display: block; width: 100%; height: auto; user-select: none; }
.trade-map-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;   /* let clicks reach the canvas */
}
/* Re-enable hit-testing on individual markers so they can be dragged
   in setup mode while the rest of the SVG stays click-through. */
.trade-map-svg .map-marker { pointer-events: all; cursor: grab; touch-action: none; }
.trade-map-svg .map-marker:active { cursor: grabbing; }
.trade-map-portlist {
  max-height: 600px; overflow-y: auto;
  border: 1px solid var(--border-soft, #2a334a);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
}
.trade-map-portlist h4 { margin: 0 0 6px; font-size: 12px; }
.trade-map-portlist ul { list-style: none; padding: 0; margin: 0; }
.map-port-row {
  display: flex; align-items: center; gap: 4px;
  border-radius: 3px;
}
.map-port-row.active { background: rgba(245,184,64,0.18); }
.map-port-row.placed .map-port-mark { color: var(--warn, #f5b840); }
.map-port-btn {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 0;
  text-align: left; cursor: pointer;
  padding: 4px 6px;
  color: var(--text, #e6e6e6); font-size: 11px;
}
.map-port-btn:hover { background: rgba(255,255,255,0.05); }
.map-port-mark { width: 14px; display: inline-block; text-align: center; color: var(--muted, #8a93a8); }
.map-port-clear {
  background: transparent; border: 0; padding: 2px 6px;
  color: var(--bad, #d96560); cursor: pointer; font-size: 14px;
  line-height: 1;
}
.map-port-clear:hover { color: #fff; background: var(--bad, #d96560); border-radius: 3px; }
.map-port-supp {
  color: var(--accent, #f5b840);
  font-size: 10px;
  margin-left: 4px;
  cursor: help;
}
/* ---------- Trade map: view-mode arbitrage overlay --------------- */
.trade-map-svg .map-route {
  pointer-events: stroke;
  transition: stroke-width 80ms;
}
.trade-map-svg .map-route:hover {
  stroke-width: 0.9 !important;
  stroke-opacity: 1 !important;
}
.trade-map-svg .map-port-dot {
  pointer-events: all;
  cursor: pointer;
  transition: r 80ms;
}
.trade-map-svg .map-port-dot.hot:hover { r: 1.8; }
.trade-map-svg .map-port-dot.selected { stroke: #fff; stroke-width: 0.5; }
.map-route-count {
  font-size: 11px;
  color: var(--muted, #8a93a8);
  margin-left: auto;
}
.map-legend {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  color: var(--muted, #8a93a8);
  padding: 4px 0;
  flex-wrap: wrap;
}
.map-legend-dim, .map-legend-hot, .map-legend-line {
  display: inline-block; vertical-align: middle;
  margin-right: 2px;
}
.map-legend-dim {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(200,200,200,0.55); border: 1px solid #000;
}
.map-legend-hot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(245,184,64,0.95); border: 1px solid #000;
}
.map-legend-line {
  width: 22px; height: 3px; border-radius: 1px;
}
.map-legend-line.low  { background: hsl(0,   75%, 55%); }
.map-legend-line.high { background: hsl(120, 75%, 55%); }
.map-legend .muted { font-style: italic; margin-left: 4px; }

/* ---------- Trade map: route popout ----------------------------- */
.trade-map-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
  min-width: 200px;
  max-width: 260px;
  box-shadow: var(--shadow-2, 0 4px 14px rgba(0,0,0,0.45));
  line-height: 1.4;
}
.trade-map-tooltip[hidden] { display: none; }
.trade-map-tooltip .tt-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.trade-map-tooltip .tt-icon {
  width: 36px; height: 36px;
  flex-shrink: 0;
  image-rendering: pixelated;
  border-radius: 4px;
  background: var(--bg-3, rgba(255,255,255,0.04));
}
.trade-map-tooltip .tt-good {
  font-size: 13px; font-weight: 600;
  color: var(--text);
}
.trade-map-tooltip .tt-route {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 3px 8px;
  align-items: baseline;
  margin: 6px 0;
}
.trade-map-tooltip .tt-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.6px;
  text-align: center;
  padding: 1px 5px;
  border-radius: 3px;
}
.trade-map-tooltip .tt-label.buy  { background: rgba(78,201,106,0.18); color: var(--ok,  #4ec96a); }
.trade-map-tooltip .tt-label.sell { background: rgba(239, 91, 91,0.18); color: var(--bad, #ef5b5b); }
.trade-map-tooltip .tt-port  { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade-map-tooltip .tt-price {
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  text-align: right;
}
.trade-map-tooltip .tt-profit {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  font-family: 'JetBrains Mono', monospace;
}
.trade-map-tooltip .tt-profit b { color: var(--accent); font-size: 12px; }
.trade-map-tooltip .muted { color: var(--muted); font-weight: 400; }

/* ---------- Trade map: custom route ----------------------------- */
.trade-map-svg .map-custom-route {
  pointer-events: none;
  paint-order: stroke;
}
.trade-map-svg .map-route-tag { pointer-events: none; }
.map-route-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: var(--bg-3, rgba(255,255,255,0.04));
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 11px;
  margin-bottom: 4px;
}
.map-route-strip-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.map-route-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 6px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text);
}
.map-route-chip-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 10px; font-weight: 700;
}
.map-route-chip-name { white-space: nowrap; }
.map-route-chip-x {
  background: transparent; border: 0;
  cursor: pointer; padding: 0 4px;
  color: var(--muted); font-size: 14px; line-height: 1;
}
.map-route-chip-x:hover { color: var(--bad); }
.map-route-chip-arrow {
  color: var(--muted);
  font-size: 11px;
}
.mini-btn.is-on {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* ---------- Trade map: cargo plan ------------------------------- */
.cargo-plan-panel {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  margin: 4px 0;
  overflow: hidden;
}
.cargo-plan-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  display: flex; align-items: center; gap: 12px;
  font-size: 12px;
  user-select: none;
}
.cargo-plan-panel > summary::-webkit-details-marker { display: none; }
.cargo-plan-panel > summary::before {
  content: '▸';
  color: var(--muted);
  width: 12px;
  transition: transform 100ms;
}
.cargo-plan-panel[open] > summary::before { transform: rotate(90deg); }
.cargo-plan-title { font-weight: 600; color: var(--text); }
.cargo-plan-meta  { margin-left: auto; font-size: 11px; }
.cargo-plan-meta b { color: var(--accent); font-weight: 700; }

.cargo-stops {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 10px 12px 14px;
}
.cargo-stop {
  background: var(--bg-3, rgba(255,255,255,0.04));
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 10px;
}
.cargo-stop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cargo-stop-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent); color: var(--bg);
  font-size: 11px; font-weight: 700;
}
.cargo-stop-port {
  font-size: 13px; font-weight: 600;
  color: var(--text);
}
.cargo-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.cargo-carry {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  border-top: 1px solid var(--border-soft);
}
.cargo-carry:first-child { border-top: 0; }
.cargo-icon {
  width: 28px; height: 28px;
  image-rendering: pixelated;
  border-radius: 4px;
  background: var(--bg-2);
}
.cargo-name { font-size: 12px; font-weight: 600; color: var(--text); }
.cargo-trade { font-size: 10.5px; line-height: 1.3; }
.cargo-trade b { color: var(--text); font-weight: 600; }
.cargo-leg { color: var(--muted); font-style: italic; margin-left: 2px; }
.cargo-profit {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  display: flex; flex-direction: column; align-items: flex-end;
}
.cargo-profit-total { color: var(--ok, #4ec96a); font-weight: 700; font-size: 12px; }
.cargo-profit-ppw   { color: var(--muted); font-size: 10px; }
.cargo-empty { padding: 4px 0; font-style: italic; font-size: 11px; }

.cargo-hold-input {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
  margin-left: 8px;
}
.cargo-hold-input input {
  width: 80px;
  padding: 3px 6px;
  background: var(--bg-3, rgba(255,255,255,0.04));
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-align: right;
}
.cargo-hold-input input:focus {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.cargo-stop-profit {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ok, #4ec96a);
  font-weight: 600;
}
/* When hold capacity is on, carry rows grow a qty column so the user
   sees the recommended count + cargo-space used at a glance. */
.cargo-carry.has-qty { grid-template-columns: 28px 1fr auto auto; }
.cargo-qty {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 8px;
}
.cargo-qty-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; font-weight: 700;
  color: var(--accent);
}
.cargo-qty-meta { font-size: 9.5px; }
