/* ========================================================================
   symbios — dashboard styles
   ===================================================================== */

:root {
  --bg-0: #0a0d12;
  --bg-1: #0f141b;
  --bg-2: #161c25;
  --bg-3: #1d2531;
  --line: #232c3a;
  --line-strong: #2e3a4d;
  --text: #e6edf6;
  --text-2: #9aa5b6;
  --text-3: #5f6b80;
  --accent: #6ee7ff;
  --accent-warm: #fbbf24;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 6px 24px rgba(0,0,0,0.4);
  --node-w: 200px;
  --port: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-0); color: var(--text); font-size: 13px;
}
button { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(to bottom, var(--bg-1), var(--bg-0));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; letter-spacing: 0.18em; font-size: 13px; }
.brand-tag { color: var(--text-3); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.topbar-actions { display: flex; gap: 6px; align-items: center; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.btn {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 12px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-3); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); color: #001018; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #93f0ff; }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: 240px 1fr 320px;
  height: calc(100vh - 48px);
}
.panel { background: var(--bg-1); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.panel.right { border-right: none; border-left: 1px solid var(--line); }
.panel-title {
  padding: 10px 14px; font-size: 11px; letter-spacing: 0.1em; color: var(--text-3);
  text-transform: uppercase; border-bottom: 1px solid var(--line);
}

/* ---------- Palette ---------- */
.palette-mode {
  display: flex; gap: 4px; padding: 8px 10px 0; border-bottom: 1px solid var(--line);
}
.palette-mode-btn {
  flex: 1; background: var(--bg-2); color: var(--text-3);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 5px 5px 0 0;
  padding: 6px 8px; font-size: 11px; font-family: inherit;
  cursor: pointer; letter-spacing: 0.02em;
  transition: background .12s, color .12s, border-color .12s;
}
.palette-mode-btn:hover { color: var(--text); background: var(--bg-1); }
.palette-mode-btn.active {
  background: var(--bg);
  color: var(--text);
  border-color: var(--accent);
  position: relative; z-index: 1;
  margin-bottom: -1px;
}
.palette-search {
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.palette-search input {
  width: 100%; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px;
  padding: 5px 8px; font-size: 12px; font-family: inherit;
  outline: none;
}
.palette-search input:focus { border-color: var(--accent); }
.palette { padding: 6px; overflow-y: auto; flex: 1; }

.palette-group { margin-bottom: 4px; }
.palette-cat-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px 4px; cursor: pointer; user-select: none;
  font-size: 10px; letter-spacing: 0.12em; color: var(--text-3);
  text-transform: uppercase;
}
.palette-cat-head:hover { color: var(--text); }
.palette-cat-head .caret { font-size: 9px; transition: transform .15s; width: 8px; }
.palette-cat-head .cat-name { flex: 1; }
.palette-cat-head .cat-count {
  font-size: 9px; color: var(--text-3); background: var(--bg-2);
  padding: 1px 5px; border-radius: 8px; letter-spacing: 0;
}
.palette-group.collapsed .caret { transform: rotate(-90deg); }
.palette-group.collapsed .palette-cat-body { display: none; }
.palette-cat-body { padding: 0 4px; }

.palette-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; margin: 2px 0; border-radius: 6px;
  background: var(--bg-2); border: 1px solid transparent;
  cursor: grab; user-select: none;
}
.palette-item:hover { border-color: var(--line-strong); background: var(--bg-3); }
.palette-item:active { cursor: grabbing; }
.palette-item.hidden { display: none; }
.palette-icon {
  width: 24px; height: 24px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); font-size: 13px;
}
.palette-label { font-size: 12px; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty {
  padding: 16px; text-align: center; font-size: 11px; color: var(--text-3);
}

/* ---------- Canvas ---------- */
.canvas-wrap { position: relative; overflow: hidden; background:
  radial-gradient(circle at 20% 0%, #122031 0%, var(--bg-0) 60%);
}
.viewport {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  cursor: grab;
}
.viewport.panning { cursor: grabbing; }
.world {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  width: 1px; height: 1px;  /* children positioned absolutely */
}
.edges-layer, .overlay-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
}
.world { z-index: 2; }
.overlay-layer { z-index: 4; }
.edges-layer.on-top { z-index: 3; }
.edges-layer .edge { pointer-events: stroke; }

/* ---------- Node ---------- */
.node {
  position: absolute; width: var(--node-w);
  background: linear-gradient(to bottom, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow);
  user-select: none;
  --accent-color: #6ee7ff;
  border-top: 2px solid var(--accent-color);
}
.node.selected { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.node.starved  { border-color: var(--bad); }
.node.overflowing  { border-color: var(--warn); }
.node.idle  { opacity: 0.55; }
.node.locked  { box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.node-lock {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9px; padding: 2px 5px; border-radius: 3px;
  background: rgba(110,231,255,0.15); color: var(--accent);
  border: 1px solid rgba(110,231,255,0.3);
}
.node.selected.locked { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(110,231,255,0.25), var(--shadow); }
.node-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  cursor: grab;
}
.node-head .icon {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border-radius: 5px; font-size: 13px;
}
.node-head .title { font-size: 12px; font-weight: 600; flex: 1; }
.node-head .badge {
  font-size: 9px; letter-spacing: 0.1em; padding: 2px 6px; border-radius: 3px;
  background: rgba(255,255,255,0.06); color: var(--text-2);
  text-transform: uppercase;
}
.node-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px;
  padding: 6px 0 8px;
}
.node-ports { display: flex; flex-direction: column; gap: 4px; }
.node-ports.in { padding-left: 0; }
.node-ports.out { padding-right: 0; align-items: flex-end; }
.port {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--text-2);
  padding: 2px 4px; position: relative;
}
.port.out { flex-direction: row-reverse; }
.port .dot {
  width: var(--port); height: var(--port); border-radius: 50%;
  background: var(--bg-3); border: 2px solid var(--accent-color);
  cursor: crosshair;
  flex-shrink: 0;
}
.port .dot:hover { transform: scale(1.2); }
.port .label { white-space: nowrap; }
.node-foot {
  display: flex; gap: 8px; padding: 6px 10px 8px;
  border-top: 1px solid var(--line);
  font-size: 10px; color: var(--text-3);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.node-foot .stat { display: flex; flex-direction: column; gap: 1px; }
.node-foot .stat .v { color: var(--text); font-weight: 600; }
.node-bar {
  height: 3px; background: var(--bg-3); margin: 0;
  border-radius: 0 0 9px 9px; overflow: hidden;
}
.node-bar > span {
  display: block; height: 100%;
  background: linear-gradient(to right, var(--good), var(--accent));
  transition: width .25s;
}

/* ---------- Rjukan view ---------- */
body.mode-rjukan #legend { display: none; }
body.mode-rjukan #edge-style-switch { opacity: 0.5; pointer-events: none; }
body.mode-rjukan .viewport { cursor: default; }

.node.rjukan-node {
  background: linear-gradient(to bottom, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--accent-color);
  border-radius: 8px;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 6px 8px;
  box-shadow: var(--shadow);
}
.node.rjukan-node .rjk-head {
  display: flex; align-items: center; gap: 6px;
}
.node.rjukan-node .rjk-head .icon {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border-radius: 4px; font-size: 12px;
}
.node.rjukan-node .rjk-head .title {
  font-size: 11px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node.rjukan-node .rjk-foot {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px; display: flex; align-items: baseline; gap: 4px;
}
.node.rjukan-node .rjk-foot .t { color: var(--text); font-weight: 700; }
.node.rjukan-node .rjk-foot .u { color: var(--text-3); font-size: 9px; }
.node.rjukan-node.starved      { border-color: var(--bad); }
.node.rjukan-node.overflowing  { border-color: var(--warn); }
.node.rjukan-node.idle         { opacity: 0.55; }
.node.rjukan-node.selected     { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

/* ---------- Edges ---------- */
.edges-layer path {
  fill: none; stroke-width: 2; opacity: 0.7;
  transition: opacity .15s;
}
.edges-layer path.selected { stroke-width: 3.5; opacity: 1; filter: drop-shadow(0 0 3px currentColor); }
.edges-layer .util-bg { stroke-width: 5; opacity: 0.18; }
.edges-layer .util-fill { stroke-width: 2.5; }
.edges-layer .label { fill: var(--text-2); font-size: 10px; font-family: "JetBrains Mono", ui-monospace, monospace; pointer-events: none; }

/* ---------- HUD ---------- */
.canvas-hud {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.canvas-hud > * { pointer-events: auto; }
.hud-pill {
  background: rgba(15, 20, 27, 0.9); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; font-size: 11px;
  display: flex; align-items: center; gap: 6px;
}
.hud-pill::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
}
.hud-pill.ok::before    { background: var(--good); }
.hud-pill.warn::before  { background: var(--warn); }
.hud-pill.bad::before   { background: var(--bad); }
.hud-pill.busy::before  { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.hud-metrics { display: flex; gap: 12px; }
.hud-metric { background: rgba(15,20,27,0.85); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 6px; font-size: 11px;
  font-family: "JetBrains Mono", ui-monospace, monospace; }
.hud-metric .k { color: var(--text-3); margin-right: 6px; font-size: 10px; }
.hud-metric .v { color: var(--text); }
.hud-metric.bad .v { color: var(--bad); }
.hud-metric.warn .v { color: var(--warn); }

.hud-styles {
  margin-left: auto; display: flex; align-items: center; gap: 2px;
  background: rgba(15,20,27,0.85); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px;
}
.hud-styles button {
  width: 26px; height: 24px; background: transparent; color: var(--text-2);
  border: none; border-radius: 4px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.hud-styles button:hover { background: var(--bg-3); color: var(--text); }
.hud-styles button.active { background: var(--accent); color: #001018; }
.hud-styles .seg-divider { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }

.hud-zoom { display: flex; align-items: center; gap: 4px;
  background: rgba(15,20,27,0.85); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px; }
.iconbtn {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-2); border: none; border-radius: 4px; cursor: pointer;
  font-size: 14px;
}
.iconbtn:hover { background: var(--bg-3); color: var(--text); }
#zoom-label { font-size: 11px; padding: 0 6px; color: var(--text-2); min-width: 38px; text-align: center; }

.legend {
  position: absolute; bottom: 12px; left: 12px;
  background: rgba(15,20,27,0.9); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 8px;
  display: flex; flex-wrap: wrap; gap: 8px 14px; max-width: 80%;
}
/* Hide the chrome entirely when the canvas is empty so the legend
   doesn't show up as an empty pill. */
.legend:empty { display: none; }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-2);
  cursor: pointer; padding: 2px 4px; border-radius: 4px;
  transition: background 80ms;
}
.legend-item:hover { background: var(--bg-2); color: var(--text); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

/* Legend-hover highlight: dim everything resource-bearing, then a JS-set
   `.highlight-match` class restores opacity + adds a soft glow on the
   resource the user is hovering. */
body[data-highlight-resource] g.edge,
body[data-highlight-resource] g.rjk-rail,
body[data-highlight-resource] .port {
  opacity: 0.18; transition: opacity 120ms, filter 120ms;
}
body[data-highlight-resource] g.edge.highlight-match,
body[data-highlight-resource] g.rjk-rail.highlight-match,
body[data-highlight-resource] .port.highlight-match {
  opacity: 1;
  filter: drop-shadow(0 0 4px currentColor);
}
.legend-item.highlight-match { background: var(--bg-3); color: var(--text); }
.legend-item { cursor: pointer; }

/* Pinned (clicked) highlight is stronger than hover. */
body[data-highlight-pinned] g.edge.highlight-match,
body[data-highlight-pinned] g.rjk-rail.highlight-match,
body[data-highlight-pinned] .port.highlight-match {
  filter: drop-shadow(0 0 8px currentColor) drop-shadow(0 0 2px currentColor);
}
body[data-highlight-pinned] .legend-item.highlight-match {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* ---------- Inspector ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 10px 8px; background: transparent; border: none;
  color: var(--text-3); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { display: none; flex: 1; overflow-y: auto; padding: 12px 14px; }
.tab-body.active { display: block; }
.empty-state { color: var(--text-3); font-size: 12px; padding: 20px 4px; text-align: center; }

.inspector h3 { margin: 0 0 6px; font-size: 13px; }
.inspector .meta { color: var(--text-3); font-size: 11px; margin-bottom: 12px; }
.field { margin-bottom: 10px; }
.field label { display: flex; justify-content: space-between; font-size: 11px;
  color: var(--text-2); margin-bottom: 3px; }
.field label .unit { color: var(--text-3); font-size: 10px; }
.field input[type=range] { width: 100%; }
.field input[type=number] {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 6px; font-size: 12px; font-family: "JetBrains Mono", ui-monospace, monospace;
}
.field-row { display: flex; gap: 6px; align-items: center; }
.field-row input[type=range] { flex: 1; }
.field-row input[type=number] { width: 70px; }

.lock-card {
  background: rgba(110,231,255,0.06); border: 1px solid rgba(110,231,255,0.2);
  border-radius: 6px; padding: 8px 10px; margin: 6px 0 12px;
}
.lock-card .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.lock-card .head label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; cursor: pointer; color: var(--text);
}
.lock-card .head input { accent-color: var(--accent); }
.lock-card .hint { font-size: 10px; color: var(--text-3); margin-top: 6px; line-height: 1.35; }
.lock-card.disabled .field { opacity: 0.4; pointer-events: none; }
.lock-card select {
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 6px; font-size: 12px; font-family: inherit;
  flex: 1; outline: none; cursor: pointer;
}
.lock-card select:focus { border-color: var(--accent); }

.inspector-section {
  margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px;
}
.inspector-section h4 {
  margin: 0 0 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3);
}
.iorow {
  display: flex; justify-content: space-between; padding: 3px 0;
  font-size: 11px; font-family: "JetBrains Mono", ui-monospace, monospace;
}
.iorow .lbl { color: var(--text-2); }
.iorow .val { color: var(--text); }
.iorow.short .val { color: var(--bad); }
.iorow.over  .val { color: var(--warn); }

.delete-btn { background: rgba(248, 113, 113, 0.15); color: var(--bad);
  border: 1px solid rgba(248,113,113,0.3); padding: 6px 10px; border-radius: 5px;
  cursor: pointer; font-size: 11px; margin-top: 8px; width: 100%;
}
.delete-btn:hover { background: rgba(248,113,113,0.25); }

/* ---------- Results ---------- */
.results .metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.results .metric-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px;
}
.results .metric-card .lbl { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.results .metric-card .val { font-size: 18px; font-weight: 700;
  font-family: "JetBrains Mono", ui-monospace, monospace; margin-top: 4px; }
.results .metric-card.bad .val { color: var(--bad); }
.results .metric-card.warn .val { color: var(--warn); }
.results .metric-card.good .val { color: var(--good); }
.results h4 { font-size: 11px; text-transform: uppercase; color: var(--text-3);
  letter-spacing: 0.08em; margin: 12px 0 6px; }
.results-list { list-style: none; padding: 0; margin: 0; }
.results-list li {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 11px; font-family: "JetBrains Mono", ui-monospace, monospace;
  border-bottom: 1px dashed var(--line);
}
.results-list li.empty { color: var(--text-3); justify-content: center; }

.results-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.results-table th {
  padding: 4px 6px; text-align: left; border-bottom: 1px solid var(--line);
  opacity: 0.6; font-weight: 500; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3);
}
.results-table td {
  padding: 6px 6px; border-bottom: 1px dashed rgba(255,255,255,0.05);
  color: var(--text);
}
.results-table tbody tr:last-child td { border-bottom: none; }
.bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 11px; }
.bar-row .name { width: 86px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--accent); }
.bar-row .v { font-family: "JetBrains Mono", ui-monospace, monospace; color: var(--text); width: 48px; text-align: right; }

