/* ===================================================================
   MONTA CONTAINER — Apple & Rimowa Minimalist Design System
   Pure Light Theme Baseline • Swiss / Apple Precision Typography
   Zero AI Emojis • 100% Crisp Vector SVG Aesthetics
   =================================================================== */

:root {
  /* Typography - Clean Apple / SF Pro System Stack (No Stencil Fonts) */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", -apple-system, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", -apple-system, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Spacing & Radii (Apple / Rimowa Radii) */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Apple Light Baseline Palette */
  --bg-body: #F5F5F7;               /* Signature Apple light gray canvas */
  --bg-card: #FFFFFF;               /* Elevated pure white cards */
  --bg-card-secondary: #FAFAFA;     /* Subtle secondary surface */
  --bg-input: #FFFFFF;              /* Crisp white inputs */
  --bg-input-focus: #FFFFFF;
  --border: #E5E5EA;                /* Micro-border 1px */
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-focus: #0071E3;          /* Apple System Blue */

  /* Text & Hierarchy */
  --text-primary: #1D1D1F;          /* Apple rich almost-black */
  --text-secondary: #6E6E73;        /* Neutral secondary */
  --text-muted: #86868B;            /* Subtle metadata & labels */

  /* Functional Accents */
  --brand-ocean: #0071E3;           /* Apple System Blue */
  --brand-ocean-hover: #0077ED;
  --brand-cyan: #0071E3;
  --azul-maritimo: #0F2C59;         /* Brand Navy Maritime */
  --azul-profundo: #081B38;         /* Brand Deep Navy */
  --brand-amber: #D97706;           /* Amber warning */
  --brand-amber-bg: rgba(217, 119, 6, 0.08);
  --brand-success: #34C759;         /* Apple Green */
  --brand-success-bg: rgba(52, 199, 89, 0.1);
  --brand-danger: #FF3B30;          /* Apple Red */
  --brand-danger-bg: rgba(255, 59, 48, 0.08);
  --brand-whatsapp: #25D366;        /* Official WhatsApp Green */
  --brand-whatsapp-hover: #1EBE5D;

  /* Refined Micro-Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.07), 0 2px 6px rgba(0, 0, 0, 0.03);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.16);

  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  /* Derived surface tokens (themeable; see css/themes.css) */
  --bg-subtle: #FAFAFC;
  --bg-hover: #F5F5F7;
  --track: #E5E5EA;
  --ink-solid: #1D1D1F;
  --border-strong: #D1D1D6;
  --border-faint: #F0F0F2;
  --border-hover: #8E8E93;
  --border-card: rgba(0, 0, 0, 0.08);
  --glass: rgba(255, 255, 255, 0.88);

  /* 3D scene tokens (read by js/viewer3d.js) */
  --scene-bg: #F5F5F7;
  --scene-floor: #E5E5EA;
  --scene-frame: #8E8E93;
  --scene-door: #71717A;
  --scene-post: #9CA3AF;
  --scene-grid-major: #C7C7CC;
  --scene-grid-minor: #E5E5EA;
  color-scheme: light;
}

/* Force light baseline globally */
html, body {
  background-color: var(--bg-body);
  color: var(--text-primary);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Minimalist Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #D1D1D6;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #8E8E93;
}

/* Typography Helpers */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
}

/* Header (Frosted Glass Apple Design) */
.app-header {
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.header-inner {
  max-width: 1540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

/* Rimowa-style brushed aluminum container badge */
.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.brand-titles h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
}

.brand-titles p {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Presets Bar (Apple Segmented Pill Styling) */
.presets-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-right: 2px;
}

.preset-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.preset-chip:hover {
  background: var(--bg-hover);
  border-color: rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

.preset-chip.active {
  background: var(--ink-solid);
  color: #FFFFFF;
  border-color: var(--ink-solid);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.preset-chip.active svg {
  stroke: #FFFFFF;
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Unit System Segmented Toggle */
.unit-system-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--track);
  padding: 3px;
  border-radius: var(--radius-md);
  gap: 2px;
  border: 1px solid var(--border-subtle);
}

.unit-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.2;
}

.unit-btn:hover {
  color: var(--text-primary);
}

.unit-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

/* Main Container Layout */
.app-container {
  max-width: 1540px;
  margin: 20px auto;
  padding: 0 24px 48px;
  display: grid;
  grid-template-columns: 490px 1fr;
  gap: 24px;
  align-items: start;
}

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

/* Left & Right Columns */
.panel-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.viewer-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 76px;
}

