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

:root,
body[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-header: #0f172a;
  --text-header: #f8fafc;
  --border-header: #1e293b;
  --bg-panel: #ffffff;
  --bg-card: #f8fafc;
  --bg-card-active: #e0f2fe;
  --border-card-active: #0284c7;
  --bg-input: #ffffff;
  --text-main: #0f172a;
  --text-heading: #102a43;
  --text-muted: #475569;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;
  --table-header-bg: #1f3a52;
  --table-header-text: #ffffff;
  --table-even-bg: #f8fafc;
  --code-bg: #f8fafc;
  --code-border: #e2e8f0;
  --bom-totals-bg: #e0f2fe;
  --bom-totals-text: #0c4a6e;
  --dropzone-bg: #f8fafc;
  --dropzone-border: #64748b;
  --dropzone-hover-bg: #e0f2fe;
  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-secondary: #1e293b;
}

body[data-theme="dark"] {
  --bg-body: #0b1120;
  --bg-header: #020617;
  --text-header: #f1f5f9;
  --border-header: #1e293b;
  --bg-panel: #111827;
  --bg-card: #1e293b;
  --bg-card-active: #0c4a6e;
  --border-card-active: #38bdf8;
  --bg-input: #0f172a;
  --text-main: #e2e8f0;
  --text-heading: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-subtle: #1e293b;
  --table-header-bg: #0f172a;
  --table-header-text: #e2e8f0;
  --table-even-bg: #1e293b;
  --code-bg: #0f172a;
  --code-border: #334155;
  --bom-totals-bg: #0c4a6e;
  --bom-totals-text: #e0f2fe;
  --dropzone-bg: #0f172a;
  --dropzone-border: #475569;
  --dropzone-hover-bg: #1e293b;
  --accent-primary: #0284c7;
  --accent-primary-hover: #38bdf8;
  --accent-secondary: #334155;
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 13.5px;
  line-height: 1.45;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.app-header,
.draft-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background-color: var(--bg-header);
  border-bottom: 2px solid var(--border-header);
  color: var(--text-header);
}

.app-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-header);
  letter-spacing: 0.2px;
}

.governance-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-status-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-user-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: #38bdf8;
  background: #1e293b;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #334155;
}

.btn-auth-login {
  text-decoration: none;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  background: #0284c7;
  color: #ffffff;
  border-radius: 4px;
  border: 1px solid #38bdf8;
}

.btn-auth-login:hover {
  background: #0369a1;
}

.btn-auth-logout {
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  background: #334155;
  color: #f8fafc;
  border-radius: 4px;
  border: 1px solid #475569;
}

.btn-auth-logout:hover {
  background: #dc2626;
}

.btn-theme-toggle {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 4px;
}

.btn-theme-toggle:hover {
  background: #334155;
}

.lang-switcher {
  display: inline-flex;
  border: 1px solid #64748b;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-input);
}

.lang-btn {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-input);
  color: var(--text-main);
  border-radius: 0;
  border-right: 1px solid var(--border-color);
}

.lang-btn:last-child {
  border-right: none;
}

.lang-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 320px 1fr 350px;
  gap: 14px;
  padding: 14px;
  max-width: 1920px;
  margin: 0 auto;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.panel h2 {
  font-size: 15px;
  color: var(--text-heading);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
}

.panel h3 {
  font-size: 13.5px;
  color: var(--text-heading);
  margin: 12px 0 6px;
}

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

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Left Column: Projects & Equipment */
.inline-form-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.inline-form-row input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 12.5px;
}

.archive-toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  cursor: pointer;
}

