/* AES TM59 Overheating Compliance Suite — shares look & feel with the
 * Modelling Schedule Generator and Site Builder. Most of this is lifted
 * from sapschedule/styles.css with TM59-specific additions for the drawing
 * builder, orientation dial, sliders, and results panel.
 */
:root {
  --bg: #f2f2f2;
  --surface: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e0e0e0;
  --border-light: #eeeeee;
  --accent: #009B8D;
  --accent-light: #e0f5f3;
  --accent-hover: #007a6e;
  --brand-green: #8DC63F;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #c0392b;
  --red-bg: #fee2e2;
  --blue: #0077B6;
  --blue-bg: #e0f0fb;
  --pass: #16a34a;
  --pass-bg: #dcfce7;
  --radius: 8px;
  --radius-sm: 5px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.mono { font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace; }

.topbar {
  background: #fff;
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
  border-bottom: 3px solid var(--brand-green);
}
.topbar .brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  gap: 10px;
}
.topbar .brand .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--brand-green);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}
.topbar .tagline {
  font-size: 12px;
  color: var(--muted);
  border-left: 1px solid var(--border);
  padding-left: 16px;
  margin-left: 4px;
}
.topbar .right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.status-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--border-light);
  color: var(--muted);
  transition: background 0.3s, color 0.3s;
}
.status-pill.ready { background: var(--accent-light); color: var(--accent); }
.status-pill.busy { background: var(--amber-bg); color: var(--amber); }
.status-pill.error { background: var(--red-bg); color: var(--red); }
.status-pill.build-pill {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  letter-spacing: 0;
  cursor: help;
  background: transparent;
  color: #999;
  border: 1px solid var(--border);
}

main { padding: 24px; max-width: 1280px; margin: 0 auto; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 10px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  border-top: 3px solid var(--brand-green);
}
.card .card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  margin-top: -6px;
}

.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > * { flex: 1; min-width: 200px; }
.row.tight > * { min-width: 140px; }
.row + .row { margin-top: 12px; }

label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* range sliders */
.slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) 50%, var(--border) 50%, var(--border) 100%);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
}

/* checkbox row */
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin: 0;
}
.check input { margin: 0; }

/* radio chip group */
.radio-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.radio-chips label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-weight: 500;
  margin: 0;
}
.radio-chips label:has(input:checked) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.radio-chips input { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn-secondary:hover:not(:disabled) { background: var(--accent-light); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-lg { font-size: 14px; padding: 11px 22px; }
.btn-sm { font-size: 11px; padding: 5px 10px; }
.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ----- ORIENTATION DIAL ----- */
.compass {
  display: flex;
  align-items: center;
  gap: 14px;
}
.compass-svg {
  width: 84px;
  height: 84px;
  cursor: grab;
  flex-shrink: 0;
}
.compass-svg:active { cursor: grabbing; }
.compass-readout {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.compass-readout small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-top: 2px;
}

/* ----- DRAWING BUILDER ----- */
.drawing-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  align-items: center;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.tool-btn:hover { border-color: var(--accent); }
.tool-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.tool-btn .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.tool-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}
.tool-spacer { flex: 1; }

.drawing-canvas-wrap {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.drawing-canvas {
  display: block;
  width: 100%;
  height: 460px;
  background-image:
    linear-gradient(to right, rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 20px 20px;
  cursor: crosshair;
}
.canvas-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
.canvas-pill {
  background: rgba(255,255,255,0.92);
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  border: 1px solid var(--border);
}
.canvas-overlay-tr {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}

.room-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.room-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  background: #fff;
  border-radius: var(--radius-sm);
  font-size: 11px;
  border: 1px solid var(--border);
}
.room-row.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.room-row .swatch { width: 12px; height: 12px; border-radius: 2px; }
.room-row .name { font-weight: 600; }
.room-row .meta { color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.room-row .delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
}
.room-row .delete-btn:hover { color: var(--red); }
.room-empty {
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* ----- RESULTS PANEL ----- */
.criteria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.criterion {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  border-left: 4px solid var(--border);
  position: relative;
}
.criterion.pass { border-left-color: var(--pass); }
.criterion.fail { border-left-color: var(--red); }
.criterion .crit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.criterion .crit-name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}
.criterion .crit-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-family: 'IBM Plex Mono', monospace;
}
.criterion .crit-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}
.criterion .crit-threshold {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  font-family: 'IBM Plex Mono', monospace;
}

.verdict-pill {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.verdict-pill.pass { background: var(--pass-bg); color: var(--pass); }
.verdict-pill.fail { background: var(--red-bg); color: var(--red); }
.verdict-pill.marginal { background: var(--amber-bg); color: var(--amber); }

.heatmap {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  margin-top: 8px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--accent-light);
  transition: background 0.4s;
}

.results-chart {
  width: 100%;
  height: 200px;
  margin-top: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.mitigations {
  background: var(--amber-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 12px;
  border-left: 3px solid var(--amber);
}
.mitigations h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--amber);
  font-weight: 700;
  margin-bottom: 8px;
}
.mitigations ul {
  list-style: none;
  font-size: 12px;
  color: var(--text);
}
.mitigations li {
  padding: 3px 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.mitigations li::before {
  content: "→";
  color: var(--amber);
  font-weight: 700;
}

.justification-box {
  background: var(--blue-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 12px;
  border-left: 3px solid var(--blue);
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
  font-style: italic;
}
.justification-box.hidden { display: none; }

/* ----- PROGRESS / LOG ----- */
.progress {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  background: #1a1a1a;
  color: #e5e5e5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-top: 12px;
}
.progress .ok { color: #8DC63F; }
.progress .warn { color: #fbbf24; }
.progress .info { color: #93c5fd; }
.progress .err { color: #fca5a5; }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
}

.msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}
.msg.info { background: var(--blue-bg); color: var(--blue); }
.msg.warn { background: var(--amber-bg); color: var(--amber); }
.msg.error { background: var(--red-bg); color: var(--red); }
.msg.ok { background: var(--pass-bg); color: var(--pass); }

.hidden { display: none !important; }
.small-muted { font-size: 11px; color: var(--muted); }
.spacer { flex: 1; }

.passcounter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.passcounter button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

/* tabbed sections */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.tab {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: -1px;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Vibes toggle - special highlight */
.vibes-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #fef3c7 0%, #fce7f3 100%);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px dashed #c084fc;
}
.vibes-toggle input { margin: 0; }

/* fake animated arrows for ventilation paths */
@keyframes flow {
  0% { stroke-dashoffset: 24; }
  100% { stroke-dashoffset: 0; }
}
.flow-arrow {
  stroke-dasharray: 6 4;
  animation: flow 1.2s linear infinite;
}

/* spinning recalc icon when busy */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin { animation: spin 1s linear infinite; display: inline-block; }
