/*
 * engi-calcx.css — Shared Design System
 * Engi·calcx Universal Calculator Stylesheet
 * Apply this CSS to every calculator. See engi-calcx-template.html for full rules.
 */

/* ── TOKENS ── */
:root {
  --c-bg:         #F2F4F7;
  --c-surface:    #FFFFFF;
  --c-border:     #E4E7EC;
  --c-text-head:  #101828;
  --c-text-body:  #344054;
  --c-text-muted: #98A2B3;
  --c-accent:     #2563EB;
  --c-accent-lt:  #EFF4FF;
  --c-result:     #D97706;
  --c-result-lt:  #FFFBEB;
  --c-danger:     #DC2626;

  --radius-sm:  6px;
  --radius-md:  8px;
  --radius-lg: 10px;
  --shadow-card: 0 1px 4px rgba(0,0,0,.07), 0 0 0 1px var(--c-border);
  --shadow-btn:  0 1px 3px rgba(0,0,0,.12);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--c-bg); font-family: "IBM Plex Sans", system-ui, sans-serif; color: var(--c-text-body); font-size: 14px; -webkit-font-smoothing: antialiased; }

/* ── NAV ── */
.navbar {
  height: 48px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 6px;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .logo { font-weight: 700; font-size: 15px; color: var(--c-text-head); text-decoration: none; }
.navbar .sep  { color: var(--c-text-muted); }
.navbar .crumb { color: var(--c-text-muted); text-decoration: none; }
.navbar .crumb:hover { color: var(--c-text-body); }
.navbar .crumb.active { color: var(--c-text-body); font-weight: 500; }

/* ── PAGE SHELL ── */
.page-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--c-text-head); margin-bottom: 6px; }
.page-header p  { font-size: 13px; color: var(--c-text-muted); margin-bottom: 12px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center;
  background: var(--c-accent-lt);
  color: var(--c-accent);
  border: 1px solid #BFDBFE;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px; font-weight: 500;
}

/* ── TWO-COLUMN GRID ── */
.calc-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  align-items: start;
}

/* ── LEFT PANEL ── */
.left-panel {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 80px);
}
.left-panel-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 20px 20px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}
.left-panel-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--c-surface);
}

/* Panel title */
.panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text-head);
  margin-bottom: 18px;
}
.panel-title .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-accent);
  flex-shrink: 0;
}

/* ── UNIT TOGGLE ── */
.unit-toggle {
  display: flex;
  background: var(--c-bg);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 20px;
}
.unit-toggle button {
  flex: 1;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.unit-toggle button.active {
  background: var(--c-surface);
  color: var(--c-text-head);
  box-shadow: var(--shadow-btn);
}

/* ── SECTIONS ── */
.section { padding: 16px 0; }
.section + .section { border-top: 1px solid var(--c-border); }
.section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-muted);
  margin-bottom: 12px;
}

/* ── FORM GRID ── */
.form-grid { display: grid; gap: 10px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 11px; font-weight: 500; color: var(--c-text-body); }

/* ── INPUTS ── */
input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--c-border);
  border-radius: 7px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--c-text-head);
  background: var(--c-surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
input::placeholder { color: var(--c-text-muted); font-size: 13px; }
input:focus, select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2398A2B3' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ── ADD-ROW BUTTON ── */
.btn-add-row {
  width: 100%;
  height: 34px;
  border: 1px dashed var(--c-border);
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--c-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all .15s;
}
.btn-add-row:hover { border-color: var(--c-accent); color: var(--c-accent); }

/* ── CALCULATE BUTTON ── */
.btn-calculate {
  width: 100%;
  height: 44px;
  background: var(--c-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, box-shadow .15s;
}
.btn-calculate:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37,99,235,.3); }

/* ── SECONDARY BUTTON ── */
.btn-secondary {
  width: 100%;
  height: 40px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--c-text-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--c-bg); border-color: #C0C9D8; }

/* ── RIGHT PANEL ── */
.right-panel { display: flex; flex-direction: column; gap: 16px; }

/* ── EMPTY STATE ── */
.empty-state {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  font-size: 13px;
  text-align: center;
}
.empty-state strong { color: var(--c-text-head); }

/* ── RESULT SUMMARY CARDS ── */
.result-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.result-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
}
.result-card .rc-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--c-text-muted); margin-bottom: 6px; }
.result-card .rc-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 28px; font-weight: 700;
  color: var(--c-result);
  display: flex; align-items: baseline; gap: 4px;
}
.result-card .rc-value .rc-unit { font-size: 14px; font-weight: 500; }
.result-card .rc-sub { font-size: 11px; color: var(--c-text-muted); margin-top: 4px; }

/* ── FORMULA BOX ── */
.formula-box {
  background: var(--c-accent-lt);
  border-left: 3px solid var(--c-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 12px 16px;
}
.formula-box .fb-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--c-accent); margin-bottom: 8px; }
.formula-box .fb-expr { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--c-text-body); line-height: 1.7; }

/* ── CONTENT CARD (wraps charts, tables, etc.) ── */
.content-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.content-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.content-card-title { font-size: 15px; font-weight: 600; color: var(--c-text-head); }
.content-card-badge { font-size: 12px; font-weight: 600; color: var(--c-result); }

/* ── DATA TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead tr { border-bottom: 2px solid var(--c-border); }
.data-table thead th { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); padding: 0 0 8px; text-align: left; }
.data-table tbody tr { height: 36px; }
.data-table tbody tr:nth-child(even) { background: #FAFAFA; }
.data-table tbody td { font-size: 13px; font-family: "IBM Plex Mono", monospace; color: var(--c-text-body); padding: 0 8px; }
.data-table tbody td.val-accent { color: var(--c-result); font-weight: 600; }
.data-table tbody td.val-neg     { color: var(--c-danger); font-weight: 600; }

/* ── KEY VALUES TABLE ── */
.kv-table-wrap { overflow-x: auto; }
.kv-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: "IBM Plex Mono", monospace; }
.kv-table thead th { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--c-text-muted); padding: 0 6px 6px; border-bottom: 2px solid var(--c-border); text-align: right; }
.kv-table thead th:first-child { text-align: left; }
.kv-table tbody tr { height: 30px; }
.kv-table tbody tr:nth-child(even) { background: #FAFAFA; }
.kv-table tbody td { padding: 0 6px; color: var(--c-text-body); text-align: right; }
.kv-table tbody td:first-child { text-align: left; color: var(--c-text-muted); }
.kv-table .hi { color: var(--c-result); font-weight: 600; }

/* ── DIAGRAM PLACEHOLDER ── */
.diagram-placeholder {
  height: 180px;
  background: var(--c-bg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--c-text-muted);
  border: 1px dashed var(--c-border);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .calc-grid { grid-template-columns: 1fr; }
  .left-panel { position: static; max-height: none; }
  .result-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .result-cards { grid-template-columns: 1fr; }
}
@media print { .no-print { display: none !important; } }
