/* PROJECT EXASCALE · style.css · V0.810.0
   Industrial HUD over an isometric world. Quiet graphite chrome, one safety-orange action colour,
   system colours reserved for data (power, thermal, fiber, freight, fault, ok, warn).
   No external fonts: system sans with tabular numerals. */

:root {
  --bg: #141618;
  --panel: #1c2024;
  --panel-2: #22272b;
  --panel-3: #2a3035;
  --line: #30363b;
  --line-2: #3c434a;
  --text: #ecebe5;
  --muted: #9aa3ab;
  --dim: #6f7880;
  --accent: #e8702a;
  --accent-2: #f08a4a;
  --accent-ink: #1a0d05;
  --power: #f2b23c;
  --cool: #49c9d8;
  --fiber: #b792ff;
  --road: #9bcf7a;
  --fault: #ff5c48;
  --ok: #5fdc9a;
  --warn: #f0c419;
  --radius: 3px;
  --topbar-h: 52px;
  --dock-w: 392px;
  --nav-w: 64px;
  --tabbar-h: 58px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
button { font: inherit; color: inherit; }
button, select, input, label { touch-action: manipulation; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 13.5px; }
p { margin: 0 0 8px; }
pre { margin: 0; font: 12px/1.45 var(--font); white-space: pre-wrap; word-break: break-word; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ layout */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: 1fr var(--dock-w);
  grid-template-areas: "top top" "stage dock";
}
.topbar { grid-area: top; }
.stage { grid-area: stage; }
.dock { grid-area: dock; }
.tabbar { display: none; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: linear-gradient(180deg, #202428, #191c1f);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -1px 0 #0b0c0d;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 26px; height: 26px; flex: none;
  background:
    linear-gradient(135deg, var(--accent) 0 50%, transparent 50%),
    repeating-linear-gradient(135deg, #2b3035 0 4px, #3a4148 4px 8px);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: 0.08em; font-size: 13px; }
.brand-sub { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock-group { display: flex; align-items: center; gap: 12px; margin-left: 10px; min-width: 0; }
.clock { font-weight: 700; font-size: 14px; letter-spacing: 0.04em; white-space: nowrap; }
.feed { color: var(--muted); font-size: 11.5px; white-space: nowrap; letter-spacing: 0.04em; }
.live { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid var(--line-2); border-radius: 20px; font-size: 11px; letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(95, 220, 154, 0.18); }
.live.alert { color: #ffd9d3; border-color: rgba(255, 92, 72, 0.5); }
.live.alert i { background: var(--fault); box-shadow: 0 0 0 3px rgba(255, 92, 72, 0.22); animation: pulse 1.2s ease-in-out infinite; }
.live.degraded i { background: var(--warn); box-shadow: 0 0 0 3px rgba(240, 196, 25, 0.2); }
@keyframes pulse { 50% { opacity: 0.45; } }
.time-controls { display: flex; gap: 6px; margin-left: auto; }
.file-controls { display: flex; gap: 4px; }

/* ------------------------------------------------------------------ buttons */
.btn { white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; padding: 6px 12px;
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--radius);
  cursor: pointer; font-weight: 600; font-size: 12.5px; line-height: 1.2;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:hover { background: #333a41; border-color: #4a525a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: #c95c1c; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent); }
.btn-small { min-height: 28px; padding: 3px 10px; font-size: 11.5px; }
.btn-wide { width: 100%; }
.btn-icon span { font-size: 12px; }
.btn-time { min-width: 96px; }
.import-label { position: relative; }

/* ------------------------------------------------------------------ stage */
.stage { position: relative; overflow: hidden; background: #121314; min-width: 0; }
.viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.viewport.dragging { cursor: grabbing; }
.viewport.tool-build { cursor: crosshair; }
.viewport.tool-service { cursor: cell; }
.viewport.tool-demolish { cursor: not-allowed; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#map:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-2); }
.hoverlabel {
  position: absolute; display: none; pointer-events: none;
  padding: 6px 9px; background: rgba(20, 22, 24, 0.92); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: var(--radius); font-size: 12px; max-width: 280px; z-index: 5; box-shadow: var(--shadow);
}
.hoverlabel b { display: block; font-size: 12.5px; }
.hoverlabel small { color: var(--muted); display: block; }
.hoverlabel.show { display: block; }

/* resources */
.hud-resources {
  position: absolute; top: 12px; left: 12px; z-index: 4;
  display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 310px);
}
.res {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 104px; padding: 7px 10px 6px;
  background: rgba(20, 22, 24, 0.86); border: 1px solid rgba(60, 67, 74, 0.8); border-radius: var(--radius);
  backdrop-filter: blur(6px);
}
.res-label { font-size: 10.5px; color: var(--muted); letter-spacing: 0.02em; }
.res-value { font-size: 18px; font-weight: 800; line-height: 1.1; display: flex; align-items: baseline; gap: 4px; }
.res-value small { font-size: 10.5px; font-weight: 600; color: var(--muted); }
.res-foot { font-size: 10.5px; color: var(--dim); }
.res-capital .res-value { color: #fff; }
.res-compute .res-value { color: #c7d2ff; }
.res.low .res-value { color: var(--fault); }
.res.warn .res-value { color: var(--warn); }

/* objective */
.hud-objective {
  position: absolute; top: 12px; right: 12px; z-index: 4; width: 280px;
  padding: 9px 12px 10px; background: rgba(20, 22, 24, 0.86); border: 1px solid rgba(60, 67, 74, 0.8); border-left: 3px solid var(--accent);
  border-radius: var(--radius); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; gap: 2px;
}
.obj-kicker { font-size: 10.5px; color: var(--muted); }
.hud-objective strong { font-size: 13.5px; }
.hud-objective > span:not(.obj-kicker) { font-size: 12px; color: #cfd5da; }
.obj-progress { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.obj-bar { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; }
.obj-bar div { height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.obj-progress span { font-size: 11px; color: var(--muted); }
.hud-objective.done { border-left-color: var(--ok); }

/* alerts */
.hud-alerts { position: absolute; top: 112px; right: 12px; z-index: 4; width: 280px; display: flex; flex-direction: column; gap: 6px; }
.alert {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 7px 10px; background: rgba(20, 22, 24, 0.9); border: 1px solid rgba(60, 67, 74, 0.8); border-left: 3px solid var(--warn);
  border-radius: var(--radius); font-size: 12px;
}
.alert svg { width: 15px; height: 15px; margin-top: 1px; color: var(--warn); }
.alert.critical { border-left-color: var(--fault); }
.alert.critical svg { color: var(--fault); }
.alert b { display: block; }
.alert small { color: var(--muted); }

/* map controls */
.hud-mapcontrols { position: absolute; right: 12px; bottom: 204px; z-index: 4; display: flex; flex-direction: column; gap: 4px; }
.mapbtn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: rgba(28, 32, 36, 0.92); border: 1px solid var(--line-2); border-radius: var(--radius); cursor: pointer; color: var(--text);
}
.mapbtn:hover { background: #333a41; }
.mapbtn.toggle[aria-pressed="true"] { background: var(--accent); border-color: #c95c1c; color: var(--accent-ink); }
.mapbtn-gap { height: 8px; }
.minimap { position: absolute; left: 12px; bottom: 204px; z-index: 4; width: 180px; height: 100px; background: rgba(20, 22, 24, 0.86); border: 1px solid var(--line-2); border-radius: var(--radius); }

/* build dock */
.build-dock {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5;
  background: rgba(24, 27, 30, 0.94); border: 1px solid var(--line-2); border-radius: var(--radius);
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "tabs tools" "body body" "foot foot";
}
.dock-tabs { grid-area: tabs; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; min-width: 0; }
.dock-tabs::-webkit-scrollbar { display: none; }
.cat {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; min-height: 40px;
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; font-weight: 600; white-space: nowrap;
}
.cat:hover { color: var(--text); }
.cat.selected { color: var(--text); border-bottom-color: var(--accent); }
.cat svg { width: 16px; height: 16px; }
.dock-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.dock-body { display: contents; }
.building-grid, .route-bar { grid-area: body; margin: 8px; }
.building-grid { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; min-height: 82px; }
.building {
  flex: none; width: 156px; display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto auto; column-gap: 8px; align-items: center; align-content: center;
  padding: 7px 9px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent-c, var(--line-2)); border-radius: var(--radius); cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.building:hover { background: var(--panel-3); }
.building.selected { background: #3a2a1f; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.building.locked { opacity: 0.5; }
.building .building-icon { grid-row: 1 / 4; width: 34px; height: 34px; display: grid; place-items: center; background: #15181b; border-radius: var(--radius); color: var(--accent-c, var(--text)); }
.building .building-icon svg { width: 22px; height: 22px; stroke-width: 1.6; }
.building-title { font-weight: 700; font-size: 12.5px; line-height: 1.15; }
.building-cost { font-size: 12px; color: #fff; }
.building-size { font-size: 10.5px; color: var(--muted); }
.building.locked .building-cost::after { content: " · locked"; color: var(--warn); }
.route-bar { display: flex; gap: 6px; }
.line-btn {
  flex: 1; display: grid; grid-template-columns: 14px 1fr; column-gap: 8px; align-items: center; text-align: left;
  padding: 7px 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); cursor: pointer;
}
.line-btn i { grid-row: 1 / 3; width: 14px; height: 14px; border-radius: 2px; }
.line-btn span { font-weight: 700; font-size: 12.5px; }
.line-btn small { color: var(--muted); font-size: 10.5px; }
.line-btn.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #3a2a1f; }
.line-power i { background: var(--power); }
.line-cool i { background: var(--cool); }
.line-fiber i { background: var(--fiber); }
.line-road i { background: var(--road); }
.tool-bar { grid-area: tools; display: flex; align-items: center; gap: 2px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0 8px; }
.tool-bar .tool {
  display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 2px 10px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius); color: var(--muted); cursor: pointer; font-weight: 600; font-size: 12px; white-space: nowrap;
}
.tool-bar .tool:hover { color: var(--text); background: var(--panel-3); }
.tool-bar .tool.active, .tool-bar .tool[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: #c95c1c; }
.tool svg { width: 15px; height: 15px; }
.dock-foot { grid-area: foot; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px; border-top: 1px solid var(--line); min-height: 30px; }
.dock-status { font-size: 12px; color: #cfd5da; min-width: 0; }
.dock-status.hint { color: var(--warn); }

/* ------------------------------------------------------------------ dock */
.dock {
  display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line);
}
.sheet-handle { display: none; }
.dock-nav { display: flex; flex-direction: column; background: #171a1d; border-right: 1px solid var(--line); padding-top: 4px; }
.nav {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px;
  background: transparent; border: 0; border-left: 3px solid transparent; color: var(--muted); cursor: pointer; font-size: 10.5px; font-weight: 600;
}
.nav:hover { color: var(--text); background: var(--panel-2); }
.nav.selected { color: var(--text); border-left-color: var(--accent); background: var(--panel); }
.nav svg { width: 20px; height: 20px; }
.nav .badge { position: absolute; }
.dock-views { overflow-y: auto; overscroll-behavior: contain; min-height: 0; scrollbar-width: thin; }
.view { padding: 0 14px 24px; }
.view-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; white-space: nowrap; padding: 14px 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.view-sub { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.panel:last-child { border-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-head h3 { flex: 1; min-width: 0; }
.panel.notice { font-size: 11.5px; color: var(--muted); }
.panel.notice b { color: var(--text); }
.lede { color: #cfd5da; }
.note { color: var(--muted); font-size: 12px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--panel-3); color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.chip.ok { background: rgba(95, 220, 154, 0.16); color: var(--ok); }
.chip.warn { background: rgba(240, 196, 25, 0.16); color: var(--warn); }
.chip.fault { background: rgba(255, 92, 72, 0.16); color: #ffb3a8; }
.output { padding: 8px 10px; background: #15181b; border: 1px solid var(--line); border-radius: var(--radius); color: #d6dbe0; margin-top: 8px; max-height: 260px; overflow: auto; }
.feedback { margin-top: 8px; font-size: 12px; color: var(--ok); min-height: 16px; }
.feedback.err { color: var(--fault); }

/* key/value grids used by app.js render() */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px 10px; margin-top: 8px; }
.kv .k { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.2; }
.kv .v { display: block; font-size: 13px; font-weight: 700; line-height: 1.25; word-break: break-word; }
.kv .v.ok { color: var(--ok); }
.kv .v.warn { color: var(--warn); }
.kv .v.fault { color: var(--fault); }
.kv .wide { grid-column: 1 / -1; }
.kv .wide .v { font-weight: 500; font-size: 12px; color: #cfd5da; }
.kv-title { grid-column: 1 / -1; font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; }
.micro { font-size: 11px; color: var(--muted); grid-column: 1 / -1; }
.diagnostic { font-size: 12px; color: #cfd5da; padding: 6px 0; }

/* fields */
.field-row { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; margin: 6px 0; }
.field-row label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.field-row select { min-width: 0; }
.field-row .btn { grid-column: 1 / -1; }
select {
  width: 100%; min-height: 34px; padding: 5px 28px 5px 9px; font: inherit; color: var(--text);
  background: #15181b url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%239aa3ab' stroke-width='1.6'/></svg>") no-repeat right 9px center;
  border: 1px solid var(--line-2); border-radius: var(--radius); appearance: none;
}
.action-row { display: flex; gap: 6px; margin: 8px 0; }
.action-row.wrap { flex-wrap: wrap; }
.action-row .btn { flex: 1; }

/* missions */
.mission-progress { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; margin: 6px 0 4px; }
.mission-progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.mission-meter { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.mission-list { display: flex; flex-direction: column; }
.mission { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.mission .mark { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 11px; color: var(--muted); margin-top: 1px; }
.mission.done .mark { background: var(--ok); border-color: var(--ok); color: #0b2a1a; font-weight: 800; }
.mission.next .mark { border-color: var(--accent); color: var(--accent); }
.mission strong { display: block; font-size: 12.5px; }
.mission.done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.3); }
.mission small { color: var(--muted); display: block; }
.mission .mission-go { grid-column: 2; justify-self: start; margin-top: 4px; }

/* health bars */
.health-row { margin: 6px 0; }
.health-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.health-label b { color: var(--text); }
.bar { height: 7px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; }
.bar div { height: 100%; background: var(--ok); border-radius: 3px; transition: width 0.3s; }
.bar div.short { background: var(--fault); }
.health-row.power .bar div { background: var(--power); }
.health-row.cool .bar div { background: var(--cool); }
.health-row.fiber .bar div { background: var(--fiber); }
.health-row .bar div.short { background: var(--fault); }

/* logs */
.logs { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow: auto; }
.log { padding: 5px 8px; background: #15181b; border-left: 2px solid var(--line-2); font-size: 11.5px; color: #cfd5da; }
.log.alert { border-left-color: var(--fault); }
.log.good { border-left-color: var(--ok); }

/* freight orders */
.freight-orders { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.freight-order { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 4px; align-items: center; padding: 8px; background: #15181b; border: 1px solid var(--line); border-radius: var(--radius); }
.freight-order .order-meta { grid-column: 1 / -1; }
.freight-order strong { display: block; font-size: 12.5px; }
.freight-order small { display: block; color: var(--muted); font-size: 11px; }
.freight-order button { min-height: 28px; padding: 2px 9px; font-size: 11px; font-weight: 700; background: var(--panel-3); border: 1px solid var(--line-2); border-radius: var(--radius); cursor: pointer; }
.freight-order button.cancel-order { color: #ffb3a8; }
.freight-order .planning-eta { font-size: 11px; color: var(--warn); margin-top: 2px; }
.freight-orders:empty::after, .freight-orders.empty { color: var(--muted); font-size: 12px; }

/* techs, contracts, strategies, planning */
.tech, .contract { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.tech b { display: block; font-size: 12.5px; }
.tech small { color: var(--muted); display: block; }
.tech button { min-height: 32px; padding: 4px 12px; font-weight: 700; background: var(--panel-3); border: 1px solid var(--line-2); border-radius: var(--radius); cursor: pointer; white-space: nowrap; }
.tech button:not(:disabled) { background: var(--accent); color: var(--accent-ink); border-color: #c95c1c; }
.tech button:disabled { opacity: 0.55; cursor: not-allowed; }
.tech.done button { background: rgba(95, 220, 154, 0.16); color: var(--ok); border-color: transparent; opacity: 1; }
.strategy-row { padding: 7px 0; border-top: 1px solid var(--line); }
.strategy-row strong { display: block; font-size: 12.5px; }
.strategy-row small { color: var(--muted); }
.planning-risk { padding: 6px 9px; margin: 4px 0; border-left: 3px solid var(--warn); background: #15181b; font-size: 12px; }
.planning-risk.high { border-left-color: var(--fault); }
.planning-risk.low { border-left-color: var(--line-2); }
.hall-settlement { font-size: 12px; color: #cfd5da; padding: 6px 0 2px; }

/* frontier (land/finance/water/charter) */
.frontier-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 6px 0 10px; }
.frontier-metric { padding: 7px 9px; background: #15181b; border: 1px solid var(--line); border-radius: var(--radius); }
.frontier-metric small { display: block; color: var(--muted); font-size: 10.5px; }
.frontier-metric b { font-size: 13px; }
.frontier-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.frontier-row b { display: block; font-size: 12.5px; }
.frontier-row small { display: block; color: var(--muted); font-size: 11px; }
.frontier-row button, .frontier-actions button, .deep-card button, .deep-choices button {
  min-height: 32px; padding: 4px 11px; font-weight: 700; font-size: 11.5px; background: var(--panel-3); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--radius); cursor: pointer;
}
.frontier-row button:hover, .frontier-actions button:hover, .deep-card button:hover, .deep-choices button:hover { background: #333a41; }
.frontier-row button:disabled, .frontier-actions button:disabled, .deep-card button:disabled, .deep-choices button:disabled { opacity: 0.45; cursor: not-allowed; }
.frontier-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.frontier-compact { padding: 8px 0; border-top: 1px solid var(--line); }
.frontier-compact b { display: block; font-size: 12.5px; }
.frontier-compact p { color: var(--muted); font-size: 11.5px; margin: 3px 0 6px; }
.frontier-ok { color: var(--ok); font-weight: 700; }
.frontier-warn { color: var(--warn); font-weight: 700; }
details { margin: 6px 0; }
summary { cursor: pointer; font-weight: 700; font-size: 12.5px; padding: 8px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(45deg); }
summary::-webkit-details-marker { display: none; }

/* deep console */
.deep-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 6px 0; }
.deep-stat { padding: 7px 9px; background: #15181b; border: 1px solid var(--line); border-radius: var(--radius); }
.deep-stat small { display: block; color: var(--muted); font-size: 10.5px; }
.deep-stat b { font-size: 13px; }
.deep-choices { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.deep-choices button { text-align: left; white-space: normal; line-height: 1.3; }
.deep-choices button.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.deep-notes { font-size: 12px; color: #cfd5da; margin: 6px 0; }
.deep-card { padding: 8px 0; border-top: 1px solid var(--line); }
.deep-card strong { display: block; font-size: 12.5px; }
.deep-card small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.deep-controls { display: flex; flex-wrap: wrap; gap: 6px; }

/* inspector */
.inspector-body { display: flex; flex-direction: column; gap: 10px; }
.spec-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.spec { padding: 7px 9px; background: #15181b; border: 1px solid var(--line); border-radius: var(--radius); }
.spec small { display: block; color: var(--muted); font-size: 10.5px; }
.spec b { font-size: 13px; }
.spec.wide { grid-column: 1 / -1; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.checks li { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; padding: 5px 8px; background: #15181b; border-radius: var(--radius); border-left: 3px solid var(--ok); }
.checks li.bad { border-left-color: var(--fault); }
.checks li.pending { border-left-color: var(--line-2); color: var(--muted); }
.checks li i { font-style: normal; font-weight: 800; }
.inspector-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.inspector-actions .btn { flex: 1; min-width: 120px; }
.cond { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.cond div { height: 100%; background: var(--ok); }
.cond div.warn { background: var(--warn); }
.cond div.fault { background: var(--fault); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 11.5px; color: #cfd5da; }
.legend li { display: flex; align-items: center; gap: 8px; }
.sw { width: 14px; height: 10px; border-radius: 2px; flex: none; }
.sw-power { background: var(--power); } .sw-cool { background: var(--cool); } .sw-fiber { background: var(--fiber); } .sw-road { background: var(--road); }
.sw-hazard { background: repeating-linear-gradient(135deg, var(--warn) 0 4px, #1b1b1b 4px 8px); }
.sw-fault { background: var(--fault); } .sw-ok { background: var(--ok); } .sw-warn { background: var(--warn); opacity: 0.6; }

/* ------------------------------------------------------------------ shortcuts + toast */
.shortcuts { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); padding: 16px; }
.shortcuts-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 4px; padding: 14px 16px; box-shadow: var(--shadow); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 0; font-size: 12.5px; }
.keys dt { font-weight: 800; color: var(--accent-2); white-space: nowrap; }
.keys dd { margin: 0; color: #cfd5da; }
.toast {
  position: fixed; left: 50%; bottom: 204px; transform: translateX(-50%); z-index: 60;
  display: none; max-width: min(520px, calc(100% - 32px)); padding: 10px 14px;
  background: #22272b; border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: var(--radius);
  font-size: 12.5px; box-shadow: var(--shadow);
}
.toast.show { display: block; animation: toastin 0.18s ease-out; }
.toast.err { border-left-color: var(--fault); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toastin { from { transform: translate(-50%, 6px); opacity: 0; } }

/* ------------------------------------------------------------------ responsive: narrow desktop */
@media (max-width: 1540px) {
  .cat:not(.selected) span { display: none; }
  .cat { padding: 8px 11px; }
}
@media (max-width: 1280px) {
  :root { --dock-w: 360px; }
  .file-controls .btn span, .btn-time span { display: none; }
  .btn-time { min-width: 44px; }
  .brand-sub { display: none; }
}
@media (max-width: 1100px) {
  :root { --dock-w: 336px; }
  .res { min-width: 104px; }
  .hud-resources { max-width: calc(100% - 300px); }
}

/* ------------------------------------------------------------------ responsive: phones and portrait tablets */
@media (max-width: 900px) {
  :root { --topbar-h: 48px; }
  .app { grid-template-columns: 1fr; grid-template-rows: var(--topbar-h) 1fr var(--tabbar-h); grid-template-areas: "top" "stage" "tabs"; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-text { display: none; }
  .clock-group { gap: 6px; margin-left: 0; flex: 1; min-width: 0; }
  .feed { display: none; }
  .clock { font-size: 13px; }
  .live span { display: none; }
  .live { padding: 4px; border: 0; }
  .time-controls { margin-left: 0; }
  .file-controls .btn span, .btn-time span { display: none; }
  .btn-time { min-width: 44px; padding: 6px 8px; }
  .file-controls { gap: 2px; }
  .file-controls .btn { min-width: 40px; padding: 6px 6px; }
  #help-keys, #save, #reset { display: none; }
  .live { flex: none; margin-left: auto; }
  .clock { flex: none; }

  .hud-resources { top: 8px; left: 8px; right: 8px; max-width: none; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 4px; padding-bottom: 2px; }
  .hud-resources::-webkit-scrollbar { display: none; }
  .res { min-width: 96px; padding: 5px 8px 4px; }
  .res-value { font-size: 15px; }
  .res-foot { display: none; }
  .hud-objective { top: 64px; left: 8px; right: 8px; width: auto; padding: 7px 10px; }
  .hud-objective > span:not(.obj-kicker) { display: none; }
  .obj-progress { margin-top: 4px; }
  .hud-alerts { top: 152px; left: 8px; right: 8px; width: auto; }
  .hud-alerts .alert:nth-child(n+2) { display: none; }
  .hud-mapcontrols { right: 8px; bottom: calc(var(--sheet-peek, 56px) + 10px); flex-direction: column; }
  .mapbtn { width: 44px; height: 44px; }
  .minimap { display: none; }
  .hoverlabel { display: none !important; }

  /* build dock becomes part of the sheet (re-parented by hud.js) */
  .build-dock { position: static; margin: 0 0 10px; box-shadow: none; }
  .build-dock { grid-template-columns: 1fr; grid-template-areas: "tabs" "body" "tools" "foot"; }
  .tool-bar { flex-wrap: wrap; border-left: 0; border-bottom: 0; border-top: 1px solid var(--line); padding: 8px; gap: 6px; }
  .tool-bar .tool { min-height: 44px; flex: 1; justify-content: center; }
  .building { width: 160px; min-height: 64px; }
  .route-bar { flex-direction: column; }
  .dock-foot { flex-direction: column; align-items: flex-start; gap: 2px; }
  .line-btn { min-height: 44px; }
  .dock-status { font-size: 12px; }

  /* dock becomes a bottom sheet */
  .dock {
    position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 20;
    grid-template-columns: 1fr; grid-template-rows: auto 1fr;
    height: 50vh; max-height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 8px);
    border-left: 0; border-top: 1px solid var(--line-2); border-radius: 10px 10px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.22s ease, height 0.22s ease;
  }
  .dock.collapsed { transform: translateY(calc(100% - 40px)); }
  .dock.full { height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 8px); }
  .sheet-handle { display: grid; place-items: center; height: 40px; cursor: pointer; }
  .sheet-handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); }
  .dock-nav { display: none; }
  .dock-views { padding-bottom: env(safe-area-inset-bottom); }
  .view { padding: 0 12px 20px; }
  .view-head { padding: 4px 0 8px; }

  .tabbar {
    grid-area: tabs; display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none;
    background: #171a1d; border-top: 1px solid var(--line); z-index: 21; padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .tab {
    flex: 1 0 auto; min-width: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: transparent; border: 0; border-top: 2px solid transparent; color: var(--muted); font-size: 10.5px; font-weight: 600; cursor: pointer; padding: 6px 8px;
  }
  .tab.selected { color: var(--text); border-top-color: var(--accent); }
  .tab svg { width: 20px; height: 20px; }
  .kv { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .field-row label { margin-top: 4px; }
  .toast { bottom: auto; top: 118px; }
  select, .btn { min-height: 44px; }
  .btn-small { min-height: 36px; }
}
@media (max-width: 420px) {
  .res { min-width: 88px; }
  .building { width: 136px; }
}
/* landscape tablets: keep the side dock but narrower */
@media (min-width: 901px) and (max-width: 1100px) and (orientation: landscape) {
  .hud-objective { width: 240px; }
  .hud-alerts { width: 240px; }
}

/* ------------------------------------------------------------------ motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* V0.850 Living Campus: preserve Claude's industrial palette and model language. */
#run-toggle { min-width: 64px; font-weight: 800; }
#run-speed { width: 58px; min-height: 34px; padding: 4px 7px; }
.simulation-running #run-toggle { background: #316448; color: #f3f8f4; border-color: #569672; }
.time-controls { gap: 5px; }
.topbar { gap: 10px; }
@media (min-width: 901px) {
  body:not([data-view="inspect"]) .build-dock { display: none; }
  body:not([data-view="inspect"]) .minimap { bottom: 16px; }
  body:not([data-view="inspect"]) .hud-mapcontrols { bottom: 16px; }
  .dock-nav { overflow-y: auto; scrollbar-width: thin; }
}
.campus-quick { position: absolute; bottom: 18px; left: 208px; z-index: 5; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line-2); border-left: 3px solid var(--accent); background: #1c2024ee; color: var(--text); border-radius: 3px; padding: 10px 14px; cursor: pointer; font-size: 12px; }
body[data-view="inspect"] .campus-quick { bottom: 202px; }
.shift-briefing { position: absolute; top: 140px; left: 28px; z-index: 12; width: min(460px,calc(100% - 56px)); padding: 25px; background: #191e22f7; border: 1px solid #475048; border-top: 3px solid var(--accent); box-shadow: 0 18px 80px #0006; }
.brief-kicker { color: var(--accent-2); letter-spacing: .14em; font-size: 10px; font-weight: 700; }
.shift-briefing h1 { font-size: clamp(24px,2.4vw,33px); line-height: 1.15; margin: 12px 0; }
.shift-briefing p { font-size: 13px; line-height: 1.6; color: #c1c8c9; }
.brief-facts { display: flex; justify-content: space-between; gap: 10px; padding: 14px 0 18px; font-size: 11px; }
.brief-facts b { display: block; font-size: 17px; color: var(--accent-2); }
.brief-start { width: 100%; flex-direction: column; align-items: flex-start; font-size: 15px; padding: 11px 13px; }
.brief-start span { font-size: 11px; font-weight: 500; }
.shift-briefing .note { font-size: 11px; margin: 10px 0; }
.brief-blank { width: 100%; margin: 4px 0 14px; }
.shift-briefing small { color: var(--muted); font-size: 10px; }
.operations-view .panel { padding-bottom: 16px; }
.ops-field { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11px; margin-bottom: 10px; }
.ops-field select { width: 100%; min-width: 0; min-height: 38px; }
.ops-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.ops-inline .btn { flex: 1; min-height: 34px; }
.ops-toggle { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 12px 0; }
.ops-toggle input { accent-color: var(--accent); width: 17px; height: 17px; }
.ops-notice { border-left: 2px solid var(--power); padding: 8px 10px; color: #e0d3b2; background: #33302466; font-size: 11px; margin: 12px 0; line-height: 1.5; }
.allocation-meter { display: flex; height: 7px; border-radius: 2px; background: #353c3f; overflow: hidden; margin: 12px 0 9px; }
.allocation-meter span { transition: width .25s ease; min-width: 0; }
.allocation-tenant { background: var(--fiber); }.allocation-jobs { background: var(--accent); }.allocation-spot { background: #7eac9a; }
.ops-legend { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 10px; color: var(--muted); }
.legend-tenant { color: var(--fiber); }.legend-jobs { color: var(--accent-2); }.legend-spot { color: #7eac9a; }
.ops-empty { padding: 12px; border: 1px dashed #465048; border-radius: 3px; }
.ops-empty b { font-size: 12px; }.ops-empty p { margin: 5px 0 0; }
.job-card { border: 1px solid var(--line-2); border-left: 2px solid var(--accent); padding: 12px; background: #161a1d; margin: 0 0 10px; border-radius: 3px; }
.job-card.blocked { border-left-color: var(--fault); }
.job-card-head,.offer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.job-card-head small { color: var(--muted); font-size: 10px; }.job-card-head h3 { font-size: 14px; margin-top: 2px; }
.job-card .chip { font-size: 9px; padding: 3px 5px; }
.job-pipeline { display: flex; align-items: center; gap: 4px; margin: 14px 0 9px; }
.job-pipeline span { flex: 1; border-bottom: 2px solid #3d4448; padding-bottom: 5px; color: var(--dim); font-size: 10px; }
.job-pipeline span.current { color: var(--accent-2); border-color: var(--accent); }.job-pipeline span.done { color: var(--ok); border-color: #44825d; }
.job-progress { height: 4px; background: #343a3d; overflow: hidden; }.job-progress div { height: 100%; background: var(--accent); transition: width .25s; }
.job-facts { display: flex; justify-content: space-between; font-size: 10px; color: #bbc3c8; margin: 7px 0; }
.offer-card { padding: 12px 0; border-top: 1px solid var(--line); }.offer-card:first-child { border-top: 0; }
.offer-head strong { font-size: 13px; }.offer-value { color: var(--accent-2); font-size: 12px; white-space: nowrap; }
.offer-client { color: var(--muted); font-size: 10px; display: block; margin: 2px 0 7px; }
.offer-details summary { color: var(--muted); font-size: 11px; cursor: pointer; }.offer-details p { margin-top: 8px; }
.offer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }.offer-risk { font-size: 10px; color: var(--ok); }
.offer-card.locked { opacity: .6; }.rack-card { padding: 10px 0; border-top: 1px solid var(--line); }.rack-card .offer-head { margin-bottom: 8px; }
.ops-events { margin-top: 12px; max-height: 260px; overflow: auto; }.ops-event { display: grid; grid-template-columns: 34px 1fr; gap: 6px; padding: 7px 0; font-size: 10px; border-top: 1px solid var(--line); color: var(--muted); }.ops-event time { color: #c2c9cf; }.ops-event.success { color: #8ecdaa; }.ops-event.warning { color: #eac078; }
.fx-disabled * { transition: none !important; }
.fx-disabled :is(.live.alert i,.toast.show,.g-reward.pop) { animation: none !important; }
@media (max-width: 1400px) and (min-width: 901px) { .brand-sub { display: none; }.file-controls .btn span { display: none; }.feed { display: none; } }
@media (max-width: 900px) {
  #step,#fast { display: none; }
  #run-toggle { min-width: 44px; padding: 7px 8px; min-height: 40px; }
  #run-speed { min-height: 40px; width: 49px; padding: 4px; }
  .clock-group { gap: 5px; }.topbar { gap: 5px; }.brand-mark { width: 20px; height: 22px; }.clock { font-size: 11.5px; letter-spacing: 0; }
  .live { display: none; }
  .res { min-width: 87px; }.res-value { font-size: 14px; }.res-label { font-size: 10px; }
  .hud-objective { top: 63px; padding: 6px 9px; }
  .obj-kicker { display: none; }.hud-objective strong { font-size: 12px; }.obj-progress { margin-top: 4px; }
  .hud-alerts { top: 116px; }.hud-alerts .alert { padding: 6px 9px; font-size: 11px; }.hud-alerts .alert small { font-size: 10px; }
  .campus-quick,body[data-view="inspect"] .campus-quick { bottom: calc(var(--sheet-peek,40px) + 14px); left: 10px; max-width: calc(100% - 75px); padding: 10px 12px; font-size: 11px; }
  .shift-briefing { left: 12px; top: 146px; width: calc(100% - 24px); padding: 18px; max-height: calc(100% - 168px); overflow: auto; }
  .shift-briefing h1 { font-size: 25px; }.shift-briefing p { font-size: 12px; }.brief-facts { padding: 10px 0; font-size: 10px; }.brief-start { min-height: 56px; }
  .ops-inline .btn,.offer-foot .btn { min-height: 42px; }.ops-field select { min-height: 44px; }.ops-toggle { min-height: 36px; }
  .offer-details summary { min-height: 32px; display: flex; align-items: center; }
  .dock.full { max-height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 10px); }
}
@media (max-width: 360px) { .brand { display: none; }.clock { font-size: 11px; }.file-controls .btn { min-width: 36px; }.topbar { padding: 0 6px; } }

/* Header groups cannot shrink through one another. */
.time-controls,.file-controls,.clock-group { flex-shrink: 0; }
.brand { flex: 1 1 170px; }
.brand-name { white-space: nowrap; }
.rack-service { margin-top: 10px; }
@media (min-width: 901px) and (max-width: 1560px) { .feed { display: none; }.brand-sub { font-size: 10px; } }
@media (min-width: 901px) and (max-width: 1180px) { .live { max-width: 140px; overflow: hidden; }.brand-name { font-size: 11px; }.clock-group { margin-left: 0; }.topbar { gap: 7px; padding: 0 10px; } }
@media (max-width: 900px) { .brand { flex: 0 0 auto; }.time-controls { margin-left: auto; }.clock-group { margin-left: 2px; } }

.ops-policies > summary { color: var(--text); font-weight: 600; cursor: pointer; padding: 8px 0; }.ops-policies[open] > summary { margin-bottom: 10px; }

