/* ===================================================
   CR GKT Roof Designer — Stylesheet
   Tema: Navy Gelap + Emas + Latar Cerah
=================================================== */

:root {
  --navy: #0d1b2a;
  --navy-mid: #1b2c3e;
  --navy-light: #253a50;
  --gold: #f0a500;
  --gold-light: #f7c040;
  --white: #ffffff;
  --bg-light: #f4f6f8;
  --bg-canvas: #fdfdfd;
  --border: #d0d8e4;
  --text-dark: #1a2a3a;
  --text-mid: #4a5a6a;
  --text-light: #8a9ab0;
  --danger: #c0392b;
  --danger-light: #e74c3c;
  --success: #27ae60;
  --warning: #e67e22;
  --info: #2980b9;

  --panel-w: 220px;
  --right-panel-w: 320px;
  --header-h: 58px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  font-size: 13px;
  color: var(--text-dark);
  background: var(--bg-light);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== HEADER ===== */
.app-header {
  height: var(--header-h);
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 100;
}
.header-left { display: flex; align-items: center; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 3px 6px;
  border-radius: 6px;
  height: 40px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  flex-shrink: 0;
}
.logo-img {
  height: 34px;
  width: auto;
  max-width: 44px;
  object-fit: contain;
  display: block;
}
.logo-text { display: flex; align-items: center; }
.logo-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.logo-title .brand-cr {
  color: var(--gold);
  font-weight: 800;
  margin-right: 4px;
}

.tab-nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.tab-btn {
  background: transparent; border: none;
  color: #7a9ab8; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  transition: all 0.2s;
}
.tab-btn:hover { background: var(--navy-light); color: var(--white); }
.tab-btn.active {
  background: var(--gold); color: var(--navy);
  font-weight: 700;
}

.header-right { display: flex; align-items: center; gap: 8px; }
.btn-export-roof {
  background: var(--gold);
  color: var(--navy);
  border: 1px solid var(--gold-light);
  font-weight: 700;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.btn-export-roof:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(240, 165, 0, 0.35);
}
.btn-export-roof:active {
  transform: translateY(0);
}
.btn-icon {
  background: var(--navy-light); border: 1px solid var(--navy-light);
  color: var(--white); cursor: pointer;
  padding: 7px 12px; border-radius: var(--radius);
  font-size: 16px; transition: all 0.2s;
}
.btn-icon:hover { background: var(--gold); color: var(--navy); }

/* ===== MAIN ===== */
.app-main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.tab-panel { display: none; flex: 1; overflow: hidden; }
.tab-panel.active { display: flex; }

/* ===== LAYOUT ===== */
.workspace-layout,
.bumbung-layout,
.model3d-layout,
.ortografik-layout {
  display: flex; flex: 1; overflow: hidden; gap: 0;
}

/* ===== LEFT / RIGHT PANELS ===== */
.left-panel {
  width: var(--panel-w, 220px);
  background: var(--white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.right-panel {
  width: var(--right-panel-w, 320px);
  background: var(--white);
  border-left: 1px solid var(--border);
  border-right: none;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.right-panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  border-left: none !important;
  overflow: hidden !important;
  display: none !important;
}

.right-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.btn-panel-toggle {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-panel-toggle:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.right-panel-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  padding: 4px;
  gap: 3px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.rp-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 2px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  transition: all 0.15s ease;
  position: relative;
  min-height: 44px;
}

.rp-tab-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.rp-tab-btn.active {
  background: #ffffff;
  color: #1e40af;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-weight: 700;
}

.rp-tab-icon {
  font-size: 14px;
  line-height: 1;
  margin-bottom: 2px;
}

.rp-tab-label {
  font-size: 9.5px;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.rp-tab-btn .acc-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 8.5px;
  padding: 0 4px;
  border-radius: 8px;
  background: #cbd5e1;
  color: #1e293b;
  margin-right: 0;
}

.rp-tab-btn.active .acc-badge {
  background: #bfdbfe;
  color: #1e40af;
}

.right-panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.rp-tab-pane {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px 10px 20px 10px;
}

.rp-tab-pane.active {
  display: flex;
}

/* 2-Column form grid */
.form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.contextual-guidance-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.35;
  margin-top: 4px;
  margin-bottom: 4px;
}

.advanced-settings-box {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 8px;
  background: #f8fafc;
  margin-top: 6px;
}

.advanced-settings-box summary {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  user-select: none;
  outline: none;
}

.btn-floating-open-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #334155;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-floating-open-panel:hover {
  background: #1e293b;
  border-color: #64748b;
}

/* ===== ACCORDION SETTINGS PANEL (RIGHT PANEL) ===== */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--white);
  margin-bottom: 6px;
  transition: all 0.2s ease;
}

