﻿/* ============================================================
   WB-PIPE — Piping Database Design System
   Dual Theme (Dark / Light) | Teal-Cyan Identity
   One family with WB-STEEL — same layout, different palette
   ============================================================ */

:root, [data-theme="dark"] {
  --bg-primary:      #050e18;
  --bg-secondary:    #0a1929;
  --bg-tertiary:     #0d2137;
  --bg-card:         #0c1e33;
  --bg-hover:        rgba(6, 182, 212, 0.08);
  --accent:          #06b6d4;
  --accent-dim:      #0e7490;
  --accent-glow:     rgba(6, 182, 212, 0.25);
  --accent-amber:    #f59e0b;
  --accent-rose:     #f43f5e;
  --accent-green:    #10b981;
  --text-primary:    #f0f9ff;
  --text-secondary:  #7dd3fc;
  --text-muted:      #475569;
  --border:          rgba(6, 182, 212, 0.18);
  --border-subtle:   rgba(255, 255, 255, 0.05);
  --canvas-bg:       #020c14;
  --th-bg:           #0a1929;
  --tr-even:         rgba(6, 182, 212, 0.03);
  --sidebar-w:       248px;
  --header-h:        60px;
  --radius-lg:       12px;
  --radius-md:       8px;
  --radius-sm:       6px;
  --shadow-modal:    0 24px 60px rgba(0,0,0,0.75);
  --transition:      all 0.18s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg-primary:      #f8fafc;
  --bg-secondary:    #ffffff;
  --bg-tertiary:     #f0f9ff;
  --bg-card:         #ffffff;
  --bg-hover:        rgba(8, 145, 178, 0.08);
  --accent:          #0891b2;
  --accent-dim:      #0e7490;
  --accent-glow:     rgba(8, 145, 178, 0.2);
  --accent-amber:    #d97706;
  --accent-rose:     #e11d48;
  --accent-green:    #059669;
  --text-primary:    #0f172a;
  --text-secondary:  #0369a1;
  --text-muted:      #64748b;
  --border:          rgba(8, 145, 178, 0.22);
  --border-subtle:   rgba(226, 232, 240, 0.9);
  --canvas-bg:       #f8fafc;
  --th-bg:           #f1f5f9;
  --tr-even:         rgba(240, 249, 255, 0.65);
  --shadow-modal:    0 24px 60px rgba(15, 23, 42, 0.12);
}

/* Reset & Base */
*, *::before, *::after { box-sizing:border-box; margin:0; padding:0; }
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
}
html { font-size:14px; scroll-behavior:smooth; }
body {
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  background:var(--bg-primary);
  color:var(--text-primary);
  height:100vh;
  overflow:hidden;
  line-height:1.5;
  transition:background-color 0.2s ease, color 0.2s ease;
}

/* ============================================================ LAYOUT */
.app-layout {
  display:grid;
  grid-template-columns:var(--sidebar-w) 1fr;
  grid-template-rows:var(--header-h) 1fr;
  grid-template-areas:"sidebar header" "sidebar main";
  height:100vh;
  overflow:hidden;
}

/* ============================================================ SIDEBAR */
.sidebar {
  grid-area:sidebar;
  background:var(--bg-secondary);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  position:relative;
  z-index:10;
}
.sidebar::before {
  content:'';
  position:absolute;
  top:0; left:0; right:0;
  height:2px;
  background:linear-gradient(90deg, var(--accent), transparent);
}
.sidebar-logo {
  display:flex;
  align-items:center;
  gap:10px;
  padding:18px 16px 16px;
  border-bottom:1px solid var(--border-subtle);
  flex-shrink:0;
}
.logo-icon {
  width:34px; height:34px;
  background:linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius:9px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  flex-shrink:0;
  box-shadow:0 0 16px var(--accent-glow);
}
.logo-text {
  font-size:1.2rem;
  font-weight:700;
  color:var(--text-primary);
  letter-spacing:0.03em;
}
.logo-text span { color:var(--accent); }
.sidebar-section-label {
  font-size:0.68rem;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.12em;
  color:var(--text-muted);
  padding:14px 16px 6px;
}
.nav-list {
  flex:1;
  overflow-y:auto;
  padding:4px 8px 8px;
  scrollbar-width:thin;
  scrollbar-color:var(--accent-dim) transparent;
}
.nav-list::-webkit-scrollbar { width:4px; }
.nav-list::-webkit-scrollbar-thumb { background:var(--accent-dim); border-radius:2px; }
.nav-group-label {
  font-size:0.65rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.1em;
  color:var(--text-muted);
  padding:10px 8px 4px;
  opacity:0.7;
}
/* Sidebar Navigation Buttons */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(14, 116, 144, 0.12));
  color: var(--accent);
  font-weight: 600;
  border-color: rgba(6, 182, 212, 0.35);
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.85;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item.active .nav-icon { opacity: 1; color: var(--accent); }
.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-badge {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.22);
  color: var(--accent);
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}
.nav-item.active .nav-badge {
  background: rgba(6, 182, 212, 0.25);
  border-color: var(--accent);
  color: var(--accent);
}
.sidebar-divider { height:1px; background:var(--border-subtle); margin:8px 16px; flex-shrink:0; }
.sidebar-footer { padding:10px 16px 14px; flex-shrink:0; }
.footer-title { font-size:0.75rem; font-weight:600; color:var(--text-secondary); }
.footer-meta { font-size:0.65rem; color:var(--text-muted); margin-top:2px; }

