/* Chiller Cycle Simulator — Visual system matched to Ideal Gas Simulator */
:root {
  --bg: #12151c;
  --surface: #1b2030;
  --inset: #0b0d12;
  --border: #2c3550;
  --border-subtle: #252e45;
  --border-ctrl: #435388;
  --text: #dde3ee;
  --muted: #9fb0d0;
  --accent: #ff8a3d;
  --accent-bg: #d9622b;
  --accent-link: #ff9a5c;
  --btn-bg: #2c3a62;
  --btn-hover: #3a4c80;
  --pass: #4be08a;
  --fail: #ff5a5a;
  --warn: #f5b942;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

/* Header & Navigation */
header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

header nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

header nav button {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 15px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

header nav button:hover {
  color: #ffffff;
}

header nav button.active {
  color: #ffffff;
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.header-spacer {
  flex: 1;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Main Page Container */
main.page {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Cards & Boxes */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 10px 0;
  font-size: 19px;
  color: #ffffff;
}

.card h3 {
  margin: 14px 0 8px 0;
  font-size: 15px;
  color: #ffffff;
}

.card p {
  margin: 0 0 10px 0;
}

.card p:last-child {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
}

.setup-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.const-bar {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* Links & Buttons */
a, .link-btn {
  color: var(--accent-link);
  text-decoration: none;
}

a:hover, .link-btn:hover {
  text-decoration: underline;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

button.b {
  background: var(--btn-bg);
  border: 1px solid var(--border-ctrl);
  color: #ffffff;
  border-radius: 5px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

button.b:hover {
  background: var(--btn-hover);
}

button.b.big {
  background: var(--accent-bg);
  border-color: var(--accent);
  font-weight: 600;
  padding: 8px 18px;
  font-size: 14px;
}

button.b.big:hover {
  background: #e56d35;
}

button.b:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Segmented Controls */
.seg {
  display: inline-flex;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-ctrl);
}

.seg button {
  background: var(--btn-bg);
  border: none;
  border-right: 1px solid var(--border-ctrl);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.seg button:last-child {
  border-right: none;
}

.seg button:hover {
  background: var(--btn-hover);
}

.seg button.on {
  background: var(--accent-bg);
  color: #ffffff;
  font-weight: 600;
}

/* Form Controls */
select, input[type="number"] {
  background: var(--inset);
  color: var(--text);
  border: 1px solid var(--border-ctrl);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 13px;
}

input[type="number"] {
  width: 82px;
  text-align: right;
}

input[type="range"] {
  accent-color: #3b82f6;
  cursor: pointer;
  width: 100%;
}

label.ctrl-lbl {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 3px;
}

label.ctrl-lbl .val {
  color: #ffffff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.num-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Simulation Top Toolbar */
.sim-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

/* Guided Walkthrough Banner */
.walkthrough-bar {
  display: none;
  background: #1d2538;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.walkthrough-bar.active {
  display: flex;
}

.walkthrough-text {
  flex: 1;
  min-width: 260px;
}

.walkthrough-stage {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.walkthrough-desc {
  font-size: 13px;
  color: var(--text);
}

.walkthrough-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
}

.kpi-box .kpi-title {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi-box .kpi-val {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.kpi-box .kpi-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.kpi-box.recip-accent {
  border-left: 3px solid #38bdf8;
}

.kpi-box.absorp-accent {
  border-left: 3px solid #ff8a3d;
}

/* Simulation Grids */
.sim-grid-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.sim-grid-single {
  display: grid;
  grid-template-columns: 620px 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 1180px) {
  .sim-grid-side,
  .sim-grid-single {
    grid-template-columns: 1fr;
  }
}

.chiller-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pane-header h2 {
  margin: 0;
  font-size: 15.5px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: #23304d;
  color: #93c5fd;
  border: 1px solid #354c7a;
}

.badge.orange {
  background: #3d2418;
  color: #ffb07c;
  border-color: #7c3f22;
}

.badge.warn {
  background: #422b0e;
  color: var(--warn);
  border-color: #926018;
}

.badge.danger {
  background: #42171b;
  color: var(--fail);
  border-color: #8c2a32;
}

.canvas-wrap {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--inset);
}

.charts-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.chart-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.chart-title-row strong {
  color: #ffffff;
}

/* Controls Panel Grid */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.ctrl-section-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  margin: 0 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}

.ctrl-item {
  margin-bottom: 8px;
}

.ctrl-item:last-child {
  margin-bottom: 0;
}

/* State-Point Tables */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

table.data-table th,
table.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  white-space: nowrap;
}

table.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(11, 13, 18, 0.45);
}

table.data-table td.num,
table.data-table th.num {
  text-align: right;
}

/* Welcome Page Grids */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 820px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.role-box {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px 14px;
}

.role-box h3 {
  margin-top: 0;
}

.step-list {
  margin: 8px 0;
  padding-left: 20px;
}

.step-list li {
  margin-bottom: 6px;
}

code {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9em;
}

/* Validation Status */
.pass {
  color: var(--pass);
  font-weight: 700;
}

.fail {
  color: var(--fail);
  font-weight: 700;
}

.eq-block {
  background: #f1f5f9;
  border-left: 3px solid var(--accent-bg);
  padding: 8px 12px;
  border-radius: 4px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  margin: 8px 0;
  overflow-x: auto;
}

/* Footer */
footer.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
}

footer.site-footer strong {
  color: var(--text);
}

/* =========================================================
   LIGHT READING THEME (Validation & Credits tabs)
   ========================================================= */
body.light-page {
  background: #ffffff;
  color: #1a202c;
}

body.light-page header {
  background: #1b2030;
  border-bottom-color: #2c3550;
}

body.light-page header h1 {
  color: #ffffff;
}

body.light-page .card {
  background: #ffffff;
  border: 1px solid #d5dde8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  color: #1a202c;
}

body.light-page .card h2,
body.light-page .card h3 {
  color: #0f172a;
}

body.light-page .muted {
  color: #475569;
}

body.light-page .role-box {
  background: #f8fafc;
  border: 1px solid #d5dde8;
  color: #1a202c;
}

body.light-page .role-box h3 {
  color: #0f172a;
}

body.light-page code {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #0f172a;
}

body.light-page a,
body.light-page .link-btn {
  color: #c2410c;
}

body.light-page .pass {
  color: #15803d;
}

body.light-page .fail {
  color: #dc2626;
}

body.light-page table.data-table th {
  background: #f8fafc;
  color: #334155;
  border-bottom: 1px solid #cbd5e1;
}

body.light-page table.data-table td {
  border-bottom: 1px solid #e2e8f0;
  color: #1a202c;
}

body.light-page footer.site-footer {
  background: #f8fafc;
  border-top: 1px solid #d5dde8;
  color: #475569;
}

body.light-page footer.site-footer strong {
  color: #0f172a;
}

/* Hardware & Cutaways Tab Components */
.photo-frame {
  position: relative;
  background: #0b0d12;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}

.photo-frame img {
  display: block;
  width: 100%;
  height: 290px;
  object-fit: cover;
}

.scale-overlay {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(11, 13, 18, 0.86);
  color: #ffffff;
  border: 1px solid #ff8a3d;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
}

.photo-credit {
  font-size: 12px;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 8px 10px;
  margin-top: 8px;
}

.part-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.part-pill {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  border-radius: 14px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.part-pill:hover {
  background: #e2e8f0;
}

.part-pill.active {
  background: #d9622b;
  border-color: #c2410c;
  color: #ffffff;
}

.insp-box {
  background: #f8fafc;
  border: 1px solid #d5dde8;
  border-left: 4px solid #d9622b;
  border-radius: 6px;
  padding: 10px 12px;
}

.insp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14px;
  color: #0f172a;
}

body.light-page .badge {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