/* ---------- Scenarios ---------- */
/* ---------- Cascade ---------- */
.cascade .driver-card {
  border: 1px solid var(--accent); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 10px;
  background: rgba(110,231,255,0.06);
}
.cascade .driver-card h5 {
  margin: 0 0 4px; font-size: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.cascade .driver-card h5 .target {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--accent); font-weight: 700;
}
.cascade .branch {
  margin: 4px 0 8px;
}
.cascade .branch h6 {
  margin: 8px 0 4px; font-size: 10px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.cascade .casc-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 6px; padding: 4px 8px; align-items: center;
  font-size: 11px; border-bottom: 1px dashed var(--line);
}
.cascade .casc-row .who {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.cascade .casc-row .who .icon {
  width: 18px; height: 18px; display: inline-flex; align-items: center;
  justify-content: center; background: var(--bg-3); border-radius: 4px; font-size: 12px;
}
.cascade .casc-row .who .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cascade .casc-row .what {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--text-2); font-size: 10px;
}
.cascade .casc-row .val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 600; min-width: 64px; text-align: right;
}
.cascade .casc-row.ok .val   { color: var(--good); }
.cascade .casc-row.short .val { color: var(--bad); }
.cascade .casc-row.warn .val  { color: var(--warn); }
.cascade .casc-row.ok::before, .cascade .casc-row.short::before, .cascade .casc-row.warn::before {
  /* No leading bullet — values speak for themselves. */
}