/* ============================================================ HEADER */
.header {
  grid-area:header;
  background:var(--bg-secondary);
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 20px;
  position:sticky;
  top:0;
  z-index:9;
}
.search-wrap {
  flex:1;
  position:relative;
  max-width:520px;
}
.search-icon {
  position:absolute;
  left:11px; top:50%;
  transform:translateY(-50%);
  color:var(--text-muted);
  pointer-events:none;
  display:flex;
}
#searchInput {
  width:100%;
  padding:8px 36px 8px 34px;
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  background:var(--bg-tertiary);
  color:var(--text-primary);
  font-size:0.82rem;
  outline:none;
  font-family:inherit;
  transition:var(--transition);
}
#searchInput:focus {
  border-color:var(--accent);
  box-shadow:0 0 0 3px var(--accent-glow);
  background:var(--bg-card);
}
#searchInput::placeholder { color:var(--text-muted); }
.search-clear-btn {
  position:absolute;
  right:8px; top:50%;
  transform:translateY(-50%);
  background:none; border:none;
  color:var(--text-muted);
  cursor:pointer; font-size:0.9rem;
  padding:2px 4px;
  border-radius:4px;
  transition:var(--transition);
}
.search-clear-btn:hover { color:var(--text-primary); background:var(--bg-hover); }
.global-search-dropdown {
  position:absolute;
  top:calc(100% + 6px);
  left:0; right:0;
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-modal);
  z-index:100;
  max-height:340px;
  overflow-y:auto;
}
.search-result-item {
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 14px;
  cursor:pointer;
  border-bottom:1px solid var(--border-subtle);
  transition:var(--transition);
  font-size:0.82rem;
}
.search-result-item:last-child { border-bottom:none; }
.search-result-item:hover { background:var(--bg-hover); }
.search-result-cat {
  font-size:0.65rem;
  color:var(--accent);
  font-weight:600;
  background:rgba(6,182,212,0.1);
  padding:1px 6px;
  border-radius:4px;
  white-space:nowrap;
}
.search-no-result { padding:16px; text-align:center; color:var(--text-muted); font-size:0.82rem; }
.header-right { display:flex; align-items:center; gap:10px; margin-left:auto; }
.unit-toggle-wrap { display:flex; align-items:center; gap:6px; font-size:0.75rem; color:var(--text-muted); }
.toggle-switch {
  position:relative;
  width:38px; height:20px;
  display:inline-block;
}
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider {
  position:absolute; cursor:pointer;
  top:0; left:0; right:0; bottom:0;
  background:var(--bg-tertiary);
  border-radius:10px;
  border:1px solid var(--border);
  transition:var(--transition);
}
.toggle-slider::before {
  content:'';
  position:absolute;
  height:14px; width:14px;
  left:2px; top:2px;
  background:var(--text-muted);
  border-radius:50%;
  transition:var(--transition);
}
input:checked + .toggle-slider { background:var(--accent-dim); border-color:var(--accent); }
input:checked + .toggle-slider::before { transform:translateX(18px); background:#fff; }
.btn-icon {
  width:34px; height:34px;
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  background:var(--bg-tertiary);
  color:var(--text-secondary);
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:var(--transition);
}
.btn-icon:hover { border-color:var(--accent); color:var(--accent); background:var(--bg-hover); }
.btn-calc-header {
  display:flex; align-items:center; gap:6px;
  padding:0 14px;
  height:34px;
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  background:var(--bg-tertiary);
  color:var(--text-secondary);
  cursor:pointer;
  font-size:0.78rem;
  font-weight:500;
  font-family:inherit;
  transition:var(--transition);
}
.btn-calc-header:hover { border-color:var(--accent); color:var(--accent); background:var(--bg-hover); }

/* ============================================================ MAIN */
.main-content {
  grid-area:main;
  overflow-y:auto;
  background:var(--canvas-bg);
  padding:20px 24px;
  scrollbar-width:thin;
  scrollbar-color:var(--accent-dim) transparent;
}
.main-content::-webkit-scrollbar { width:6px; }
.main-content::-webkit-scrollbar-thumb { background:var(--accent-dim); border-radius:3px; }

/* ============================================================ SECTION HEADER */
.section-header {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:20px;
  flex-wrap:wrap;
}
.section-title-block {}
.section-title {
  font-size:1.35rem;
  font-weight:700;
  color:var(--text-primary);
  display:flex;
  align-items:center;
  gap:10px;
}
.section-title-icon {
  width:36px; height:36px;
  background:linear-gradient(135deg, rgba(6,182,212,0.2), rgba(14,116,144,0.1));
  border-radius:9px;
  border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  color:var(--accent);
}
.section-desc {
  font-size:0.78rem;
  color:var(--text-muted);
  margin-top:4px;
  line-height:1.6;
  max-width:620px;
}
.section-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* ============================================================ FILTER CONTAINER & MULTI-ROW FILTERING */
.filter-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-row-secondary {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.filter-row-header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 90px;
  flex-shrink: 0;
}

.filter-label {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: 'JetBrains Mono', monospace;
}

.filter-reset-mini {
  font-size: 0.65rem;
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.filter-reset-mini:hover {
  background: rgba(244, 63, 94, 0.25);
}

.filter-pills-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.filter-btn {
  padding: 4px 11px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  transition: var(--transition);
  white-space: nowrap;
  outline: none;
  box-sizing: border-box;
}
.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.filter-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 10px var(--accent-glow);
}
.filter-select {
  padding: 5px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.filter-select:focus { border-color: var(--accent); }

/* ============================================================ TABLE */
.table-wrap {
  background:var(--bg-card);
  border-radius:var(--radius-lg);
  border:1px solid var(--border);
  overflow:hidden;
  box-shadow:0 4px 24px rgba(0,0,0,0.18);
}
.table-scroll { overflow-x:auto; }
table {
  width:100%;
  border-collapse:collapse;
  font-size:0.8rem;
}
thead th {
  background:var(--th-bg);
  color:var(--text-secondary);
  font-size:0.68rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.08em;
  padding:10px 14px;
  text-align:left;
  white-space:nowrap;
  position:sticky;
  top:0;
  z-index:1;
  cursor:pointer;
  user-select:none;
  transition:var(--transition);
  border-bottom:1px solid var(--border);
}
thead th:hover { color:var(--accent); }
thead th .sort-icon { display:inline-block; margin-left:4px; opacity:0.4; font-size:0.6rem; }
thead th.sorted-asc .sort-icon::after { content:'▲'; opacity:1; color:var(--accent); }
thead th.sorted-desc .sort-icon::after { content:'▼'; opacity:1; color:var(--accent); }
thead th:not(.sorted-asc):not(.sorted-desc) .sort-icon::after { content:'⇅'; }
tbody tr {
  border-bottom:1px solid var(--border-subtle);
  transition:background 0.12s;
}
tbody tr:last-child { border-bottom:none; }
tbody tr:nth-child(even) { background:var(--tr-even); }
tbody tr:hover { background:var(--bg-hover); }
tbody td {
  padding:9px 14px;
  color:var(--text-primary);
  white-space:nowrap;
  font-family:'JetBrains Mono',monospace;
  font-size:0.78rem;
}
td.col-name {
  font-family:'Inter',sans-serif;
  font-weight:500;
  color:var(--text-primary);
  white-space:normal;
  min-width:160px;
}
td.col-num { text-align:right; color:var(--text-secondary); }
td.col-nps { font-weight:700; color:var(--accent); }
td.col-sch {
  font-weight:600;
  font-size:0.72rem;
  color:var(--accent-amber);
}
td.col-type {
  font-weight:600;
  font-size:0.72rem;
}
td.col-type.WN { color:#10b981; }
td.col-type.SO { color:#3b82f6; }
td.col-type.BL { color:#f59e0b; }
td.col-type.Conc { color:#8b5cf6; }
td.col-type.Ecc { color:#ec4899; }
.table-footer {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 14px;
  border-top:1px solid var(--border-subtle);
  font-size:0.72rem;
  color:var(--text-muted);
  background:var(--th-bg);
  flex-wrap:wrap;
  gap:8px;
}
.table-count strong { color:var(--accent); }

/* ============================================================ INFO CARDS */
.info-cards {
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(200px, 1fr));
  gap:12px;
  margin-bottom:20px;
}
.info-card {
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  padding:14px 16px;
  transition:var(--transition);
}
.info-card:hover { border-color:var(--accent); box-shadow:0 0 12px var(--accent-glow); }
.info-card-label { font-size:0.65rem; font-weight:700; text-transform:uppercase; letter-spacing:0.1em; color:var(--text-muted); margin-bottom:4px; }
.info-card-value { font-size:1.05rem; font-weight:700; color:var(--text-primary); font-family:'JetBrains Mono',monospace; }
.info-card-sub { font-size:0.7rem; color:var(--text-muted); margin-top:2px; }

/* ============================================================ STANDARD POPOVER & DIALOGS */
.popover-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  margin-left: 10px;
  vertical-align: middle;
}
.popover-btn:hover {
  background: rgba(6, 182, 212, 0.22);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  transform: translateY(-1px);
}
.popover-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.15s ease;
}
.popover-overlay.open,
.popover-overlay.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.popover-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  max-width: 520px;
  width: 92%;
  box-shadow: var(--shadow-modal);
  animation: slideUp 0.2s ease;
  position: relative;
  max-height: 88vh;
  overflow-y: auto;
}
.popover-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 4px;
  padding: 4px 8px;
  transition: var(--transition);
}
.popover-close:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}
.popover-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.std-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 12px;
}
.std-info-table tr {
  border-bottom: 1px solid var(--border-subtle);
}
.std-info-table tr:last-child {
  border-bottom: none;
}
.std-info-table td:first-child {
  width: 135px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 10px 10px 0;
  vertical-align: top;
}
.std-info-table td:last-child {
  color: var(--text-primary);
  padding: 10px 0;
  line-height: 1.6;
}
.std-info-table strong {
  color: var(--accent);
}
.popover-row { display: flex; gap: 10px; margin-bottom: 10px; font-size: 0.8rem; }
.popover-row-label { color: var(--text-muted); min-width: 90px; font-weight: 500; }
.popover-row-val { color: var(--text-primary); flex: 1; }