@media (max-width: 1180px) {
  .viewer-column {
    position: static;
  }
}

/* Cards (Rimowa & Apple Precision) */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-title .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

/* Route Section & Port Combobox Architecture (Apple / Clean) */
.route-card {
  position: relative;
  z-index: 25;
}

.route-selector-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: flex-end;
  gap: 10px;
  position: relative;
}

@media (max-width: 640px) {
  .route-selector-container {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .route-swap-wrap {
    display: flex;
    justify-content: center;
    margin: 2px 0;
  }
}

.port-combobox-group {
  position: relative;
  min-width: 0;
}

.port-combobox-wrapper {
  position: relative;
  width: 100%;
}

.port-combobox-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.port-combobox-flag {
  position: absolute;
  left: 10px;
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
}

.port-combobox-input {
  width: 100%;
  height: 38px;
  padding: 8px 30px 8px 34px !important;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.port-combobox-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.btn-clear-port {
  position: absolute;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  z-index: 2;
}

.btn-clear-port.has-value,
.port-combobox-input-wrap:hover .btn-clear-port.has-value {
  opacity: 0.7;
  pointer-events: auto;
}

.btn-clear-port:hover {
  opacity: 1 !important;
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Swap Route Button */
.route-swap-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 1px;
}

.btn-swap-route {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.2s ease,
              border-color 0.2s ease,
              color 0.2s ease,
              box-shadow 0.2s ease;
  flex-shrink: 0;
}

.btn-swap-route:hover {
  background: var(--bg-hover);
  border-color: var(--brand-ocean);
  color: var(--brand-ocean);
  transform: rotate(180deg);
  box-shadow: var(--shadow-md);
}

.btn-swap-route:active {
  transform: rotate(180deg) scale(0.94);
}

/* Combobox Dropdown */
.port-combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0, 0, 0, 0.1));
  z-index: 100;
  scroll-behavior: smooth;
  padding: 4px 0;
}

.port-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.12s ease;
  border-bottom: 1px solid var(--border-subtle);
}

.port-option:last-child {
  border-bottom: none;
}

.port-option:hover,
.port-option.highlighted {
  background: var(--bg-hover);
}