.accordion-item.active {
  border-color: #93c5fd;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.accordion-header {
  background: #f8fafc;
  padding: 7px 10px;
  font-weight: 700;
  font-size: 11.5px;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}

.accordion-header:hover {
  background: #f1f5f9;
}

.accordion-item.active > .accordion-header {
  background: #eff6ff;
  color: #1e40af;
  border-bottom: 1px solid #dbeafe;
}

.acc-title {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  font-size: 11.5px;
  font-weight: 700;
}

.acc-badge {
  background: #e2e8f0;
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-right: 6px;
}

.accordion-item.active .acc-badge {
  background: #bfdbfe;
  color: #1e40af;
}

.acc-chevron {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.accordion-body {
  display: none;
  padding: 8px 10px;
  flex-direction: column;
  gap: 6px;
  background: var(--white);
}

.accordion-item.active > .accordion-body {
  display: flex;
}

.acc-select-dropdown {
  width: 100%;
  padding: 6px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f8fafc;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.acc-select-dropdown:focus {
  border-color: #3b82f6;
  outline: none;
  background: #fff;
}

.compact-list {
  max-height: 100px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #fdfdfd;
  margin-top: 4px;
}

.compact-list .bahagian-item {
  padding: 5px 8px;
  font-size: 11px;
}

.acc-technical-details {
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 6px 8px;
  background: #f8fafc;
  font-size: 11px;
  margin-top: 6px;
}

.acc-technical-details summary {
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  outline: none;
}

.panel-section { display: flex; flex-direction: column; gap: 6px; }
.panel-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-light);
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--gold); color: var(--navy);
  border: none; cursor: pointer;
  padding: 10px 12px; border-radius: var(--radius);
  font-weight: 700; font-size: 13px; width: 100%;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--gold-light); }

.btn-secondary {
  background: var(--navy-light); color: var(--white);
  border: none; cursor: pointer;
  padding: 8px 12px; border-radius: var(--radius);
  font-size: 12px; width: 100%; transition: all 0.2s;
}
.btn-secondary:hover { background: var(--navy-mid); }

.btn-danger {
  background: var(--danger); color: var(--white);
  border: none; cursor: pointer;
  padding: 8px 12px; border-radius: var(--radius);
  font-size: 12px; width: 100%; transition: all 0.2s;
}
.btn-danger:hover { background: var(--danger-light); }

.btn-action {
  background: var(--info); color: var(--white);
  border: none; cursor: pointer;
  padding: 9px 12px; border-radius: var(--radius);
  font-size: 12px; width: 100%; font-weight: 600; transition: all 0.2s;
}
.btn-action:hover { opacity: 0.85; }

.btn-tool {
  background: var(--bg-light); color: var(--text-dark);
  border: 1px solid var(--border); cursor: pointer;
  padding: 6px 10px; border-radius: 6px;
  font-size: 12px; flex: 1; transition: all 0.2s;
}
.btn-tool:hover { background: var(--navy-mid); color: var(--white); }
.btn-tool:disabled { opacity: 0.4; cursor: not-allowed; }

.tools-row { display: flex; gap: 6px; align-items: center; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 11px; color: var(--text-mid); font-weight: 600; }
.form-group input, .form-group select {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px;
  background: var(--bg-light); color: var(--text-dark);
  width: 100%; transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--gold);
}
.form-group hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; width: 100%; }

/* ===== TOGGLE ===== */
.toggle-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; cursor: pointer; color: var(--text-mid);
}