/* ============================================================ CALCULATOR SELECTOR & SEARCH (LIKE BANDINGKAN) */
.calc-selector-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calc-selector-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.calc-selector-label svg {
  color: var(--accent);
}

.calc-count-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}

.calc-search-wrap {
  position: relative;
  display: flex;
  width: 100%;
}

.calc-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}

.calc-search-input {
  width: 100%;
  padding: 7px 28px 7px 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}
.calc-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.calc-search-input::placeholder {
  color: var(--text-muted);
}

.calc-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: var(--transition);
}
.calc-clear-btn:hover {
  color: var(--accent-rose);
}

.calc-dropdown {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  cursor: pointer;
}
.calc-dropdown optgroup {
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-card);
  font-family: 'Inter', sans-serif;
}
.calc-dropdown option {
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.calc-selected-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  font-size: 0.72rem;
}
.preview-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
}
.preview-text {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  flex: 1;
}

.calc-preset-btns {
  display: flex;
  gap: 3px;
}
.calc-preset-btn {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-family: 'JetBrains Mono', monospace;
}
.calc-preset-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.calc-field-select {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}
.calc-field-select:focus {
  border-color: var(--accent);
}

/* ============================================================ CALC PANEL */
.calc-panel {
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:20px 24px;
  margin-bottom:20px;
}
.calc-panel-title {
  font-size:0.9rem;
  font-weight:700;
  color:var(--text-primary);
  margin-bottom:16px;
  display:flex;
  align-items:center;
  gap:8px;
}
.calc-panel-title svg { color:var(--accent); }
.calc-form {
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(160px, 1fr));
  gap:12px;
  margin-bottom:14px;
}
.calc-field label { display:block; font-size:0.68rem; font-weight:700; text-transform:uppercase; letter-spacing:0.08em; color:var(--text-muted); margin-bottom:4px; }
.calc-field input, .calc-field select {
  width:100%;
  padding:7px 10px;
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  background:var(--bg-tertiary);
  color:var(--text-primary);
  font-size:0.82rem;
  font-family:'JetBrains Mono',monospace;
  outline:none;
  transition:var(--transition);
}
.calc-field input:focus, .calc-field select:focus { border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-glow); }
.calc-result {
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
  gap:10px;
  padding:14px;
  background:var(--bg-tertiary);
  border-radius:var(--radius-md);
  border:1px solid var(--border-subtle);
}
.calc-result-item {}
.calc-result-label { font-size:0.65rem; color:var(--text-muted); font-weight:600; text-transform:uppercase; letter-spacing:0.08em; }
.calc-result-val { font-size:1rem; font-weight:700; color:var(--accent); font-family:'JetBrains Mono',monospace; }
.btn-calc {
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 18px;
  border-radius:var(--radius-md);
  border:none;
  background:linear-gradient(135deg, var(--accent), var(--accent-dim));
  color:#fff;
  font-size:0.82rem;
  font-weight:600;
  font-family:inherit;
  cursor:pointer;
  transition:var(--transition);
  box-shadow:0 0 16px var(--accent-glow);
}
.btn-calc:hover { opacity:0.9; transform:translateY(-1px); }