.project-list,
.equipment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.project-card,
.equipment-card {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: 5px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.project-card:hover,
.equipment-card:hover {
  border-color: var(--border-card-active);
}

.project-card.active,
.equipment-card.active {
  background: var(--bg-card-active);
  border: 1.5px solid var(--border-card-active);
}

.project-card.archived {
  opacity: 0.72;
  border-style: dashed;
}

.project-card-header,
.equipment-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.project-card-meta,
.equipment-card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.btn-archive-proj {
  padding: 2px 7px;
  font-size: 11px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 3px;
}

.btn-archive-proj:hover {
  background: var(--accent-secondary);
  color: #ffffff;
}

.add-equipment-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.add-equipment-box input,
.add-equipment-box select {
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 12.5px;
}

.equip-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--accent-primary);
  color: #ffffff;
}

/* Section 3: Drop Target & Drag-and-Drop Zone */
.drop-target-box {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: 5px;
  padding: 8px;
  margin-bottom: 8px;
}

.drop-radio-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.drop-target-sub {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 5px;
  padding-left: 18px;
}

.target-select,
.target-input {
  width: 100%;
  padding: 5px 7px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-main);
}

.rfq-dropzone {
  border: 2px dashed var(--dropzone-border);
  background: var(--dropzone-bg);
  border-radius: 6px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rfq-dropzone:hover,
.rfq-dropzone.drag-active {
  background: var(--dropzone-hover-bg);
  border-color: var(--accent-primary);
}

.dropzone-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.dropzone-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.dropzone-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.attached-files-list {
  margin-top: 6px;
  font-size: 11.5px;
}

.attached-file-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 7px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: 4px;
  margin-bottom: 4px;
}

/* Formulas Table */
.formulas-used-section {
  margin-top: 12px;
}

.formulas-used-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}

.formula-std {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 600;
  font-size: 11px;
}

.formula-sym,
.formula-sub {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 11.5px;
  color: var(--text-main);
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--code-border);
  display: inline-block;
  word-break: break-word;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.param-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  gap: 4px;
}

.param-grid input,
.param-grid select,
.scenario-controls select {
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-main);
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 7px 13px;
  font-weight: 600;
  font-size: 12.5px;
}

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

.btn-primary:hover {
  background: var(--accent-primary-hover);
}

.btn-secondary {
  background: var(--accent-secondary);
  color: #fff;
}

.btn-warning {
  background: #d97706;
  color: #fff;
}

.full-width {
  width: 100%;
  margin-top: 6px;
}

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

.export-link {
  text-decoration: none;
  padding: 5px 9px;
  border-radius: 4px;
  background: #0f172a;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid #334155;
}

.export-link:hover {
  background: #334155;
}

.svg-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: #fff;
  text-align: center;
}

.svg-container svg {
  max-width: 100%;
  height: auto;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.card {
  background: var(--bg-card);
  border-left: 4px solid var(--accent-primary);
  padding: 8px 10px;
  border-radius: 4px;
}

.card.pass {
  border-left-color: #16a34a;
}

.card.fail {
  border-left-color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

.card-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.card-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}

th {
  background: var(--table-header-bg);
  color: var(--table-header-text);
  text-align: left;
  padding: 6px 8px;
}

td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

tr:nth-child(even) {
  background: var(--table-even-bg);
}

.bom-totals {
  background: var(--bom-totals-bg);
  color: var(--bom-totals-text);
  padding: 8px 10px;
  border-radius: 4px;
  font-weight: 600;
  margin-bottom: 8px;
}

.clar-list {
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-main);
}

.clar-list li {
  margin-bottom: 4px;
}

.conflict-box {
  background: #fef2f2;
  border: 2px solid #dc2626;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 14px;
  color: #7f1d1d;
}

.feedback-banner {
  background: #eff6ff;
  border: 2px solid #0284c7;
  border-left: 6px solid #0284c7;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  color: #0f172a;
  font-size: 13px;
}

.feedback-banner.warn {
  background: #fffbeb;
  border-color: #d97706;
  border-left-color: #d97706;
  color: #78350f;
}

.feedback-banner.success {
  background: #f0fdf4;
  border-color: #16a34a;
  border-left-color: #16a34a;
  color: #14532d;
}

.conflict-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #fca5a5;
}

.conflict-btn-group {
  display: flex;
  gap: 6px;
}