.cascade .summary-grid {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 4px 10px; font-size: 11px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  margin-top: 6px;
}
.cascade .summary-grid .h {
  font-family: inherit; color: var(--text-3); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line); padding-bottom: 2px;
}
.cascade .summary-grid .res-name {
  display: flex; align-items: center; gap: 6px; color: var(--text);
}
.cascade .summary-grid .swatch { width: 8px; height: 8px; border-radius: 2px; }
.cascade .summary-grid .gap { color: var(--bad); }
.cascade .summary-grid .gap.zero { color: var(--text-3); }

.scenarios .scenario {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px;
  background: var(--bg-2);
}
.scenarios .scenario h5 { margin: 0 0 4px; font-size: 12px; }
.scenarios .scenario .row {
  display: flex; justify-content: space-between; font-size: 11px;
  font-family: "JetBrains Mono", ui-monospace, monospace; color: var(--text-2);
}
.scenarios .scenario.bad   { border-color: var(--bad); }
.scenarios .scenario.warn  { border-color: var(--warn); }
.scenarios .scenario.good  { border-color: var(--good); }
.scenarios .delta { color: var(--text); }
.scenarios .delta.bad  { color: var(--bad); }
.scenarios .delta.good { color: var(--good); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--line-strong); padding: 8px 16px;
  border-radius: 999px; font-size: 12px; color: var(--text);
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; box-shadow: var(--shadow); z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Drag preview ---------- */
.drag-ghost {
  position: fixed; pointer-events: none; opacity: 0.7;
  background: var(--bg-2); border: 1px solid var(--accent); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; z-index: 1000;
}