/* ============================================================ EMPTY STATE */
.empty-state {
  text-align:center;
  padding:60px 20px;
  color:var(--text-muted);
}
.empty-state svg { opacity:0.3; margin-bottom:12px; }
.empty-state h3 { font-size:0.95rem; color:var(--text-secondary); margin-bottom:6px; }
.empty-state p { font-size:0.8rem; }

/* ============================================================ ANIMATIONS */
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.fade-in { animation:fadeIn 0.25s ease; }

/* ============================================================ RESPONSIVE */
@media (max-width:768px) {
  .app-layout {
    grid-template-columns:1fr;
    grid-template-rows:var(--header-h) 1fr;
    grid-template-areas:"header" "main";
  }
  .sidebar { display:none; }
  .header-right .btn-calc-header span { display:none; }
}

/* ============================================================ SCROLLBAR (global) */
* { scrollbar-width:thin; scrollbar-color:var(--accent-dim) transparent; }
*::-webkit-scrollbar { width:5px; height:5px; }
*::-webkit-scrollbar-thumb { background:var(--accent-dim); border-radius:3px; }

/* ============================================================ PRINT */
@media print {
  .sidebar, .header { display:none; }
  .app-layout { display:block; }
  .main-content { overflow:visible; height:auto; padding:0; }
  body { overflow:auto; }
}

/* ============================================================ 2-COLUMN APP MAIN GRID */
.app-main-grid {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  .app-main-grid {
    grid-template-columns: 1fr;
  }
}

.table-panel {
  min-width: 0;
}

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 10px;
}

/* --- Diagram Card --- */
.diagram-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);
}

.diagram-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.diagram-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.diagram-card-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.diagram-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid var(--border);
  color: var(--accent);
  text-transform: uppercase;
}

.diagram-wrap {
  background: var(--canvas-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 8px;
  position: relative;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#sectionSvg {
  width: 100%;
  max-width: 330px;
  height: 220px;
  display: block;
  transition: opacity 0.15s ease;
}

.diagram-tip {
  font-size: 0.68rem;
  text-align: center;
  color: var(--text-muted);
  margin-top: 8px;
}

/* --- Props / Specs Card --- */
.props-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.props-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.props-card-header h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.active-profile-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}

.props-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.prop-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}

.prop-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.prop-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

/* Selected row highlight */
table tbody tr.selected-row {
  background: rgba(6, 182, 212, 0.16) !important;
  outline: 1px solid var(--accent);
}
table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}