/* ===== CANVAS WRAPPER ===== */
.canvas-wrapper {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg-canvas); overflow: hidden;
}
.canvas-toolbar {
  height: 38px; background: var(--navy-mid);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  color: #a0c0d8; font-size: 12px;
}
.zoom-controls { display: flex; align-items: center; gap: 8px; }
.btn-zoom {
  background: var(--navy-light); color: var(--white);
  border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px;
  font-size: 16px; line-height: 1; transition: all 0.2s;
}
.btn-zoom:hover { background: var(--gold); color: var(--navy); }
#zoomLabel { color: var(--white); font-size: 12px; min-width: 40px; text-align: center; }

.canvas-container {
  flex: 1; overflow: hidden; position: relative;
  cursor: crosshair;
}
canvas#canvas2D { display: block; }

.canvas-footer {
  height: 28px; background: var(--navy-mid);
  display: flex; align-items: center; padding: 0 14px;
  color: #a0c0d8; font-size: 11px;
}

/* ===== BAHAGIAN LIST ===== */
.bahagian-list { display: flex; flex-direction: column; gap: 4px; }
.bahagian-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px;
  background: var(--bg-light); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
  font-size: 12px;
}
.bahagian-item:hover { border-color: var(--gold); background: #fff8e1; }
.bahagian-item.active { border-color: var(--gold); background: #fff8e1; font-weight: 700; }
.bahagian-item .label-badge {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--navy); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 11px; flex-shrink: 0;
}
.bahagian-item .label-dim { color: var(--text-light); font-size: 11px; }

/* ===== VALIDATION ===== */
.validation-idle { color: var(--text-light); font-size: 12px; }
.validation-ok { color: var(--success); font-size: 12px; font-weight: 600; }
.validation-error { color: var(--danger); font-size: 12px; }
.validation-error ul { padding-left: 16px; margin-top: 6px; }
.validation-error li { margin-bottom: 4px; }

/* ===== LEGEND ===== */
.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.swatch {
  width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}
.swatch-block { background: #a8c8e8; }
.swatch-selected { background: var(--gold); }
.swatch-overlap { background: #e88; }
.swatch-disconnected { background: #f8a; border-style: dashed; }

/* ===== HELP LIST ===== */
.help-list { padding-left: 16px; display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-mid); }
.help-list li { line-height: 1.5; }

/* ===== NO SELECTION ===== */
.no-selection { color: var(--text-light); font-size: 12px; font-style: italic; }

/* ===== BUMBUNG MODULE ===== */
.bumbung-main {
  flex: 1; overflow-y: auto; padding: 20px;
  background: var(--bg-light);
}
.bumbung-config-area { max-width: 700px; }
.placeholder-text { color: var(--text-light); font-size: 13px; }

.bumbung-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.bumbung-card h3 {
  font-size: 15px; margin-bottom: 14px;
  color: var(--navy); display: flex; align-items: center; gap: 8px;
}
.bumbung-card h3 .badge {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 13px;
}

.jenis-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 14px; }
.jenis-btn {
  background: var(--bg-light); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 12px 8px;
  cursor: pointer; text-align: center; transition: all 0.2s;
}
.jenis-btn:hover { border-color: var(--navy-light); }
.jenis-btn.active { border-color: var(--gold); background: #fff8e1; }
.jenis-btn .jenis-icon { font-size: 24px; display: block; margin-bottom: 4px; }
.jenis-btn .jenis-name { font-size: 11px; font-weight: 600; color: var(--text-dark); }

.orientasi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 14px; }
.orientasi-btn {
  background: var(--bg-light); border: 2px solid var(--border);
  border-radius: 6px; padding: 8px 4px;
  cursor: pointer; text-align: center; font-size: 12px; transition: all 0.2s;
}
.orientasi-btn:hover { border-color: var(--navy-light); }
.orientasi-btn.active { border-color: var(--gold); background: #fff8e1; font-weight: 700; }

.cerun-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cerun-row label { font-size: 12px; color: var(--text-mid); min-width: 80px; }
.cerun-row input { width: 80px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }

.bumbung-summary { display: flex; flex-direction: column; gap: 6px; }
.summary-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; padding: 6px 8px;
  background: var(--bg-light); border-radius: 6px;
}
.summary-row .s-badge {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--navy); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 10px; flex-shrink: 0;
}

/* ===== 3D MODEL ===== */
.model3d-toolbar {
  height: 42px;
  background: var(--navy-mid);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 14px;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.toolbar-title {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.view-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-view {
  background: var(--navy-light);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.btn-view:hover {
  background: #334e68;
  color: var(--white);
  border-color: var(--gold);
}
.btn-view.active {
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(245, 166, 35, 0.4);
}
.canvas-3d-container {
  flex: 1; background: #ffffff;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.model-placeholder { text-align: center; color: #64748b; }
.model-placeholder p { margin-bottom: 8px; font-size: 14px; }

/* ===== ORTOGRAFIK ===== */
.ortografik-layout { background: var(--bg-light); }
.ortografik-container {
  flex: 1; overflow: auto; padding: 20px;
  display: flex; align-items: flex-start; justify-content: center;
}
#ortografik-svg { background: white; box-shadow: var(--shadow); border-radius: 4px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--white);
  padding: 12px 24px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: opacity 0.3s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.hidden { opacity: 0; pointer-events: none; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-light); }
::-webkit-scrollbar-thumb { background: #c0cfd8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0b0c0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .left-panel, .right-panel { width: 200px; }
  .jenis-grid { grid-template-columns: 1fr; }
  .orientasi-grid { grid-template-columns: repeat(2,1fr); }
  .logo-title { font-size: 14px; }
  .logo-badge { height: 36px; padding: 2px 4px; }
  .logo-img { height: 30px; }
}
@media (max-width: 768px) {
  .app-header { padding: 0 10px; gap: 8px; }
  .logo-title { font-size: 13px; }
  .tab-btn { padding: 6px 8px; font-size: 12px; }
}

/* ===== COLOR SWATCHES ===== */
.color-swatch-btn {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.color-swatch-btn:hover {
  transform: scale(1.18);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.color-swatch-btn.active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0f172a;
}

/* ===== ORIENTATION BUTTONS ===== */
.btn-orient {
  background: #243b53;
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 6px 2px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.btn-orient:hover {
  background: #334e68;
  color: #fff;
  border-color: var(--gold);
}
.btn-orient.active {
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(245, 166, 35, 0.4);
}

/* ===== CR GKT HOUSE DESIGNER — 3D & 2D ADDITIONS ===== */
.btn-header-jana3d {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  width: 74px;
  min-height: 56px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}
.btn-header-jana3d:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.6);
}

.dropdown-preset {
  position: relative;
  display: inline-block;
}
.btn-preset-toggle {
  background: #1b2c3e;
  color: #e2e8f0;
  border: 1px solid #334e68;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-preset-toggle:hover {
  background: #253a50;
  border-color: var(--gold);
}
.preset-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  min-width: 250px;
  z-index: 1000;
  overflow: hidden;
}
.preset-item {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  color: #1e293b;
  cursor: pointer;
  transition: background 0.15s;
  display: block;
}
.preset-item:hover {
  background: #f8fafc;
  color: #0284c7;
  font-weight: 600;
}

/* 2D Tool Mode Grid */
.tools-grid-mode {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.btn-tool-mode {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 8px 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn-tool-mode:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}
.btn-tool-mode.active {
  background: #0d1b2a;
  color: #f0a500;
  border-color: #f0a500;
  box-shadow: 0 0 0 2px rgba(240, 165, 0, 0.25);
}

/* Porch Checkbox Container */
.checkbox-porch-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 8px 10px;
  border-radius: 6px;
  margin: 8px 0;
}
.hint-subtext {
  font-size: 11px;
  color: #475569;
  margin-top: 3px;
  line-height: 1.3;
}

/* Zone & Roof Control */
.zone-control-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 8px 0;
}
.zone-roof-radio-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}
.zone-roof-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.zone-boundary-badge {
  font-size: 11px;
  color: #0369a1;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 4px;
  padding: 3px 6px;
  margin-top: 6px;
  font-family: monospace;
}
.badge-roof-yes {
  background: #dcfce7;
  color: #15803d;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.badge-roof-no {
  background: #fee2e2;
  color: #b91c1c;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

/* Legend Swatches */
.swatch-porch {
  background: #eff6ff;
  border: 1.5px dashed #3b82f6 !important;
}
.swatch-column {
  background: #0f172a;
  border: 1px solid #fff;
}
.swatch-door {
  background: #d97706;
}
.swatch-window {
  background: #0284c7;
}
.swatch-offset {
  background: #fef2f2;
  border: 1.5px dashed #dc2626 !important;
}
.swatch-floor-overhang {
  background: #ecfdf5;
  border: 1.5px dashed #059669 !important;
}
.swatch-roof-overhang {
  background: #fffbeb;
  border: 1.5px dashed #d97706 !important;
}

/* 3D Parameters & Stats */
.view-mode-badge {
  background: #e2e8f0;
  color: #0f172a;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  border: 1px solid #cbd5e1;
}
.stat-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
}
.param-group label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-top: 6px;
  display: block;
}
.param-group input, .param-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 12px;
  background: #ffffff;
}