.btn-resolve {
  background: #ffffff;
  color: #7f1d1d;
  border: 1px solid #dc2626;
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 4px;
}

.btn-resolve:hover {
  background: #dc2626;
  color: #ffffff;
}

/* Right Column: Engineering Assistant & Notes */
.assistant-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.assistant-header-row h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.gemini-mode-switcher {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-input);
}

.gemini-mode-btn {
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-input);
  color: var(--text-muted);
  border-radius: 0;
  border-right: 1px solid var(--border-color);
}

.gemini-mode-btn:last-child {
  border-right: none;
}

.gemini-mode-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

.eng-command-textarea {
  width: 100%;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-main);
  resize: vertical;
  margin-bottom: 8px;
}

.eng-action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.eng-action-row button {
  flex: 1;
  font-size: 11.5px;
  padding: 6px 8px;
}

.eng-assistant-log {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.eng-notes-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.eng-note-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-primary);
  background: var(--bg-card);
  border-radius: 4px;
  font-size: 12px;
}

.btn-delete-note {
  padding: 2px 6px;
  font-size: 11px;
  background: #dc2626;
  color: #ffffff;
  border-radius: 3px;
}

.hidden {
  display: none;
}

.coord-item {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-left: 4px solid #f59e0b;
  padding: 6px 8px;
  border-radius: 4px;
  margin-top: 6px;
  font-size: 12px;
}

.hist-card {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 8px;
  border-radius: 4px;
  margin-top: 6px;
  font-size: 12px;
}

.btn-apply-hist {
  margin-top: 5px;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--accent-primary);
  color: #ffffff;
  border-radius: 3px;
}

/* Inline Red Input Field Error Highlighting & Multi-Option 1-Click Engineering Solutions */
.input-has-error {
  border: 2px solid #dc2626 !important;
  background-color: rgba(220, 38, 38, 0.08) !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.22);
}

.label-has-error {
  color: #dc2626 !important;
  font-weight: 700;
}

.input-alt-highlight {
  border: 2px dashed #d97706 !important;
  background-color: rgba(217, 119, 6, 0.08) !important;
}

.label-alt-highlight {
  color: #b45309 !important;
  font-weight: 700;
}

.field-error-hint {
  margin-top: 5px;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #fca5a5;
  border-left: 3px solid #dc2626;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
}

.field-error-hint.alt-hint {
  border-color: #fcd34d;
  border-left-color: #d97706;
}

.field-error-reason {
  color: #dc2626;
  font-weight: 600;
  margin-bottom: 3px;
}

.field-error-nearest {
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.field-error-solutions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.btn-field-apply-nearest {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #b91c1c;
  padding: 3px 7px;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
}

.btn-field-apply-nearest:hover {
  background: #b91c1c;
}

.btn-field-apply-alt {
  background: var(--accent-primary);
  color: #ffffff;
  border: 1px solid var(--accent-primary-hover);
  padding: 3px 7px;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
}

.btn-field-apply-alt:hover {
  background: var(--accent-primary-hover);
}

/* Mandatory Full-Screen Login Gate Overlay (Jupp D.6) */
body.auth-locked {
  overflow: hidden !important;
}

body.auth-locked #top-governance-bar,
body.auth-locked #workspace-main {
  filter: blur(10px);
  pointer-events: none !important;
  user-select: none !important;
}

.login-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
}

.login-gate-overlay.hidden {
  display: none !important;
}

.login-gate-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--accent-primary);
  border-radius: 10px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.login-gate-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(2, 132, 199, 0.15);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin-bottom: 14px;
}

.login-gate-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

.login-gate-subtitle {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.login-gate-error {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #dc2626;
  background: rgba(220, 38, 38, 0.12);
  color: #ef4444;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
}

.btn-login-gate-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  border-radius: 6px;
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--accent-primary-hover);
  transition: background 0.15s ease;
}

.btn-login-gate-google:hover {
  background: var(--accent-primary-hover);
}

.login-gate-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
}


