:root {
  --bg: #f1f2f4;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #d8dce2;
  --line-strong: #b9bfc9;
  --text: #1c2129;
  --muted: #5f6877;
  --ink: #1c2129;
  --good: #23784b;
  --bad: #b83232;
  --warn: #a86a0a;
  --road: #c5ccd5;
  --company-color: var(--ink);

  /* building colours: tile / icon */
  --farm: #bcd68f;       --farm-ink: #4a6e22;
  --factory: #a5b4c8;    --factory-ink: #3b4f6e;
  --shop: #f0cc8a;       --shop-ink: #8a5a0d;
  --cafe: #dcc1a0;       --cafe-ink: #7a4d22;
  --warehouse: #cdb99c;  --warehouse-ink: #6b5433;
  --apartment: #a9c9ea;  --apartment-ink: #2f5f8f;
  --hotel: #e8adad;      --hotel-ink: #8f3a3a;
  --depot: #f2b998;      --depot-ink: #8a4520;

  /* district colours: tile / strip */
  --center: #ddd5ec;     --center-strip: #8a70b8;
  --midtown: #d2e3e5;    --midtown-strip: #4f9aa3;
  --suburbs: #dfe7d2;    --suburbs-strip: #7d9a58;
  --outskirts: #ebe3cf;  --outskirts-strip: #b59b5a;

  --font: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
}
[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
.muted { color: var(--muted); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- buttons and fields ---------- */
button {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
button:hover:not(:disabled) { background: var(--panel-2); border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
button.primary:hover:not(:disabled) { background: #333b48; border-color: #333b48; }
button.danger { color: var(--bad); }
button.small { padding: 3px 8px; font-size: 12px; }

input, select {
  font: inherit;
  color: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  min-width: 0;
}

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- toolbar ---------- */
.toolbar { background: var(--panel); border-bottom: 1px solid var(--line); }
.toolbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  min-height: 52px;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 20px;
}
.toolbar-inner > * { margin-top: 6px; margin-bottom: 6px; }
@media (max-width: 700px) {
  .toolbar-inner { gap: 0 12px; }
  .date { order: 5; flex-basis: 100%; margin-top: 0; font-size: 12px; }
}
.toolbar h1 { font-size: 17px; font-weight: 600; }
.date { color: var(--muted); white-space: nowrap; }
.toolbar-actions { margin-left: auto; display: flex; gap: 8px; }

.toolbar h1 a { color: inherit; text-decoration: none; }
.toolbar-company { display: inline-flex; align-items: center; gap: 7px; color: var(--text); text-decoration: none; min-width: 0; }
.toolbar-company-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.company-mark { width: 28px; height: 28px; display: inline-grid; place-items: center; flex: none; color: #fff; background: var(--mark-color); border-radius: 6px; }
.company-mark .icon { width: 17px; height: 17px; }

/* Tabs inside a page are buttons; the page navigation in the toolbar is links. Both look the same. */
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button, .tabs a {
  white-space: nowrap;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  padding: 6px 10px;
  color: var(--muted);
  text-decoration: none;
}
.tabs button:hover:not(:disabled), .tabs a:hover { background: none; color: var(--text); border-color: var(--line-strong); }
.tabs button.active, .tabs a.active { color: var(--text); border-bottom-color: var(--ink); font-weight: 500; }
.main-tabs { align-self: stretch; align-items: stretch; }
.main-tabs a { padding: 0 12px; display: flex; align-items: center; }

/* A link that looks like a button. */
a.button {
  display: inline-block;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 12px;
  text-decoration: none;
  transition: background-color .12s, border-color .12s;
}
a.button:hover { background: var(--panel-2); border-color: var(--muted); }
a.button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
a.button.primary:hover { background: #333b48; border-color: #333b48; }
a.button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.empty-state a, .muted a { color: var(--text); }

.app { max-width: 1360px; margin: 0 auto; padding: 16px; }

/* ---------- summary bar ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
}
.sum-item { display: flex; gap: 10px; padding: 12px 14px; border-left: 1px solid var(--line); min-width: 0; }
.sum-item:first-child { border-left: 0; }
.sum-item .icon { color: var(--muted); margin-top: 2px; }
.sum-item span { display: block; color: var(--muted); font-size: 12px; }
.sum-item b.neg { color: var(--bad); }
.sum-item b.pos { color: var(--good); }
.sum-item b { display: block; font-size: 19px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.sum-item small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 5px 0 3px; }
.meter i { display: block; height: 100%; background: var(--ink); }
@media (max-width: 700px) { .sum-item:nth-child(odd) { border-left: 0; } .sum-item { border-top: 1px solid var(--line); } .sum-item:nth-child(-n+2) { border-top: 0; } }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; align-items: start; }
@media (max-width: 1050px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; min-width: 0; }
.panel > h2 { margin-bottom: 8px; }

/* ---------- city map ---------- */
.map-panel { max-width: 860px; margin: 0 auto; width: 100%; min-width: 0; }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.map-tools button { min-height: 32px; }
.city-picker { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.city-picker select { height: 32px; padding-top: 4px; padding-bottom: 4px; color: var(--text); }
.map-zoom { display: inline-flex; align-items: center; }
.map-zoom button { width: 34px; border-radius: 0; padding-left: 0; padding-right: 0; }
.map-zoom button:first-child { border-radius: 6px 0 0 6px; }
.map-zoom button:last-child { border-radius: 0 6px 6px 0; }
.map-zoom-label { min-width: 50px; height: 32px; display: grid; place-items: center; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); background: var(--panel); font-size: 12px; }
.map-selection { margin-left: auto; color: var(--muted); font-size: 12px; }
.map-wrap {
  position: relative;
  height: clamp(430px, 62vh, 650px);
  overflow: hidden;
  background: var(--road);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.map-wrap.dragging { cursor: grabbing; }
.map-wrap:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.map {
  position: absolute;
  left: 0;
  top: 0;
  width: 780px;
  height: 780px;
  transform-origin: 0 0;
  background: var(--road);
}
.map-help { margin-top: 7px; color: var(--muted); font-size: 12px; }
.map-minimap {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 176px;
  height: 112px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  pointer-events: none;
}

.cell {
  --tile: var(--outskirts);
  --strip: var(--outskirts-strip);
  --ink-c: var(--muted);
  position: relative;
  width: 49px;
  height: 49px;
  position: absolute;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--tile);
  border: 1px solid rgba(0, 0, 0, .14);
  border-bottom: 3px solid var(--strip);
  border-radius: 4px;
  color: var(--ink-c);
  overflow: hidden;
}
.cell:hover:not(:disabled) { background: var(--tile); border-color: var(--ink); border-bottom-color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.cell.company-owned { box-shadow: inset 0 0 0 3px var(--company-color); }
.cell.company-owned:hover:not(:disabled) { box-shadow: inset 0 0 0 3px var(--company-color), 0 1px 4px rgba(0, 0, 0, .3); }
.cell.selected { border-color: var(--ink); border-bottom-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); z-index: 1; }
.cell.company-owned.selected { box-shadow: inset 0 0 0 3px var(--company-color), 0 0 0 2px var(--ink); }
.cell.primary-selected { box-shadow: 0 0 0 3px var(--ink); z-index: 2; }
.cell.company-owned.primary-selected { box-shadow: inset 0 0 0 3px var(--company-color), 0 0 0 3px var(--ink); }
.cell.forsale { border-style: dashed; border-bottom-style: solid; }

/* Colour tokens for map tiles and the inspector badge. Later rules beat earlier ones. */
.d-center { --strip: var(--center-strip); }
.d-midtown { --strip: var(--midtown-strip); }
.d-suburbs { --strip: var(--suburbs-strip); }
.d-outskirts { --strip: var(--outskirts-strip); }
.forsale.d-center { --tile: var(--center); }
.forsale.d-midtown { --tile: var(--midtown); }
.forsale.d-suburbs { --tile: var(--suburbs); }
.forsale.d-outskirts { --tile: var(--outskirts); }
.empty { --tile: #f3f6ee; --ink-c: #6f8560; }
.b-farm { --tile: var(--farm); --ink-c: var(--farm-ink); }
.b-factory { --tile: var(--factory); --ink-c: var(--factory-ink); }
.b-shop { --tile: var(--shop); --ink-c: var(--shop-ink); }
.b-cafe { --tile: var(--cafe); --ink-c: var(--cafe-ink); }
.b-warehouse { --tile: var(--warehouse); --ink-c: var(--warehouse-ink); }
.b-apartment { --tile: var(--apartment); --ink-c: var(--apartment-ink); }
.b-hotel { --tile: var(--hotel); --ink-c: var(--hotel-ink); }
.b-depot { --tile: var(--depot); --ink-c: var(--depot-ink); }
.cell .icon { width: 56%; height: 56%; max-width: 30px; max-height: 30px; }
.cell .lv {
  position: absolute; right: 2px; bottom: 1px;
  font-size: 10px; font-weight: 600; line-height: 1;
  color: var(--ink-c);
}
.cell .price { font-size: 11px; font-weight: 500; }
.cell .plus { font-size: 20px; line-height: 1; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cell .dot { position: absolute; top: 3px; right: 3px; border: 1px solid rgba(255, 255, 255, .8); }
.dot.ok { background: var(--good); }
.dot.nostaff { background: var(--bad); }
.dot.nostock, .dot.full { background: #d99a1e; }
.dot.waiting { background: #3f7fd0; }
@media (max-width: 560px) {
  .map-wrap { height: 430px; }
  .map-selection { flex-basis: 100%; margin-left: 0; }
  .map-minimap { width: 132px; height: 84px; }
  .cell .price { font-size: 9px; }
  .cell .lv { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  button, a.button { transition: none; }
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .2); background: var(--sw); border-bottom: 3px solid var(--sw-strip); }

.tooltip {
  position: fixed;
  z-index: 30;
  max-width: 260px;
  padding: 8px 10px;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.tooltip b { display: block; font-size: 13px; margin-bottom: 2px; }
.tooltip span { display: block; color: #d3d8e0; }

/* ---------- inspector ---------- */
.insp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.insp-head > div { min-width: 0; }
.badge { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: var(--tile, #eceef1); color: var(--ink-c, var(--muted)); flex: none; border: 1px solid rgba(0, 0, 0, .12); border-bottom: 3px solid var(--strip, rgba(0, 0, 0, .12)); }
.badge.b-farm, .badge.b-factory, .badge.b-shop, .badge.b-cafe, .badge.b-warehouse, .badge.b-apartment, .badge.b-hotel, .badge.b-depot { border-bottom-width: 1px; }
.badge .icon { width: 24px; height: 24px; }
.insp-head h2 { font-size: 16px; }
.insp-head small { display: block; color: var(--muted); font-size: 12px; }
.status { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.insp-tabs { margin: 12px 0 0; border-bottom: 1px solid var(--line); }
.insp-tabs button { margin-bottom: -1px; }
.tab-body { padding-top: 12px; }

.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 4px 0; }
.row.total { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; font-weight: 600; }
.row .num { font-variant-numeric: tabular-nums; }

.checks { display: grid; gap: 4px; margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; }
.check .icon { width: 16px; height: 16px; }
.check.yes { color: var(--good); }
.check.no { color: var(--bad); }
.check span { color: var(--text); }

.notice { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 13px; color: var(--muted); margin: 8px 0; }

.empty-state { text-align: center; padding: 22px 12px; color: var(--muted); }
.empty-state .icon { width: 30px; height: 30px; margin-bottom: 6px; color: var(--line-strong); }
.empty-state b { display: block; color: var(--text); font-weight: 500; margin-bottom: 2px; }

.est { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--panel-2); }
.est .row { margin: 2px 0; font-size: 13px; }
.est-title { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.build-list { display: grid; gap: 10px; margin-top: 12px; }
.build-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; }
.build-top { display: flex; align-items: center; gap: 10px; }
.build-top .badge { width: 34px; height: 34px; }
.build-top .badge .icon { width: 20px; height: 20px; }
.build-top b { display: block; }
.build-top small { color: var(--muted); font-size: 12px; }
.build-top .cost { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.tag { font-size: 11px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.tag.good { color: var(--good); border-color: var(--good); }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.build-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }

.workers { display: grid; gap: 6px; }
.worker { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.worker small { display: block; color: var(--muted); font-size: 12px; }
.hire { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; }

.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0 8px; }
.bar i { display: block; height: 100%; background: var(--ink); }
.item-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.item-row:first-of-type { border-top: 0; }
.item-row small { display: block; color: var(--muted); font-size: 12px; }
.item-row .btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.level-bar { display: flex; gap: 4px; margin: 6px 0 10px; }
.level-bar i { flex: 1; height: 6px; border-radius: 2px; background: var(--line); }
.level-bar i.on { background: var(--ink); }
.compare { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
.compare td { padding: 3px 0; }
.compare td + td { text-align: right; font-variant-numeric: tabular-nums; }
.compare td:last-child { font-weight: 500; }

.price-input { width: 96px; text-align: right; }
.tx { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 12px; }
.tx small { display: block; color: var(--muted); }
.tx b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-list { max-height: 300px; overflow: auto; }

.build-actions { margin-top: 12px; }
.bulk-builds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.bulk-builds button { text-align: left; }
@media (max-width: 480px) { .bulk-builds { grid-template-columns: minmax(0, 1fr); } }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid;
  border-left-width: 4px;
  border-radius: 6px;
  font-size: 13px;
}
.alert.warn { background: #fdf4e0; border-color: #d99a1e; color: #5f4306; }
.alert.bad { background: #fbeaea; border-color: #b83232; color: #6e1f1f; }
.alert.info { background: #eaf1fb; border-color: #3f7fd0; color: #1f3f6b; }
.alert button { flex: none; }

.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.small-note { font-size: 12px; margin-top: 8px; }
.outlook { font-size: 13px; }
button.link { border: 0; background: none; padding: 4px 0; color: var(--muted); text-decoration: underline; }
button.link:hover:not(:disabled) { background: none; color: var(--text); }

.modal-box .log-full { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 60vh; overflow: auto; }
.log-full li { padding: 6px 0; border-top: 1px solid var(--line); margin: 0; }
.log-full li:first-child { border-top: 0; }

/* ---------- log ---------- */
.log { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; font-size: 12px; }
.log li { padding: 4px 0; border-top: 1px solid var(--line); color: var(--muted); }
.log li:first-child { border-top: 0; color: var(--text); }

/* ---------- market screen ---------- */
.market-view { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .market-view { grid-template-columns: minmax(0, 1fr); } }

/* Company page: the list of buildings beside the one you are looking at. */
.company-view { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .company-view { grid-template-columns: minmax(0, 1fr); } }
.company-profile { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.company-profile-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.company-profile-main h2, .company-profile-main p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-mark-large { width: 42px; height: 42px; border-radius: 8px; }
.company-mark-large .icon { width: 24px; height: 24px; }
.co-list { display: grid; gap: 8px; margin-top: 10px; }
.co-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.co-row.selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.co-row .badge { width: 34px; height: 34px; }
.co-row .badge .icon { width: 20px; height: 20px; }
.co-main { flex: 1; min-width: 0; }
.co-main b { display: block; }
.co-main small { display: block; color: var(--muted); font-size: 12px; }
.co-side { text-align: right; white-space: nowrap; }
.co-side b { display: block; }
.co-side small { display: flex; align-items: center; justify-content: flex-end; gap: 6px; color: var(--muted); font-size: 12px; }

/* Finance page: summary panels beside the tables. */
.finance-view { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .finance-view { grid-template-columns: minmax(0, 1fr); } }
.fin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fin-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 0; }
.fin-table th:nth-child(2), .fin-table th:nth-child(3), .fin-table td:nth-child(2), .fin-table td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.fin-table td { padding: 6px 0; border-top: 1px solid var(--line); }
.fin-table td:last-child, .fin-table th:last-child { text-align: right; width: 1%; padding-left: 10px; }
.fin-table tfoot td { font-weight: 600; border-top: 2px solid var(--line-strong); }
.mk-item { padding: 8px 0; border-top: 1px solid var(--line); }
.mk-item:first-of-type { border-top: 0; }
.listing { display: grid; grid-template-columns: 1fr auto 70px; gap: 8px; font-size: 12px; padding: 2px 0; }
.listing span:nth-child(2), .listing span:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--bad); font-style: normal; }
.down { color: var(--good); font-style: normal; }
.field { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.field label { flex: 0 0 90px; color: var(--muted); font-size: 12px; }
.field select, .field input { flex: 1; }
.listing-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 12px; }
.listing-row small { display: block; color: var(--muted); }

/* ---------- toasts and modal ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 9px 12px; border-radius: 6px; font-size: 13px; max-width: 320px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 24, 31, .5); display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--panel); border-radius: 8px; padding: 20px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-box h2 { font-size: 18px; margin-bottom: 10px; }
.modal-box ul { margin: 8px 0 0; padding-left: 18px; }
.modal-box li { margin: 5px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Company identity uses fixed choices so the future server can validate the same values. */
.company-form { display: grid; gap: 12px; }
.company-name-field, .company-form legend { font-weight: 500; }
.company-form > input { width: 100%; }
.company-form fieldset { margin: 0; padding: 0; border: 0; }
.company-form legend { margin-bottom: 6px; }
.company-symbols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.company-symbol-option, .company-color-option { cursor: pointer; }
.company-symbol-option { display: flex; align-items: center; gap: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 6px; }
.company-symbol-option:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.company-symbol-option input, .company-color-option input { position: absolute; opacity: 0; pointer-events: none; }
.company-symbol-option .company-mark { width: 25px; height: 25px; }
.company-symbol-option .company-mark .icon { width: 15px; height: 15px; }
.company-colors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.company-color-option { display: flex; align-items: center; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; text-transform: capitalize; font-size: 12px; }
.company-color-option:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.company-color-option > span:first-of-type { width: 17px; height: 17px; flex: none; border-radius: 4px; background: var(--swatch); border: 1px solid rgba(0, 0, 0, .18); }
.company-symbol-option:has(input:focus-visible), .company-color-option:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 1px; }
.company-form-hint { font-size: 12px; }
@media (max-width: 480px) {
  .company-symbols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .company-colors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- world overview ---------- */
#modal .modal-box:has(.world-grid) { max-width: 980px; }
.world-intro { margin-bottom: 12px; }
.world-grid { max-height: 62vh; overflow: auto; border: 1px solid var(--line); }
.world-city-card { display: grid; grid-template-columns: minmax(150px, 1.4fr) repeat(4, minmax(70px, .65fr)) minmax(105px, .8fr) auto; align-items: center; gap: 10px; padding: 9px 10px; border-top: 1px solid var(--line); background: var(--panel); font-size: 12px; }
.world-city-card:first-child { border-top: 0; }
.world-city-card.current { border-left: 3px solid var(--ink); background: var(--panel-2); padding-left: 7px; }
.world-city-name { display: flex; align-items: center; gap: 7px; }
.world-city-card > span em, .world-city-card > span b { display: block; font-style: normal; }
.world-city-card > span em { color: var(--muted); font-size: 11px; }
.world-city-price { color: var(--muted); }
@media (max-width: 760px) {
  .world-city-card { grid-template-columns: minmax(150px, 1fr) repeat(2, minmax(70px, auto)) auto; }
  .world-city-card > span:nth-of-type(3), .world-city-card > span:nth-of-type(4), .world-city-price { display: none; }
}
@media (max-width: 480px) {
  .world-city-card { grid-template-columns: minmax(0, 1fr) auto; }
  .world-city-card > span { display: none; }
}

/* ---------- deliveries (Company page) ---------- */
.company-view #deliveries { grid-column: 1 / -1; }
.notice.bad { color: var(--bad); border-color: var(--bad); }
.contract-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 24px; margin-top: 4px; }
.contract-form .field label { flex-basis: 130px; }
.del-counts { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 10px 0 4px; color: var(--muted); }
.del-counts b { color: var(--text); font-variant-numeric: tabular-nums; }
.del-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 4px 32px; margin-top: 6px; }
.del-group h3 { margin-top: 18px; }
.del-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.del-main { flex: 1; min-width: 0; }
.del-main small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.del-mid { text-align: right; }
.del-mid small { display: block; color: var(--muted); font-size: 12px; }
.del-side { min-width: 52px; text-align: right; }
.del-hint { margin-top: 6px; }
.pill { font-size: 11px; font-weight: 400; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 6px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.pill.contract { color: var(--depot-ink); border-color: var(--depot-ink); }
@media (max-width: 700px) {
  .del-lists { grid-template-columns: minmax(0, 1fr); }
  .del-row { flex-wrap: wrap; }
  .del-mid { text-align: left; flex-basis: 100%; order: 3; }
}

/* ---------- bank ---------- */
.score { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 2px; }
.score b { font-size: 30px; font-weight: 600; line-height: 1.1; }
.score span { color: var(--muted); }
.factor { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.factor small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.factor .num { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.loan { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.loan:first-of-type { border-top: 0; padding-top: 4px; }
.loan-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.loan-head button { margin-left: auto; }
.loan-total { margin-bottom: 8px; }
.pill.ok { color: var(--good); border-color: var(--good); }
.pill.late { color: var(--bad); border-color: var(--bad); }