/* connection draft line */
#overlay-layer .draft-line {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-dasharray: 4 3; pointer-events: none;
}

/* ---------- Timeline tab ---------- */
.timeline { display: flex; flex-direction: column; gap: 8px; padding: 6px; }
.tl-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 6px; background: var(--bg-2); border-radius: 6px;
}
.tl-stat { display: flex; flex-direction: column; align-items: center; }
.tl-stat label { font-size: 10px; opacity: 0.6; text-transform: uppercase; }
.tl-stat b { font-size: 14px; font-weight: 600; }
.tl-stat.tl-warn b { color: #fbbf24; }
.tl-xaxis {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  font-size: 10px; opacity: 0.5; padding: 0 2px;
}
.tl-section { display: flex; flex-direction: column; gap: 4px; }
.tl-section-title {
  font-size: 10px; opacity: 0.5; text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 6px;
}
.tl-row {
  background: var(--bg-2); border-radius: 6px; padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.tl-row-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
}
.tl-icon { font-size: 14px; }
.tl-label { flex: 1; }
.tl-spark { width: 100%; height: 38px; }
.tl-spark svg { width: 100%; height: 100%; display: block; }
.tl-sub { font-size: 10px; opacity: 0.55; }

/* ---------- Robust scrolling for the right panel ---------- */
.panel.right { min-height: 0; }
.panel.right .tab-body { min-height: 0; }
.inspector { display: flex; flex-direction: column; gap: 6px; }

/* ---------- AI assistant card ---------- */
.ai-card textarea {
  width: 100%; box-sizing: border-box;
  padding: 6px 8px; font: inherit; font-size: 12px;
  background: var(--bg-2); color: var(--text-1);
  border: 1px solid var(--line); border-radius: 6px;
  resize: vertical; min-height: 38px;
}
.ai-card textarea:focus { outline: none; border-color: var(--accent); }
.ai-card .ai-row {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
}
.ai-card .btn.small {
  padding: 4px 10px; font-size: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: 0; border-radius: 6px; cursor: pointer;
}
.ai-card .btn.small:hover { filter: brightness(1.1); }
.ai-card .btn.small:disabled { opacity: 0.55; cursor: wait; }
.ai-card .ai-status { font-size: 10px; opacity: 0.65; }

/* ---------- Scrollable panels — visible, themed, always-on ---------- */
/* Applies to the left palette and the right inspector / results / timeline.
   Default GTK scrollbars are auto-hiding and easy to miss; these are
   thin but always visible so users see they CAN scroll. */
.palette,
.tab-body,
.timeline,
.inspector,
.results,
.cascade,
.scenarios {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.palette::-webkit-scrollbar,
.tab-body::-webkit-scrollbar,
.timeline::-webkit-scrollbar,
.inspector::-webkit-scrollbar,
.results::-webkit-scrollbar,
.cascade::-webkit-scrollbar,
.scenarios::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.palette::-webkit-scrollbar-track,
.tab-body::-webkit-scrollbar-track,
.timeline::-webkit-scrollbar-track,
.inspector::-webkit-scrollbar-track,
.results::-webkit-scrollbar-track,
.cascade::-webkit-scrollbar-track,
.scenarios::-webkit-scrollbar-track {
  background: transparent;
}
.palette::-webkit-scrollbar-thumb,
.tab-body::-webkit-scrollbar-thumb,
.timeline::-webkit-scrollbar-thumb,
.inspector::-webkit-scrollbar-thumb,
.results::-webkit-scrollbar-thumb,
.cascade::-webkit-scrollbar-thumb,
.scenarios::-webkit-scrollbar-thumb {
  background: var(--line-strong, #444);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
  min-height: 30px;
}
.palette::-webkit-scrollbar-thumb:hover,
.tab-body::-webkit-scrollbar-thumb:hover,
.timeline::-webkit-scrollbar-thumb:hover,
.inspector::-webkit-scrollbar-thumb:hover,
.results::-webkit-scrollbar-thumb:hover,
.cascade::-webkit-scrollbar-thumb:hover,
.scenarios::-webkit-scrollbar-thumb:hover {
  background: var(--accent, #6aa6ff);
  background-clip: padding-box;
}

/* Subtle gradient hint at the bottom of scrollable panels —
   tells the user "there's more below" when content overflows. */
.panel.left,
.panel.right {
  position: relative;
}
.panel.left::after,
.panel.right::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 18px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg-1) 90%);
  opacity: 0.7;
}

/* Make sure flex containers can shrink below their content height so
   that overflow:auto on inner scroll panes actually triggers. */
.panel.left, .panel.right { min-height: 0; }
.palette { min-height: 0; }

/* ---------- Reports tab ---------- */
.report { display: flex; flex-direction: column; gap: 10px; padding: 6px; }
.rep-card {
  background: var(--bg-2); border-radius: 8px; padding: 10px 12px;
  border: 1px solid var(--line);
}
.rep-card h4 {
  margin: 0 0 8px; font-size: 11px; opacity: 0.65;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.rep-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-bottom: 8px;
}
.rep-stat label {
  display: block; font-size: 10px; opacity: 0.55;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.rep-stat b {
  font-size: 18px; font-weight: 600; line-height: 1.2;
  display: block; margin-top: 2px;
}
.rep-stat b span { font-size: 11px; opacity: 0.55; font-weight: 400; }
.rep-stat small { font-size: 10px; opacity: 0.5; }
.rep-stat b.positive, .positive { color: #10b981; }
.rep-stat b.negative, .negative { color: #f97316; }

/* Bars (used for circularity + co2 split) */
.rep-bar-group { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.rep-bar-row {
  display: grid; grid-template-columns: 70px 1fr 60px; gap: 8px;
  align-items: center; font-size: 11px;
}
.rep-bar-row span { opacity: 0.6; text-transform: uppercase; font-size: 10px; }
.rep-bar-row b { text-align: right; font-weight: 600; }
.rep-bar {
  height: 8px; background: rgba(255,255,255,0.05); border-radius: 4px;
  overflow: hidden;
}
.rep-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.rep-bar-fill.positive { background: #10b981; }
.rep-bar-fill.negative { background: #f97316; }

/* Economy ledger rows */
.rep-econ-rows { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.rep-econ-row {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 12px; border-bottom: 1px dashed rgba(255,255,255,0.05);
}
.rep-econ-row b { font-variant-numeric: tabular-nums; }
.rep-econ-row.total {
  border-top: 1px solid var(--line); border-bottom: 0;
  margin-top: 4px; padding-top: 6px; font-weight: 600;
}
.rep-econ-row.positive span { color: #10b981; opacity: 0.85; }
.rep-econ-row.negative span { color: #f97316; opacity: 0.85; }

/* Per-resource table */
.rep-restable { width: 100%; border-collapse: collapse; font-size: 11px; }
.rep-restable th, .rep-restable td {
  padding: 4px 6px; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.rep-restable th { opacity: 0.6; font-weight: 500; text-align: right; }
.rep-restable th:first-child, .rep-restable td:first-child { text-align: left; }
.rep-restable td { font-variant-numeric: tabular-nums; }
.rep-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}

.rep-table { margin-top: 8px; }
.rep-table-title {
  font-size: 10px; opacity: 0.55; text-transform: uppercase; margin-bottom: 4px;
}
.rep-row {
  display: flex; justify-content: space-between; font-size: 11px; padding: 2px 0;
}
.rep-foot {
  font-size: 10px; opacity: 0.5; padding: 6px 4px; line-height: 1.4;
}
.rep-foot code {
  background: var(--bg-2); padding: 1px 4px; border-radius: 3px;
}

/* ---------- Lightbulb idea button + modal ---------- */
.idea-btn {
  font-size: 16px; padding: 4px 10px; line-height: 1;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1a1a1a; border: 0; cursor: pointer;
}
.idea-btn:hover { filter: brightness(1.1); }

.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.55);
}
.modal-card {
  position: relative; z-index: 1;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 10px; min-width: 480px; max-width: 640px;
  max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.modal-head, .modal-foot {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 8px;
}
.modal-head {
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 14px; flex: 1; }
.modal-close {
  background: none; border: 0; color: var(--text-2);
  font-size: 20px; cursor: pointer; padding: 0 6px;
}
.modal-close:hover { color: var(--text-1); }
.modal-body {
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
}
.modal-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modal-row input[type=text],
.modal-row textarea {
  width: 100%; box-sizing: border-box;
  padding: 8px 10px; font: inherit; font-size: 13px;
  background: var(--bg-2); color: var(--text-1);
  border: 1px solid var(--line); border-radius: 6px; resize: vertical;
}
.modal-row input[type=text]:focus,
.modal-row textarea:focus { outline: none; border-color: var(--accent); }

.modal-segment {
  display: flex; gap: 0; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
}
.modal-segment button {
  background: transparent; color: var(--text-2);
  border: 0; padding: 6px 12px; font: inherit; font-size: 12px;
  cursor: pointer;
}
.modal-segment button:hover { background: var(--bg-3); color: var(--text-1); }
.modal-segment button.active {
  background: var(--accent); color: #0c0e12;
}

.modal-file-pick {
  background: var(--bg-2); border: 1px dashed var(--line-strong);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.modal-file-pick:hover { background: var(--bg-3); }
.modal-hint { font-size: 11px; opacity: 0.55; }

.modal-attachments {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.modal-att {
  position: relative; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-2); padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.modal-att img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 4px; background: #000;
}
.modal-att-icon {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 4 / 3; font-size: 36px;
  background: var(--bg-1); border-radius: 4px;
}
.modal-att-name {
  font-size: 10px; opacity: 0.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.modal-att-remove {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: 0; cursor: pointer;
}
.modal-att-remove:hover { background: #f97316; }

.modal-foot {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}
.modal-status { font-size: 11px; opacity: 0.6; flex: 1; text-align: left; }

/* Mic button — sits to the right of the description textarea. */
.idea-body-row { align-items: stretch; flex-wrap: nowrap; }
.idea-body-row textarea { flex: 1; }
.modal-mic {
  flex: 0 0 auto;
  width: 40px;
  background: var(--bg-2); color: var(--text-1);
  border: 1px solid var(--line-strong); border-radius: 6px;
  cursor: pointer; font-size: 18px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.modal-mic:hover { background: var(--bg-3); }
.modal-mic.listening {
  background: #f87171; color: #1a1a1a; border-color: #fb923c;
  animation: pulse-mic 1.2s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
}

/* ---------- Ideas triage panel ---------- */
.tab-count {
  display: inline-block; min-width: 16px; padding: 1px 5px;
  margin-left: 4px; border-radius: 8px; font-size: 10px;
  background: var(--accent); color: #0c0e12; line-height: 1.4;
}
.tabs .tab.pulse { animation: tab-pulse 1.2s ease-out 1; }
@keyframes tab-pulse {
  0%   { background: rgba(110, 231, 255, 0.3); }
  100% { background: transparent; }
}

.ideas-panel { display: flex; flex-direction: column; height: 100%; }
.ideas-toolbar {
  display: flex; gap: 6px; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.ideas-select {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 4px 6px; font-size: 12px; font-family: inherit;
}
.ideas-count { margin-left: auto; font-size: 11px; opacity: 0.6; }
.ideas-list { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }

.idea-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden;
}
.idea-card-head {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 8px 10px; cursor: pointer; user-select: none;
}
.idea-card-head:hover { background: var(--bg-3); }
.idea-card-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  flex-direction: column; gap: 8px;
}
.idea-card.open    .idea-card-body { display: flex; }
.idea-card:not(.open) .idea-card-body { display: none; }

.idea-title {
  flex: 1; min-width: 100px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.idea-date { font-size: 10px; opacity: 0.5; }

.tag {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--bg-3); color: var(--text-2);
  border: 1px solid var(--line); white-space: nowrap;
}
.tag-bug   { background: rgba(248, 113, 113, 0.15); color: #fca5a5; border-color: #f87171; }
.tag-imp   { background: rgba(110, 231, 255, 0.12); color: #93e9ff; border-color: #6ee7ff; }
.tag-idea  { background: rgba(251, 191, 36, 0.15);  color: #fcd34d; border-color: #fbbf24; }
.prio-high   { background: rgba(248, 113, 113, 0.15); color: #fca5a5; border-color: #f87171; }
.prio-medium { background: rgba(251, 191, 36, 0.10);  color: #fcd34d; border-color: #fbbf24; }
.prio-low    { background: var(--bg-3); color: var(--text-3); }
.tag-area  { font-family: ui-monospace, monospace; font-size: 9px; }
.auto-safe   { background: rgba(74, 222, 128, 0.15); color: #86efac; border-color: #4ade80; }
.needs-review{ background: var(--bg-3); color: var(--text-3); }

.idea-summary, .idea-rationale { font-size: 12px; line-height: 1.5; }
.idea-rationale { opacity: 0.75; }
.idea-body {
  font-size: 12px; line-height: 1.5; padding: 8px 10px;
  background: var(--bg-1); border-radius: 4px; max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word; font-family: inherit;
  margin: 0;
}
.idea-attachments-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.idea-att {
  font-size: 11px; padding: 3px 7px; border-radius: 4px;
  background: var(--bg-3); color: var(--accent); text-decoration: none;
  border: 1px solid var(--line);
}
.idea-att:hover { background: var(--bg-1); }
.idea-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; opacity: 0.6; }
.idea-meta code { font-size: 11px; background: var(--bg-1); padding: 1px 5px; border-radius: 3px; }

.idea-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px;
  padding-top: 8px; border-top: 1px dashed var(--line);
}

/* ---------- Auth: topbar pill, sign-in modal, banner ---------- */
.auth-slot { display: inline-flex; align-items: center; position: relative; }

.auth-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 3px 10px 3px 3px; cursor: pointer; font-size: 12px;
}
.auth-pill:hover { background: var(--bg-3); }
.auth-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #0c0e12;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
}
.auth-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-role {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 0.5px;
  background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line);
}
.role-superadmin {
  background: rgba(251, 191, 36, 0.18); color: #fcd34d; border-color: #fbbf24;
}
.role-contributor {
  background: rgba(110, 231, 255, 0.12); color: #93e9ff; border-color: #6ee7ff;
}

.auth-menu {
  position: absolute; top: 100%; right: 0; margin-top: 6px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px; z-index: 1500; min-width: 180px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.auth-menu[hidden] { display: none; }
.auth-menu button {
  background: none; color: var(--text); border: 0;
  padding: 7px 10px; text-align: left; font: inherit; font-size: 12px;
  border-radius: 4px; cursor: pointer;
}
.auth-menu button:hover { background: var(--bg-3); }

.auth-banner {
  background: rgba(251, 191, 36, 0.12); color: #fcd34d;
  border-bottom: 1px solid #fbbf24; padding: 6px 12px; font-size: 12px;
  text-align: center;
}

.auth-card { min-width: 360px; max-width: 420px; }
.auth-card .modal-row input[type=email],
.auth-card .modal-row input[type=password] {
  width: 100%; padding: 8px 10px; font: inherit; font-size: 13px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
}
.auth-card .modal-row input:focus { outline: none; border-color: var(--accent); }
.auth-card .modal-hint { padding: 4px 0; }

/* ---------- Profile modal ---------- */
.profile-card-wrap { min-width: 640px; max-width: 820px; }
.profile-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--line);
  padding: 0 12px; background: var(--bg-1);
}
.profile-tab {
  background: transparent; border: 0; color: var(--text-2);
  padding: 10px 14px; font: inherit; font-size: 12px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.profile-tab:hover { color: var(--text); }
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.profile-body { padding: 14px 18px; min-height: 200px; max-height: 70vh; }
.profile-body h4 { margin: 0 0 10px; font-size: 14px; }
.profile-body p { margin: 6px 0; font-size: 12px; line-height: 1.5; }
.profile-body hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

.profile-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 4px 0;
}
.profile-row input[type=text],
.profile-row input[type=email],
.profile-row input[type=password],
.profile-row select,
.profile-row textarea,
.profile-body textarea {
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 8px; font: inherit; font-size: 12px;
}
.profile-body textarea {
  width: 100%; resize: vertical; box-sizing: border-box;
  margin: 6px 0;
}
.profile-row input { flex: 1; min-width: 120px; }
.profile-label { width: 110px; opacity: 0.6; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.profile-sub { color: var(--text-3); font-size: 11px; }
.profile-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.profile-pre {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 5px;
  padding: 8px 10px; font-family: inherit; font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto;
  margin: 6px 0;
}

.profile-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 12px; margin-bottom: 10px;
}
.profile-card-head {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin-bottom: 6px;
}

.profile-table {
  width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px;
}
.profile-table th, .profile-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left;
}
.profile-table th { color: var(--text-3); font-weight: 600; font-size: 11px; }
.profile-table tr.disabled { opacity: 0.5; }
.profile-actions-cell { display: flex; gap: 4px; }

.profile-create {
  background: var(--bg-1); border: 1px dashed var(--line-strong);
  border-radius: 6px; padding: 8px 12px; margin-bottom: 12px;
}
.profile-create summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.loading { opacity: 0.6; padding: 20px; text-align: center; }

/* ---- Top toolbar climate selector ------------------------------------- */
.topbar-climate {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 8px;
}
.topbar-climate select {
  background: transparent; color: var(--text); border: none;
  font-size: 12px; cursor: pointer; outline: none;
}
.topbar-mode {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 8px;
}
.topbar-mode select {
  background: transparent; color: var(--text); border: none;
  font-size: 12px; cursor: pointer; outline: none;
}

/* ---- Climate tab ------------------------------------------------------- */
.climate-grid {
  display: grid; grid-template-columns: 240px 1fr;
  gap: 12px; margin-top: 8px;
}
.climate-list { display: flex; flex-direction: column; gap: 6px; }
.climate-loc {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px;
  background: var(--bg-1); transition: border-color 120ms;
}
.climate-loc.selected { border-color: var(--accent); }
.climate-loc.empty    { opacity: 0.6; }
.climate-loc-head     { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.climate-loc-meta     { margin-top: 2px; }
.climate-loc-actions  { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.climate-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: var(--bg-2); color: var(--text-3);
}
.climate-badge.active  { background: var(--accent); color: var(--bg-0); }
.climate-badge.missing { color: #fbbf24; }

.climate-detail { min-width: 0; overflow-x: auto; }
.climate-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.climate-table th, .climate-table td {
  padding: 4px 6px; border-bottom: 1px solid var(--line);
  text-align: right; vertical-align: middle;
}
.climate-table th:first-child, .climate-table td:first-child { text-align: left; }
.climate-table th { color: var(--text-3); font-weight: 600; font-size: 11px; }
.climate-bar { color: var(--accent); display: block; }

.climate-add {
  margin-top: 12px; background: var(--bg-1);
  border: 1px dashed var(--line-strong); border-radius: 6px;
  padding: 8px 12px;
}
.climate-add summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.climate-add-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.climate-row { display: flex; gap: 6px; flex-wrap: wrap; }
.climate-row input, .climate-row select {
  flex: 1; min-width: 100px; padding: 4px 8px;
  background: var(--bg-0); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px; font-size: 12px;
}
.btn.small  { padding: 2px 8px; font-size: 11px; }
.btn.danger { color: #f87171; }

/* Geocoding search dropdown + map preview inside the climate add form */
.climate-search-results {
  background: var(--bg-0); border: 1px solid var(--line);
  border-radius: 4px; max-height: 200px; overflow-y: auto;
  margin-top: -4px;
}
.climate-search-row {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--text);
  padding: 6px 10px; cursor: pointer; font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.climate-search-row:last-child { border-bottom: none; }
.climate-search-row:hover { background: var(--bg-2); }
.climate-search-empty {
  padding: 8px 10px; color: var(--text-3); font-size: 11px; font-style: italic;
}
.climate-map-wrap {
  border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
  background: var(--bg-0);
  display: flex; flex-direction: column;
}
.climate-map {
  width: 100%; height: 320px; min-height: 240px;
  border: none; display: block;
  background: var(--bg-0);
  cursor: crosshair;
}
.climate-map-hint { padding: 4px 8px; margin: 0; font-size: 10px; }
/* Leaflet popups & controls keep their default font; just keep the
   tile-attribution text visible against the dark theme. */
.leaflet-control-attribution { font-size: 9px !important; }

/* ---- Idea run-NOW: section headers + live log ------------------------- */
.edge-tooltip {
  position: fixed; z-index: 9000;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 220px; max-width: 320px;
  font-size: 11px; color: var(--text-1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.edge-tooltip .tip-head {
  font-size: 12px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
  color: var(--text-1);
}
.edge-tooltip .tip-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3); margin: 6px 0 2px;
}
.edge-tooltip .tip-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 1px 0;
}
.edge-tooltip .tip-row span:first-child { color: var(--text-2); }
.edge-tooltip .tip-row span:last-child  { color: var(--text-1); font-variant-numeric: tabular-nums; }
.edge-tooltip .tip-row em { color: #fbbf24; font-style: normal; cursor: help; }
.edge-tooltip .tip-empty { color: var(--text-3); font-style: italic; }

.chem-card { max-width: 560px; }
.chem-card h5 { margin: 12px 0 4px; font-size: 12px; color: var(--text-1); }
.chem-card .chem-mode { font-weight: normal; color: var(--text-3); font-size: 10px; margin-left: 6px; }
.chem-card .chem-port {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  margin-bottom: 8px; background: var(--bg-1);
}
.chem-card .chem-notes {
  background: rgba(251, 191, 36, 0.1); border-left: 3px solid #fbbf24;
  padding: 6px 10px; margin: 8px 0; font-size: 11px; color: var(--text-2);
}
.chem-card em { color: var(--text-3); font-size: 10px; font-style: normal; }

.profile-section {
  margin: 18px 0 6px; font-size: 13px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
.profile-section.profile-section-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.profile-section.profile-section-row .btn {
  text-transform: none; letter-spacing: 0;
}
.profile-card.in-progress { border-left: 3px solid var(--accent); }
.profile-card.approved    { border-left: 3px solid #34d399; }

.sweep-faq {
  margin: 4px 0 14px; padding: 10px 14px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  font-size: 12px;
}
.sweep-faq summary {
  cursor: pointer; font-weight: 600; color: var(--text-2);
  list-style: none; user-select: none;
}
.sweep-faq summary::-webkit-details-marker { display: none; }
.sweep-faq summary::before { content: '▸ '; color: var(--text-3); }
.sweep-faq[open] summary::before { content: '▾ '; }
.sweep-faq dl { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.sweep-faq dt { color: var(--text-3); font-weight: 500; }
.sweep-faq dd { margin: 0; color: var(--text-2); }
.sweep-faq code { background: var(--bg-3); padding: 1px 5px; border-radius: 3px; font-size: 11px; }

/* Save/open drawings modal */
.drawing-modal {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
}
.drawing-modal[hidden] { display: none; }
.drawing-modal-card {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px;
  min-width: 520px; max-width: 720px; max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.drawing-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.drawing-modal-head strong { flex: 1; font-size: 14px; }
.drawing-modal-body { padding: 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.drawing-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px;
}
.drawing-row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drawing-row-actions { display: flex; gap: 6px; }
.run-log {
  background: #050709; color: #d4d8e0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; line-height: 1.45;
  padding: 10px 12px; margin: 8px 0 0;
  border: 1px solid var(--line); border-radius: 4px;
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