/* Status Box variants */
.status-box {
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.4;
  border: 1px solid transparent;
}
.status-idle {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
}
.status-success {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}
.status-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* ── MODAL GALERI PELAN CONTOH ────────────────────────── */
.btn-galeri-nav {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff !important;
  font-weight: 600;
  border: 1px solid #0284c7;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.25);
}
.btn-galeri-nav:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.35);
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-catalogue-window {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  width: 95%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  color: #f8fafc;
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-catalogue-header {
  padding: 18px 24px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.modal-catalogue-header h2 {
  margin: 0;
  font-size: 20px;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-sub {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}
.btn-modal-close {
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-modal-close:hover {
  background: #334155;
  color: #ffffff;
}

.catalogue-filter-bar {
  padding: 12px 24px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-chip {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-chip:hover {
  background: #334155;
  color: #ffffff;
}
.filter-chip.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  font-weight: 600;
}

.catalogue-grid {
  padding: 20px 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  flex: 1;
}

.catalogue-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}
.catalogue-card:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.card-thumb-wrap {
  position: relative;
  background: #0f172a;
  padding: 12px;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
}
.plan-thumb-svg {
  width: 100%;
  height: 100%;
  max-height: 120px;
}
.card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #0284c7;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.card-code {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-dimensions {
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace;
}
.card-title {
  margin: 4px 0 8px 0;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.3;
}
.card-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
  margin-bottom: 12px;
}

.card-specs {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px;
  font-size: 11px;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.spec-row {
  line-height: 1.3;
}
.spec-row b {
  color: #f1f5f9;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}
.tag-pill {
  background: #334155;
  color: #cbd5e1;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-select-plan {
  margin-top: auto;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-select-plan:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.modal-catalogue-footer {
  padding: 14px 24px;
  background: #1e293b;
  border-top: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== STEPPER BUTTONS UNTUK TRANSFORMS BUMBUNG ===== */
.btn-stepper {
  padding: 3px 2px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  border-radius: 3px;
  cursor: pointer;
  color: #334155;
  transition: all 0.15s ease;
  user-select: none;
}
.btn-stepper:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}
.btn-stepper:active {
  background: #cbd5e1;
}

/* ── TEMPLAT CONTOH MODAL & CARDS ─────────────────── */
.templat-toolbar {
  padding: 10px 24px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.templat-search-wrap {
  position: relative;
  min-width: 240px;
}
.templat-search-input {
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: #f8fafc;
  outline: none;
  transition: all 0.2s;
}
.templat-search-input:focus {
  border-color: #38bdf8;
  background: #0f172a;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}
.templat-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}
.templat-card-actions .btn-select-plan {
  flex: 1;
  margin-top: 0;
  font-size: 12px;
  padding: 8px 10px;
}
.templat-card-actions .btn-3d-templat {
  background: #334155;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.templat-card-actions .btn-3d-templat:hover {
  background: #475569;
  border-color: #94a3b8;
  color: #ffffff;
}
.btn-danger-icon {
  background: #450a0a;
  border: 1px solid #991b1b;
  color: #f87171;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-danger-icon:hover {
  background: #dc2626;
  color: #ffffff;
}
.card-badge-custom {
  background: #d97706 !important;
}
.card-badge-builtin {
  background: #0284c7 !important;
}
.custom-templat-card {
  border-color: #475569;
}
.custom-templat-card:hover {
  border-color: #f59e0b;
}

/* Modal Simpan Window */
.modal-simpan-window {
  max-width: 600px;
}
.modal-simpan-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.simpan-preview-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
}
.simpan-preview-box .plan-thumb-svg {
  max-height: 120px;
}
.simpan-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.simpan-form label {
  font-size: 13px;
  color: #f8fafc;
}
.simpan-form .form-control {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 12px;
  color: #f8fafc;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
.simpan-form .form-control:focus {
  border-color: #38bdf8;
  background: #0f172a;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}
.simpan-form .input-error {
  border-color: #ef4444 !important;
  background: #450a0a !important;
}
.simpan-form .form-hint {
  font-size: 11px;
  color: #94a3b8;
}
.simpan-error-banner {
  background: #450a0a;
  border: 1px solid #dc2626;
  color: #fca5a5;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 12px;
}

/* Modal Confirm Window */
.modal-confirm-window {
  max-width: 480px;
}

/* ===== EKSPORT PDF & IMEJ ===== */
.export-layout {
  display: flex;
  height: calc(100vh - 56px);
  background: #090d16;
  overflow: hidden;
}

.export-sidebar {
  width: 340px;
  min-width: 320px;
  background: #1e293b;
  border-right: 1px solid #334155;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.export-views-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
}
.export-views-count {
  color: #38bdf8;
  font-weight: 600;
}
.export-views-actions {
  display: flex;
  gap: 8px;
}
.btn-link {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.btn-link:hover {
  color: #38bdf8;
}

.export-views-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.export-view-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
  transition: background 0.15s;
}
.export-view-item:hover {
  background: #1e293b;
  color: #ffffff;
}
.export-view-item input[type="checkbox"] {
  cursor: pointer;
}
.export-view-item .view-label {
  flex: 1;
}
.view-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}
.tag-ortho {
  background: #065f46;
  color: #34d399;
}
.tag-3d {
  background: #1e3a8a;
  color: #93c5fd;
}

.export-select {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  color: #f8fafc;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.export-select:focus {
  border-color: #38bdf8;
}

.export-btn-group {
  display: flex;
  gap: 4px;
  background: #0f172a;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid #334155;
}
.btn-group-item {
  flex: 1;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-group-item:hover {
  color: #ffffff;
}
.btn-group-item.active {
  background: #0284c7;
  color: #ffffff;
}

.export-crop-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.export-crop-actions .btn-action {
  flex: 1;
  padding: 6px;
  font-size: 11px;
  background: #334155;
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 4px;
  cursor: pointer;
}
.export-crop-actions .btn-action:hover {
  background: #475569;
  border-color: #38bdf8;
}

.export-crop-info {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.crop-info-row {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
}
.crop-info-row b {
  color: #f1f5f9;
}

.export-alert-box {
  margin: 10px 16px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.alert-warning {
  background: #451a03;
  border: 1px solid #d97706;
  color: #fef3c7;
}
.alert-info {
  background: #0c4a6e;
  border: 1px solid #0284c7;
  color: #e0f2fe;
}

/* ── KAWASAN PRATONTON KERTAS (VIEWPORT & CANVAS) ── */
.export-preview-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0b1120;
  overflow: hidden;
  position: relative;
}

.export-preview-toolbar {
  padding: 8px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #f8fafc;
  font-size: 12px;
  z-index: 5;
}
.preview-title {
  font-weight: 600;
  color: #38bdf8;
}
.preview-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preview-scale-tag {
  background: #0f172a;
  border: 1px solid #334155;
  color: #38bdf8;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}
.btn-preview-tool {
  background: #334155;
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
}
.btn-preview-tool:hover {
  background: #475569;
  color: #ffffff;
}

.export-sheet-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  position: relative;
}

.export-sheet-paper {
  position: relative;
  background: #ffffff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
  border-radius: 3px;
  max-width: 90%;
  max-height: 85%;
  aspect-ratio: 1.414; /* A4/A3 ratio default */
  display: flex;
  transition: transform 0.15s ease-out;
  transform-origin: center center;
}

.export-sheet-margin {
  flex: 1;
  margin: 3.5%;
  border: 1.5px solid #0f172a;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #ffffff;
  overflow: hidden;
}

.export-model-stage {
  flex: 1;
  position: relative;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#exportCanvasPreview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── BINGKAI CROP INTERAKTIF & PEMEGANG (HANDLES) ── */
.export-crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.crop-box {
  position: absolute;
  border: 2px dashed #0284c7;
  background: rgba(2, 132, 199, 0.08);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.35); /* dim effect outside crop */
  cursor: move;
  box-sizing: border-box;
}

.crop-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 2px solid #0284c7;
  border-radius: 2px;
  box-sizing: border-box;
}
.handle-tl { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-t  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-tr { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-r  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }
.handle-br { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle-b  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-bl { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-l  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }

.crop-dimension-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.85);
  color: #38bdf8;
  font-size: 10px;
  font-family: monospace;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
}

.export-title-block {
  height: 48px;
  border-top: 1px solid #0f172a;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  color: #0f172a;
}
.title-block-left .title-project {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.title-block-left .title-view {
  font-size: 12px;
  font-weight: 800;
  color: #0284c7;
}
.title-block-right {
  text-align: right;
}
.title-block-right .title-scale {
  font-size: 11px;
  font-weight: 700;
}
.title-block-right .title-meta {
  font-size: 9px;
  color: #64748b;
}

/* Opsyen Pelan Lantai 2D */
.export-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px 12px;
}
.export-options-list .toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #e2e8f0;
  cursor: pointer;
  user-select: none;
}
.export-options-list .toggle-label input[type="checkbox"] {
  cursor: pointer;
}
.export-options-list .toggle-label:hover {
  color: #ffffff;
}

/* Butang Cetak Pelan 2D */
.btn-print-2d {
  background: #0d9488 !important;
  color: #ffffff !important;
  border: 1px solid #14b8a6 !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.btn-print-2d:hover {
  background: #0f766e !important;
  border-color: #2dd4bf !important;
}

/* ===== UI REFINEMENT V2: compact toolbar and panel terminology ===== */
:root { --header-h: 66px; }

.app-header {
  padding: 0 12px;
  gap: 10px;
}

.header-left {
  flex: 0 0 auto;
  min-width: 0;
}

.logo { gap: 8px; }

.tab-nav {
  flex: 1 1 auto;
  min-width: 0;
  gap: 3px;
  justify-content: center;
}

.tab-btn {
  flex: 0 0 auto;
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.header-right {
  flex: 0 0 auto;
  min-width: 0;
  gap: 4px;
}

.header-right .dropdown-preset { flex: 0 0 auto; }

.header-right .header-action,
.header-right .btn-header-jana3d {
  width: 74px;
  min-width: 74px;
  min-height: 56px;
  padding: 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1;
  white-space: normal;
  text-align: center;
  border-radius: 6px;
}

.header-right .header-action-icon {
  display: block;
  font-size: 18px;
  line-height: 1;
}

.header-right .header-action-label {
  display: block;
  max-width: 68px;
  font-size: 9px;
  line-height: 1.05;
  font-weight: 700;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

#btnExportRoofProject {
  background: var(--navy-light);
  color: var(--white);
  border: 1px solid #37506a;
  box-shadow: none;
}

#btnExportRoofProject:hover {
  background: #304a63;
  border-color: var(--gold);
  transform: translateY(-1px);
}

.btn-zoom.btn-toolbar-toggle {
  width: auto;
  min-width: 56px;
  height: 28px;
  white-space: nowrap;
  line-height: 1;
}

.rp-tab-btn.active {
  background: #fff8e1;
  color: var(--navy);
  border-color: var(--gold);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.rp-tab-btn.active .acc-badge {
  background: var(--gold-light);
  color: var(--navy);
}

@media (max-width: 1180px) {
  .app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "brand actions"
      "tabs tabs";
    height: auto;
    min-height: var(--header-h);
    padding: 6px 12px;
    gap: 6px 12px;
  }

  .header-left { grid-area: brand; }
  .header-right {
    grid-area: actions;
    justify-content: flex-end;
    overflow: visible;
  }
  .tab-nav {
    grid-area: tabs;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: thin;
  }
}

@media (max-width: 900px) {
  .canvas-toolbar {
    height: auto;
    min-height: 38px;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 5px 8px;
  }

  .canvas-toolbar > #skalaInfo { flex: 1 1 100%; }

  .zoom-controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
  }
}

@media (max-width: 800px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "actions"
      "tabs";
  }

  .header-left { justify-content: flex-start; }

  .header-right {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .tab-nav { width: 100%; }
}

/* ===== TOOLBAR ORDER V3 ===== */
.app-header {
  gap: 10px;
}

.header-right {
  align-items: stretch;
  gap: 0;
  flex: 0 0 auto;
}

.toolbar-action-group {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 2px;
  padding: 0 5px;
}

.toolbar-action-group + .toolbar-action-group {
  border-left: 1px solid rgba(122, 154, 184, 0.35);
}

.header-right .dropdown-preset {
  position: relative;
  display: flex;
  align-items: stretch;
}

.header-right .header-action,
.header-right .btn-header-jana3d {
  width: 54px;
  min-width: 54px;
  height: 68px;
  min-height: 68px;
  padding: 1px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  background: transparent;
  color: var(--white);
  border: 0;
  border-radius: 5px;
  box-shadow: none;
  transform: none;
  line-height: 1;
  white-space: normal;
  text-align: center;
  cursor: pointer;
}

.header-right .header-action-icon {
  width: 40px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: #07509a;
  color: #fff;
  border: 1px solid #1976d2;
  border-radius: 7px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  font-size: 20px;
  line-height: 1;
}

.header-right .header-action-label {
  display: block;
  width: 100%;
  max-width: 58px;
  min-height: 20px;
  color: inherit;
  font-size: 9px;
  line-height: 1.05;
  font-weight: 700;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

.header-right .header-action:hover,
.header-right .header-action:focus-visible {
  color: var(--gold-light);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
}

.header-right .header-action:hover .header-action-icon,
.header-right .header-action:focus-visible .header-action-icon,
.header-right .header-action.active .header-action-icon {
  border-color: var(--gold);
}

.header-right .dropdown-preset > .header-action::after {
  content: "▾";
  position: absolute;
  top: 31px;
  right: 2px;
  color: var(--white);
  font-size: 9px;
  pointer-events: none;
}

#btnExportRoofProject {
  background: transparent;
  color: var(--white);
  border: 0;
}

#btnExportRoofProject:hover {
  background: rgba(255, 255, 255, 0.04);
  border: 0;
  transform: none;
}

.header-right .toolbar-view-controls {
  gap: 3px;
  padding-left: 8px;
  margin-left: 4px;
}

.toolbar-view-controls .btn-zoom {
  width: 30px;
  min-width: 30px;
  height: 34px;
  padding: 0;
  color: var(--white);
  background: var(--navy-light);
  border: 1px solid #37506a;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
}

.toolbar-view-controls #btnZoomFit {
  width: 40px;
  min-width: 40px;
  font-size: 11px;
  font-weight: 700;
}

#zoomLabel {
  min-width: 38px;
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.header-right .toolbar-action-group .btn-toolbar-toggle.active .header-action-icon {
  background: #bd8500;
  border-color: var(--gold-light);
}

.tab-nav {
  flex: 1 1 auto;
}

.tab-nav .tab-btn {
  background: var(--navy-light);
  color: var(--white);
  border: 1px solid #28527b;
  border-radius: 7px;
}

.tab-nav .tab-btn:hover {
  background: #304a63;
  color: var(--white);
  border-color: var(--gold);
}

.tab-nav .tab-btn.active {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
  font-weight: 700;
}

@media (max-width: 1700px) {
  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "tabs"
      "actions";
    height: auto;
    min-height: var(--header-h);
    padding: 6px 12px;
    gap: 4px;
  }

  .header-left { grid-area: brand; }
  .tab-nav {
    grid-area: tabs;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .header-right {
    grid-area: actions;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: thin;
  }
}

@media (max-width: 800px) {
  .toolbar-action-group { padding: 0 3px; }
  .header-right .header-action,
  .header-right .btn-header-jana3d {
    width: 51px;
    min-width: 51px;
  }
  .header-right .header-action-icon {
    width: 38px;
    height: 36px;
    font-size: 18px;
  }
  .header-right .header-action-label { font-size: 8px; }
}
