/* Azure sky theme, light and dark. Each color is light-dark(light, dark): color-scheme picks which one, so
   System follows the device, and data-theme on <html> (the user's choice, from the server) forces one. */
:root {
  --bg: light-dark(#f3f9fd, #0c1722); --surface: light-dark(#ffffff, #132231); --surface-2: light-dark(#f8fbfe, #182a3b); --text: light-dark(#0f2433, #dce9f3); --muted: light-dark(#557083, #96aec0); --border: light-dark(#d4e6f2, #2a425a);
  --accent: light-dark(#0284c7, #38bdf8); --accent-text: light-dark(#ffffff, #04202f); --accent-tint: light-dark(#a9dcf5, #1d4d6b); --danger: light-dark(#b42318, #ff8f85); --highlight: light-dark(#e6f4fc, #17364d);
  --error-bg: light-dark(#fdecec, #3d1e21); --warn-bg: light-dark(#fff4cc, #3a3012); --warn: light-dark(#7a5600, #f2cc60); --warn-border: light-dark(#f3d9a4, #6b5420);
  --on-danger: light-dark(#ffffff, #2b0a08);
  --good-bg: light-dark(#e3f4dc, #213d1c); --good-text: light-dark(#3f6212, #b4de8c); --good-border: light-dark(#c7e6b8, #3f6132); --good-soft: light-dark(#f3faef, #182e22); --good-soft-border: light-dark(#dcefd2, #2d4a2c);
  --ok-bg: light-dark(#ddf3e4, #173d27); --ok-text: light-dark(#1d6b36, #8bdaa6); --up-text: light-dark(#3f7d16, #97d46b); --tone-good: light-dark(#4d8a1f, #8fcf60); --tone-good-bg: light-dark(#e8f5df, #203b1c);
  --info-bg: light-dark(#e0f2fe, #123a54); --info-text: light-dark(#0369a1, #8fd3fb);
  /* The factions' colors, as in the game: Antares (AI1) red, Castillo-Ito (CI1) blue, Insitor (IC1) green, NEO
     Charter (NC1) amber. Shades checked together for color blindness in each theme; where red, green and amber
     are close for some eyes (light), the name is always written too. */
  --faction-ai: light-dark(#c73a17, #cc3f20); --faction-ci: light-dark(#1f78d1, #3c9be8);
  --faction-ic: light-dark(#0f7a28, #199e70); --faction-nc: light-dark(#b98200, #bf8700);
  --admin-bg: light-dark(#fff4e0, #332510); --admin-text: light-dark(#92400e, #f6c27a); --admin-hover: light-dark(#fde8c4, #4a3515); --admin-active-text: light-dark(#ffffff, #231400);
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* always wins over a component's own display */
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .01em; }
.brand img { width: 26px; height: 26px; display: block; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: 4px 0; margin-right: 16px; }
.topbar nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.topbar nav:not(.admin-nav) a:hover { color: var(--text); }
/* The hover line where the active one is, along the link's box: an underline (text-decoration) would stop at the
   Alpha pill (an inline-block). The phone menu keeps its own lines between links. */
@media (min-width: 701px) { .topbar nav:not(.admin-nav) a:not(.active):hover { box-shadow: inset 0 -2px currentColor; } }
/* Loading bar across the top, while a page or a tab loads (app.js: page.loader). */
.page-loader { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; overflow: hidden;
  background: var(--accent-tint); opacity: 0; transition: opacity .2s; pointer-events: none; }
.page-loader.on { opacity: 1; }
.page-loader span { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, transparent, var(--accent) 70%, #38bdf8);
  box-shadow: 0 0 10px var(--accent); animation: page-loader-slide 1.1s cubic-bezier(.4, 0, .2, 1) infinite; }
@keyframes page-loader-slide { from { left: -40%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .page-loader span { animation-duration: 3s; } }
/* Full-page loader, "Loading data from FIO…" (_fio_loader.html): after a second of loading (app.js), or while a
   page waits for the order books (idea 57). */
.fio-loader { position: fixed; inset: 0; z-index: 999; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(2px); }
.fio-loader[hidden] { display: none; }
.fio-loader-box { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 8px 30px rgb(0 0 0 / .15); }
.fio-loader-box p { margin: 0; font-weight: 600; }
.fio-spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-tint);
  border-top-color: var(--accent); animation: fio-spin .8s linear infinite; }
@keyframes fio-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .fio-spinner { animation-duration: 3s; } }
main { padding: 24px 24px 48px; }
.app-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 12px 24px 24px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.footer-links { display: flex; gap: 16px; margin-left: auto; }
.card.error-page { max-width: 520px; margin: 24px auto; text-align: center; padding: 32px 24px; }
.error-page .error-code { margin: 0 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.error-page p:last-child { margin: 20px 0 0; }
.legal { max-width: 80ch; line-height: 1.55; }
.legal h2 { margin: 22px 0 8px; font-size: 16px; }
.legal p, .legal ul { margin: 0 0 10px; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal-lead { font-size: 15px; padding: 10px 14px; background: var(--surface-2); border-radius: 6px; }
h1 { margin: 0 0 16px; font-size: 24px; }
h2 { margin: 0 0 16px; font-size: 17px; }
.count { color: var(--muted); font-weight: 400; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; width: 100%; min-width: 0; }
select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { font: inherit; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); border-radius: 6px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
/* A button with an icon: the icon sits centred on the text, not on its baseline. :where() keeps it at zero
   weight, so any rule that hides or lays out a button (.menu-toggle, .ph-only...) still wins. */
:where(button, .button):has(> .icon) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; vertical-align: middle; }
:where(button, .button):has(> .icon) > .icon { flex: none; }
button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 400; }
button.link.danger { color: var(--danger); }
.actions { display: flex; gap: 10px; margin-top: 8px; }
.hint { min-height: 1.5em; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.errors { background: var(--error-bg); color: var(--danger); border-radius: 6px; padding: 10px 10px 10px 30px; margin: 0 0 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.view-switch { display: inline-flex; }
.view-switch button { border-radius: 0; padding: 4px 12px; font-size: 13px; }
.view-switch button:first-child { border-radius: 6px 0 0 6px; }
.view-switch button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.view-switch button.secondary[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
/* Market: any material, its history and its exchanges */
.mat-link { text-decoration: none; }
.mat-link:hover .mat-tile, .mat-link:focus-visible .mat-tile { outline: 2px solid var(--accent); outline-offset: 1px; }
.ph-lookup-cell { display: none; }
/* The exchange picker: each in its faction's color (a bar under its code); the shown one is tinted and
   outlined in it. The text keeps the page's ink, readable on every tint. */
nav.exchange-switch { gap: 6px; flex-wrap: wrap; }
nav.exchange-switch a { padding: 4px 14px; min-width: 52px; text-align: center; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-bottom: 4px solid var(--ex); border-radius: 6px; }
nav.exchange-switch a:hover { background: color-mix(in srgb, var(--ex) 10%, var(--surface)); }
nav.exchange-switch a.on { background: color-mix(in srgb, var(--ex) 22%, var(--surface)); border-color: var(--ex); box-shadow: 0 0 0 1px var(--ex); }
/* The shown exchange on the boxes it fills, too. */
.faction-edge { border-top: 4px solid var(--ex); }
.market-find { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.market-search { flex: 1 1 260px; }
.recent { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.market-table td a:not(.mat-link) { color: var(--text); text-decoration: none; }
.market-table tbody tr:hover td { background: var(--highlight); }
.market-table td { vertical-align: middle; padding-top: 6px; padding-bottom: 6px; }
.market-table .row-link { display: inline-flex; align-items: center; gap: 10px; }
.market-table .category-cell { font-size: 13px; color: var(--muted); }
.market-table .spark { display: block; }
.market-table .under { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; }
.market-table .maker-cell { font-size: 13px; }
.market-table .maker-cell span { display: block; white-space: nowrap; }
/* Every row the same height, with or without a graph, units or a market maker: room for two lines of 13px. */
.market-table .no-spark { display: block; height: 24px; line-height: 24px; }
.market-table .category-cell, .market-table .under, .market-table .maker-cell { line-height: 1.3; }
@media (min-width: 701px) { .market-table tbody td { height: 56px; } }
.material-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.material-title .meta { font-size: 13px; font-weight: 400; }
.chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.check-label { flex-direction: row; align-items: center; gap: 6px; }
.check-label input { width: auto; }
/* An exchange's color, as --ex. "All" is nobody's: gray (the app's blue would read as CI1). */
.ex-ai1 { --ex: var(--faction-ai); } .ex-ci1 { --ex: var(--faction-ci); }
.ex-ic1 { --ex: var(--faction-ic); } .ex-nc1 { --ex: var(--faction-nc); }
.ex-universe { --ex: var(--muted); }
.material-chart .line-key { fill: var(--ex); }
.material-chart .line-name { fill: var(--text); font-weight: 600; }
.chart-legend .swatch[class*="ex-"] { background: var(--ex); }
.mm-key { display: inline-block; width: 16px; border-top: 2px dashed var(--muted); }
.chart-name { margin: 10px 0 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.material-chart { touch-action: pan-y; }
.material-chart svg.price-svg { height: 260px; }
.material-chart svg.volume-svg { height: 110px; }
.material-chart .price-line { fill: none; stroke: var(--ex); stroke-width: 2; stroke-linejoin: round; }
.material-chart .price-dot { fill: var(--ex); }
.material-chart .volume-bar { fill: var(--ex); }  /* no outline: on a phone a day's bar is a pixel or two wide */
.material-chart .mm-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 4; }
.material-chart .plan-tip div + div { font-weight: 400; }
.chart-table summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-top: 8px; }
.chart-table .table-wrap { max-height: 300px; overflow-y: auto; }
.exchange-table tr.shown-exchange td { background: color-mix(in srgb, var(--ex) 14%, var(--surface)); }
.exchange-table tbody td:first-child { box-shadow: inset 4px 0 0 var(--ex); }
.exchange-table td:first-child a { color: var(--text); }
.exchange-table tbody + tbody tr td { border-top: 2px solid var(--border); }
.material-empire > summary { cursor: pointer; }
.material-empire > summary h2 { display: inline-flex; align-items: center; margin: 0; }
.material-empire[open] > summary { margin-bottom: 12px; }
.material-mine { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 32px; }
.material-mine h3 { margin: 0 0 6px; font-size: .85rem; color: var(--muted); }
.material-mine ul { margin: 0; padding-left: 18px; }
@media (max-width: 700px) {
  /* The exchanges on one row across the screen, all the same width: bigger targets than their codes need. */
  nav.exchange-switch { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); flex: 1 1 100%; width: 100%; }
  nav.exchange-switch a { min-width: 0; padding: 4px 0; min-height: 48px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
  /* A phone's row is the box, not its first cell. */
  table.exchange-table.phone-rows tbody td:first-child { box-shadow: none; }
  table.exchange-table.phone-rows.phone-rows tbody tr { box-shadow: inset 4px 0 0 var(--ex); }
  table.exchange-table.phone-rows.phone-rows tbody tr.shown-exchange { background: color-mix(in srgb, var(--ex) 14%, var(--surface)); }
  .material-chart svg.price-svg { height: 200px; }
}

.recipe-cell { line-height: 2; }
.recipe-split .recipe-table td { vertical-align: middle; }
.recipe-part { display: inline-flex; align-items: center; gap: 2px; margin-right: 8px; white-space: nowrap; }
.recipe-tiles { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 0; }
.recipe-arrow { margin: 0 8px 0 0; color: var(--muted); }
.recipe-row.recipe-ro { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.market-find form { margin: 0; }
/* Movers: three ranked lists side by side, each row a link. */
.movers-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 14px; }
.movers-filter label { flex-direction: row; align-items: center; gap: 8px; }
.movers-filter select { width: auto; }
.movers-filter p { margin: 0; }
.mover-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
@media (max-width: 1100px) { .mover-columns { grid-template-columns: minmax(0, 1fr); } }
.mover-list h2 { align-items: center; margin-bottom: 12px; }
.movers { list-style: none; margin: 0; padding: 0; }
.movers li { border-top: 1px solid var(--border); }
.movers a { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 9px 16px; color: var(--text); text-decoration: none; }
.movers a:hover, .movers a:focus-visible { background: var(--highlight); }
.mover-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.mover-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover-main { justify-self: end; font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mover-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.spark { justify-self: end; width: 80px; height: 24px; }
.spark polyline { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
button.link.movers-all { display: flex; align-items: center; width: 100%; padding: 10px 16px; border-top: 1px solid var(--border); border-radius: 0; text-align: left; }
.mover-empty { padding-bottom: 14px; }
.mover-list:not(.all) .movers li:nth-child(n+11) { display: none; }
button.link.movers-all.all-on-computer { display: none; }
@media (max-width: 700px) {
  .mover-list:not(.all) .movers li:nth-child(n+6) { display: none; }
  button.link.movers-all.all-on-computer { display: flex; }
  button.link.movers-all.all-on-phone { display: none; }
  button.link.movers-all { min-height: 44px; }
  .movers-filter { padding: 0 12px; }
}

table[data-sortable] th.sortable { cursor: pointer; user-select: none; position: relative; }
table[data-sortable] th.sortable:hover { color: var(--accent); }
table[data-sortable] th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table[data-sortable] th[aria-sort]::after { position: absolute; right: 0; bottom: 11px; font-size: 8px; color: var(--accent); }
table[data-sortable] th[aria-sort="ascending"]::after { content: "\25B2"; }
table[data-sortable] th[aria-sort="descending"]::after { content: "\25BC"; }
tr:target td { background: var(--highlight); }  /* a base linked as /bases#base-{id} */
/* The Bases page's list by group: each group's line, and its bases set in a little */
.list-group tr.group-row td { background: var(--surface-2); border-top: 2px solid var(--border); font-weight: 600; }
.list-group tr.in-group td:first-child { padding-left: 28px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.small { font-size: 12px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin-left: 12px; }
.empty { color: var(--muted); margin: 0; }
.fallback { color: var(--muted); font-style: italic; }

/* Base detail page */
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
/* Warning lists (<ul class="warnings">): one amber box, each line with a triangle icon (a mask, so it takes the text color). */
.warnings { list-style: none; margin: 0 0 16px; padding: 10px 14px; background: var(--warn-bg); color: var(--warn);
  border: 1px solid var(--warn-border); border-left-width: 4px; border-radius: 6px; font-size: 14px; line-height: 1.45; }
.warnings li { position: relative; padding-left: 24px; }
.warnings li + li { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--warn-border); }
.warnings li::before { content: ""; position: absolute; left: 0; top: .15em; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z'/%3E%3Cpath d='M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z'/%3E%3Cpath d='M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat; }
.warnings li + li::before { top: calc(6px + .15em); }
.warnings a { color: inherit; text-decoration: underline; }
.base-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 16px; }
.base-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
.base-side .card { padding: 16px; margin-bottom: 14px; }
.base-main { min-width: 0; }
@media (max-width: 900px) {
  .base-layout { grid-template-columns: minmax(0, 1fr); }
  .base-side { position: static; max-height: none; overflow: visible; }
}
.source p { margin: 0 0 6px; }
.source h2 { margin-bottom: 8px; }
.src-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-left: 6px; }
.warn-text { color: var(--danger); }
.up-text { color: var(--up-text); }
.meta.inline { display: inline; }
.defaults-grid { display: grid; gap: 12px; margin-top: 10px; }
.pad-h { padding: 18px 20px 0; }
h2.pad-h { display: flex; align-items: baseline; gap: 8px; }
h2 .meta.sub { margin-left: auto; text-align: right; font-weight: 400; }
/* Every card heading with a subtitle: the title on the left, the subtitle on the same line to the right
   (it wraps under the title, still right-aligned, when there isn't room). */
h2:has(> .meta.sub) { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.src-label { margin-left: auto; }
.source h2, .defaults h2 { display: flex; align-items: baseline; gap: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin: 0 0 16px; }
.tab { background: none; border: none; border-bottom: 3px solid transparent; border-radius: 0; margin-bottom: -2px; padding: 10px 16px; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--text); background: var(--highlight); }
a.tab { text-decoration: none; }  /* a tab that opens a page (Market, Reports) looks like the others */
.tab.active, .tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab-badge { font-size: 11px; font-weight: 700; min-width: 20px; padding: 1px 6px; border-radius: 999px; text-align: center; }
.tab-badge.due { background: var(--error-bg); color: var(--danger); }
.tab-badge.soon { background: var(--warn-bg); color: var(--warn); }
.supply-table th.r, .supply-table td.r { text-align: right; }
.supply-table td { vertical-align: middle; font-variant-numeric: tabular-nums; }
/* Tickers take three monospace characters, so "DW" and "C" leave blank space and names line up. */
.ticker { font-family: ui-monospace, Consolas, monospace; display: inline-block; min-width: 3ch; white-space: pre; }
.supply-table td:first-child { white-space: nowrap; }
.days-in { width: 76px; text-align: right; padding: 4px 6px; }
tr.restock td { background: var(--error-bg); }
.repair-table td { white-space: nowrap; }
tr.restock td.days { color: var(--danger); font-weight: 700; }
tr.soon td { background: var(--warn-bg); }
tr.soon td.days { color: var(--warn); font-weight: 700; }
/* A base with a red warning (storage, workforce or repair): red row. Listed after the yellow "soon" row. */
tr.alert-red td { background: var(--error-bg); }
/* Bases due for a repair within the Repairs due window: red row, next repair in bold red */
tr.repair-soon td { background: var(--error-bg); }
tr.repair-soon td.next-repair { color: var(--danger); font-weight: 700; }

/* API cache page */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 40px; }  /* same height with or without a button */
.page-head h1 { margin: 0; }
.sticky-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0; margin: 0 0 6px; border-bottom: 1px solid var(--border); }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#save-status.unsaved, .save-status.unsaved { color: var(--accent); font-weight: 600; }
button:disabled { opacity: .45; cursor: not-allowed; }
/* A form on its way (app.js): its buttons stay enabled, so the clicked one still sends its value. */
form.form-busy :is(button, input[type="submit"]):not([type="button"]) { opacity: .6; cursor: progress; }
.intro { color: var(--muted); max-width: 75ch; margin: 8px 0 16px; }
.flash { background: var(--highlight); border-radius: 6px; padding: 8px 12px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.card.flush { padding: 0; overflow: hidden; }
/* Lent and Borrowed line up: the same fixed widths. Narrower than this, a table scrolls in its box. */
.loans-running, .loans-history { table-layout: fixed; min-width: 1150px; }
.list-table.loans-running td:first-child, .list-table.loans-history td:first-child { white-space: normal; overflow-wrap: anywhere; }
.loans-tiles .kpi-label, .loans-tiles .kpi-sub { white-space: normal; }  /* wrap, never cut off */
.loans-ended { border-top: 1px solid var(--border); background: var(--surface-2); }  /* under a box's running loans */
.loans-ended > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); padding: 10px 20px; }
.loans-ended > summary:hover { color: var(--accent); }

/* Loans: the Finances box. Lent and money in are blue, borrowed and money out orange. */
.loans-finances { --loan-in: light-dark(#2a78d6, #3987e5); --loan-out: light-dark(#eb6834, #d95926); }
.fin-dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.fin-dot.in, .fin-side.lent .fin-dot { background: var(--loan-in); }
.fin-dot.out, .fin-side.borrowed .fin-dot { background: var(--loan-out); }
.fin-label, .fin-side-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.fin-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 14px; }
.fin-side { --side: var(--loan-in); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; background: var(--surface-2); }
.fin-side.borrowed { --side: var(--loan-out); }
.fin-side-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fin-big { display: block; font-size: 34px; line-height: 1.25; font-variant-numeric: tabular-nums; margin: 2px 0 10px; }
.fin-meter { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden;
             background: color-mix(in srgb, var(--side) 22%, var(--surface)); }
.fin-meter .done { background: var(--side); }
.fin-meter .never { background: repeating-linear-gradient(45deg, var(--muted) 0 3px, transparent 3px 6px); }
.fin-side-split { display: flex; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; margin-top: 8px; font-size: 14px;
                  font-variant-numeric: tabular-nums; }
.fin-never { margin: 6px 0 0; }

.loan-headlines { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.loan-headline { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 2px 14px; border-left: 3px solid var(--accent); }
.loan-headline strong { font-size: 22px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.loan-headline > span:last-child { font-size: 13px; color: var(--muted); }
.loan-headline.short-of { border-left-color: var(--danger); }
.loan-headline.short-of strong { color: var(--danger); }

.fin-heading { font-size: 14px; margin: 24px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.fin-breakdown.loans-interest { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.fin-part.total.loss { border-color: var(--warn-border); background: var(--warn-bg); }
.loans-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 28px; align-items: start; }
.loans-columns > div { min-width: 0; }

.fin-panel { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 8px; }
.fin-chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); }
.fin-chart-legend > span { display: inline-flex; align-items: center; }
.fin-chart { display: flex; align-items: stretch; margin-top: 4px; }
.fin-week { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; border-radius: 6px; }
.fin-week:hover, .fin-week:focus { background: var(--highlight); }
.fin-up, .fin-down { width: 100%; display: flex; flex-direction: column; align-items: center; }
.fin-up { justify-content: flex-end; border-bottom: 1px solid var(--muted); }  /* the zero line */
.fin-col { display: block; flex: none; width: 24px; max-width: 70%; }
.fin-col.in { background: var(--loan-in); border-radius: 4px 4px 0 0; }
.fin-col.out { background: var(--loan-out); border-radius: 0 0 4px 4px; }
.fin-val { font-size: 11px; line-height: 18px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-week-label { font-size: 11px; color: var(--muted); padding: 4px 0 2px; white-space: nowrap; }
.fin-tip { display: none; position: absolute; z-index: 5; bottom: 100%; left: 50%; transform: translateX(-50%); flex-direction: column;
           gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
           box-shadow: 0 4px 14px rgba(0, 0, 0, .18); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fin-tip > span { display: inline-flex; align-items: center; }
.fin-week:hover .fin-tip, .fin-week:focus .fin-tip { display: flex; }
.fin-week:first-child .fin-tip { left: 0; transform: none; }
.fin-week:last-child .fin-tip { left: auto; right: 0; transform: none; }

.fin-volume { width: 34%; }
.fin-volume-row { display: flex; align-items: center; gap: 10px; }
.fin-track { display: flex; flex: 1; gap: 2px; height: 10px; min-width: 60px; }
.fin-seg { display: block; min-width: 3px; border-radius: 0 4px 4px 0; }
.fin-seg.in { background: var(--loan-in); }
.fin-seg.out { background: var(--loan-out); }
.fin-volume-num { flex: none; min-width: 84px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

.loans-compare th .fin-dot { vertical-align: 0; }
.loans-compare tbody th { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 400; color: var(--text); padding: 6px 10px; }
.loans-coming tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
@media (max-width: 1100px) { .loans-columns { grid-template-columns: minmax(0, 1fr); gap: 14px 0; } }
@media (max-width: 800px) { .fin-sides, .loan-headlines, .fin-breakdown.loans-interest { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .fin-val { display: none; } .fin-week-label { font-size: 9px; } .fin-big { font-size: 26px; } }
.pad { padding: 20px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill-fresh { background: var(--ok-bg); color: var(--ok-text); }
.pill-stale { background: light-dark(#fff1cc, #3f3210); color: var(--warn); }
.pill-invalidated { background: light-dark(#e8e6ff, #2a2752); color: light-dark(#4a3fb3, #bdb4ff); }
.pill-error { background: var(--error-bg); color: var(--danger); }
.pill-auto { background: var(--highlight); color: var(--accent); }
.pill-icon { display: inline-flex; align-items: center; gap: 5px; }
.pill-icon .icon { flex: none; }
h1 .pill { vertical-align: middle; margin-left: 8px; }
.pill-no-data { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
/* Alpha: an early version, not every feature there yet (Leases). Amber, so it doesn't read as a finished feature. */
.pill-alpha { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); text-transform: uppercase;
              font-size: 10px; letter-spacing: .06em; padding: 1px 6px; }
.nav-beta { margin-left: 2px; vertical-align: 2px; }
/* Leases' testing notice (_lease_alpha_notice.html), under the title of every lease page. */
.lease-alpha-notice { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; padding: 10px 14px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); font-size: 14px; }
.lease-alpha-notice > .icon { flex: none; margin-top: 1px; }
.lease-alpha-notice ul { margin: 4px 0 0; padding-left: 18px; }
.lease-alpha-notice li + li { margin-top: 2px; }
.cache-table td { vertical-align: top; font-size: 14px; }
.cache-table th.r, .cache-table td.r { text-align: right; font-variant-numeric: tabular-nums; }
.cache-table .call { min-width: 280px; }
.cache-table .call .src { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 6px; }
.page-head .actions { margin-top: 0; }
button.secondary.danger { color: var(--danger); }
.log-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.log-filters input[type="search"] { min-width: 220px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 12px 0; }
.cache-group { margin-bottom: 14px; }
.cache-group > summary { cursor: pointer; padding: 10px 16px; font-weight: 600; list-style: none; }
.cache-group > summary::-webkit-details-marker { display: none; }
.cache-group > summary::before { content: "▸"; display: inline-block; width: 1.2em; color: var(--muted); }
.cache-group[open] > summary::before { content: "▾"; }
.cache-table .call .mono { word-break: break-all; }
.meta { display: block; font-size: 12px; color: var(--muted); }
.cache-table .err { max-width: 240px; font-size: 13px; }
.err-current { color: var(--danger); }
.nowrap { white-space: nowrap; }
.cache-table .row-actions form { display: block; margin: 0 0 4px; text-align: right; }

/* Config page */
.masked { color: var(--muted); letter-spacing: .05em; }
.inline-check { flex-direction: row; align-items: center; gap: 8px; }
.inline-check input { width: auto; }

/* A setting row on Profile (Appearance, Security, the game settings): a tile that folds. Where it matters, its left
   edge says where it stands. */
.setting { display: flex; flex-direction: column; margin-top: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
/* Profile › Appearance: the time zone, a box like Security's under the themes. */
.zone-pill { font-weight: 600; text-transform: none; letter-spacing: 0; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.zone-form { max-width: 420px; }
.zone-form select { width: 100%; }
.zone-form .zone-now { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; color: var(--text); }
.zone-form .zone-clock { display: inline-flex; color: var(--accent); }
.zone-form .meta { margin: 0; }
/* Profile's game settings (API keys, Prices, Selling surplus): rows like Security's, the value in a pill on the
   closed line. An API key's row has an icon tinted by its state. */
/* Prices and Selling: one row each, two values on the closed line (each with its name above it), two fields side
   by side once opened (one under the other on a phone). */
.value-facts { display: flex; flex-wrap: wrap; gap: 6px 32px; }
.value-fact { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.value-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.value-fact strong { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.value-fact strong img { flex: none; }
.pair-setting .setting-text { gap: 6px; }
.pair-form { display: flex; flex-direction: column; gap: 14px; }
.pair-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.pair-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pair-field > label { font-weight: 600; font-size: 14px; color: var(--text); }
.pair-field select, .pair-field .logo-field, .pair-field .with-unit { width: 100%; max-width: none; }
.pair-field select, .pair-field input { background: var(--surface); }  /* white on the row's gray, like other fields */
.pair-field .meta { margin: 0; }
.pair-form .actions { margin: 0; }
@media (max-width: 700px) { .pair-fields { grid-template-columns: minmax(0, 1fr); } }
.key-icon { flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
            background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.key-ok .key-icon { background: var(--good-bg); color: var(--good-text); border-color: var(--good-border); }
.key-bad .key-icon { background: var(--error-bg); color: var(--danger); border-color: var(--danger); }
.key-status { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.key-mask { font-size: 13px; letter-spacing: 1px; color: var(--text); }
.key-row .setting-body { padding-left: 52px; }  /* under the name, past the icon */
.key-row .stack-form label .meta { display: block; font-weight: 400; }
.key-remove { margin-top: 10px; }
.keys-foot { margin: 14px 0 0; }
@media (max-width: 700px) { .key-row .setting-body { padding-left: 0; } }
/* Selectors with faction logos. Without a logo (Universe, No faction) an empty space keeps the names level. */
.logo-field { display: flex; align-items: center; gap: 8px; }
.logo-field select { min-width: 0; }
.logo-select .faction-logo, .logo-none { flex: none; display: inline-block; width: 20px; height: 20px; margin: 0; vertical-align: -5px; }
.logo-fallback { flex: none; }
.logo-fallback[hidden] { display: none; }
.logo-field.small { gap: 6px; }
.logo-field.small .logo-fallback { width: 16px; height: 16px; }
@supports (appearance: base-select) {
  .logo-fallback { display: none; }
  .logo-select, .logo-select::picker(select) { appearance: base-select; }
  .logo-select { display: flex; align-items: center; height: 38px; min-height: 38px; padding: 0 12px; }
  /* The select's own button: not one of the app's buttons (no fill, padding or height of theirs). */
  .logo-select > button { flex: 1; min-width: 0; display: flex; margin: 0; padding: 0; border: 0; border-radius: 0; min-height: 0;
    background: none; color: inherit; font: inherit; box-shadow: none; }
  .logo-select selectedcontent { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; white-space: nowrap; }
  .logo-select::picker-icon { margin-left: auto; color: var(--muted); }
  .logo-select::picker(select) { min-width: anchor-size(width); padding: 4px; background: var(--surface); color: var(--text);
                                 border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
  .logo-select option { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 4px 10px; border-radius: 6px; }
  .logo-select option:hover, .logo-select option:focus-visible { background: var(--highlight); }
  .logo-select option:checked { font-weight: 600; }
  .logo-select option:disabled { color: var(--muted); }
  /* Compact, in cards and table rows (Resupply's ships, the Stockpiles tab). */
  .logo-select.small { height: 28px; min-height: 28px; padding: 0 8px; font-size: 13px; }
  .logo-select.small > button { padding: 0; }  /* the browser's own padding would cut the name in a narrow card */
  .logo-select.small selectedcontent { gap: 6px; }
  .logo-select.small .faction-logo, .logo-select.small .logo-none { width: 16px; height: 16px; vertical-align: -3px; }
  .logo-select.small::picker(select) { font-size: 13px; }
  .logo-select.small option { gap: 8px; min-height: 30px; padding: 3px 8px; }
}
.with-unit { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.hq-bonuses { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.bonus-who { flex-basis: 100%; }
.bonus { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--good-border); background: var(--good-bg); color: var(--good-text); }
.feature-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
                border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
/* The Loans page before any loan: what will show there, beside its picture (_loans_art.html) */
.loans-start { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 32px; }
.loans-start > div { flex: 1 1 320px; }
.loans-start ul { margin: 8px 0 0; padding-left: 20px; }
.loans-start li { margin-bottom: 4px; }
.loans-art { flex: 0 1 300px; width: 100%; max-width: 300px; margin: 0 auto; }
.loans-art .art-floor { fill: var(--text); opacity: .07; }
.loans-art .art-coin-side { fill: light-dark(#c98a06, #a87405); }
.loans-art .art-coin-top { fill: light-dark(#f5bd23, #e0a71b); stroke: light-dark(#fbd766, #f2c94c); stroke-width: 1.5; }
.loans-art .art-coin-mark { fill: none; stroke: light-dark(#b87d04, #9a6a04); stroke-width: 1.5; }
.loans-art .art-arrow { fill: none; stroke-width: 7; stroke-linecap: round; }
.loans-art .art-arrow.out { stroke: light-dark(#eb6834, #d95926); }
.loans-art .art-arrow.in { stroke: light-dark(#2a78d6, #3987e5); }
.loans-art .art-head.out { fill: light-dark(#eb6834, #d95926); }
.loans-art .art-head.in { fill: light-dark(#2a78d6, #3987e5); }
.loans-art .art-badge { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.loans-art .art-percent { fill: var(--accent); font-size: 28px; font-weight: 700; }

/* Plan tab */
.tab-badge.info { background: var(--highlight); color: var(--accent); }
.rate-in { width: 110px; text-align: right; padding: 4px 6px; }
.ticker-in { width: 170px; padding: 4px 6px; text-transform: uppercase; }
.remove-in { width: auto; }
.plan-table td { white-space: nowrap; }
.plan-table .pp-col { color: var(--muted); background: var(--surface-2); }
tr.plan-different td, tr.plan-local-only td, tr.plan-remote-only td { background: var(--highlight); }
tr.plan-different .pp-col, tr.plan-local-only .pp-col, tr.plan-remote-only .pp-col { background: var(--highlight); color: var(--text); }
.diff-label { font-weight: 600; color: var(--accent); margin-right: 10px; }
.plan-table .inline-check { display: inline-flex; font-size: 13px; color: var(--text); }
.pad-note { padding: 10px 20px 16px; margin: 0; }

/* Consumables and Materials share the same column widths */
.supply-table.aligned { table-layout: fixed; min-width: 900px; }
.supply-table.aligned td:first-child { overflow: hidden; text-overflow: ellipsis; }
/* The item column needs a width too: without one, fixed-layout tables squeeze it to nothing when the
   other columns fill the width (narrow windows). Then the table scrolls sideways instead. */
.supply-table.aligned col:first-child { width: 230px; }
.supply-table.aligned .c-perday { width: 230px; }
.supply-table.aligned .c-num { width: 110px; }
.supply-table.aligned .c-input { width: 120px; }
.supply-table.aligned .c-amount { width: 160px; }
.supply-table.aligned th { white-space: nowrap; }
.calc { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; margin-right: 8px; }

/* Compact rows on the base page */
.base-main .supply-table th { padding: 6px 10px; }
.base-main .supply-table td { padding: 3px 10px; font-size: 14px; line-height: 1.35; }
.base-main .supply-table input { padding: 2px 6px; font-size: 14px; }
/* Total rows are as tall as the item rows above them (the item rows hold 26px inputs and tiles). */
.base-main .supply-table tfoot td { height: 32px; }
.base-main .pad-h { padding: 12px 16px 2px; }
.base-main h2.pad-h { margin-bottom: 8px; }
.base-main .card { margin-bottom: 14px; }
/* Every row as tall as one with an input box, so tables without inputs breathe the same */
.base-main .supply-table tbody tr { height: 32px; }

/* PRUNplanner plan picker on the Bases form */
.plan-picker { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); grid-column: span 2; }
.plan-picker label { display: inline; }
.optional { font-size: 11px; color: var(--muted); font-style: italic; margin-left: 4px; }
.plan-picker select { margin-top: 2px; }
@media (max-width: 700px) { .plan-picker { grid-column: auto; } }

/* Planet search: one suggestion per line, "Display Name (Planet ID)" */
.combo-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 2px); max-height: 320px; overflow-y: auto;
  margin: 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(15, 36, 51, .12); }
.combo-list li { padding: 6px 10px; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list li .own-tag { margin-left: 8px; font-size: 12px; color: var(--muted); }
.combo-list li.combo-hint { cursor: default; font-size: 12px; color: var(--muted); background: none; border-bottom: 1px solid var(--border); }
.combo-list li:hover, .combo-list li.active { background: var(--highlight); color: var(--accent); }
.none { color: var(--muted); }
.plan-empty { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 16px; background: var(--highlight); border-color: var(--accent-tint); }
.plan-empty p { margin: 0; }

/* In-game bases not in the app yet */
.suggest-box { border-color: var(--accent-tint); }
.suggest-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.suggest-head h2 { margin: 0; display: flex; align-items: baseline; gap: 8px; }
.suggest-all { display: flex; gap: 8px; }
.suggest-list { list-style: none; margin: 0 0 8px; padding: 0; columns: 3 280px; column-gap: 24px; }
.suggest-list li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border); break-inside: avoid; font-size: 14px; }
.suggest-actions { display: flex; gap: 12px; }
.suggest-actions form { display: inline; }
.muted-link { color: var(--muted) !important; }
.restore-dismissed { margin-top: 12px; display: flex; gap: 8px; align-items: baseline; }

/* Base switcher: the heading is a select that looks like the title */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.base-title { display: flex; align-items: center; gap: 10px; }
.base-switch { position: relative; display: inline-flex; align-items: center; }
.base-switch-name { padding-right: 26px; white-space: nowrap; }
.base-switch-name::after { content: ""; position: absolute; right: 6px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
.base-switch select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font-size: 15px; }
.base-switch:hover .base-switch-name { color: var(--accent); }
.base-switch:hover .base-switch-name::after { border-color: var(--accent); }
.base-switch:focus-within .base-switch-name { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Bases list: quick plan import */
.plan-cell { white-space: nowrap; }
.inline-form { display: inline; margin-left: 8px; }
button.mini { font-size: 12px; padding: 1px 8px; }
.pill-diff { margin-left: 8px; background: var(--warn-bg); color: var(--warn); text-decoration: none; }
.pill-diff:hover { text-decoration: underline; }

/* Inline editing in the bases list */
.inline-cell { white-space: nowrap; }
.inline-pick { position: relative; display: inline-flex; align-items: center; }
.inline-pick .pill { padding-right: 22px; }
.inline-pick::after { content: ""; position: absolute; right: 9px; top: 50%; width: 5px; height: 5px; margin-top: -4px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); color: var(--muted); pointer-events: none; }
.inline-pick select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.inline-pick:hover .pill { outline: 1px solid var(--accent); }
.inline-pick:focus-within .pill { outline: 2px solid var(--accent); }
.plan-inline { width: auto; max-width: 320px; padding: 3px 6px; font-size: 13px; }
.inline-status { font-size: 12px; margin-left: 6px; color: var(--muted); }
.inline-status.ok { color: var(--ok-text); }
.inline-status.bad { color: var(--danger); }
h1 .inline-pick { font-size: 12px; font-weight: 600; }
h1 .inline-pick .pill { margin-left: 0; }

/* Previous / next base arrows around the title */
.base-step { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px;
  color: var(--muted); border: 1px solid var(--border); background: var(--surface); flex: none; }
.base-step:hover { color: var(--accent); border-color: var(--accent); }
.base-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Ships page */
/* Compact list tables (Bases and Ships) */
.list-table td { vertical-align: middle; font-size: 14px; padding: 6px 10px; }
.list-table th.r, .list-table td.r { text-align: right; font-variant-numeric: tabular-nums; }
.list-table td:first-child { white-space: nowrap; }
.list-table tbody tr { height: 40px; }
.route { min-width: 260px; }
.route .arrow { color: var(--muted); margin: 0 4px; }
.fill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fill-bar { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; vertical-align: middle; }
.fill-level { display: block; height: 100%; background: var(--accent); }
.fill-level.low { background: var(--danger); }
.route-bar { display: block; width: 100%; max-width: 260px; margin-top: 4px; }
.list-table td.worn { color: var(--warn); font-weight: 700; background: var(--warn-bg); }
/* Ships: wear a day, the 7- and 30-day averages one under the other */
.ships-table td.wear .wear-avg { display: block; font-variant-numeric: tabular-nums; }
.ships-table td.wear .wear-avg + .wear-avg { margin-top: 2px; }

/* Add a base: one row */
.add-base { padding: 12px 16px; }
.add-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.add-row h2 { margin: 0 8px 7px 0; font-size: 15px; white-space: nowrap; }
.field-planet { flex: 1 1 240px; min-width: 200px; }
.field-draft-name { flex: 1 1 200px; min-width: 180px; }
.field-plan { flex: 2 1 380px; grid-column: auto; gap: 4px; }
.field-plan label { display: flex; flex-direction: row; align-items: baseline; gap: 6px; }
.field-plan label .link { margin-left: auto; font-size: 12px; }
.plan-row { display: flex; gap: 6px; }
.plan-row input { flex: 0 0 150px; }
.plan-row select { flex: 1 1 auto; min-width: 0; margin-top: 0; }
.field-logistics { flex: 0 0 170px; }
.add-btn { flex: none; }
.add-hints { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 0; font-size: 12px; color: var(--muted); min-height: 1.4em; }

/* Page titles: a stylized chevron before the name */
.page-title { display: flex; align-items: center; gap: 6px; }
.page-title::before {
  content: ""; flex: none; width: 26px; height: 26px; margin-left: -4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230284c7' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7l-7 7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 26px;
}
.page-title .count { margin-left: 2px; }
/* A box or message right under a title row (no summary line in between) keeps the usual gap. */
.page-head + .card, .page-head + .flash { margin-top: 16px; }

/* Ship type (cargo bay): one color per kit */
.pill.bay { font-family: ui-monospace, Consolas, monospace; min-width: 44px; text-align: center; letter-spacing: .03em; }
.bay-tcb { background: light-dark(#eceff3, #2a333f); color: light-dark(#4b5563, #c3ccd8); }
.bay-vsc { background: light-dark(#dff5f2, #123d37); color: light-dark(#0f6b5f, #7fdccd); }
.bay-scb { background: light-dark(#e3f6e3, #1b3c1d); color: light-dark(#276227, #9ad79a); }
.bay-mcb { background: light-dark(#efe7fb, #32234f); color: light-dark(#5b2ea6, #cbb0ff); }
.bay-lcb { background: light-dark(#e0f2fe, #123a54); color: light-dark(#0369a1, #8fd3fb); }
.bay-hcb { background: light-dark(#e3e8fd, #222a55); color: light-dark(#3730a3, #b3bcff); }
.bay-wcb { background: light-dark(#fdecd8, #43290f); color: light-dark(#9a4a06, #f8bb80); }
.bay-vcb { background: light-dark(#fce7f3, #471d33); color: light-dark(#9d174d, #f6a8cd); }
.bay-other { background: transparent; color: var(--muted); border: 1px dashed var(--border); }

/* Exchange prices on the Cache page */
.price-sync { margin-bottom: 16px; }
.price-sync-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.price-sync-head h2 { margin: 0; }
.price-sync .stats { margin: 8px 0 0; }

/* Prices on the base page: cost / revenue per day, with a total row */
.supply-table.aligned .c-money { width: 190px; }
.supply-table td.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Inventory: digits line up like the money columns beside it. */
/* Inventory: the "+ x on the way" hint sits to the left of the stock, on one line. */
.supply-table .stock { font-variant-numeric: tabular-nums; white-space: nowrap; }
.supply-table tfoot td { font-weight: 600; border-top: 2px solid var(--border); border-bottom: 0; }
.supply-table tfoot a.meta { font-weight: 400; margin-left: 6px; }

/* Finances tab: profit headline, revenue bar and breakdown */
.finances, .history, .lease-split { --fin-consumables: #0284c7; --fin-materials: #0d9488; --fin-repairs: #f59e0b; --fin-fees: #8b5cf6; --fin-profit: #65a30d; --fin-revenue: light-dark(#0f2433, #dce9f3); }
.finances h2 .sub a { color: inherit; }
.fin-profit { color: var(--fin-profit); }
.fin-profit.neg { color: var(--danger); }
.fin-bar { position: relative; display: flex; gap: 3px; height: 16px; margin: 4px 0 20px; }
.fin-bar .seg { flex-basis: 0; min-width: 3px; height: 100%; border-radius: 3px; }
.fin-bar .seg:first-child { border-radius: 8px 3px 3px 8px; }
.fin-bar .seg:last-of-type { border-radius: 3px 8px 8px 3px; }
.fin-bar .seg:only-of-type { border-radius: 8px; }
.fin-marker { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); }
.fin-empty { color: var(--muted); font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 0; }
.sw-consumables { background: var(--fin-consumables); }
.sw-materials { background: var(--fin-materials); }
.sw-repairs { background: var(--fin-repairs); }
.sw-fees { background: var(--fin-fees); }
.sw-profit { background: var(--fin-profit); }
.sw-revenue { background: transparent; border: 2px solid var(--fin-revenue); }
.sw-price { background: var(--fin-price); }
.sw-interest { background: var(--fin-interest); }
.fin-table { width: 100%; max-width: 620px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fin-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.fin-table td:first-child { padding-left: 0; }
.fin-table td.pct { width: 70px; font-size: 13px; color: var(--muted); }
.fin-table tr.fin-revenue td { font-weight: 600; }
.fin-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
/* Production fees per building type, under the Production fees row: indented past the swatch, smaller. */
.fin-table tr.fin-sub td { padding-top: 3px; padding-bottom: 3px; font-size: 13px; color: var(--muted); border-bottom-style: dashed; }
.fin-table tr.fin-sub td:first-child { padding-left: 18px; }
.fin-table tr.fin-sub td.r { color: var(--text); cursor: help; }
.fin-table tr.fin-sub td.pct { color: var(--muted); cursor: auto; }
.fin-sub-building { display: inline-block; min-width: 76px; }
.fin-sub-building .ticker { font-size: 12px; }
.fin-sub-workers .tier-chip { white-space: nowrap; }
.fin-sub-workers .tier-chip + .tier-chip::before { content: "· "; }
.fin-note { margin-top: 12px; }

/* Price risk and market depth (Finances tab) */
.pill.side { font-size: 11px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.side-sell { background: var(--good-bg); color: var(--good-text); }
.side-buy { background: var(--info-bg); color: var(--info-text); }
.risk-low, .depth-ok { background: var(--good-bg); color: var(--good-text); }
.risk-medium, .depth-large { background: var(--warn-bg); color: var(--warn); }
.risk-high, .depth-too_large { background: var(--error-bg); color: var(--danger); }
.risk-table td, .depth-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.internal, .depth-internal { background: var(--highlight); color: var(--accent); }

/* Empire page */
.empire-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.profit-table .bar-col { width: 22%; min-width: 160px; }
.fin-bar-sm { height: 10px; margin: 0; gap: 2px; }
.fin-bar .seg-fill { flex-basis: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -8px 0 12px; }
.empire-empty { max-width: 720px; }
.empire-empty ol { padding-left: 20px; }
.empire-empty li { margin-bottom: 6px; }

/* Empire: repairs due box and base warnings */
.empire-table td.alerts { white-space: normal; }
.pill.alert { font-size: 11px; margin: 1px 4px 1px 0; display: inline-block; }
/* Warning pills (warn-pill): Needs attention on the Overview and base page, and the Bases tab tables. Outlined in their own colour. */
.warn-pill { border: 1px solid currentColor; }
.alert-stale, .alert-not_in_fio, .alert-rates { background: var(--warn-bg); color: var(--warn); }
.alert-off_plan { background: var(--highlight); color: var(--accent); }
.alert-ran_out, .alert-storage, .alert-workforce, .alert-repair { background: var(--error-bg); color: var(--danger); }

/* Empire: Manual and Automated base tables share their column widths */
.empire-table.bases-aligned { table-layout: fixed; min-width: 1000px; }
.bases-aligned td:first-child { overflow: hidden; text-overflow: ellipsis; }
.bases-aligned .c-days { width: 130px; }
.bases-aligned .c-alerts { width: 280px; }
.bases-aligned .c-synced { width: 140px; }
.bases-aligned th { white-space: nowrap; }

/* Market makers worth trading with */
.pill.mm-pill { background: var(--good-bg); color: var(--good-text); font-size: 11px; }
.depth-market_maker { background: var(--good-bg); color: var(--good-text); }

/* Ships: places read as a planet ID or station; text that couldn't be read stays as written */
.place-id { font-weight: 600; }
.place-raw { font-style: italic; color: var(--muted); border-bottom: 1px dashed var(--border); }
.faction-logo { width: 18px; height: 18px; vertical-align: -4px; margin-right: 5px; }

/* Base page: ships on their way */
.incoming { margin: 8px 0 2px; font-size: 13px; }
.incoming-ships { margin: 0 0 8px; padding-left: 18px; font-size: 13px; }

/* Empire Overview: the dashboard */
.overview-table { width: 100%; }
.all-good { margin: 0; color: var(--good-text); }
.all-good::before { content: "✓ "; font-weight: 700; }
.overview-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Base page: the same warnings as the Empire page */
.base-alerts { border-left: 4px solid var(--danger); padding: 14px 20px; }
.base-alerts h2 { margin-bottom: 8px; }
.base-alerts ul { margin: 0; padding: 0; list-style: none; }
.base-alerts li { margin: 4px 0; }

/* Accounts: navigation */
.topbar .account { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; }

/* The bell (idea 75): before the account on a computer (order), beside the Menu button on a phone. */
.topbar > .bell { order: 1; margin-left: auto; position: relative; }
.topbar > .bell ~ .top-menu .account { order: 2; margin-left: 0; }
.bell > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; min-height: 32px;
  padding: 4px 8px; border-radius: 8px; color: var(--muted); }
.bell > summary::-webkit-details-marker { display: none; }
.bell > summary:hover, .bell[open] > summary { background: var(--highlight); color: var(--text); }
.bell > summary .icon { position: static; }
.bell-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: min(380px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .14);
  padding: 6px; max-height: min(70vh, 520px); overflow-y: auto; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 8px;
  border-bottom: 1px solid var(--border); font-size: 14px; }
.bell-head form { margin: 0; }
.bell-head button { font-size: 13px; }
.bell-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; padding: 8px;
  border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.bell-item:hover { background: var(--highlight); }
.bell-item .bell-text { overflow-wrap: anywhere; }
.bell-item .meta { font-size: 12px; white-space: nowrap; }
.bell-item.unread { color: var(--text); font-weight: 600; }
.bell-icon { display: inline-flex; padding-top: 2px; color: var(--muted); }
.bell-item.unread .bell-icon { color: var(--accent); }
.bell-item .meta { padding-top: 1px; }
.bell-empty { padding: 10px 8px; margin: 0; }
.pill.admin-pill { background: var(--highlight); color: var(--accent); font-size: 11px; }
.pill.user-pill { background: var(--bg); color: var(--muted); border: 1px solid var(--border); font-size: 11px; }

/* Landing page */
.landing { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, 420px); gap: 48px; align-items: start;
           max-width: 1100px; margin: 32px auto 0; }
.topbar-space { height: 51px; }  /* the top bar's height */
.landing-single { grid-template-columns: minmax(320px, 440px); justify-content: center; }
.landing-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }  /* the logo beside the name */
.landing-brand h1 { min-width: 0; }
.landing-logo { flex: none; width: 64px; height: 64px; display: block; }
@media (max-width: 1100px) { .landing-hero .landing-brand h1 { font-size: 28px; } }  /* the name on two lines at most */
.landing-hero h1 { font-size: 34px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.landing-pitch { font-size: 18px; color: var(--muted); margin: 0 0 28px; max-width: 560px; }
.landing-features { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.landing-features li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border);
                       border-radius: 8px; padding: 14px; }
.landing-features .icon { color: var(--accent); flex: none; margin-top: 2px; }
.landing-features strong { display: block; margin-bottom: 2px; }
.landing-features span:not(.pill) { font-size: 14px; color: var(--muted); }
.landing-features .pill { margin-left: 4px; vertical-align: 1px; }
/* To get started: three numbered steps, one a row, boxed like the features: number, what and why, pill */
.landing-h2 { margin: 28px 0 12px; font-size: 18px; }
.landing-needs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.landing-needs li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 14px;
                    background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.landing-needs li > .need-step { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
.landing-needs li > strong { grid-column: 2; grid-row: 1; }
.landing-needs li > .pill { grid-column: 3; grid-row: 1; }
.landing-needs li > span:not(.pill):not(.need-step) { grid-column: 2 / -1; grid-row: 2; font-size: 14px; color: var(--muted); }
.need-step { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
             background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 14px; }
.landing-card { padding: 28px; }
.landing-card h2 { font-size: 20px; }
.landing-form { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 16px; }
.landing-form label { font-weight: 600; font-size: 14px; margin-top: 8px; }
.landing-form input { font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.landing-form input:focus { outline: 2px solid var(--accent-tint); border-color: var(--accent); }
.landing-form button { margin-top: 14px; padding: 10px 14px; }
.landing-privacy { display: flex; gap: 8px; align-items: flex-start; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.landing-privacy .icon { flex: none; margin-top: 2px; color: var(--accent); }
.form-error { background: var(--error-bg); color: var(--danger); border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
@media (max-width: 860px) {
  .landing { grid-template-columns: 1fr; gap: 24px; margin-top: 8px; }
  .landing-features { grid-template-columns: 1fr; }
  .landing-side { order: -1; }  /* on a phone, signing in comes first */
}

/* Users page */
.link-card { border-left: 4px solid var(--accent); }
.link-copy { display: flex; gap: 8px; }
.link-copy input { flex: 1; font: 13px ui-monospace, Consolas, monospace; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
.add-user { display: flex; gap: 8px; }
.add-user input { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; width: 260px; }
.users-filter { margin: 4px 0 10px; }
.users-filter input { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; width: 260px; max-width: 100%; }
.users-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.users-table th.sortable:hover { color: var(--accent); }
.users-table th[aria-sort="ascending"]::after { content: " \25B2"; font-size: 9px; }
.users-table th[aria-sort="descending"]::after { content: " \25BC"; font-size: 9px; }
.users-table td.user-actions { text-align: right; white-space: nowrap; }
.users-table .user-row-actions { display: flex; gap: 14px; justify-content: flex-end; align-items: center; }
.users-table td.user-actions form { margin: 0; }

/* Empire page: the Share dialog */
.share-dialog { width: min(780px, 94vw); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; background: var(--surface); color: var(--text); }
.share-dialog::backdrop { background: light-dark(rgba(15, 36, 51, .5), rgba(0, 0, 0, .65)); }
.share-dialog canvas { width: 100%; height: auto; aspect-ratio: 1200 / 630; display: block; border: 1px solid var(--border); border-radius: 8px; margin: 12px 0; }
.share-option { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 4px 0 12px; font-size: 14px; color: var(--text); cursor: pointer; }
.share-option input { width: auto; margin: 0; padding: 0; flex: none; }
.share-option[hidden] { display: none; }
.share-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#share-open, #resupply-open { display: inline-flex; align-items: center; gap: 8px; }
/* Empire: Resupply and Share stay top right, beside the title on a phone too (right-aligned if they wrap). */
.empire-actions { margin-left: auto; }
@media (max-width: 700px) { #share-open, #resupply-open { gap: 6px; padding-left: 10px; padding-right: 10px; } .empire-actions { gap: 8px; } }
.share-sides { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; border: 0; padding: 0; margin: 10px 0 0; }
.share-sides legend { float: left; font-size: 14px; font-weight: 600; padding: 0; margin-right: 4px; }
.share-sides .share-option { margin: 0; }
.share-sides .share-option:has(input:disabled) { opacity: .5; cursor: default; }

/* Navigation: the admin pages sit in their own amber group, apart from the everyday pages */
.admin-nav { display: flex; align-items: center; gap: 2px; padding: 3px 4px 3px 10px; border-radius: 999px;
             background: var(--admin-bg); border: 1px solid var(--warn-border); }
.admin-nav-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
                   text-transform: uppercase; letter-spacing: .06em; color: var(--admin-text); margin-right: 6px;
                   position: relative; top: 1px; }  /* small capitals sit level with the links' text, not above it */
/* The shield level with the capitals: the box centres it on the line, about 4 px below the capitals' middle at
   11 px. Its box sits 2 px under that middle: a shield is heavy at the top and pointed at the bottom, so it looks
   higher than its box (centred exactly, it looked too high). */
.admin-nav-label .icon { position: relative; top: -2px; }
.topbar .admin-nav a { color: var(--admin-text); text-decoration: none; font-size: 14px; padding: 2px 10px; border-radius: 999px; margin: 0; }
.topbar .admin-nav a:hover { background: var(--admin-hover); }
.topbar .admin-nav a.active { background: #f59e0b; color: var(--admin-active-text); border-bottom: none; }
.topbar .profile-link { display: inline-flex; align-items: center; gap: 5px; color: var(--text); text-decoration: none;
                        padding: 3px 8px; border-radius: 6px; }
.topbar .profile-link:hover, .topbar .profile-link.active { background: var(--highlight); }

/* Profile */
.profile-facts { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; margin: 0 0 12px; }
.profile-facts dt { color: var(--muted); }
.profile-facts dd { margin: 0; }

/* Maintenance: best repair interval */
.repair-plan .plan-summary { margin: 8px 0 12px; }
.plan-pick.active td { background: var(--highlight); }
.plan-pick .plan-tab { font: inherit; }
.plan-chart { margin: 0; position: relative; }
.plan-chart figcaption { margin-bottom: 4px; }
.plan-chart svg { width: 100%; height: auto; display: block; }  /* full width, 1200 × 150 proportions */
.plan-chart .grid { stroke: var(--border); stroke-width: 1; }
.plan-chart .axis { fill: var(--muted); font-size: 11px; }
.plan-chart .band { fill: var(--good-bg); }
.plan-chart .curve { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.plan-chart .best-dot { fill: #65a30d; stroke: var(--surface); stroke-width: 2; }
.plan-chart .best-label { fill: var(--good-text); font-size: 11px; font-weight: 700; }
.plan-chart .current { stroke: var(--muted); stroke-dasharray: 4 3; }
.plan-chart .current-dot { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.plan-chart .legend { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -8px; vertical-align: -1px; }
.key-best { background: #65a30d; border-radius: 50%; }
.key-band { background: var(--good-bg); border: 1px solid var(--good-border); }
.key-current { border: 2px solid var(--text); border-radius: 50%; background: var(--surface); }
.plan-chart .axis, .plan-chart .best-label { font-family: system-ui, "Segoe UI", sans-serif; }
.plan-pick.all td { border-bottom: 2px solid var(--border); }
.plan-chart .hover-area { fill: transparent; cursor: crosshair; }
.plan-chart .hover-line { stroke: var(--text); stroke-width: 1; opacity: .35; }
.plan-chart .hover-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.plan-chart .hover { pointer-events: none; }
.alert-settings { background: var(--warn-bg); color: var(--warn); }
.plan-tip { position: absolute; pointer-events: none; white-space: nowrap; background: var(--text); color: var(--surface);
            font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.plan-chart .band2 { fill: var(--good-soft); }
.key-band2 { background: var(--good-soft); border: 1px solid var(--good-soft-border); }

/* Empire: the numbers under a profit bar */
/* Revenue, the four costs and the profit: one row of six, or two rows of three when it's narrower. */
.fin-breakdown { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: -6px 0 14px; }
@media (max-width: 1200px) { .fin-breakdown { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fin-part { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; background: var(--surface-2); }
.fin-part dt { font-size: 13px; color: var(--muted); display: flex; align-items: center; }
.fin-part dd { margin: 2px 0 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
               font-variant-numeric: tabular-nums; }
.fin-part dd strong { font-size: 15px; }
.fin-part dd span { font-size: 12px; color: var(--muted); }
.fin-part.total { border-color: var(--good-border); background: var(--good-soft); }
@media (max-width: 900px) { .fin-breakdown { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Base groups */
.pill.group-pill { background: light-dark(hsl(var(--group-hue) 70% 93%), hsl(var(--group-hue) 40% 20%)); color: light-dark(hsl(var(--group-hue) 55% 30%), hsl(var(--group-hue) 70% 82%));
                   border: 1px solid light-dark(hsl(var(--group-hue) 50% 82%), hsl(var(--group-hue) 35% 34%)); font-size: 11px; font-weight: 600;
                   padding: 0 7px; margin-right: 6px; vertical-align: 1px; white-space: nowrap; }
.group-cell { white-space: nowrap; }
.group-cell .group-show { font: inherit; }
.group-cell .group-show .group-pill { margin-right: 0; cursor: pointer; }
.group-edit { display: inline-flex; align-items: center; gap: 6px; }
.group-edit input { font: inherit; font-size: 14px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; width: 190px; }
.profit-table .gtotal { display: block; font-size: .75rem; font-weight: 400; color: var(--muted); }
.profit-table .gtotal.warn-text { color: var(--danger); }
.profit-table tr.group-row td { background: var(--surface-2); border-top: 2px solid var(--border); font-weight: 600; }
.profit-table tr.in-group td:first-child { padding-left: 28px; }
.base-title .title-group { text-decoration: none; display: inline-flex; align-items: center; }
.base-title .title-group .group-pill { font-size: 13px; padding: 1px 9px; margin: 0; }

/* Resupply planner */
.rs-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.rs-ships { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.rs-pool { display: flex; flex-direction: column; gap: 8px; min-height: 60px; border-radius: 8px; padding: 2px; }
.rs-pool.over, .rs-base.over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.rs-ship { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); cursor: grab;
           user-select: none; }
.rs-ship:hover { border-color: var(--accent-tint); }
.rs-ship.dragging { opacity: .5; }
.rs-ship.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.rs-ship.away { border-left: 4px solid var(--warn); }
.rs-ship-name { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.rs-where { margin-top: 2px; font-size: 13px; }
.rs-group { padding-bottom: 8px; }
/* Stockpiles and the HQ upgrade side by side, one above the other when there isn't room for both. */
.rs-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 0 20px; align-items: start; }
.rs-top > .card { min-width: 0; }
/* HQ upgrade: Current level -> Target level, labels above the fields, the Ship it toggle on the right. */
.hq-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin: 2px 0 10px; }
.hq-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.hq-field > label, .hq-field-label { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.hq-ship-field { margin-left: auto; }
.hq-field select { min-width: 96px; height: 36px; padding: 0 10px; font: inherit; font-weight: 600; font-variant-numeric: tabular-nums;
                   border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.hq-arrow { display: flex; align-items: center; height: 36px; color: var(--muted); }
.hq-ship { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; height: 36px; margin: 0; padding: 0 14px;
           border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; }
.hq-ship input { margin: 0; width: auto; }
.hq-ship:has(input:checked) { border-color: var(--accent); background: var(--highlight); color: var(--accent); }
@media (max-width: 700px) { .hq-arrow, .hq-ship { height: 44px; } }  /* as tall as a phone's selects */
.rs-base { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
.rs-base.covered { border-color: var(--good-border); background: light-dark(#f9fdf6, #16291f); }
.rs-base header { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.rs-reasons .pill { font-size: 11px; margin-left: 4px; }
.rs-choices { display: flex; gap: 6px 20px; flex-wrap: wrap; margin: 6px 0; font-size: 14px; }
.rs-choices label { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.rs-choices input[type=checkbox] { margin: 0; width: auto; }
.rs-drop { display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; padding: 6px; border: 1px dashed var(--border);
           border-radius: 6px; background: var(--surface-2); }
.rs-drop .rs-ship { flex: 1 1 220px; }
.rs-hint { color: var(--muted); font-size: 13px; align-self: center; }
.rs-cover { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.rs-meter { display: flex; align-items: center; gap: 6px; }
.rs-meter .fill-bar { width: 120px; }
.rs-num { font-variant-numeric: tabular-nums; color: var(--muted); }
.plan-text { font: 13px/1.45 ui-monospace, Consolas, monospace; white-space: pre; overflow-x: auto; padding: 16px 20px; }
.button.muted { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
@media (max-width: 860px) { .rs-layout { grid-template-columns: minmax(0, 1fr); } .rs-ships { position: static; max-height: none; } }
.rs-station-pick { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 13px; font-weight: 400; text-align: left; }
.rs-pile-tools { align-items: center; justify-content: space-between; }
.rs-pile-tools button { font-size: 13px; padding: 3px 12px; }
.rs-pile-table td:first-child label { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.rs-pile-table input[type=checkbox] { margin: 0; width: auto; }
.rs-pile-table .rs-pile-qty { font: inherit; width: 110px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; text-align: right; }
.rs-pile-table .rs-pile-qty.bad { border-color: var(--danger); box-shadow: 0 0 0 2px var(--error-bg); }
.rs-pile-table tr.off td, .sum-cx tr.off td { opacity: .5; }
.rs-pile-others { margin-top: 10px; }
.rs-pile-others > summary { cursor: pointer; }
#rs-form { display: flex; gap: 8px; flex-wrap: wrap; }  /* Reset beside Make the loading plan */
.rs-restored { margin: 8px 0 0; padding: 8px 12px; border-radius: 6px; background: var(--highlight); font-size: 13px; }
.sum-cx { margin-top: 16px; }
/* A station's four values above its table: one strip, cells split by thin lines; To buy stands out. */
.cx-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 14px; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; }
.cx-total { padding: 10px 14px; border-left: 1px solid var(--border); min-width: 0; }
.cx-total:first-child { border-left: 0; }
.cx-total dt { font-size: 12px; color: var(--muted); }
.cx-total dd { margin: 2px 0 0; display: flex; flex-direction: column; }
.cx-total strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.cx-total dd span { font-size: 12px; color: var(--muted); }
.cx-total.none strong { color: var(--muted); font-weight: 600; }
.cx-total.cx-buy { background: var(--highlight); }
.cx-total.cx-buy dt { color: var(--accent); font-weight: 600; }
@media (max-width: 640px) {
  .cx-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cx-total:nth-child(3) { border-left: 0; }
  .cx-total:nth-child(n+3) { border-top: 1px solid var(--border); }
}
.rs-station-pick select { font: inherit; padding: 2px 4px; border: 1px solid var(--border); border-radius: 4px; max-width: 230px; }
/* The station selector never runs past its ship card: it takes the room left beside "Load at", or goes under it. */
.rs-station-pick { flex-wrap: wrap; }
.rs-station-pick .logo-field { flex: 1 1 170px; min-width: 0; max-width: 100%; }
.rs-station-pick .logo-field select { flex: 1 1 auto; min-width: 0; max-width: 100%; }
.rs-ship.needs-station { border-color: var(--danger); box-shadow: 0 0 0 2px var(--error-bg); }

/* Banner: data that couldn't be refreshed */
.data-issues { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--warn-border); padding: 10px 24px; font-size: 14px; }
.data-issues ul { margin: 4px 0 4px 18px; padding: 0; }
.data-issues li { margin: 1px 0; }
.data-issues .meta { color: var(--warn); opacity: .8; }
.data-issues a { color: var(--warn); font-weight: 600; }

/* ---------------------------------------------------------------- Profit history */
.history-changes { display: flex; gap: 8px 28px; flex-wrap: wrap; margin-bottom: 8px; }
.history-changes > div { display: flex; flex-direction: column; gap: 2px; }
.history-changes .trend { font-size: 1.15rem; font-weight: 700; }
/* Profit history: costs from the bottom, the profit on them, the revenue as the line on top */
/* The profit view (idea 65): the line on its fitted scale, and each day's change under it */
.history-chart .profit-line { fill: none; stroke: var(--fin-profit); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.history-chart .profit-line.estimated { stroke-dasharray: 5 4; opacity: 0.7; }
.history-chart .profit-fill { fill: var(--fin-profit); opacity: 0.12; }
.history-chart .profit-fill.estimated { opacity: 0.05; }
.history-chart .profit-end { fill: var(--fin-profit); stroke: var(--surface); stroke-width: 2; }
/* Below a profit of 0: the same line and fill in red (_history.html clips each copy to its side of 0). */
.history-chart .profit-line.loss { stroke: var(--danger); }
.history-chart .profit-fill.loss { fill: var(--danger); }
.history-chart .profit-end.loss { fill: var(--danger); }
.history-chart .profit-zero { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.45; }
.history-chart .change-bar.up { fill: var(--up-text); }
.history-chart .change-bar.down { fill: var(--danger); }
.history-chart .change-bar.estimated { opacity: 0.45; }
.history-chart .bar-break { fill: var(--surface); }
.history-chart .zero-line { stroke: var(--muted); stroke-width: 1; opacity: 0.6; }
.history-chart .event-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.history .view-switch, .why .view-switch { align-self: flex-start; margin-bottom: 8px; }
/* Why profit changed: what it was, a bar from the middle, the amount */
.why-list { list-style: none; margin: 8px 0 0; padding: 0; }
.why-list li { display: grid; grid-template-columns: minmax(0, 3fr) minmax(80px, 2fr) 110px; gap: 4px 16px; align-items: center;
               padding: 7px 0; border-top: 1px solid var(--border); }
.why-list .trend { text-align: right; }
.why-bar { position: relative; height: 12px; }
.why-bar::before { content: ""; position: absolute; left: 50%; top: -5px; bottom: -5px; width: 1px; background: var(--border); }
.why-bar span { position: absolute; top: 0; height: 100%; border-radius: 3px; }
.why-bar .up { left: 50%; background: var(--up-text); }
.why-bar .down { right: 50%; background: var(--danger); }
@media (max-width: 600px) {
  .why-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .why-bar { display: none; }
}
.history-chart .area { stroke: var(--surface); stroke-width: 1; stroke-linejoin: round; }
.history-chart .area-consumables { fill: var(--fin-consumables); }
.history-chart .area-materials { fill: var(--fin-materials); }
.history-chart .area-repairs { fill: var(--fin-repairs); }
.history-chart .area-fees { fill: var(--fin-fees); }
.history-chart .area-profit { fill: var(--fin-profit); }
.history-chart .total { fill: none; stroke: var(--fin-revenue); stroke-width: 2.5; stroke-linejoin: round; }
/* Days rebuilt from prices (idea 53): the same colors, lighter, the revenue line dashed. */
.history-chart .area.estimated { opacity: 0.4; }
.history-chart .total.estimated { stroke-dasharray: 5 4; opacity: 0.7; }
.history > .history-chart { flex-basis: 280px; min-height: 280px; }
/* A base: the graph fills what's left, so Profit history is as tall as Daily profit beside it */
.split > .history > .history-chart { flex-basis: 220px; min-height: 220px; }
@media (max-width: 1000px) { .split > .history > .history-chart { flex-basis: 280px; min-height: 280px; } }  /* stacked */
/* A base's Daily profit: the changes against earlier days, across the bottom of the box */
#finances { display: flex; flex-direction: column; }
.change-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 14px; }
.change-strip > div { flex: 1 1 200px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px;
                      border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; background: var(--surface-2); }
.change-strip .meta { margin: 0; }
.change-strip .trend { font-size: 1.1rem; font-weight: 700; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: 12px; color: var(--muted); }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { margin: 0; }
/* The profit history's two legends in one grid cell: the hidden one keeps its room, so both views are as tall. */
.legend-stack { display: grid; }
.legend-stack > .chart-legend { grid-area: 1 / 1; }
.legend-stack > .chart-legend[hidden] { display: flex; visibility: hidden; }
.swatch.sw-up { background: var(--up-text); }
.swatch.sw-down { background: var(--danger); }
.swatch.sw-loss { background: color-mix(in srgb, var(--danger) 22%, transparent); box-shadow: inset 0 -2px 0 var(--danger); }
/* Market › a material: the legends under the Price history title. */
.price-history > .chart-legend { margin-top: 12px; }
.price-history > .chart-legend + .chart-legend { margin-top: 4px; }
.history-chart .plan-tip div + div { font-weight: 400; }
/* The chart takes the room left under the card's text (on the base page, the height of the Daily profit card
   beside it). The SVG fills the figure; the script draws it at the figure's size (_history.html). */
.history { display: flex; flex-direction: column; }
.history-chart { position: relative; flex: 1 0 240px; min-height: 240px; margin: 8px 0 0; }
/* Beside the Daily profit card, the row is as tall as that card, and the chart fills what's left of it. */
.history-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.history-chart .axis { font-size: 11px; }
.trend { white-space: nowrap; font-variant-numeric: tabular-nums; }
.trend.up { color: var(--up-text); }
.trend.down { color: var(--danger); }
.trend.flat { color: var(--muted); }
.trend-pct { font-weight: 400; font-size: .9em; }

/* ---------------------------------------------------------------- Sell tab */
.sell-table tr.kept td { color: var(--muted); }
.sell-table tr.kept td strong { font-weight: 400; }
.sell-table td:first-child .meta:not(.inline) { display: block; }
.sell-table td:first-child { white-space: normal; min-width: 130px; }
.sell-table .holder { display: block; white-space: nowrap; }
.sell-table .made-at { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; font-size: .8rem; color: var(--muted); }
.sell-table .made-at-base { display: inline-flex; align-items: center; gap: 0; padding: 1px 0; border-radius: 999px; background: var(--highlight); color: var(--accent); font-weight: 600; white-space: nowrap; text-decoration: none; }
.sell-table a.made-at-base:hover { outline: 1px solid var(--accent); }
.sell-table .made-at-name { padding: 0 10px; }
.sell-table .made-at-base.grouped .made-at-name { padding-left: 5px; }
.sell-table .made-at-base .group-pill { display: flex; align-items: center; align-self: stretch; margin: 0; padding: 0 5px 0 10px; border-width: 0; border-radius: 999px 0 0 999px; font-size: inherit; line-height: inherit; }
.keep-input { width: 84px; }
/* A card's title with actions (e.g. a Save button) on the right. */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* ---------------------------------------------------------------- Stockpiles */
/* Rows as tall as their inputs (the same small inputs as the base page's tables), not taller */
.stockpile-table td { padding: 7px 10px; }
.stockpile-table input, .stockpile-table select { padding: 2px 6px; font-size: 14px; }
.stockpile-table input[type=number] { width: 96px; text-align: right; }
.stockpile-table select { max-width: 230px; }
.stockpile-table td.pile-status { white-space: nowrap; }
.stockpile-table .pile-status .fill-bar { display: inline-block; width: 70px; vertical-align: middle; margin-right: 6px; }
.stockpile-table td.c { text-align: center; }
.stockpile-table .pile-new td { background: var(--surface); }
.stockpile-table td.r { white-space: nowrap; }

/* ---------------------------------------------------------------- Config: required keys */
.pill-required { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.pill-optional { background: var(--border); color: var(--muted); font-weight: 600; }
.setup-note { border-left: 4px solid var(--accent); }
.setup-note h2 { margin-top: 0; }
.overview-table td.pile-status { white-space: nowrap; }
.overview-table .pile-status .fill-bar { width: 48px; margin-right: 6px; }

/* ---------------------------------------------------------------- Construction tab */
.pill-planet { background: var(--warn-bg); color: var(--warn); margin-left: 4px; }

/* ---------------------------------------------------------------- Plan tab: production settings and recipes */
.production-settings { padding-top: 14px; padding-bottom: 14px; }
.prod-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.prod-head h2 { margin: 0; }
.prod-status { font-size: 12px; }
.prod-status.ok { color: var(--up-text); }
.prod-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.prod-row { display: flex; gap: 10px 32px; flex-wrap: wrap; align-items: flex-start; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.prod-cell { display: flex; flex-direction: column; gap: 4px; }
.prod-cell select { min-width: 190px; }
.prod-cell .inline-check { flex-direction: row; align-items: center; gap: 6px; height: 34px; color: var(--text); font-size: 14px; }
.prod-value { display: flex; align-items: baseline; gap: 8px; height: 34px; align-items: center; }
/* As many columns as fit with full names (three in a half-width box, more when wider). */
.prod-experts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-items: center; gap: 6px; padding-top: 12px; }
.prod-experts > .prod-label { grid-column: 1 / -1; margin: 0; }
.prod-experts .expert-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.prod-experts .expert-icon { flex: none; width: 1.3em; text-align: center; font-size: 15px; }
.prod-experts .expert { flex-direction: row; align-items: center; justify-content: space-between; gap: 2px; padding: 2px 2px 2px 6px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 11px; color: var(--muted); position: relative; min-width: 0; }
.prod-experts .expert span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-experts .expert { padding: 3px 3px 3px 6px; gap: 4px; font-size: 12.5px; }
.prod-experts .expert.set { color: var(--text); border-color: var(--accent-tint); background: var(--highlight); }
.prod-experts .expert.differs { border-color: var(--warn); }
.prod-experts .expert-ro { flex: none; min-width: 30px; padding-right: 8px; text-align: center; font-size: 13px; }  /* a shared base: the count, as wide as the field */
.prod-experts .expert input { width: 30px; flex: none; padding: 2px 0; text-align: center; font-size: 13px;
  -moz-appearance: textfield; appearance: textfield; }
.prod-experts .expert input::-webkit-inner-spin-button, .prod-experts .expert input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.prod-experts .pp-mark { position: absolute; top: -8px; right: 4px; font-size: 9px; padding: 0 3px; border-radius: 4px;
  background: var(--warn-bg); color: var(--warn); }
.prod-diff { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.plan-buildings td.recipes { min-width: 250px; }
.recipe-row { display: flex; gap: 6px; align-items: center; margin: 2px 0; }
.recipe-row select { width: 240px; text-overflow: ellipsis; font-size: 12px; padding-left: 6px; padding-right: 4px; }
.plan-buildings td.recipes .meta, .plan-buildings .recipe-pp { font-size: 11px; }
.recipe-row .amt-in { width: 48px; }
.recipe-pp { display: block; white-space: normal; overflow-wrap: anywhere; max-width: 240px; }

/* Drafts and migrations */
.alert-migration, .alert-construction { background: var(--highlight); color: var(--accent); }
.pill-draft { background: var(--highlight); color: var(--accent); font-size: 13px; vertical-align: middle; }
/* Construction progress on the base page: how many of the plan's buildings are built (_ui.html build_bar). */
.build-progress { flex: 0 1 auto; max-width: 100%; display: flex; align-items: center; gap: 12px; margin: 0 0 6px; }
.build-progress .meta { white-space: nowrap; }
.build-bar { flex: 0 1 260px; width: 260px; max-width: 100%; height: 6px; border-radius: 999px; background: var(--accent-tint); overflow: hidden; }
.build-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.build-remove { color: var(--warn); font-weight: 700; }
.live-part { display: contents; }  /* a Plan tab box the plan preview redraws: no box of its own */  /* buildings beyond the plan: to take down */
.draft-fields { display: grid; gap: 10px; }
.draft-fields label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.draft-fields input, .draft-fields select { width: 100%; }
.draft-list { margin: 4px 0 8px; padding-left: 18px; }
.migration-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 24px; margin-bottom: 12px; }
.migration-grid h3, .card h3 { font-size: 15px; margin: 8px 0 6px; }
.todo { margin: 0; padding-left: 18px; }
.todo li { margin: 3px 0; }
.todo-in::marker, .todo-in { color: inherit; }
li.todo-in::marker { content: "+ "; color: var(--accent); font-weight: 700; }
li.todo-out::marker { content: "− "; color: var(--danger); font-weight: 700; }
.recipe-line { display: block; font-size: 13px; }
.recipe-line.todo-in { color: var(--accent); }
.recipe-line.todo-out { color: var(--danger); text-decoration: line-through; }
.up { color: var(--accent); }
.down { color: var(--danger); }
.actions-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.confirm-box { border-left: 4px solid var(--accent); }
.compare-planets { margin: 0 0 8px; }
.supply-table.compact { width: auto; min-width: 280px; }

/* Storage at a full restock (base page, Supply and production tab) */
.restock-load.over { border-left: 4px solid var(--danger); }
.load-rows { display: grid; gap: 6px; margin: 4px 0 8px; }
.load-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.load-label { width: 60px; font-weight: 600; }
.load-row .fill-bar { width: 160px; height: 8px; }
.restock-load details { margin-top: 6px; }
.load-chart { margin: 4px 0 8px; }
.load-chart svg { width: 100%; height: auto; display: block; }
.load-chart .grid { stroke: var(--border); stroke-width: 1; }
.load-chart .axis { font-size: 11px; fill: var(--muted, #6b7280); }
.load-chart .full-line { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 5 4; }
.load-line { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.load-line.weight, .peak-dot.weight { stroke: var(--accent); }
.load-line.volume, .peak-dot.volume { stroke: #d97706; }
.peak-dot { fill: var(--surface, #fff); stroke-width: 2.5; }
.load-chart .key { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin: 0 4px 0 10px; }
.load-chart .key-weight { background: var(--accent); }
.load-chart .key-volume { background: #d97706; }
.load-chart .key-full { border-top: 2px dashed var(--danger); height: 0; }
.load-chart .legend { display: block; margin: 6px 0 0; }
.load-chart .legend .key:first-child { margin-left: 0; }

/* Plan tab: Production and, on the base page, the storage over a restock period side by side. */
.plan-top.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; align-items: stretch; }
.plan-top.two > .card { margin-top: 0; min-width: 0; }
@media (max-width: 1200px) { .plan-top.two { display: block; } }

/* Plan tab, under the experts: permits and the area the plan's buildings take. */
.prod-area { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 32px; padding-top: 14px; margin-top: 12px; border-top: 1px solid var(--border); }
.prod-area select { width: auto; }
.prod-housing { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border); }
.prod-housing .inline-check { font-weight: 600; }
.prod-area .area-used .prod-value { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prod-area .fill-bar { width: 120px; height: 8px; }
.max-provision { margin: 4px 0 8px; }

/* ---------------------------------------------------------------- Shared layout (the Empire tabs set the standard)
   Every tab: a row of KPI tiles, then boxes; small boxes go two by two (.split). Card titles start with a
   tinted icon (.title-icon). Long explanations fold away at the bottom of a card (.notes). */
.card { box-shadow: 0 1px 2px rgba(15, 36, 51, .04); }
.tab .icon { flex: none; opacity: .75; }
.tab.active .icon, .tab[aria-selected="true"] .icon, .tab:hover .icon { opacity: 1; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; margin: 0 0 20px; }
.kpi { --tone: var(--accent); --tone-bg: var(--highlight);
       position: relative; overflow: hidden; min-width: 0; display: flex; align-items: flex-start; gap: 12px;
       background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
       box-shadow: 0 1px 2px rgba(15, 36, 51, .04); }
.kpi.good { --tone: var(--tone-good); --tone-bg: var(--tone-good-bg); }
.kpi.bad { --tone: var(--danger); --tone-bg: var(--error-bg); }
.kpi.warn { --tone: light-dark(#b7791f, #e5ac52); --tone-bg: var(--warn-bg); }
.kpi.good::before, .kpi.bad::before, .kpi.warn::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone); }
.kpi-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
            border-radius: 10px; background: var(--tone-bg); color: var(--tone); }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi-value { font-size: 21px; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.bad .kpi-value { color: var(--danger); }
.kpi-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Two boxes side by side, as tall as each other; one column on narrow screens. */
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.split > .card { min-width: 0; display: flex; flex-direction: column; }
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }
.card-foot { margin: auto 0 0; padding-top: 12px; }

/* Card titles: a tinted icon, the title, and the subtitle on the right */
h2.card-title, h2.card-title:has(> .meta.sub) { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
/* Release notes: the date sits on the title's baseline, not centred on it */
.release h2.card-title { align-items: baseline; }
.release-system { margin: 12px 0 0; }
/* A release's highlights (### Featured): cards first, with a star. */
.release-featured { list-style: none; margin: 4px 0 16px; padding: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.featured-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px;
  background: var(--highlight); border: 1px solid var(--accent-tint); }
.featured-item p { margin: 0; }
.featured-icon { flex: none; color: var(--accent); margin-top: 1px; }
.featured-icon svg { fill: currentColor; }
.featured-title { display: block; margin-bottom: 2px; color: var(--text); }  /* "12 various system changes": the [internal] lines, counted */
.title-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
              border-radius: 8px; background: var(--highlight); color: var(--accent); }
h2.card-title .meta.sub a { color: var(--accent); }

/* Folded explanations */
.notes { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 13px; color: var(--muted); }
.card.flush .notes { margin: 0; padding: 10px 20px 14px; border-top: 0; }
.notes summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; list-style: none; }
.notes summary::-webkit-details-marker { display: none; }
.notes summary::after { content: "›"; font-size: 15px; line-height: 1; transition: transform .15s; }
.notes[open] summary::after { transform: rotate(90deg); }
.notes summary:hover { color: var(--accent); }
.notes-body p { margin: 6px 0 0; max-width: 120ch; }

/* Empty boxes: a faint icon and one line, centred in whatever room the box has */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
               padding: 24px 20px 28px; text-align: center; color: var(--muted); }
.empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%;
              background: var(--highlight); color: var(--accent); }
.empty-state p { margin: 0; max-width: 48ch; font-size: 14px; }
.page-section > .empty-state { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }

/* A one-line message at the top of a table card */
.callout { margin: 0 20px 14px; padding: 8px 12px; border-radius: 6px; background: var(--highlight); font-size: 13px; }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
.setting .callout { margin: 0 0 10px; display: flex; gap: 8px; align-items: flex-start; }  /* inside a Config tile */
.setting .callout svg { flex: none; margin-top: 2px; }

/* Overview: what needs attention, one line per check */
/* Same icon tile as the box's title (.title-icon), so every text starts 38px in */
.attention .check { display: flex; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border); }
.attention h2 + .check { border-top: 0; padding-top: 0; }
.attention.has-alert { border-left: 4px solid var(--danger); }
.check-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; }
.check.ok .check-mark { background: var(--tone-good-bg); color: var(--tone-good); }
.check.bad .check-mark { background: var(--error-bg); color: var(--danger); animation: attention-glow 2.4s ease-in-out infinite; }
@keyframes attention-glow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 0%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 22%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .check.bad .check-mark { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 35%, transparent); }
}
.check-body { flex: 1; min-width: 0; }
.check h3 { display: flex; align-items: baseline; gap: 6px; margin: 0; font-size: 14px; }
.check h3 .sub { margin-left: auto; font-size: 12px; font-weight: 400; }
.check.bad h3 .count { color: var(--danger); font-weight: 700; }
.check .meta { margin: 1px 0 0; font-size: 13px; }
.check-list { margin: 4px 0 0; padding: 0; list-style: none; }
.check-list li { padding: 2px 0; }

/* Profit split as a list (the Overview's half-width box) */
.stacked .fin-breakdown { grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0; }
.stacked .fin-breakdown .fin-part { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 12px; }
.stacked .fin-breakdown .fin-part dd { margin: 0; gap: 16px; }
.stacked .fin-breakdown .fin-part dd span { min-width: 52px; text-align: right; }


/* Bases tab: resupply and repairs side by side */
.resupply-card p { margin: 0; }
.resupply-card.needed, .repairs-due:not(.ok) { border-left: 4px solid var(--danger); }
.repairs-due .meta { margin: 0; }

/* Material picker (_ui.html material_picker, material-picker.js): materials listed as in the tables */
.mat-pick { position: relative; display: inline-block; width: 220px; max-width: 100%; vertical-align: middle; }
.mat-pick .mat-input { width: 100%; }
.mat-pick-show { position: absolute; inset: 1px; display: none; align-items: center; gap: 8px; padding: 0 9px;
                 border-radius: 5px; background: var(--surface-2); pointer-events: none; overflow: hidden; white-space: nowrap; }
.mat-pick.chosen .mat-pick-show { display: flex; }
.mat-pick.chosen .mat-input { color: transparent; }
.mat-pick:has(.mat-input:placeholder-shown) .mat-pick-show { display: none; }
.mat-pick-show .mat-name, .mat-list .mat-name { overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.mat-list { position: fixed; z-index: 50; right: auto; top: auto; max-width: 420px; }
.mat-list li { display: flex; align-items: center; gap: 10px; padding: 5px 10px; }
.mat-list li .mat-tile { flex: none; }
.mat-list li.active { background: var(--highlight); }
.mat-list li.active .mat-name { color: var(--accent); }
.mat-list .mat-none { color: var(--muted); cursor: default; }

/* Shared layout on every page */
.page-head + .kpis, .page-head + .flash + .kpis { margin-top: 16px; }
.kpi-value.neg { color: var(--danger); }
.kpi:has(.kpi-value.neg) { --tone: var(--danger); --tone-bg: var(--error-bg); }
.card .kpis .kpi { background: var(--surface-2); box-shadow: none; }
.base-main .kpis { margin-bottom: 14px; }
.split.split-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
@media (max-width: 1000px) { .split.split-wide { grid-template-columns: minmax(0, 1fr); } }
.add-row h2 { display: inline-flex; align-items: center; gap: 8px; }
.base-side h2.card-title { margin-bottom: 10px; }
.base-side .title-icon { width: 24px; height: 24px; }
.construction-notes .meta { margin: 0 0 4px; }
.construction-top > :only-child { grid-column: 1 / -1; }
@media (max-width: 1200px) { .split.construction-top { grid-template-columns: minmax(0, 1fr); } }  /* narrower, the Population table would scroll */
.base-alerts h2.card-title { margin-bottom: 8px; }
.plan-table .mat-pick { width: 190px; }

/* Building picker: buildings the planet's CoGC program boosts */
.mat-list li.cogc { background: var(--good-soft); }
.mat-list li.cogc.active { background: var(--highlight); }
.pill.cogc-pill { margin-left: auto; flex: none; font-size: 11px; background: var(--good-bg); color: var(--good-text); }

/* Recipe selectors (Plan tab): recipes drawn with ticker tiles */
select.recipe-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.recipe-row { position: relative; }
.recipe-btn { display: inline-flex; align-items: center; gap: 6px; min-width: 215px; max-width: 100%; min-height: 30px; padding: 3px 26px 3px 8px;
              position: relative; font: inherit; font-weight: 400; font-size: 13px; color: var(--text); text-align: left; white-space: normal;
              background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.recipe-btn:hover { border-color: var(--accent-tint); }
.recipe-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.recipe-btn.empty { color: var(--muted); }
.rc-caret { position: absolute; right: 10px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
            border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); }
.rc-recipe { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.rc-part { display: inline-flex; align-items: center; gap: 2px; }
.rc-n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rc-arrow { color: var(--muted); margin: 0 2px; }
.rc-recipe .mat-tile { min-width: 34px; padding: 1px 4px; font-size: 11px; }
.recipe-list li { gap: 8px; }
.recipe-list li.rc-plain { color: var(--muted); }
.plan-table input[disabled] { background: var(--bg); color: var(--muted); cursor: not-allowed; }

/* Empire > Balance: consumed / produced per item; the grayed small numbers are what the plans still add. */
.balance-table { width: 100%; }
.balance-table .coming { display: block; font-size: .75rem; font-weight: 400; color: var(--muted); }
.balance-table .bases-n { display: inline-block; box-sizing: border-box; width: 2.4em; margin-left: 8px; padding: 0; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-size: .75rem; color: var(--muted); text-align: center; }
.balance-section th { text-align: left; background: var(--bg); }
.balance-section th.r { text-align: right; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--text); }
.balance-section th.r.warn-text { color: var(--danger); }
.balance-section th .coming { font-weight: 400; }
.balance-row { cursor: pointer; }
.balance-row:hover, .balance-row:focus-visible { background: var(--highlight); }
.balance-row td:first-child::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); }
.balance-row[aria-expanded="true"] td:first-child::before { content: "▾"; }
.balance-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; padding: 4px 8px 8px 24px; white-space: normal; }
.balance-split h3 { margin: 0 0 4px; font-size: .85rem; color: var(--muted); }
.balance-split h3:not(:first-child) { margin-top: 16px; }  /* "Repairs at" under the consumers' list */
.balance-bases { list-style: none; margin: 0; padding: 0; column-width: 340px; column-gap: 28px; }
.balance-bases li { display: flex; gap: 8px; align-items: baseline; break-inside: avoid; }
.balance-base { display: inline-flex; align-items: center; flex-wrap: nowrap; min-width: 0; }
.balance-base a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.balance-bases .num { margin-left: auto; font-variant-numeric: tabular-nums; }
.balance-bases .coming { display: inline; }

/* Price trend arrow (Price risk tables, Overview's Top price risks): blue up, red down, plain when flat; a grey dash for thin markets */
.price-trend { display: inline-flex; vertical-align: middle; }
.price-trend .icon { stroke-width: 2.5; }
.price-trend[data-direction="up"] { color: var(--accent); }
.price-trend[data-direction="down"] { color: var(--danger); }

/* Building pills after a base's name: the 2 production buildings that make the most (or the ones pinned) */
.pill.bld-pill { margin-left: 4px; padding: 1px 7px; font-size: 11px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); vertical-align: 1px; }
.pill.bld-pill.pinned { border-color: var(--accent); color: var(--accent); }
/* "Building" (the plan isn't all built yet), beside the building pills: their size and shape, the accent tint. */
.pill.bld-pill.build-state { background: var(--highlight); color: var(--accent); border-color: transparent; margin-left: 6px; }
.base-title .title-pills { display: inline-flex; gap: 2px; margin-left: 8px; }
.base-title .title-pills .bld-pill { font-size: 12px; margin-left: 0; }
.plan-link-form { margin: 8px 0; }
.plan-link-form label { display: block; margin-bottom: 4px; }
.plan-link-form .plan-row select { flex: 1 1 auto; }

/* Loading plan summary */
.sum { margin-bottom: 20px; }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 14px; }
.sum-base header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.sum-parts { display: flex; gap: 6px; flex-wrap: wrap; }
.sum-base > .sum-parts { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }  /* at the bottom, under the ships */
.sum-base { display: flex; flex-direction: column; }  /* so the pills line up at the bottom of every box in a row */
.sum-ship { display: flex; justify-content: space-between; align-items: center; gap: 6px 14px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.sum-route { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sum-arrow { color: var(--muted, #667); font-size: 13px; }
.sum-ship .fill-bar { width: 110px; height: 8px; }
.sum-short { margin: 8px 0 0; font-size: 13px; color: var(--danger); }
.sum-buy { border-left: 3px solid var(--accent); }
.sum-buy header > div { display: flex; align-items: center; gap: 8px; }  /* the icon tile beside the title, centered */
.sum-details-box { margin-top: 20px; }
.sum-details-box summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

button.danger-button { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.turnstile { margin: 8px 0; min-height: 65px; }
.landing-side { display: flex; flex-direction: column; gap: 16px; }
.recovery-title { display: flex; gap: 6px; align-items: center; font-size: 16px; margin: 16px 0 4px; }
.recovery-row { display: flex; gap: 8px; margin: 12px 0 4px; }
.recovery-code { flex: 1; min-width: 0; font: 600 18px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.notice-box { border-left: 4px solid var(--danger); }
.recovery-reminder { display: flex; gap: 6px; align-items: center; margin: 0; padding: 6px 24px; font-size: 13px; background: var(--highlight); color: var(--text); }
.token-value { font-size: 14px; }
.token-example { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.release-pill { background: var(--highlight); color: var(--accent); font-size: 11px; vertical-align: 1px; }

/* ---------------------------------------------------------------- Profile
   A header, a section menu on the left (a row of chips on a phone), and one card per section. Each action is
   one row (a <details>): what it is, its status, and a button that opens its form. */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-head .page-title { margin: 0; }
.profile-head .page-title::before { display: none; }
.profile-head p { margin: 2px 0 0; }
.profile-avatar { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-size: 22px; font-weight: 700; }
.profile-notice { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.profile-notice p { margin: 0; flex: 1 1 360px; }
.profile-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 16px; }
.profile-main { max-width: 760px; min-width: 0; }
.profile-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; }
.profile-nav a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.profile-nav a:hover { background: var(--surface); color: var(--accent); }
.profile-nav a .icon { color: var(--muted); flex: none; }
.profile-nav a.nav-danger, .profile-nav a.nav-danger .icon { color: var(--danger); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-left: auto; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.profile-section { scroll-margin-top: 16px; }
.profile-section > .card-title { margin-bottom: 12px; }
.profile-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.profile-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); text-decoration: none; }
a.profile-tile:hover { border-color: var(--accent); }
.tile-value { font-size: 20px; font-weight: 700; }
.tile-label { font-size: 13px; color: var(--muted); }
/* The Account box's company, from FIO (idea 72): who it is, then its HQ, level and permits, then the bonus. */
.company-box { margin-top: 16px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); display: grid; gap: 14px; }
.company-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.company-monogram { flex: none; display: inline-grid; place-items: center; min-width: 48px; height: 48px; padding: 0 8px;
  border-radius: 10px; background: var(--accent-tint); color: var(--accent); font-weight: 700; font-size: 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); }
.company-names { display: flex; flex-direction: column; min-width: 0; }
.company-names strong { font-size: 17px; overflow-wrap: anywhere; }
.company-names .meta { font-size: 12px; }
.company-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 0; }
.company-facts > div { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.company-facts dt { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); }
.company-facts dt .icon { color: var(--accent); }
.company-facts dd { margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.company-facts dd strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.company-sub { flex-basis: 100%; font-size: 12px; }
.company-logo { flex: none; border-radius: 4px; }
.company-bar { flex-basis: 100%; height: 6px; margin-top: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.company-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.company-bonus { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.company-bonus-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-weight: 600; }
.company-bonus-head .icon { align-self: center; color: var(--tone-good); }
.company-bonus-list { display: flex; flex-wrap: wrap; gap: 6px; }
.company-bonus-list .bonus { padding: 3px 10px; border-radius: 999px; background: var(--tone-good-bg);
  border: 1px solid var(--good-soft-border); }
.company-bonus-list .bonus strong { color: var(--tone-good); }
.profile-privacy { display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; }
.profile-privacy .icon { flex: none; margin-top: 2px; color: var(--accent); }

/* Appearance: a button per theme, with a small picture of the app in it. */
.theme-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
button.theme-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 8px 10px; text-align: left;
  white-space: normal; font-weight: 400; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; }
button.theme-choice:hover { border-color: var(--accent); }
button.theme-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.theme-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--highlight); }
.theme-preview { display: flex; width: 100%; aspect-ratio: 16 / 10; margin-bottom: 6px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
/* Each picture sets its own color-scheme, so the app's colors come out light or dark whatever the page's theme. */
.theme-mock { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.theme-mock-light { color-scheme: light; }
.theme-mock-dark { color-scheme: dark; }
.mock-bar { height: 17%; background: var(--surface); border-bottom: 1px solid var(--border); }
.mock-card { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 9%; margin: 9% 10%; padding: 0 9%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.mock-card i { height: 8%; width: 80%; border-radius: 99px; background: var(--muted); opacity: .45; }
.mock-card i:first-child { width: 55%; background: var(--text); opacity: .75; }
.mock-card i.mock-accent { height: 14%; width: 38%; background: var(--accent); opacity: 1; }
/* System: the two halves of one window, light on the left and dark on the right. */
.theme-preview-system .mock-card { margin-left: 18%; margin-right: 0; border-right: 0; border-radius: 4px 0 0 4px; }
.theme-preview-system .theme-mock-dark .mock-card { margin-left: 0; margin-right: 18%; border-right: 1px solid var(--border); border-left: 0; border-radius: 0 4px 4px 0; }
.theme-preview-system .theme-mock-dark .mock-card i { visibility: hidden; }
.theme-name { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; font-weight: 700; font-size: 14px; }
.theme-check { display: inline-flex; color: var(--accent); visibility: hidden; }
.theme-choice[aria-pressed="true"] .theme-check { visibility: visible; }
.theme-choice .meta { font-size: 12px; }

.setting { border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; }
.setting > summary { display: flex; align-items: center; gap: 16px; padding: 14px 0; cursor: pointer; list-style: none; }
.setting > summary::-webkit-details-marker { display: none; }
.setting-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.setting-text strong { display: flex; align-items: center; gap: 8px; }
.setting-action { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.setting[open] > summary .setting-action { visibility: hidden; }
.setting-body { padding: 0 0 18px; }
.stack-form { display: flex; flex-direction: column; gap: 6px; max-width: 380px; }
.stack-form label { font-weight: 600; font-size: 14px; margin-top: 6px; }
.stack-form input, .stack-form select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.stack-form .actions { margin-top: 10px; }
.inline-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-fields select { flex: 1; }
.token-form .expiry-date { display: none; }
.token-form:has(option[value="date"]:checked) .expiry-date { display: block; }

.token-list { list-style: none; margin: 4px 0 8px; padding: 0; }
.token-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.token-row:first-child { border-top: 0; }
.token-icon { width: 34px; height: 34px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--highlight); color: var(--accent); }
.token-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.token-main .meta { font-size: 13px; }
.token-row.token-ended .token-icon { background: var(--surface-2); color: var(--muted); }
.token-row.token-ended strong { color: var(--muted); }
.empty-note { color: var(--muted); margin: 4px 0 8px; }
.ended-tokens { margin: 0 0 8px; }
.ended-tokens > summary, .example > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.ended-tokens > summary:hover, .example > summary:hover { color: var(--accent); }
#tokens > .setting { border-top: 1px solid var(--border); }
#appearance > .setting { margin-top: 18px; border-top: 1px solid var(--border); }  /* the time zone, after the themes */

.connect-box { margin-top: 8px; padding: 14px 16px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.connect-box h3 { margin: 0 0 6px; font-size: 15px; }
.connect-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 10px; align-items: center; padding: 8px 0; }
.connect-label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.connect-label .meta { font-weight: 400; font-size: 13px; }
.connect-value { font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; white-space: nowrap; }
.copy-button { padding: 5px 8px; }
.copy-button.copied { border-color: var(--accent); background: var(--highlight); }
.connect-box > .meta { margin: 8px 0 0; }
.example { margin-top: 4px; }
/* Profile: connecting PRUNplanner's MCP server too (idea 48). */
.pp-mcp { margin: 8px 0 4px; font-size: 14px; }
.pp-mcp > p { margin: 0 0 6px; }
.pp-mcp > ul { margin: 4px 0 6px; padding-left: 20px; }
.pp-mcp > ul li + li { margin-top: 3px; }
.pp-mcp > .meta { margin: 6px 0 0; }
/* Fine print at the foot of the PRUNplanner part: set apart by a thin line, quiet but not lost. */
.pp-mcp > .pp-disclaimer { display: flex; gap: 6px; align-items: flex-start; margin: 10px 0 0; padding-top: 8px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.pp-disclaimer svg { flex: none; margin-top: 1px; }
.rate-limits { margin: 8px 0 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.rate-limits > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 10px; }
.rate-limits > div + div { border-top: 1px solid var(--border); }
.rate-limits dd { flex: none; margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rate-note { margin: 0 0 4px; }

.delete-account { border-color: light-dark(#f3c7c3, #6b2f2f); }
.delete-account > .card-title { color: var(--danger); }
.delete-account > .card-title .title-icon { background: var(--error-bg); color: var(--danger); }

@media (max-width: 800px) {
  .profile-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .profile-nav { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .profile-nav a { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); padding: 6px 10px; }
  .nav-dot, .nav-count { margin-left: 2px; }
  .profile-tiles { gap: 8px; }
  .profile-tile { padding: 10px; }
  .tile-value { font-size: 17px; }
  .theme-choices { gap: 8px; }
  button.theme-choice { padding: 6px 6px 8px; }
  .connect-row { grid-template-columns: minmax(0, 1fr) auto; }
  .connect-row .connect-label { grid-column: 1 / -1; }
  .connect-value { white-space: normal; word-break: break-all; }
}

/* ---------------------------------------------------------------- API usage (admin) */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: var(--on-danger);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; margin-left: 2px; }
.usage-alert { background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 8px 12px; }
.usage-change { color: var(--muted); }
.usage-change.up { color: var(--warn); }
.usage-legend { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch.mcp, .usage-bar .seg.mcp { background: var(--accent); }
.swatch.api, .usage-bar .seg.api { background: var(--accent-tint); }
.usage-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.usage-bar { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; min-width: 0; }
.usage-bar:hover .seg { filter: brightness(.9); }
.usage-bar .seg { display: block; width: 100%; }
.usage-bar .seg.mcp { border-radius: 2px 2px 0 0; }
.usage-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.usage-grid { display: grid; grid-template-columns: minmax(200px, 2.4fr) repeat(6, minmax(64px, 1fr)) minmax(90px, 1fr);
  gap: 8px; align-items: center; padding: 10px 16px; }
.usage-grid .r { text-align: right; }
.usage-head { font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); padding-top: 4px; padding-bottom: 6px; }
.usage-user { border-bottom: 1px solid var(--border); }
.usage-user > summary { cursor: pointer; list-style: none; }
.usage-user > summary::-webkit-details-marker { display: none; }
.usage-user > summary:hover { background: var(--surface-2); }
.usage-user[open] > summary { background: var(--highlight); }
.usage-user.flagged > summary { box-shadow: inset 3px 0 0 var(--warn); }
.usage-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.usage-who .meta { flex-basis: 100%; font-size: 12px; }
.usage-who strong::before { content: "▸"; color: var(--muted); display: inline-block; width: 1em; }
.usage-user[open] .usage-who strong::before { content: "▾"; }
.usage-body { padding: 4px 16px 16px; }
.usage-flag { margin: 4px 0; background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 6px 10px; font-size: 14px; }
.usage-tokens td, .usage-tokens th { white-space: nowrap; }
.usage-tools-row > td { padding-top: 0; }
.usage-tools > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.usage-tools > summary:hover { color: var(--accent); }
.usage-tools table { margin: 6px 0 4px; }
.plain-list { margin: 4px 0; padding-left: 18px; }
@media (max-width: 900px) {
  .usage-grid { grid-template-columns: minmax(0, 1fr) repeat(2, minmax(56px, auto)); }
  .usage-grid > :nth-child(n+4) { display: none; }
}
.token-usage { color: var(--text); }
.usage-summary { display: flex; gap: 6px; align-items: flex-start; margin: 4px 0 10px; }
.usage-summary .icon { flex: none; margin-top: 3px; }
.admin-nav a { white-space: nowrap; }

/* ---------------------------------------------------------------- Phone (700 px and less; tablets get the desktop)
   The pages a player checks on a phone: the Overview, a base's status, Stockpiles, Sell and Ships.
   The page itself never scrolls sideways. Forms and the plan editor stay as on a computer. */
.top-menu { display: contents; }  /* on a computer the menu's parts sit in the top bar itself */
.menu-toggle, .ph-more, .ph-warn { display: none; }
@media (min-width: 701px) { .ph-only { display: none !important; } }  /* parts only a phone shows */

@media (max-width: 700px) {
  main { padding: 12px 12px 32px; }
  /* Boxes and banners go from one edge of the screen to the other (the KPI tiles keep their space).
     A box with a colored left edge keeps it. */
  main :is(.card, .errors, .warnings, .flash) { margin-left: -12px; margin-right: -12px; border-radius: 0; }
  main .card { padding: 14px 12px; border-left-width: 0; border-right-width: 0; }
  main .card.flush { padding: 0; }
  main .card:is(.base-alerts, .attention.has-alert, .resupply-card.needed, .repairs-due:not(.ok), .setup-note) { border-left-width: 4px; }
  main :is(.pad-h, .base-main .pad-h) { padding-left: 12px; padding-right: 12px; }
  .app-footer { padding: 12px 12px 20px; }

  /* Top bar: a menu button. The menu lists only the pages that work on a phone (the rest are .desk-only). */
  .topbar { flex-wrap: wrap; gap: 0 8px; padding: 6px 12px; }
  .brand { flex: 1; min-width: 0; font-size: 14px; }
  .menu-toggle { display: inline-flex; align-items: center; gap: 6px; background: transparent; color: var(--accent); }
  .top-menu { display: none; flex-basis: 100%; flex-direction: column; }
  .topbar > .bell { order: 0; margin-left: 0; position: static; }
  .topbar > .bell ~ .top-menu .account { order: 0; }
  .bell-panel { position: fixed; left: 12px; right: 12px; top: 52px; width: auto; }
  .top-menu.open { display: flex; }
  .desk-only { display: none !important; }  /* beats the menu's own link styles */
  .topbar .top-menu nav { display: flex; flex-direction: column; }
  .topbar .top-menu nav a { display: flex; align-items: center; min-height: 44px; margin: 0; border-bottom: 1px solid var(--border); }
  .topbar .top-menu nav a.active { border-bottom: 2px solid var(--accent); }
  .topbar .account { margin: 0; justify-content: space-between; min-height: 44px; }
  /* The admin group in the menu: a box of its own under the pages, with only Users (idea 49). */
  .topbar .top-menu nav.admin-nav { align-items: stretch; gap: 0; margin: 8px 0; padding: 6px 10px; border-radius: 8px; }
  .topbar .top-menu nav.admin-nav a { min-height: 44px; padding: 0 6px; border-radius: 6px; border-bottom: 0; font-size: 15px; }
  .topbar .top-menu nav.admin-nav a.active { border-bottom: 0; }
  /* Users (admin): each account shows its role, status and actions; a tap opens the rest. The actions wrap,
     each a full-size target, so a new password link or an invite is one tap on a phone. */
  .users-table.phone-rows.phone-rows tr > td.user-actions.ph-key { flex: 1 1 100%; text-align: left; white-space: normal; }
  .users-table .user-row-actions { justify-content: flex-start; flex-wrap: wrap; gap: 4px 16px; }
  .users-table .user-row-actions .link { min-height: 44px; }
  .users-filter input { width: 100%; }
  .link-copy { flex-wrap: wrap; }
  .link-copy input { flex: 1 1 100%; }
  .link-copy button { flex: 1 1 100%; min-height: 44px; }

  /* Tabs: one strip that scrolls sideways (app.js keeps the open tab in view) */
  .tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
  .tab { flex: none; margin-bottom: 0; padding: 10px 12px; }
  /* The Empire's eight tabs: all in sight, four across, each icon above its name and its count in the corner */
  .tabs.tabs-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; overflow: visible; border-bottom: 0; margin-top: 18px; }
  .tabs.tabs-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }  /* a base's and a draft's six */
  .tabs.tabs-grid .tab.tab { position: relative; flex-direction: column; justify-content: center; gap: 2px; min-height: 58px; padding: 6px 2px;
                    font-size: 12px; line-height: 1.2; text-align: center; white-space: normal;
                    background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
  .tabs-grid .tab.active, .tabs-grid .tab[aria-selected="true"] { border-color: var(--accent); background: var(--highlight); }
  .tabs-grid .tab-badge { position: absolute; top: 3px; right: 3px; min-width: 18px; padding: 0 4px; font-size: 10px; line-height: 16px; }

  /* A page's Save button (.ph-save): nothing while there's nothing to save; with changes, a bar held at the
     top of the screen, wherever the page is scrolled to. */
  .ph-save.ph-save:has(button:disabled) { display: none; }
  .ph-save.ph-save:not(:has(button:disabled)) { position: fixed; top: 0; left: 0; right: 0; z-index: 900; display: flex; flex-wrap: nowrap;
    align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 8px 12px; background: var(--surface);
    border-bottom: 2px solid var(--accent); box-shadow: 0 4px 12px rgba(0, 0, 0, .18); }

  /* Landing page: signing in first, then what the app does; the boxes go from edge to edge */
  .topbar-space { display: none; }
  .landing { gap: 20px; margin-top: 0; }
  .landing-hero .landing-brand h1 { font-size: clamp(21px, 6.6vw, 26px); }
  .landing-pitch { font-size: 16px; margin-bottom: 18px; }
  .landing-brand { gap: 12px; }
  .landing-logo { width: 52px; height: 52px; }
  .landing-features, .landing-needs { grid-template-columns: minmax(0, 1fr); gap: 0; margin-left: -12px; margin-right: -12px; }
  .landing-needs li { padding: 12px; }
  .landing-features li, .landing-needs li { border-width: 0 0 1px; border-radius: 0; padding: 12px; }
  .landing-features li:first-child, .landing-needs li:first-child { border-top-width: 1px; }
  .landing-privacy { margin-bottom: 0; }

  /* Profile: its section links as a grid, like the tabs: icon over name, the count or dot in the corner */
  .profile-nav.profile-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; overflow: visible; padding: 0; }
  .profile-nav.profile-nav a { position: relative; flex-direction: column; justify-content: center; gap: 2px; min-height: 58px; padding: 6px 2px;
    font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; white-space: normal; background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; }
  .profile-nav .nav-dot, .profile-nav .nav-count { position: absolute; top: 5px; right: 6px; margin: 0; }

  /* Headings */
  .sticky-head { position: static; }
  /* A base's heading: big arrows to the previous and next base on top, its name underneath */
  .base-title { flex-wrap: wrap; width: 100%; }
  .base-title::after { content: ""; order: -1; flex-basis: 100%; }  /* ends the arrows' line */
  .base-title .base-step.base-step { order: -2; display: inline-flex; align-items: center; justify-content: center;
                                     width: 60px; height: 44px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
  .base-title .base-step svg { width: 28px; height: 28px; }
  .base-title #next-base { margin-left: auto; }
  /* The Share button between the arrows, in the middle of their line (idea 24). */
  .base-title .share-open-ph { order: -2; margin: 0 auto; height: 44px; min-height: 44px; font-size: 15px; }  /* as tall as the arrows */
  .base-title .share-open-ph ~ #next-base { margin-left: 0; }
  /* A base: no explaining texts beside headings and lines */
  .base-layout h2 > .meta.sub, .base-layout .fin-table .meta, .base-side .defaults > p.meta { display: none; }
  /* The Bases page's forms for a new base or draft: one field a line */
  .add-base .add-row { flex-direction: column; align-items: stretch; }
  .add-base .add-row > * { flex: none; width: 100%; min-width: 0; }
  .add-base .plan-row { flex-wrap: wrap; }
  .add-base .plan-row > * { flex: 1 1 100%; min-width: 0; width: 100%; }

  /* A base: Defaults, Plan, Drafts and Inventory are the Settings tab, under the tabs like the others */
  .base-layout { display: flex; flex-direction: column; align-items: stretch; }
  .base-main { order: -1; }
  .base-side.ph-away { display: none; }

  /* KPI tiles two by two */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-icon { display: none; }
  .kpi-value { font-size: 18px; }
  .kpi-sub { white-space: normal; }

  /* "Where the revenue goes": one part per line */
  .fin-breakdown, .stacked .fin-breakdown { grid-template-columns: minmax(0, 1fr); }

  /* Tables (class phone-rows): each row shows its name and the columns marked data-key in the template.
     Tapping a row shows the others, each with its column's title (app.js puts it in data-label). */
  table.phone-rows.phone-rows, table.phone-rows > tbody, table.phone-rows > tfoot { display: block; width: 100%; min-width: 0; table-layout: auto; }
  table.phone-rows > colgroup, table.phone-rows > thead { display: none; }
  table.phone-rows.phone-rows tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 12px; height: auto; padding: 10px 12px;
                        border-bottom: 1px solid var(--border); }
  table.phone-rows.phone-rows tfoot tr { border-top: 2px solid var(--border); border-bottom: 0; }
  table.phone-rows.phone-rows tr > td { display: none; width: auto; height: auto; padding: 0; border: 0; background: none; white-space: normal; text-align: left; }
  table.phone-rows.phone-rows tr > td:first-child { display: block; order: 0; flex: 1 1 100%; min-width: 0; max-width: none; padding: 0; }
  table.phone-rows.phone-rows tr > td.ph-key { display: block; order: 1; flex: 1 1 0; min-width: 76px; }
  table.phone-rows td.ph-key[data-label]::before { content: attr(data-label); display: block; font-size: 10px; font-weight: 600;
                        text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  /* An opened row, and the row that adds a stockpile: every other cell on its own line */
  table.phone-rows.phone-rows tr.ph-open > td:not(:first-child):not(.ph-key):not(:empty),
  table.phone-rows.phone-rows .pile-new tr > td:not(:first-child):not(:empty) {
    display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px 8px; order: 3; flex: 1 1 100%; text-align: right; }
  table.phone-rows tr.ph-open > td[data-label]:not(:first-child):not(.ph-key):not(:empty)::before,
  table.phone-rows .pile-new td[data-label]:not(:first-child):not(:empty)::before {
    content: attr(data-label); margin-right: auto; font-size: 12px; color: var(--muted); text-align: left; }
  table.phone-rows tbody tr.ph-more-row { cursor: pointer; }
  table.phone-rows.phone-rows tr.ph-more-row > td:first-child { position: relative; padding-right: 44px; min-height: 32px; }
  table.phone-rows .ph-more { display: inline-flex; align-items: center; justify-content: center; position: absolute; top: -6px; right: -8px;
                        width: 44px; height: 44px; padding: 0; background: transparent; border: 0; color: var(--muted); }
  .ph-more::after { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
  .ph-more[aria-expanded="true"]::after { transform: rotate(-135deg); }
  /* A highlighted row colors the whole row, not each cell */
  table.phone-rows tr.restock, table.phone-rows tr.alert-red, table.phone-rows tr.repair-soon { background: var(--error-bg); }
  table.phone-rows tr.soon { background: var(--warn-bg); }
  table.phone-rows .calc { display: block; white-space: normal; }

  /* A red triangle instead of words */
  .ph-hide { display: none !important; }
  .ph-warn { display: inline-flex; vertical-align: -4px; margin-left: 6px; color: var(--danger); }
  .pile-status .ph-warn { margin-left: 0; }

  /* Ships: Status narrow, Location / route beside it */
  table.ships-table.phone-rows.phone-rows tr > td.ph-key:nth-child(3) { flex: 0 0 76px; }

  /* Stockpiles, an opened row and the row that adds one: Station on a line, then the two amounts side by side,
     each under its title */
  table.stockpile-table.phone-rows.phone-rows tr > td:nth-child(2) .logo-field { width: 70%; }
  table.stockpile-table.phone-rows.phone-rows tr > td:nth-child(2) .logo-field select { flex: 1; max-width: none; }
  table.supply-table.stockpile-table.phone-rows.phone-rows tr.ph-open > td:is(:nth-child(4), :nth-child(5)),
  table.stockpile-table.phone-rows.phone-rows .pile-new tr > td:is(:nth-child(4), :nth-child(5)) {
    flex: 1 1 40%; flex-direction: column; align-items: stretch; text-align: left; }
  table.stockpile-table.phone-rows td:is(:nth-child(4), :nth-child(5))::before { margin-right: 0; }
  table.stockpile-table.phone-rows.phone-rows td:is(:nth-child(4), :nth-child(5)) input { width: 100%; text-align: left; }
  table.stockpile-table.phone-rows input[type=checkbox] { width: 22px; height: 22px; }
  table.stockpile-table.phone-rows .pile-new .mat-pick { width: 100%; }

  /* Balance: its section lines, and the bases under an opened item, one list under the other */
  table.balance-table.phone-rows.phone-rows .balance-section tr { justify-content: space-between; align-items: baseline; background: var(--bg); }
  table.balance-table.phone-rows .balance-section th { padding: 0; border: 0; }
  table.balance-table.phone-rows .coming { display: block; }
  table.balance-table.phone-rows .balance-bases .coming { display: inline; }
  .balance-split { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 0; }
  .balance-bases { column-width: auto; }

  /* Details that wait for the row to be opened: where a Sell material is made, and made − used in Market depth */
  table.sell-table.phone-rows tr:not(.ph-open) .made-at,
  table.depth-table.phone-rows tbody tr:not(.ph-open) .calc { display: none; }

  /* Profitability: a group's line stands out, its bases are set in a little; the bar takes the whole line */
  table.profit-table.phone-rows.phone-rows tr.group-row { background: var(--surface-2); border-top: 2px solid var(--border); font-weight: 600; }
  table.profit-table.phone-rows.phone-rows tr.in-group { padding-left: 24px; }
  table.profit-table.phone-rows .bar-col .fin-bar { flex: 1 1 100%; }
  table.phone-bases.phone-rows td.mono { font-size: 13px; }
  /* Drafts: copying and deleting from the list stay on a computer (each draft's page has them) */
  table.drafts-table.phone-rows.phone-rows tr > td.row-actions { display: none !important; }

  /* The Plan tab's buildings: an opened row shows its recipes over the whole width */
  table.plan-buildings.phone-rows.phone-rows tr > td.ph-key input { width: 100%; text-align: left; }
  table.plan-buildings.phone-rows.phone-rows tr.ph-open > td.recipes:not(:empty) { flex-direction: column; align-items: stretch; text-align: left; min-width: 0; }
  table.plan-buildings.phone-rows td.recipes::before { margin: 0; }
  table.plan-buildings.phone-rows .recipe-row select { flex: 1; width: auto; min-width: 0; font-size: 14px; }
  table.plan-buildings.phone-rows .recipe-row .amt-in { width: 64px; flex: none; }
  table.plan-buildings.phone-rows tr:not(.ph-open) .recipe-pp { display: none; }
  table.plan-buildings.phone-rows input[type=checkbox] { width: 22px; height: 22px; }
  table.plan-buildings.phone-rows .inline-check { display: inline-flex; flex-direction: row; align-items: center; white-space: normal; }
  table.plan-buildings.phone-rows .plan-new .mat-pick { width: 100%; }

  /* Loans. A running loan shows four things, two by two: Status, Left to pay, Next payment and Due in. */
  table.loans-running.phone-rows.phone-rows tr > td.ph-key { flex: 1 1 40%; }
  table.loans-running.phone-rows td .inline-form { margin-left: 8px; }
  table.loans-companies.phone-rows.phone-rows tr.ph-open > td.fin-volume .fin-volume-row { flex: 1 1 100%; }
  .loans-finances .fin-side { padding: 12px; }
  .loans-finances .fin-panel { padding: 10px 6px 6px; }
  .loans-finances > h2 > .meta.sub, #lent > h2 > .meta.sub, #borrowed > h2 > .meta.sub { display: none; }
  .loans-ended > summary { padding: 12px; }
  .loans-compare th, .loans-compare td { padding-left: 4px; padding-right: 4px; }

  /* Resupply: the ships two to a line, so the bases aren't far below. One that needs a station picked takes the line.
     A stockpile item's quantity fills its column. */
  .rs-pool { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
  .rs-pool > .rs-ship.away, .rs-pool > .empty { grid-column: 1 / -1; }
  .rs-pool .rs-ship-name { flex-wrap: wrap; }
  table.rs-pile-table.phone-rows .rs-pile-qty { width: 100%; text-align: left; }

  /* The Plan tab's Population box: the planet's jobs on a line of their own */
  table.population-plan.phone-rows.phone-rows tr > td.planet-jobs { flex: 1 1 100%; }
  table.profit-table.phone-rows.phone-rows tfoot tr > td.ph-key { min-width: 96px; }  /* three totals a line */

  /* Material tiles: in a table row a tap does what it does around the tile (see app.js lookUp()). An opened
     row ends with the Look up button; a row with nothing to open has a full-size link. */
  table.phone-rows a.mat-link:not(.ph-direct) { pointer-events: none; }
  table.phone-rows a.mat-link.ph-direct { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; min-width: 44px; }
  table.phone-rows a.mat-link.ph-direct::after { content: "\203A"; font-size: 20px; color: var(--accent); }
  /* Beats the opened row's own cells (label left, value right): this one is a button across the row. */
  table.phone-rows.phone-rows.phone-rows tr.ph-open > td.ph-lookup-cell:not(:first-child):not(.ph-key):not(:empty) { display: block; order: 9; flex: 1 1 100%; }
  table.phone-rows a.ph-lookup { display: flex; width: 100%; align-items: center; justify-content: center; min-height: 44px; }
  table.phone-rows td.ph-lookup-cell::before { content: none; }
  /* A recipe's materials in an opened row: label above, the tiles on their own line. */
  table.recipe-table.phone-rows.phone-rows.phone-rows tr.ph-open > td.recipe-cell:not(:first-child):not(.ph-key):not(:empty) { justify-content: flex-start; text-align: left; }
  /* A material's Made from and Used in are for exploring: every tile is a target big enough to tap. */
  .recipe-split .recipe-table th, .recipe-split .recipe-table td { padding: 6px 5px; vertical-align: middle; }
  .recipe-split .recipe-table th:first-child, .recipe-split .recipe-table td:first-child { padding-left: 12px; }
  .recipe-split .recipe-part { margin-right: 4px; }
  .recipe-split .recipe-cell { line-height: 1.2; }
  .recipe-split a.mat-link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  .tabs.tabs-grid.market-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }  /* its three lists on one row */
  /* The Find boxes (Materials, Opportunities): search across, the two lists side by side, then each tick box
     on a line of its own, and the materials looked up lately last. */
  .market-find { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
  .market-find .market-search, .market-find .check-label, .market-find .recent { grid-column: 1 / -1; }
  .market-find select { width: 100%; min-width: 0; }
  .market-find .check-label { order: 1; min-height: 44px; gap: 10px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text); }
  .market-find .check-label input[type=checkbox] { flex: none; width: 22px; height: 22px; }
  .market-find .check-label + .check-label, .market-find .check-label ~ .check-label { margin-top: -10px; }
  .market-find .recent { order: 2; }
  /* The Market list: the whole row is the link. */
  table.market-table.phone-rows.phone-rows tbody tr { position: relative; }
  table.market-table a.row-link::after { content: ""; position: absolute; inset: 0; }
}

/* Thumb-sized controls on touch screens, tablets included. Links inside a sentence stay as they are. */
@media (pointer: coarse) {
  button:not(.link):not(.ph-more), a.button, .tab, select:not(.inline-edit),
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]) { min-height: 44px; }
  .base-step { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  button.link, .card-foot a, .sub.tab-link { display: inline-flex; align-items: center; min-height: 44px; }
  .base-main .supply-table input { min-height: 40px; }
  .loans-ended > summary { min-height: 44px; }
  .inline-pick select, .base-switch select { min-height: 0; }  /* invisible, laid over their badge */
}

/* ---------------------------------------------------------------- Planet tab (base and draft, _planet_tab.html) */
.meter { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; vertical-align: middle; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.meter.good > span { background: var(--tone-good); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--danger); }
.conc.mood-bad > span:last-child { color: var(--danger); }
.conc.mood-good > span:last-child { color: var(--tone-good); }
.mood-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); vertical-align: 0; margin: 0 2px 0 6px; }
.mood-key:first-child { margin-left: 0; }
.mood-key.bad { background: var(--danger); }
.mood-key.good { background: var(--tone-good); }
.conc { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.conc > span:last-child { min-width: 48px; text-align: right; }
.callout.good { background: var(--good-bg); color: var(--good-text); display: flex; gap: 8px; align-items: center; }
.condition-list { list-style: none; margin: 0; padding: 0; }
.condition { display: grid; grid-template-columns: 110px 100px 1fr; align-items: baseline; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border); }
.condition:last-child { border-bottom: 0; }
.condition-label { color: var(--muted); font-size: 13px; }
.condition-value { font-weight: 600; }
.condition:not(.is-extra) .condition-value { font-weight: 400; color: var(--muted); }
.condition.is-extra .condition-value { color: var(--warn); }
.condition-effect { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.condition-amount { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.planet-resource-table tr.in-plan td, .planet-pop-table tr.in-plan td:first-child { font-weight: 600; }
.fee-grid td.r { font-variant-numeric: tabular-nums; }
.fee-grid td.zero { color: var(--muted); }
.fee-grid td.fee-used { background: var(--info-bg); color: var(--info-text); font-weight: 700; }
.fee-industry { white-space: nowrap; }
.fee-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--info-bg);
  border: 1px solid var(--info-text); vertical-align: -1px; margin-right: 4px; }
@media (max-width: 700px) {
  .condition { grid-template-columns: 90px 1fr; }
  .condition-effect { grid-column: 1 / -1; }
}

/* ---------------------------------------------------------------- Payback chart (a draft's Finances tab) */
.payback { display: flex; flex-direction: column; }
.payback-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.payback-head strong { font-size: 1.15rem; }
.payback-chart { margin: 0 0 6px; }
.payback-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.payback-chart .grid { stroke: var(--border); stroke-width: 1; }
.payback-chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.payback-chart .zero-line { stroke: var(--muted); stroke-width: 1; }
.payback-chart .payback-owed { fill: var(--danger); opacity: 0.12; }
.payback-chart .payback-earned { fill: var(--tone-good); opacity: 0.18; }
.payback-chart .payback-line { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.payback-chart .payback-mark { stroke: var(--tone-good); stroke-width: 1; stroke-dasharray: 3 3; }
.payback-chart .payback-dot { fill: var(--tone-good); stroke: var(--surface); stroke-width: 2; }
.payback-chart .payback-label { fill: var(--tone-good); font-size: 12px; font-weight: 700;
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }  /* a halo over grid lines */
.payback-milestones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 8px; }
.payback-milestones > div { display: flex; flex-direction: column; gap: 2px; }
.payback-milestones dt { font-size: 12px; color: var(--muted); }
.payback-milestones dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Sharing a base (idea 24): the Share dialog */
.head-buttons { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.share-open { display: inline-flex; align-items: center; gap: 6px; }
.share-count { min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--info-bg); color: var(--info-text);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.base-share-dialog { width: min(560px, 94vw); max-height: min(88vh, 900px); overflow: auto; border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 22px 20px; background: var(--surface); color: var(--text); }
html:has(.base-share-dialog[open]) { overflow: hidden; }  /* the page stays put behind the Share popup */
.base-share-dialog::backdrop { background: light-dark(rgba(15, 36, 51, .5), rgba(0, 0, 0, .65)); }
.base-share-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.base-share-head .card-title { margin: 0; }
.base-share-close { display: inline-flex; padding: 4px; color: var(--muted); }
.base-share-part { padding: 14px 0; border-bottom: 1px solid var(--border); }
.base-share-part h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.base-share-part .link-copy input { min-width: 0; }
.share-form { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 0; font-size: 14px; }
.share-form label { display: flex; flex-direction: column; gap: 4px; }
.share-form label.inline-check { flex-direction: row; align-items: center; gap: 6px; }
.base-share-actions { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.share-people { list-style: none; margin: 4px 0 0; padding: 0; }
.share-people li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.share-people li:last-child { border-bottom: 0; }
.share-people form { margin: 0; }
.share-scopes { display: grid; gap: 8px; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.share-scopes dt { font-weight: 600; color: var(--text); }
.share-scopes dd { margin: 0; }
.copy-button.copied { color: var(--tone-good); border-color: var(--tone-good); }
.base-share-dialog .share-msg { margin: 10px 0 0; }
.base-share-more { margin-top: 10px; }
.share-views { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 6px 0 0; font-size: 14px; }
.share-views svg { color: var(--muted); }
.base-share-more form { margin: 0; }
.share-new-link { margin: 0 0 12px; padding: 12px; border-radius: 8px; background: var(--highlight); border: 1px solid var(--accent-tint); }
.share-new-link .meta { margin: 0 0 8px; }
@media (max-width: 700px) {
  /* On a phone the dialog takes the whole screen, its close button always in reach. */
  .base-share-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0;
    padding: 0 16px 24px; }
  .base-share-head { position: sticky; top: 0; z-index: 1; margin: 0 -16px; padding: 12px 16px; background: var(--surface);
    border-bottom: 1px solid var(--border); }
  .base-share-close { min-width: 44px; min-height: 44px; justify-content: center; align-items: center; }
  .share-form select, .share-form button { min-height: 44px; }
}
/* The shared base page: no left column, a line under the name for who shared it and what it shows. */
.pill-shared { background: var(--info-bg); color: var(--info-text); vertical-align: 4px; display: inline-flex; align-items: center; gap: 4px; }
.shared-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.shared-head form { margin: 0; }
.shared-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -6px 0 16px; color: var(--muted); font-size: 14px; }
.shared-meta strong { color: var(--text); }
.shared-meta .shared-views { display: inline-flex; align-items: center; gap: 4px; }
.shared-foot { display: flex; gap: 6px; align-items: flex-start; margin-top: 24px; }
.shared-foot svg { flex: none; margin-top: 2px; }

/* ---------------------------------------------------------------- leases (idea 23) */
.lease-terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 24px; margin: 0; }
.lease-terms > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--border); }
.lease-terms dt { color: var(--muted); font-size: 13px; }
.lease-terms dd { margin: 0; }
.lease-notes h3, .lease-cv h3 { font-size: 15px; margin: 16px 0 6px; }
.lease-cv h3:first-child { margin-top: 0; }
.pre-line { white-space: pre-line; }
.lease-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; align-items: end; }
.lease-field { display: flex; flex-direction: column; gap: 4px; }
.term-detail .lease-field + .lease-field { margin-top: 10px; }
.lease-form .card + .card, .lease-form .card + .actions-row { margin-top: 16px; }
.lease-form textarea { width: 100%; }
.lease-applicant { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid var(--border); }
.lease-applicant .lease-cv { flex: 1 1 420px; }
.lease-applicant .inline-form { margin-left: 0; }
/* The agreements already made from an offer leased to several owners. */
.lease-agreements { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 6px; }
.lease-agreements li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lease-agreements .icon { color: var(--ok-text); }
.lease-next .actions-row .inline-form { margin-left: 0; }
/* Apply as the owner: what the owner earns, the planets as cards, the company, the steps, one big button. */
.apply-lead { margin: 0 0 14px; font-size: 15px; }
.apply-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.apply-figure { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.apply-figure:first-child { background: var(--tone-good-bg); border-color: var(--good-soft-border); }
.apply-figure:first-child strong { color: var(--tone-good); }
.apply-figure.bad strong { color: var(--danger); }
.apply-figure-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.apply-figure strong { font-size: 18px; }
.apply-figure-sub { font-size: 12px; color: var(--muted); }
.apply-basis { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.apply-form { margin-top: 18px; display: grid; gap: 16px; }
.apply-planets { border: 0; margin: 0; padding: 0; min-width: 0; }
.apply-planets legend, .apply-as-label { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
/* Every planet card the same height (the tallest one's), whether or not it has a line under its name. */
.apply-planet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.apply-planet { position: relative; cursor: pointer; display: flex; }
.apply-planet > .apply-planet-box { flex: 1; box-sizing: border-box; }
.apply-planet input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.apply-planet-box { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); transition: border-color .12s, background .12s; }
.apply-planet-box > .icon { color: var(--accent); flex: none; }
.apply-planet-name { flex: 1; min-width: 0; }
.apply-planet-check { display: inline-flex; color: var(--accent); opacity: 0; transition: opacity .12s; }
.apply-planet:hover .apply-planet-box { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.apply-planet input:checked + .apply-planet-box { border-color: var(--accent); background: var(--accent-tint);
  box-shadow: inset 0 0 0 1px var(--accent); }
.apply-planet input:checked + .apply-planet-box .apply-planet-check { opacity: 1; }
.apply-planet input:focus-visible + .apply-planet-box { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A planet where the owner has a base already: can't be picked, a red cross where the check would be. */
.apply-planet.taken { cursor: not-allowed; }
.apply-planet.taken input { cursor: not-allowed; }
.apply-planet.taken .apply-planet-box { background: var(--surface-2); border-style: dashed;
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.apply-planet.taken .apply-planet-box > .icon { color: var(--muted); }
.apply-planet.taken .apply-planet-name { color: var(--muted); }
.apply-planet.taken .apply-planet-check { opacity: 1; color: var(--danger); }
.apply-planet.taken:hover .apply-planet-box { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.apply-planet-why { display: block; font-size: 12px; color: var(--danger); }
.apply-none { margin: 8px 0 0; }
/* A planet the owner applied on already: shown, not picked again. */
.apply-planet.applied { cursor: default; }
.apply-planet.applied input { cursor: default; }
.apply-planet.applied .apply-planet-box { background: var(--accent-tint); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.apply-planet.applied .apply-planet-check { opacity: 1; }
.apply-planet.applied .apply-planet-why { color: var(--accent); }
.apply-legend-note { margin-left: 6px; font-weight: 400; }
.apply-more { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
/* The owner's applications on an offer, one per planet. */
.applied-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.applied-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); }
.applied-list li > .icon { color: var(--muted); flex: none; }
.applied-list li.picked { border-color: var(--good-soft-border); background: var(--tone-good-bg); }
.applied-list li.picked > .icon { color: var(--tone-good); }
.applied-withdraw { margin: 0; }  /* level with the list above it */
.applied-planet { flex: 1 1 auto; }
.applied-state { font-size: 13px; color: var(--muted); }
.apply-as { display: flex; flex-direction: column; }
.apply-company { display: inline-flex; align-items: center; gap: 10px; }
.apply-company > span:last-child { display: flex; flex-direction: column; }
.apply-company .meta { font-size: 12px; }
.apply-monogram { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 6px; border-radius: 8px;
  background: var(--accent-tint); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  font-weight: 700; font-size: 13px; }
.apply-steps { list-style: none; margin: 0; padding: 12px 0 0; border-top: 1px dashed var(--border);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 16px; font-size: 13px; color: var(--muted); }
.apply-steps li { display: flex; gap: 8px; align-items: flex-start; }
.apply-steps strong { color: var(--text); }
.apply-step-no { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 11px; font-weight: 700; }
.apply-card > .apply-steps { margin-top: 16px; }
.apply-go { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0; }
.apply-card > .apply-go { margin-top: 16px; }
.apply-button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; font-size: 15px; }
.apply-button:disabled { opacity: .5; cursor: not-allowed; }
.lease-end { margin-top: 12px; }
.lease-end summary { cursor: pointer; color: var(--muted); }
.lease-end form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 0; }
.lease-history { list-style: none; margin: 0; padding: 0; }
.lease-history li { padding: 6px 0; border-top: 1px solid var(--border); }
.lease-history li:first-child { border-top: 0; }
.flash.error { background: var(--warn-bg); color: var(--warn); }
.setting-note { margin: 8px 0 0; font-size: 14px; }  /* Profile: a box's message, under it (saved in place) */
@media (max-width: 640px) { .lease-terms { grid-template-columns: 1fr 1fr; } }
/* The lease page: what it is at a glance, then the lease itself, with who's on it and where on the side. */
.lease-kpis .kpi-value, .lease-kpis .kpi-sub { white-space: normal; }
.lease-kpis .kpi-value { font-size: 18px; }
.lease-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0 20px; align-items: start; }
.lease-main, .lease-aside { min-width: 0; }
.lease-aside .lease-terms { grid-template-columns: 1fr; gap: 0; }
.lease-aside .lease-terms > div { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 12px; }
.lease-aside .lease-terms dd { text-align: right; }
.lease-main .offer-sides { border-top: 0; padding-top: 0; }
.offer-facts.lease-facts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 14px; }
.lease-notes { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.lease-notes h3 { margin-top: 0; }
@media (max-width: 960px) { .lease-layout { grid-template-columns: 1fr; } }
.lease-report { margin: 0 0 20px; padding: 0 4px; }
.lease-report summary { cursor: pointer; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.lease-report summary:hover { color: var(--danger); }
.lease-report[open] { padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.lease-report[open] summary { color: var(--text); font-weight: 600; font-size: 14px; }
.lease-report[open] summary .icon { color: var(--warn); }
.lease-report-form { display: grid; gap: 12px; margin-top: 12px; }
.lease-report-form .actions-row { margin: 0; }
.report-privacy { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 10px; border-radius: 6px;
  background: var(--surface-2); font-size: 12px; color: var(--muted); }
.report-send { display: inline-flex; align-items: center; gap: 6px; }
.report-send .icon { position: relative; top: 1px; }  /* the triangle sits level with the lowercase letters */
/* A plain text box (_ui.html plain_box): the rich editor's frame, its label in the bar, a count under it. */
.plain-bar { gap: 8px; padding: 7px 10px; }
.plain-label { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); cursor: text; }
.plain-label .icon { color: var(--accent); }
.plain-tag { margin-left: auto; flex: none; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; color: var(--muted); }
.plain-box textarea { display: block; width: 100%; min-height: 0; padding: 10px 12px; border: 0; border-radius: 0;
  background: transparent; color: var(--text); font: inherit; line-height: 1.5; resize: vertical; }
.plain-box textarea:focus { outline: none; }
.plain-box textarea::placeholder { color: var(--muted); }
.plain-foot { display: flex; justify-content: space-between; gap: 10px; padding: 5px 10px; border-top: 1px solid var(--border);
  background: var(--surface); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plain-count.low { color: var(--danger); font-weight: 600; }
/* Admins: the Moderation box on an offer. */
.lease-moderation { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.mod-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.mod-head .card-title { margin-bottom: 0; }
.mod-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.mod-lead { margin: 8px 0 14px; font-size: 13px; color: var(--muted); }
.mod-actions { display: grid; gap: 10px; }
.mod-action { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin: 0;
  padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.mod-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.mod-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mod-text span { font-size: 13px; color: var(--muted); }
.mod-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: color-mix(in srgb, var(--danger) 6%, var(--surface-2)); }
.mod-danger .mod-icon { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
@media (max-width: 560px) { .mod-action { grid-template-columns: auto 1fr; } .mod-action button { grid-column: 1 / -1; } }
/* Admins: the Reports page */
.report-list { display: grid; gap: 0; }
.report-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.report-facts { margin-bottom: 10px; }
.report-details { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.report-actions { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.report-close { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; flex: 1 1 320px; }
.report-close .lease-field { flex: 1 1 220px; }
.page-head .actions-row { margin: 0; }  /* a <p>: its margin would make the head taller than the title */
.lease-base-choice { display: inline-block; margin: 6px 8px 0 0; }
.lease-answer { display: flex; gap: 6px; flex-wrap: wrap; }
.lease-entry-form { margin-top: 10px; }

/* The public offers list: a toolbar, then one card per offer */
.offers-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 20px; }
.offer-grid > .card.offer-card { margin: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 20px 22px; }
/* Each card's head (company, last seen) and money line up with its neighbours': three rows shared by the row of
   cards (subgrid), the rest of the card below. */
@supports (grid-template-rows: subgrid) {
  .offer-grid > .card.offer-card { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 14px; }
}
.offer-head { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.offer-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.offer-card { transition: border-color .15s, box-shadow .15s; }
.offer-card:hover { border-color: var(--accent-tint); box-shadow: 0 4px 14px rgba(15, 36, 51, .08); }
/* The viewer's own offer: an accent border and band on top, a tag over the company, (You) after it, and a
   main button to manage it. */
.offer-card.offer-mine { border-color: var(--accent); box-shadow: inset 0 4px 0 var(--accent);
  background: linear-gradient(var(--highlight), var(--surface) 140px); }
.offer-card.offer-mine:hover { box-shadow: inset 0 4px 0 var(--accent), 0 4px 14px rgba(15, 36, 51, .08); }
.offer-mine-tag { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; padding: 1px 8px; vertical-align: 2px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; }
.offer-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.offer-company { min-width: 0; line-height: 1.6; }
.offer-seen { display: flex; align-items: center; gap: 6px; margin: 0; }
.offer-seen.offer-away { align-self: flex-start; padding: 2px 8px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); }
.offer-price { margin: 0; font-size: 20px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
/* A card's money for the viewer's side: the net a day and the total over the lease. */
.offer-money { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.offer-money-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 8px 10px; border-radius: 8px;
  background: var(--tone-good-bg); border: 1px solid var(--good-soft-border); font-variant-numeric: tabular-nums; }
.offer-money-item span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.offer-money-item strong { font-size: 18px; color: var(--tone-good); overflow-wrap: anywhere; }
.offer-money-item.bad { background: var(--surface-2); border-color: var(--border); }
.offer-money-item.bad strong { color: var(--danger); }
.offer-fact-price { grid-column: 1 / -1; }
.offer-planets { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
/* The name, the ID (smaller, monospace) and "agreed" share a baseline; only the icon is centred. */
.offer-planets li { display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--highlight); color: var(--text); font-size: 13px; }
.offer-planets .icon { color: var(--accent); flex: none; align-self: center; }
.offer-draft { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.offer-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }
.offer-facts > div { min-width: 0; }
.offer-facts dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.offer-facts dd { margin: 2px 0 0; font-size: 14px; }
.offer-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
@media (max-width: 640px) { .offer-grid { grid-template-columns: minmax(0, 1fr); } .offer-grid > .card.offer-card { padding: 16px; } }

/* The terms form: rows of fields, segments for choices, planet chips, a sticky save bar */
.lease-form { margin-top: 0; }  /* the .intro above sets the space, as on other pages */
.lease-form > * + *, .lease-form .card + .card { margin-top: 16px; }
.lease-form .card { margin-bottom: 0; }
/* Two cards side by side (one column on a narrow screen); a card alone in the row takes it all */
.form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.form-pair > .card + .card { margin-top: 0; }
.form-pair > .card:only-child { grid-column: 1 / -1; }
@media (max-width: 900px) { .form-pair { grid-template-columns: minmax(0, 1fr); } }
.form-hint-end { margin-bottom: 0; }
.form-hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.form-sub { font-size: 14px; margin: 0 0 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 16px; align-items: end; margin-top: 12px; }
.form-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px 32px; }
.form-split > div + div { border-left: 1px solid var(--border); padding-left: 32px; }
@media (max-width: 760px) {
  .form-split { grid-template-columns: minmax(0, 1fr); }
  .form-split > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 16px; }
}
.seg-grid { display: flex; flex-wrap: wrap; gap: 14px 24px; }
.seg-field { border: 0; margin: 0; padding: 0; min-width: 0; max-width: 100%; }
.seg-field legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
/* A segmented choice (radio buttons as one control). Not `.seg`: that is a bar segment (.fin-bar, .usage-bar). */
.seg-choice { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); padding: 3px; gap: 3px; max-width: 100%; }
.seg-choice label { display: block; position: relative; margin: 0; font-size: 14px; color: var(--text); cursor: pointer; }
.seg-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg-choice span { display: block; padding: 5px 12px; border-radius: 6px; white-space: nowrap; transition: background .12s, color .12s; }
@media (max-width: 400px) { .seg-choice span { padding: 5px 9px; } }  /* three choices still fit one line on a phone */
.seg-choice label:hover span { background: var(--highlight); }
.seg-choice input:checked + span { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Only the fields the choice above needs */
.lease-form:has(input[name=price_kind][value=period]:checked) .when-unit,
.lease-form:has(input[name=price_kind][value=unit]:checked) .when-period,
.lease-form:not(:has(input[name=end_kind][value=time]:checked)) .when-time,
.lease-form:not(:has(input[name=end_kind][value=quantity]:checked)) .when-quantity,
.lease-form:has(input[name=end_kind]:not([value=none]):checked) .when-none,
.lease-form:not(:has(input[name=construction_by][value=loan]:checked)) .when-loan,
.lease-form:not(:has(input[name=repairs_by][value=tenant]:checked)) .when-tenant-repairs { display: none; }
/* What the choice above it asks for, in a panel tied to it; a line before the next part of the card (notice,
   owners). Fields with a unit after them stay short. */
.term-detail { margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.term-detail input, .term-detail select { background: var(--surface); }
.term-split { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.term-split .lease-field { margin-bottom: 6px; }
div.lease-field { font-size: 13px; color: var(--muted); }  /* like a label: a field of two parts (an amount and its period) */
.price-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.price-row > input, .lease-form .with-unit input, .owners-field input { width: 120px; }
.price-row select { width: auto; }
.owners-field { align-items: flex-start; }
/* A material the plan makes, a row each: its tile, the field, what it counts (units, or the currency each). */
.mat-rows { display: grid; gap: 8px; }
.mat-rows:empty { display: none; }
.mat-row { display: grid; grid-template-columns: 52px minmax(0, 140px) auto; align-items: center; gap: 10px; margin: 0; }
.mat-row-unit { font-size: 13px; color: var(--muted); white-space: nowrap; }
.mat-rows-none { margin: 0; }
.planet-chips { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.planet-chips:empty { display: none; }
.planet-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--highlight); border: 1px solid var(--accent-tint); font-size: 14px; }
.planet-chip > .icon { color: var(--accent); }
button.chip-x { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0;
  border-radius: 50%; border: 0; background: transparent; color: var(--muted); }
button.chip-x:hover { background: var(--surface); color: var(--danger); }
.planet-none { margin: 8px 0; }
.planet-add { display: flex; gap: 8px; align-items: flex-start; max-width: 460px; }
.planet-add .combo { flex: 1; min-width: 0; }
.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 -4px 14px rgba(15, 36, 51, .06); }

/* Rich text: the editor (toolbar, box, preview) and how it reads */
.rich-editor { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.rich-editor:focus-within { border-color: var(--accent); }
.rich-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
.rich-group { display: inline-flex; gap: 2px; }
.rich-group + .rich-group { padding-left: 10px; border-left: 1px solid var(--border); }
.rich-views { margin-left: auto; display: inline-flex; gap: 2px; }
button.rich-btn { background: transparent; border: 1px solid transparent; color: var(--text); font-weight: 600; font-size: 13px;
  padding: 3px 8px; border-radius: 5px; min-width: 30px; }
button.rich-btn:hover:not(:disabled) { background: var(--highlight); }
button.rich-btn[aria-pressed="true"] { background: var(--highlight); color: var(--accent); border-color: var(--accent-tint); }
.rich-editor textarea { display: block; width: 100%; border: 0; border-radius: 0; background: transparent; resize: vertical; min-height: 140px; }
.rich-editor textarea:focus { outline: none; }
.rich-preview { position: relative; padding: 10px 12px; min-height: 140px; max-height: 60vh; overflow-y: auto; background: var(--surface); overflow-wrap: anywhere; }
.rich-preview[contenteditable]:focus { outline: none; }
.rich-preview.is-empty::before { content: attr(data-placeholder); position: absolute; left: 12px; top: 10px; color: var(--muted); pointer-events: none; }
.rich-text > :first-child { margin-top: 0; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text h3 { font-size: 18px; margin: 14px 0 6px; }
.rich-text h4 { font-size: 16px; margin: 12px 0 6px; }
.rich-text h5 { font-size: 14px; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rich-text p, .rich-text ul, .rich-text ol { margin: 0 0 8px; }
.rich-text ul, .rich-text ol { padding-left: 22px; }
.rich-text blockquote { margin: 0 0 8px; padding: 4px 12px; border-left: 3px solid var(--accent-tint); color: var(--muted); }
.rich-text hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.rich-text code { font-size: 13px; padding: 1px 4px; border-radius: 4px; background: var(--highlight); }

/* The offers' search box, and a card's excerpt */
.offers-search { flex: 1 1 280px; min-width: 0; position: relative; display: flex; align-items: center; }
.offers-search > .icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
/* Near a station: the station (with its faction logo) and how many jumps. */
.offers-near { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.offers-near-label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.offers-near .logo-field { min-width: 190px; }
.offers-within { width: auto; }
.offer-near { display: flex; align-items: baseline; gap: 5px; margin: 0; font-size: 13px; color: var(--muted); }
.offer-near > .icon { color: var(--accent); align-self: center; flex: none; }
.offer-near strong { color: var(--text); }
.offers-search input { padding-left: 32px; width: 100%; }
.offers-found { margin: -4px 0 12px; }
.offer-excerpt { margin: 0; font-size: 14px; color: var(--muted); max-height: 6em; overflow: hidden; position: relative; }
.offer-excerpt.overflows { -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.offer-desc.open .offer-excerpt { max-height: none; -webkit-mask-image: none; mask-image: none; }
.offer-excerpt.rich-text h3 { font-size: 15px; margin: 6px 0 2px; color: var(--text); }
.offer-excerpt.rich-text h4, .offer-excerpt.rich-text h5 { font-size: 14px; margin: 6px 0 2px; }
.offer-excerpt.rich-text p, .offer-excerpt.rich-text ul, .offer-excerpt.rich-text ol, .offer-excerpt.rich-text blockquote { margin-bottom: 4px; }
button.offer-more { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 2px 0; background: none; border: 0;
  color: var(--accent); font-size: 13px; font-weight: 600; }
button.offer-more[hidden] { display: none; }
button.offer-more .icon { transition: transform .15s; }
.offer-desc.open button.offer-more .icon { transform: rotate(180deg); }
.offer-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-right: 2px; }
.offer-label .icon { color: var(--accent); }
.offer-makes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* A lease's "Who earns what": the two sides' money a day side by side (lease.html, _lease_ui.html money_split). */
.lease-split { --fin-price: light-dark(#db2777, #f472b6); --fin-interest: light-dark(#ca8a04, #facc15); --split-tenant: light-dark(#4f46e5, #818cf8); --split-owner: light-dark(#c2410c, #fb923c); }
/* Each side spans the grid's four rows (title, lines, share, once) as a subgrid, so the two nets line up. */
.split-sides { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(5, auto); column-gap: 12px; }
.split-side { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  display: grid; grid-row: span 5; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
.split-side > .split-lines:first-of-type { display: flex; flex-direction: column; }
.split-side > .split-lines:first-of-type .split-net { margin-top: auto; }
.split-side.split-me { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: inset 0 3px 0 var(--accent); }
.split-lines { margin: 0; display: grid; gap: 5px; font-size: 13px; font-variant-numeric: tabular-nums; }
.split-lines > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.split-lines dt { display: flex; align-items: center; gap: 6px; min-width: 0; }
.split-lines dt .swatch { margin-right: 0; flex: none; }
.split-lines dt .icon { color: var(--muted); flex: none; }
.split-lines dd { margin: 0; white-space: nowrap; }
.split-lines .gain dd { color: var(--up-text); }
.split-lines .cost dd { color: var(--muted); }
.split-net { margin-top: 3px; padding-top: 7px; border-top: 1px solid var(--border); font-weight: 700; font-size: 15px; }
.split-lines dd.pos { color: var(--tone-good); }
.split-lines dd.neg { color: var(--danger); }
.split-share { margin: 3px 0 0; text-align: right; font-size: 12px; color: var(--muted); }
.split-once { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); align-content: start; }
.split-once:empty { display: none; }
.split-total { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 700; font-size: 15px; align-self: start; }
.split-total:empty { display: none; }
.split-bar-title { margin: 18px 0 6px; font-size: 13px; color: var(--muted); }
.split-bar-title strong { color: var(--text); }
.split-bar.fin-bar { margin: 0 0 8px; }
.sp-tenant-keeps { background: var(--split-tenant); }
.sp-tenant-costs { background: color-mix(in srgb, var(--split-tenant) 35%, var(--surface)); }
.sp-owner-keeps { background: var(--split-owner); }
.sp-owner-costs { background: color-mix(in srgb, var(--split-owner) 35%, var(--surface)); }
.split-legend { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.split-legend li { display: flex; align-items: center; gap: 6px; }
.split-legend .swatch { margin-right: 0; }
.callout.split-warn { margin: 14px 0 0; display: flex; gap: 8px; align-items: center; }
.split-live-body { transition: opacity .15s; }
.split-loading .split-live-body { opacity: .55; }
@media (max-width: 560px) { .split-sides { grid-template-columns: 1fr; grid-template-rows: none; row-gap: 12px; } .split-side { display: block; } }
.offer-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.offer-side { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.offer-side-title { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 14px; }
.offer-side-title .icon { color: var(--accent); }
.offer-side-who { font-weight: 500; color: var(--muted); margin-left: -2px; }
.offer-side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 13px; }
.offer-side li { display: flex; align-items: center; gap: 6px; }
.offer-side li .icon { color: var(--muted); flex: none; }
.offer-planets li.agreed { background: var(--accent); color: var(--accent-text); }
.offer-planets li.agreed .icon, .offer-planets li.agreed .offer-draft, .offer-planets li.agreed .meta { color: var(--accent-text); }
.lease-applicant-planet { flex-basis: 100%; order: -1; margin: 0; display: inline-flex; align-items: center; gap: 6px; }

/* A lease's quantity end: one field per material the plan makes. */
/* A lease's plan: its buildings, what it makes and uses, as chips. */
.plan-facts { display: grid; gap: 10px; margin: 14px 0 0; }
.plan-facts dt { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.plan-facts dt .icon { color: var(--accent); }
.plan-facts dd { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.plan-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 4px; border-radius: 6px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 13px; font-variant-numeric: tabular-nums; }
.plan-chip:not(:has(.mat-tile)) { padding-left: 8px; }
/* Recipes (a lease's plan): a building's ticker, then its recipes; the tickers in a column of their own. */
.plan-facts dd.plan-recipes { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 10px; align-items: baseline; }
.plan-recipes > .ticker { padding-top: 3px; }
.plan-recipe-list { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-chip .recipe-tiles .recipe-part:last-child { margin-right: 0; }