.port-option-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.port-option-flag {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.port-option-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.port-option-country {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.port-option-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.port-option-locode {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  background: var(--track, #E5E5EA);
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.port-option-limit {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--brand-amber-bg, rgba(217, 119, 6, 0.08));
  color: var(--brand-amber, #D97706);
  white-space: nowrap;
}

.port-option-empty {
  padding: 12px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Custom Creatable Location Option */
.port-option-custom {
  border-top: 1px dashed var(--border-subtle);
  border-bottom: none;
  background: var(--surface-secondary, rgba(0, 0, 0, 0.015));
  cursor: pointer;
  padding: 8px 10px;
  transition: background 0.12s ease;
}

.port-option-custom:hover,
.port-option-custom.highlighted {
  background: var(--surface-hover, var(--bg-hover));
}

.port-option-custom-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.port-option-custom .port-option-name {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-primary);
}

.port-option-custom .port-option-name strong {
  font-weight: 600;
  color: var(--brand-ocean, #0E7490);
}

.port-custom-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--brand-ocean-bg, rgba(14, 116, 144, 0.08));
  color: var(--brand-ocean, #0E7490);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* Frequent Ports Row */
.frequent-ports-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.frequent-ports-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.frequent-port-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-card-secondary, #FAFAFA);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}

.frequent-port-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.frequent-port-chip:active {
  transform: scale(0.96);
}

/* Route Weight Banner Modernization */
.route-weight-banner {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-secondary, #FAFAFA);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-overview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.route-overview-path {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.route-point {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.route-arrow {
  color: var(--text-muted);
  font-size: 12px;
}

.route-bottleneck-badge-wrap {
  display: flex;
  align-items: center;
}

.route-bottleneck-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.route-bottleneck-badge.is-restricted {
  background: var(--brand-amber-bg, rgba(217, 119, 6, 0.1));
  color: var(--brand-amber, #B45309);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.route-bottleneck-badge.is-open {
  background: rgba(0, 113, 227, 0.08);
  color: var(--brand-ocean, #0071E3);
  border: 1px solid rgba(0, 113, 227, 0.2);
}

.route-bottleneck-badge.is-disabled {
  background: var(--track, #E5E5EA);
  color: var(--text-muted);
  border: 1px solid transparent;
}

.route-banner-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.route-country-select-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 200px;
}

.route-country-select-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.route-country-select-group select {
  width: 100%;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  padding: 0 8px;
}

#route-weight-desc {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13.5px;
  transition: var(--transition);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

/* Item Entry Form */
.item-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.item-form-grid .full-span {
  grid-column: span 3;
}

.checkbox-group {
  display: flex;
  gap: 16px;
  margin: 8px 0 16px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--brand-ocean);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Action Buttons */
.btn-primary {
  background: var(--brand-ocean);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.22);
}

.btn-primary:hover {
  background: var(--brand-ocean-hover);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-danger {
  background: transparent;
  color: var(--brand-danger);
  border: 1px solid rgba(255, 59, 48, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-danger:hover {
  background: var(--brand-danger-bg);
  border-color: var(--brand-danger);
}

.btn-whatsapp {
  background: var(--brand-whatsapp);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 500;
  font-size: 13.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
}

.btn-whatsapp:hover {
  background: var(--brand-whatsapp-hover);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
}

/* Packing List Table */
.packing-list-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.packing-list-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 200px;
  max-width: 320px;
}

.packing-list-search-wrapper .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.packing-list-search-wrapper input.items-search-input {
  width: 100%;
  padding-left: 32px !important;
  padding-right: 10px;
  padding-top: 7px;
  padding-bottom: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12.5px;
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--transition);
  box-sizing: border-box;
}

.packing-list-search-wrapper input.items-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.packing-list-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.sortable-th:hover {
  background: var(--border-subtle, rgba(0, 0, 0, 0.04));
}

.th-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.sort-indicator {
  font-size: 11px;
  color: var(--accent);
  display: inline-block;
  min-width: 12px;
}

.items-count-badge {
  background: var(--bg-body);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.items-table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 480px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.items-table th {
  background: var(--bg-subtle);
  padding: 10px 12px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.items-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-faint);
  color: var(--text-primary);
  vertical-align: middle;
}

.items-table tr:last-child td {
  border-bottom: none;
}

.items-table tr:hover td {
  background-color: var(--bg-subtle);
}

.item-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.item-color-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  border: 1px solid var(--border-card);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.status-pill.success {
  background: var(--brand-success-bg);
  color: #248A3D;
}

.status-pill.danger {
  background: var(--brand-danger-bg);
  color: #D70015;
}

.status-pill.cyan {
  background: rgba(0, 113, 227, 0.08);
  color: #0071E3;
}

.status-pill.muted {
  background: rgba(142, 142, 147, 0.12);
  color: #636366;
}

/* Interactive Status Pill Button */
.status-pill-toggle {
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  line-height: inherit;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  outline: none;
}

.status-pill-toggle:hover {
  filter: brightness(0.96);
  border-color: rgba(0, 0, 0, 0.18);
  transform: translateY(-0.5px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.status-pill-toggle:active {
  transform: scale(0.96);
}

.status-pill-toggle:focus-visible {
  outline: 2px solid var(--brand-ocean);
  outline-offset: 1px;
}

.item-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.action-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.action-icon-btn.delete:hover {
  background: var(--brand-danger-bg);
  color: var(--brand-danger);
  border-color: var(--brand-danger);
}

.action-icon-btn.edit:hover {
  background: rgba(0, 113, 227, 0.08);
  color: var(--brand-ocean);
  border-color: var(--brand-ocean);
}

.action-icon-btn.save {
  background: var(--brand-ocean);
  color: #FFFFFF;
  border-color: var(--brand-ocean);
}

.action-icon-btn.save:hover {
  background: #0062c4;
  border-color: #0062c4;
  color: #FFFFFF;
}

.action-icon-btn.cancel {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.action-icon-btn.cancel:hover {
  background: var(--brand-danger-bg);
  color: var(--brand-danger);
  border-color: var(--brand-danger);
}

/* Inline Edit Row Components */
.row-editing {
  background-color: rgba(0, 113, 227, 0.03) !important;
}

.table-inline-input {
  width: 100%;
  font-size: 12px;
  padding: 4px 6px;
  height: 27px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  box-sizing: border-box;
  transition: var(--transition);
}

.table-inline-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.15);
}

.table-inline-select {
  width: 100%;
  max-width: 175px;
  font-size: 11px;
  padding: 3px 6px;
  height: 25px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  box-sizing: border-box;
  transition: var(--transition);
}

.table-inline-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.15);
}

.inline-dim-inputs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.inline-dim-inputs .edit-len,
.inline-dim-inputs .edit-wid,
.inline-dim-inputs .edit-hei {
  width: 44px;
  text-align: center;
  padding: 4px 2px;
}

.dim-separator {
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}

.inline-unit-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-unit-input .edit-weight {
  width: 55px;
  text-align: right;
  padding: 4px 4px;
}

.inline-unit-label {
  font-size: 11px;
  color: var(--text-secondary);
  user-select: none;
}

.inline-qty-inputs {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inline-qty-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-qty-row .edit-packages,
.inline-qty-row .edit-items-per-pkg {
  width: 50px;
  text-align: right;
  padding: 4px 4px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 36px 20px;
}

.empty-state .icon {
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}

/* Integrated 3D Comparison Section */
.viewer-comparison-section {
  padding: 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  transition: var(--transition);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

.viewer-single-metrics {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.viewer-metrics-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-faint);
  min-width: 0;
  box-sizing: border-box;
}

.viewer-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.viewer-summary-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.viewer-summary-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.viewer-summary-value .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.viewer-metrics-progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 600px) {
  .viewer-metrics-progress-grid {
    grid-template-columns: 1fr;
  }
}

.viewer-comparison-section .matrix-grid {
  display: block;
  margin-top: 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.viewer-comparison-section .lcl-alert {
  margin-top: 12px;
}

/* Comparison Matrix */
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 600px) {
  .matrix-grid {
    grid-template-columns: 1fr;
  }
}

.matrix-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.matrix-card:hover {
  border-color: var(--brand-ocean);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.matrix-card.active-view {
  border: 2px solid var(--brand-ocean);
  box-shadow: 0 0 0 1px var(--brand-ocean);
}

.matrix-card.recommended {
  background: var(--bg-card);
  border-color: var(--ink-solid);
}

.recommended-pill {
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--ink-solid);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

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

.matrix-card-header h4 {
  font-size: 14px;
  font-weight: 600;
}

.iso-tag {
  background: var(--bg-body);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.matrix-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.matrix-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.metric-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--text-secondary);
  gap: 8px;
  min-width: 0;
}

.metric-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.metric-title {
  font-weight: 500;
  color: var(--text-primary);
}

.metric-scope-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
  font-weight: 600;
}

.metric-value-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-align: right;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 0;
}

.metric-qty {
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
}

.metric-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-details-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.metric-detail-item {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.metric-detail-item strong {
  color: var(--text-primary);
  font-weight: 600;
}

.metric-cap-muted {
  color: var(--text-muted);
}

/* Multi-container distribution breakdown */
.viewer-containers-breakdown {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breakdown-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11.5px;
}

.breakdown-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-primary);
}

.breakdown-total-tag {
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(0, 113, 227, 0.06);
  border: 1px solid rgba(0, 113, 227, 0.16);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.breakdown-total-tag strong {
  color: var(--text-primary);
}

.breakdown-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.breakdown-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.breakdown-card:hover {
  border-color: var(--brand-ocean);
  background: rgba(0, 113, 227, 0.02);
}

.breakdown-card.active {
  border-color: var(--brand-ocean);
  background: rgba(0, 113, 227, 0.06);
  box-shadow: 0 0 0 1px var(--brand-ocean);
}

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

.breakdown-card-tag {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.breakdown-pill-current {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--brand-ocean);
  color: #fff;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
}

.breakdown-card-data {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.breakdown-label {
  color: var(--text-secondary);
}

.breakdown-val {
  color: var(--text-primary);
}

.breakdown-pct {
  font-size: 10px;
  color: var(--text-muted);
}

.progress-bar-bg {
  position: relative;
  width: 100%;
  height: 12px;
  background: var(--track);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-bar-fill.ocean {
  background: var(--brand-ocean);
}

.progress-bar-fill.amber {
  background: #FF9F0A;
}

.progress-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  pointer-events: none;
  z-index: 3;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  line-height: 1;
  color: var(--text-primary);
  text-shadow: none;
  letter-spacing: 0.02em;
  user-select: none;
}

.progress-bar-label.metric-pct {
  color: var(--text-primary);
  font-size: 10px;
  text-shadow: none;
}

.void-indicator {
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-faint);
  padding-top: 8px;
  margin-top: 2px;
}

/* LCL Alert Banner */
.lcl-alert {
  background: rgba(255, 159, 10, 0.08);
  border: 1px solid rgba(255, 159, 10, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.lcl-alert .icon {
  color: #D97706;
  flex-shrink: 0;
  margin-top: 2px;
}

.lcl-alert-content {
  flex: 1;
  min-width: 0;
}

.lcl-alert h5 {
  font-size: 13px;
  font-weight: 600;
  color: #92400E;
  margin-bottom: 2px;
}

.lcl-alert p {
  font-size: 12px;
  color: #78350F;
  line-height: 1.4;
}

.lcl-alert-btn {
  align-self: center;
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(217, 119, 6, 0.16);
  color: #92400E;
  border: 1px solid rgba(217, 119, 6, 0.35);
}

.lcl-alert-btn:hover {
  background: #D97706;
  color: #FFFFFF;
  border-color: #D97706;
}

[data-theme="dark"] .lcl-alert-btn {
  background: rgba(217, 119, 6, 0.25);
  color: #FBBF24;
  border-color: rgba(217, 119, 6, 0.5);
}

[data-theme="dark"] .lcl-alert-btn:hover {
  background: #D97706;
  color: #FFFFFF;
  border-color: #D97706;
}

/* 3D Viewer Card & Toolbar */
.viewer-card {
  padding: 0;
  overflow: hidden;
}

.viewer-toolbar {
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

/* Dunnage Trigger Button in 3D Viewer Toolbar */
.dunnage-trigger-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.dunnage-trigger-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.preset-dunnage-btn {
  transition: var(--transition);
}

.preset-dunnage-btn:hover {
  border-color: var(--accent) !important;
  background: var(--bg-hover) !important;
}

.preset-dunnage-btn.active {
  border-color: var(--brand-ocean) !important;
  background: rgba(0, 113, 227, 0.08) !important;
}

.dunnage-weight-pill {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.dunnage-weight-pill:hover {
  border-color: var(--brand-ocean);
  color: var(--text-primary);
  background: rgba(0, 113, 227, 0.04);
}

.dunnage-weight-pill.active {
  border-color: var(--brand-ocean) !important;
  background: rgba(0, 113, 227, 0.12) !important;
  color: var(--brand-ocean) !important;
  font-weight: 600 !important;
  box-shadow: 0 0 0 1px var(--brand-ocean);
}

/* Apple Segmented Control for Container Types */
.type-switcher {
  display: inline-flex;
  background: var(--track);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  flex: 0 1 auto;
  width: fit-content;
  min-width: 0;
}

.type-switcher::-webkit-scrollbar {
  display: none;
}

.type-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.type-tab:hover {
  color: var(--text-primary);
}

.type-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Recommended badge inside toggle tab */
.type-tab-badge {
  background: var(--brand-ocean);
  color: #FFFFFF;
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  transition: var(--transition);
}

.pager-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.pager-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.pager-btn:hover:not(:disabled) {
  background: var(--bg-hover);
}

.pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Environment Switcher Segmented Control */
.env-switcher {
  display: inline-flex;
  background: var(--track);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.env-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.env-tab:hover {
  color: var(--text-primary);
}

.env-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.env-tab svg {
  flex-shrink: 0;
}

/* Camera Angle Presets */
.camera-presets {
  display: flex;
  align-items: center;
  gap: 5px;
}

.camera-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.camera-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Canvas Viewport */
.canvas-viewport {
  width: 100%;
  height: 480px;
  background: var(--bg-hover);
  position: relative;
  overflow: hidden;
}

.canvas-viewport canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.webgl-fallback-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 30px;
  text-align: center;
  color: var(--text-secondary);
}

.webgl-fallback-notice h4 {
  margin: 12px 0 6px;
  font-size: 15px;
}

.webgl-fallback-notice p {
  max-width: 400px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Tooltip & Badges inside 3D Viewport */
.viewer3d-tooltip {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: var(--shadow-md);
  font-size: 11.5px;
  color: var(--text-primary);
}

.viewer3d-tooltip .tooltip-header {
  margin-bottom: 4px;
}

.viewer3d-tooltip .tooltip-body div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.viewer3d-void-badge {
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.void-badge-content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.void-icon {
  color: #D97706;
  margin-top: 2px;
}

.void-badge-content strong {
  font-size: 12px;
  color: #92400E;
}

.void-badge-content p {
  font-size: 11px;
  color: #78350F;
  margin-top: 1px;
}

/* Quote Layout Toolbar & Toggle (WhatsApp vs Clean Email) */
.quote-layout-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}

.quote-layout-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--track);
  padding: 2px;
  border-radius: var(--radius-md);
  gap: 2px;
  border: 1px solid var(--border-subtle);
}

.quote-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.2;
  white-space: nowrap;
}

.quote-toggle-btn:hover {
  color: var(--text-primary);
}

.quote-toggle-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#btn-quote-layout-whatsapp.active svg {
  color: var(--brand-whatsapp, #25D366);
}

#btn-quote-layout-email.active svg {
  color: var(--brand-ocean, #0071E3);
}

/* WhatsApp Quotation Box */
.quote-preview-box {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 16px;
}

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

.quote-actions .quote-action-icon-btn,
.quote-actions .quote-cfg-btn,
.quote-action-icon-btn,
.quote-cfg-btn {
  padding: 8px 10px;
  width: 36px;
  height: 35px;
  min-width: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.quote-actions .quote-action-icon-btn:hover,
.quote-actions .quote-cfg-btn:hover,
.quote-action-icon-btn:hover,
.quote-cfg-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

@media (max-width: 440px) {
  .quote-actions {
    flex-wrap: wrap;
  }
}

/* Modals (Apple Center Sheet with Blur Backdrop) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Stacked modals (e.g. Import Conflict Dialog on top of Smart Paste) */
.modal-stacked,
#modal-import-conflict {
  z-index: 1100;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Conflict Modal Details */
.conflict-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.conflict-summary-box {
  padding: 12px 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
}

.conflict-summary-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.conflict-summary-label.highlight {
  color: var(--brand-ocean);
}

.conflict-summary-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.conflict-summary-val.highlight {
  color: var(--brand-ocean);
}

.conflict-summary-sub {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.conflict-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.conflict-modal-footer .btn-secondary,
.conflict-modal-footer .btn-primary,
.conflict-modal-footer .btn-overwrite,
.conflict-modal-footer .btn-danger {
  padding: 8px 14px;
  font-size: 13px;
}

#btn-conflict-overwrite {
  background: var(--azul-maritimo, #0F2C59);
  color: #ffffff;
  border: 1px solid var(--azul-maritimo, #0F2C59);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}

#btn-conflict-overwrite:hover {
  background: var(--azul-profundo, #081B38);
  border-color: var(--azul-profundo, #081B38);
  color: #ffffff;
}

.paste-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-input);
  color: var(--text-primary);
  box-sizing: border-box;
}

/* PDF Upload & Drag-and-Drop Area */
.pdf-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 12px;
  text-align: center;
  user-select: none;
}

.pdf-drop-zone:hover,
.pdf-drop-zone.dragover {
  border-color: var(--brand-ocean, #0071E3);
  background: rgba(0, 113, 227, 0.04);
}

.pdf-drop-zone.is-loading {
  pointer-events: none;
  opacity: 0.85;
  border-color: var(--brand-ocean, #0071E3);
}

.pdf-drop-icon {
  color: var(--brand-ocean, #0071E3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.pdf-drop-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.pdf-drop-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.pdf-progress-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--brand-ocean, #0071E3);
  font-weight: 500;
}

.pdf-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 113, 227, 0.25);
  border-top-color: var(--brand-ocean, #0071E3);
  border-radius: 50%;
  animation: pdf-spin 0.8s linear infinite;
}

@keyframes pdf-spin {
  to { transform: rotate(360deg); }
}

/* OCR Prompt Banner & Progress */
.pdf-ocr-banner {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 149, 0, 0.08);
  border: 1px solid rgba(255, 149, 0, 0.35);
  border-radius: var(--radius-md, 8px);
  text-align: left;
  margin-top: 6px;
  animation: fadeIn 0.25s ease-out;
}

[data-theme="dark"] .pdf-ocr-banner,
[data-theme="atelier"][data-color-scheme="dark"] .pdf-ocr-banner {
  background: rgba(255, 149, 0, 0.12);
  border-color: rgba(255, 149, 0, 0.4);
}

.pdf-ocr-banner-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pdf-ocr-banner-icon {
  color: #d97706;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.pdf-ocr-banner-info {
  flex: 1;
}

.pdf-ocr-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.pdf-ocr-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.pdf-ocr-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn-link-action {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--brand-ocean, #0071E3);
  text-decoration: underline;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-link-action:hover {
  opacity: 0.8;
}

.btn-sm.btn-subtle-danger {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sm.btn-subtle-danger:hover {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.4);
}

.pdf-ocr-progress-card {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  text-align: left;
  margin-top: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  animation: fadeIn 0.2s ease-out;
}

.pdf-ocr-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pdf-ocr-progress-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--brand-ocean, #0071E3);
}

.pdf-ocr-progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle, rgba(0, 0, 0, 0.06));
  border-radius: 999px;
  overflow: hidden;
}

.pdf-ocr-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-ocean, #0071E3), #06b6d4);
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

.preview-table-container {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* Toast Notification (Apple Capsule) */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink-solid);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 2000;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-notification.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-notification svg {
  stroke: #FFFFFF;
  flex-shrink: 0;
}

/* Viewer controls share the scene without being removed by the renderer. */
.viewer-column { min-width: 0; }
.viewer-card { container-type: inline-size; }
.viewer-toolbar > .dunnage-trigger-btn { margin-left: auto; flex-shrink: 0; }
.viewer-scene { position: relative; }
.viewer-scene-top-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.viewer-scene-top-controls > * { pointer-events: auto; }
.viewer-scene .pager-controls {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.viewer-scene .env-switcher { margin-left: auto; }
.viewer-scene .env-tab { min-height: calc(1lh + 12px); }
.viewer-scene .camera-presets {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 3px;
  z-index: 5;
}

/* Asynchronous Calculation Status Indicator (Subtle Glassmorphic Badge) */
.calc-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
  font-size: 0.72rem;
  font-weight: 500;
  color: #1d4ed8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(-4px);
  z-index: 10;
}

.calc-status-indicator.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.calc-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #2563eb;
  box-shadow: 0 0 6px rgba(37, 99, 235, 0.7);
  animation: calc-pulse 1s infinite alternate ease-in-out;
}

[data-theme="dark"] .calc-status-indicator {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(96, 165, 250, 0.4);
  color: #93c5fd;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .calc-pulse-dot {
  background-color: #60a5fa;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.8);
}

@keyframes calc-pulse {
  from {
    transform: scale(0.85);
    opacity: 0.55;
  }
  to {
    transform: scale(1.25);
    opacity: 1;
  }
}
.viewer-controls-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  user-select: none;
  pointer-events: none;
  margin-left: auto;
}
.viewer-controls-hint svg {
  flex-shrink: 0;
  color: var(--text-muted);
}
@media (max-width: 640px) {
  .viewer-controls-hint {
    display: none;
  }
}
.viewer-metrics-scope-bar {
  padding: 8px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}
.metrics-scope-toggle {
  display: inline-flex;
  background: var(--track);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
}
.scope-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.scope-btn:hover {
  color: var(--text-primary);
}
.scope-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.scope-btn svg {
  flex-shrink: 0;
  stroke: currentColor;
}
.viewer-metrics-summary-bar {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr) auto;
  align-items: start;
}
.viewer-summary-item { min-width: 0; }
.viewer-summary-dimensions {
  font-size: 11.5px;
  color: var(--text-muted);
}
.viewer-door-value {
  display: flex;
  align-items: center;
  gap: 4px;
}
.door-void-notice { position: relative; display: inline-flex; }
.door-void-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border: 0;
  background: transparent;
  color: #D97706;
  cursor: pointer;
}
.door-void-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.door-void-tooltip {
  position: absolute;
  right: 0;
  bottom: 100%;
  z-index: 110;
  width: max-content;
  max-width: min(270px, 75cqw);
  font-weight: 400;
  line-height: 1.4;
}
.door-void-notice[hidden], .door-void-tooltip[hidden] { display: none; }
@container (max-width: 600px) {
  .viewer-metrics-summary-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .viewer-toolbar .type-switcher { flex-wrap: nowrap; }
}
@container (max-width: 500px) {
  .viewer-metrics-scope-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .metrics-scope-toggle {
    display: flex;
  }
  .metrics-scope-toggle .scope-btn {
    flex: 1;
    justify-content: center;
  }
}
@container (max-width: 380px) {
  .viewer-metrics-summary-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viewer-scene-top-controls { flex-wrap: wrap; }
}
