:root {
  --primary: #1a56db;
  --primary-hover: #1e429f;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #dce2ec;
  --text: #1e293b;
  --muted: #64748b;
  --success: #0d9488;
  --warning: #d97706;
  --danger: #dc2626;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* TOPBAR */
.app-topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  z-index: 20;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.brand-area h1 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.brand-area .subtitle {
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* BUTTONS */
.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-lg {
  padding: 10px 16px;
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #0f172a;
  color: #fff;
}
.btn-secondary:hover {
  background: #334155;
}

.btn-excel {
  background: #15803d;
  color: #fff;
}
.btn-excel:hover {
  background: #166534;
}

.btn-word {
  background: #2563eb;
  color: #fff;
}
.btn-word:hover {
  background: #1d4ed8;
}

.btn-outline {
  background: #fff;
  border-color: #cbd5e1;
  color: #334155;
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 6px;
}
.btn-link:hover {
  text-decoration: underline;
}

/* WORKSPACE SPLIT */
.workspace {
  display: grid;
  grid-template-columns: 540px 1fr;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 480px 1fr;
  }
}

/* LEFT BUILDER PANEL */
.builder-panel {
  background: #f8fafc;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.step-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  gap: 4px;
  overflow-x: auto;
  flex-shrink: 0;
}

.step-tab {
  border: none;
  background: transparent;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.step-tab .step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.step-tab.active {
  background: #eff6ff;
  color: var(--primary);
}

.step-tab.active .step-num {
  background: var(--primary);
  color: #fff;
}

.step-pane {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.step-pane.active {
  display: block;
}

.pane-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-header-row h2 {
  font-size: 15px;
  color: #0f172a;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

.helper-text {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.45;
}

/* FORMS */
.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  color: #0f172a;
  font-family: inherit;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* PROJECT SEARCH DROPDOWN */
.project-search-box {
  position: relative;
}

.project-search-box input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #93c5fd;
  border-radius: 8px;
  font-size: 13.5px;
  background: #f8fafc;
}

.project-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 290px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
  z-index: 50;
}

.project-item {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.project-item:hover {
  background: #eff6ff;
}
.project-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.project-code {
  font-weight: 700;
  color: var(--primary);
  font-size: 13px;
}
.project-cust {
  font-size: 11.5px;
  color: #475569;
  font-weight: 600;
}
.project-name {
  font-size: 12.5px;
  color: #0f172a;
  margin-top: 2px;
}
.project-addr {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

/* STEP 2: ADD EQUIPMENT */
.add-eq-bar {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
  background: #f8fafc;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.quick-chips-wrap {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

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

.chips-list {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.chip-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: #334155;
  cursor: pointer;
}
.chip-btn:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}

.eq-card {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.eq-card-info {
  flex: 1;
}

.eq-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.volt-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

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

.eq-card-controls input {
  padding: 5px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 12px;
}

.btn-icon-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 5px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.btn-icon-danger:hover {
  background: #fecaca;
}

/* STEP 3: CHECKLIST */
.eq-subtabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.eq-subtab {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #334155;
}

.eq-subtab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.checklist-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.test-item-row {
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #fff;
  transition: border-color 0.12s;
}

.test-item-row.checked {
  border-color: #60a5fa;
  background: #f8fbff;
}

.test-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.test-check-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  flex: 1;
}

.test-check-label input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.test-meta {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 4px;
  margin-left: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.test-inline-inputs {
  margin-top: 6px;
  margin-left: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.test-inline-inputs input,
.test-inline-inputs select {
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 11.5px;
}

.scope-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.scope-iso {
  background: #dcfce7;
  color: #166534;
}
.scope-non-iso {
  background: #ffedd5;
  color: #9a3412;
}

/* STEP 4: EVALUATION */
.summary-mode-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.radio-card {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  background: #f8fafc;
}
.radio-card strong {
  display: block;
  font-size: 12px;
  color: #0f172a;
}
.radio-card span {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.eval-group-card {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
}

.eval-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}

.status-pills {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
}

.status-pill-btn {
  border: none;
  background: #fff;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  color: #475569;
  border-right: 1px solid #cbd5e1;
}
.status-pill-btn:last-child {
  border-right: none;
}
.status-pill-btn.active-ok {
  background: #16a34a;
  color: #fff;
}
.status-pill-btn.active-no {
  background: #dc2626;
  color: #fff;
}
.status-pill-btn.active-sub {
  background: #d97706;
  color: #fff;
}

.eval-test-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #e2e8f0;
  font-size: 12px;
}
.eval-test-row:last-child {
  border-bottom: none;
}

/* STEP 5 CHECKBOXES */
.checkbox-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  background: #f8fafc;
}

.checkbox-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  cursor: pointer;
}
.check-line input {
  margin-top: 3px;
}

.divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 14px 0;
}

.export-action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.step-footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

/* RIGHT PANEL: LIVE A4 PREVIEW */
.preview-panel {
  background: #525659;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-toolbar {
  background: #323639;
  color: #f1f5f9;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.preview-tabs {
  display: flex;
  gap: 6px;
}

.preview-tab {
  background: #474b4f;
  color: #e2e8f0;
  border: none;
  border-radius: 5px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.preview-tab.active {
  background: #3b82f6;
  color: #fff;
}

.preview-hint {
  font-size: 12px;
  color: #cbd5e1;
}

.print-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* A4 PAPER SHEETS */
.a4-sheet {
  background: #ffffff;
  color: #000000;
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  position: relative;
}

.a4-portrait {
  width: 210mm;
  min-height: 297mm;
  padding: 10mm 12mm;
}

.a4-landscape {
  width: 297mm;
  min-height: 210mm;
  padding: 10mm 12mm;
}

/* FORM DOCUMENT STYLING (MATCHES 10-PTN-13-F02/V2.0) */
.doc-code-top {
  text-align: right;
  font-size: 10pt;
  font-weight: 700;
  margin-bottom: 4px;
}

.doc-header {
  display: grid;
  grid-template-columns: 92px 210px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.doc-header .doc-logo {
  width: 86px;
  height: auto;
}

.doc-company-info {
  font-size: 9.5pt;
  line-height: 1.35;
  color: #111;
}

.doc-company-info strong {
  font-size: 10pt;
}

.doc-main-title {
  text-align: center;
  color: #1d5ba6;
  font-size: 14pt;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
}

/* TABLES INSIDE FORM */
.ptn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5pt;
  color: #000;
}

.ptn-table th,
.ptn-table td {
  border: 1px solid #000;
  padding: 4.5px 7px;
  vertical-align: middle;
  line-height: 1.35;
}

.compact-mode .ptn-table th,
.compact-mode .ptn-table td {
  padding: 3.5px 6px;
  line-height: 1.28;
}

.sec-heading {
  font-size: 9.5pt;
  font-weight: 700;
  text-transform: uppercase;
  margin: 8px 0 4px 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.font-bold { font-weight: 700; }
.pre-line { white-space: pre-line; }

.check-mark {
  font-weight: 700;
  font-size: 11pt;
}

.sig-box {
  height: 68px;
  vertical-align: top !important;
  text-align: center;
  font-weight: 700;
  padding-top: 6px !important;
}

.compact-mode .sig-box {
  height: 56px;
}

.policy-section {
  margin-top: 8px;
  font-size: 9pt;
  line-height: 1.38;
  text-align: justify;
}

.compact-mode .policy-section {
  font-size: 8.6pt;
  line-height: 1.3;
}

.policy-section p {
  margin-bottom: 3px;
}

.appendix-title {
  text-align: center;
  font-size: 10.5pt;
  font-weight: 700;
  text-transform: uppercase;
  margin: 8px 0 6px 0;
}

.appendix-note {
  margin-top: 8px;
  font-size: 9pt;
  line-height: 1.35;
}

/* MODALS & TOAST */
.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 640px;
  max-width: 94vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

.saved-form-row {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  z-index: 200;
}

/* PRINT MEDIA RULES */
@media print {
  @page {
    margin: 8mm;
  }
  body {
    background: #fff;
    height: auto;
    overflow: visible;
  }
  .no-print {
    display: none !important;
  }
  .workspace {
    display: block;
    overflow: visible;
  }
  .preview-panel {
    background: #fff;
    overflow: visible;
  }
  .print-container {
    padding: 0;
    gap: 0;
    overflow: visible;
    display: block;
  }
  .a4-sheet {
    box-shadow: none;
    width: 100% !important;
    min-height: auto !important;
    padding: 4mm !important;
    page-break-after: always;
    break-after: page;
  }
  .a4-sheet:last-child {
    page-break-after: auto;
    break-after: auto;
  }
}
