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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a0a0f;
  color: #e0e0e4;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===== TIER 1: App Bar (Top Tier) ===== */
#tier1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #101018 0%, #0c0c14 100%);
  border-bottom: 1px solid #1a1a24;
  padding: 0 20px;
  height: 42px;
  flex-shrink: 0;
  z-index: 200;
}

.t1-left {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: space-between;
  margin-right: 24px;
}

.t1-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 11px;
  font-weight: 700;
  color: #c0c4cc;
  letter-spacing: 1.2px;
  margin-right: 20px;
  user-select: none;
}
.logo sup.badge {
  background: #1e293b;
  color: #64748b;
  font-size: 7px;
  padding: 2px 5px;
  border-radius: 2px;
  font-weight: 700;
  vertical-align: super;
  margin-left: 4px;
  letter-spacing: 0.5px;
}

/* Corporate Top Buttons */
.corp-btn {
  background: #13131d;
  border: 1px solid #1e1e2e;
  color: #c8d0da;
  padding: 5px 14px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
  font-family: inherit;
}
.corp-btn:hover {
  background: #1a1a2a;
  border-color: #2a2a3e;
  color: #e2e8f0;
}

/* Accent for Load P1 */
.btn-load {
  border-color: #1e4976 !important;
  background: rgba(56, 139, 210, 0.06) !important;
  color: #5ba3d9 !important;
}
.btn-load:hover {
  background: rgba(56, 139, 210, 0.12) !important;
  color: #7db8e3 !important;
}

/* Accent for Generate Preplot */
.btn-preplot {
  border-color: #1a5e3a !important;
  background: rgba(34, 150, 79, 0.06) !important;
  color: #4eba6f !important;
}
.btn-preplot:hover {
  background: rgba(34, 150, 79, 0.12) !important;
  color: #6dce89 !important;
}

.corp-sep {
  width: 1px;
  height: 14px;
  background: #1e1e2e;
  margin: 0 2px;
  flex-shrink: 0;
}

/* Corporate Top Navigation Tab Buttons */
.corp-nav-btn {
  background: transparent;
  border: none;
  color: #a0aebb;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  padding: 6px 10px;
  transition: color 0.12s;
  font-family: inherit;
}
.corp-nav-btn:hover {
  color: #e2e8f0;
}
.corp-nav-btn.active {
  color: #5ba3d9;
}

.t1-status {
  font-size: 9px;
  color: #8a9bb0;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.dot-green {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #4eba6f;
  display: inline-block;
  box-shadow: 0 0 4px rgba(78, 186, 111, 0.5);
}

.t1-icon {
  width: 26px; height: 26px;
  border: 1px solid #1e1e2e;
  border-radius: 3px;
  background: #13131d;
  color: #a0aebb;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  font-family: inherit;
}
.t1-icon:hover {
  background: #1a1a2a;
  color: #e2e8f0;
  border-color: #2a2a3e;
}

/* ===== TIER 2: Toolbar (Bottom Tier) ===== */
#tier2 {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #0c0c14 0%, #0a0a10 100%);
  border-bottom: 1px solid #1a1a24;
  padding: 0 20px;
  height: 36px;
  flex-shrink: 0;
  z-index: 200;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
}
#tier2::-webkit-scrollbar { height: 0; }

.t2-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #13131d;
  border: 1px solid #1e1e2e;
  color: #b0bcc8;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  transition: all 0.12s;
  font-family: inherit;
}
.t2-btn:hover {
  background: #1a1a2a;
  border-color: #2a2a3e;
  color: #e2e8f0;
}

/* Accent Start Pt button */
.btn-startpt {
  border-color: #6b4c1e !important;
  background: rgba(200, 140, 40, 0.06) !important;
  color: #d4a24c !important;
}
.btn-startpt:hover {
  background: rgba(200, 140, 40, 0.12) !important;
  color: #e0b86a !important;
}

.t2-spacer { flex: 1; }

.val {
  background: rgba(91, 163, 217, 0.1);
  border: 1px solid #1e293b;
  color: #d0d8e2;
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 9px;
  margin-left: 4px;
  font-weight: 600;
}

/* Plan Survey Tab */
.corp-tab {
  background: transparent;
  border: none;
  color: #a0aebb;
  padding: 0 16px;
  height: 100%;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.12s;
  font-family: inherit;
}
.corp-tab:hover {
  color: #e2e8f0;
}
.corp-tab.active {
  color: #5ba3d9;
  border-bottom-color: #5ba3d9;
}

/* Bottom Nav Map/Survey View Buttons */
.corp-view-btn {
  background: #13131d;
  border: 1px solid #1e1e2e;
  color: #a0aebb;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
  font-family: inherit;
}
.corp-view-btn:hover {
  background: #1a1a2a;
  color: #e2e8f0;
}
.corp-view-btn.active {
  background: rgba(91, 163, 217, 0.08);
  border-color: #2a5580;
  color: #5ba3d9;
}

/* ===== MAIN AREA ===== */
#main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Cesium globe */
#cesium-globe {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2;
}

/* Survey list panel (floating) */
#survey-list-panel {
  position: absolute;
  top: 0; left: 0; width: 220px; height: 100%;
  background: #0a0a12; border-right: 1px solid #1a1a24;
  z-index: 5; overflow-y: auto;
}
#survey-list-header {
  padding: 8px 12px; font-size: 10px; color: #c0c4cc;
  background: #0e0e16; position: sticky; top: 0;
  font-weight: 600; border-bottom: 1px solid #1a1a24;
  letter-spacing: 0.4px; text-transform: uppercase;
}
#survey-list { font-size: 11px; }
.survey-line-item {
  display: flex; justify-content: space-between;
  padding: 4px 12px; border-bottom: 1px solid #141420;
  cursor: pointer; transition: background 0.1s;
}
.survey-line-item:hover { background: #141420; }
.survey-line-item.active { background: #1a1a2a; color: #e2e8f0; }
.line-name { color: #7cc99a; font-weight: 500; }
.line-coords { color: #7c8c9e; font-size: 10px; }

/* Route stats */
#route-stats {
  display: flex;
  gap: 5px;
  font-size: 9.5px;
  color: #7cc99a;
  flex-wrap: nowrap;
  white-space: nowrap;
  align-items: center;
  font-weight: 600;
}

#route-stats span {
  background: #111a15;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid #1a2e1e;
}

#route-stats #stat-skipped {
  background: #1a1114;
  border-color: #2e1a1e;
  color: #d4828a;
}

/* Map */
#map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1;
}

/* No survey overlay */
#no-survey-overlay {
  position: absolute;
  top: 40px; left: 0; right: 0; bottom: 0;
  background: rgba(10,10,15,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}

#no-survey-card {
  background: #12121c;
  border: 1px solid #1e1e2e;
  border-radius: 8px;
  padding: 28px 32px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}

#no-survey-icon { font-size: 36px; margin-bottom: 10px; }
#no-survey-title { font-size: 15px; font-weight: 600; color: #c0c4cc; margin-bottom: 6px; }
#no-survey-sub { font-size: 12px; color: #8a9bb0; margin-bottom: 18px; line-height: 1.5; }

#no-survey-actions { display: flex; gap: 10px; justify-content: center; }

.btn-primary {
  background: #2a5580;
  color: #e2e8f0;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.12s;
}

.btn-primary:hover { background: #346a99; }

.btn-secondary {
  background: #13131d;
  color: #7c8597;
  border: 1px solid #1e1e2e;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s;
}

.btn-secondary:hover { background: #1a1a2a; color: #e2e8f0; }

/* Bottom bar */
#bottom-bar {
  position: absolute;
  bottom: 6px;
  left: 10px;
  display: flex;
  gap: 16px;
  font-size: 9px;
  color: #7c8c9e;
  z-index: 10;
  pointer-events: none;
  background: rgba(10,10,15,0.7);
  padding: 3px 10px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Right controls */
#right-controls {
  position: absolute;
  right: 10px;
  top: 50px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 100;
}

.map-ctrl-btn {
  width: 28px; height: 28px;
  background: #12121c;
  border: 1px solid #1e1e2e;
  color: #b0bcc8;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}

.map-ctrl-btn:hover { background: #1a1a2a; color: #e2e8f0; border-color: #2a2a3e; }
.ctrl-divider { height: 1px; background: #1e1e2e; margin: 2px 0; }

/* ===== SETTINGS PANELS ===== */
.settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0e0e16;
  border: 1px solid #1a1a24;
  border-radius: 6px;
  padding: 20px 24px;
  z-index: 200;
  min-width: 260px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.02);
}

.panel-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  color: #8a9bb0;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.12s;
  font-family: inherit;
  font-weight: 500;
  outline: none;
}

.panel-close-btn:hover {
  color: #e2e8f0;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #c0c4cc;
  margin-bottom: 14px;
  border-bottom: 1px solid #1a1a24;
  padding-bottom: 8px;
  letter-spacing: 0.2px;
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
}

.panel-row label { color: #c0c8d4; width: 70px; font-weight: 500; }
.panel-row input {
  flex: 1;
  background: #0a0a12;
  border: 1px solid #1a1a24;
  color: #e2e8f0;
  padding: 5px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.12s;
}
.panel-row input:focus {
  border-color: #2a5580;
  outline: none;
}
.panel-row input[type=number] {
  padding-right: 4px;
}

.panel-row span { color: #7c8c9e; font-size: 11px; }

.panel-ok {
  background: #2a5580;
  color: #e2e8f0;
  border: none;
  padding: 7px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
  transition: background 0.12s;
  font-family: inherit;
  letter-spacing: 0.3px;
}
.panel-ok:hover {
  background: #346a99;
}

.panel-cancel {
  background: #13131d;
  color: #c0c8d4;
  border: 1px solid #1e1e2e;
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.12s;
  font-family: inherit;
}
.panel-cancel:hover {
  background: #1a1a2a;
  color: #e2e8f0;
}

/* Planning progress */
#planning-overlay {
  display: none;
  position: absolute;
  top: 40px; left: 0; right: 0; bottom: 0;
  background: rgba(10,10,15,0.7);
  z-index: 60;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

#planning-overlay.visible {
  display: flex;
}

#planning-card {
  background: #0e0e16;
  border: 1px solid #1a1a24;
  border-radius: 6px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 16px 64px rgba(0,0,0,0.7);
}

#planning-card h3 { color: #5ba3d9; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
#planning-card p  { color: #c0c8d4; font-size: 12px; margin-bottom: 16px; }

.spinner {
  width: 32px; height: 32px;
  border: 2px solid #1a1a24;
  border-top-color: #5ba3d9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* Cesium globe overrides */
#cesium-globe { background: #06060c; }
#cesium-globe .cesium-viewer-toolbar,
#cesium-globe .cesium-viewer-bottom { display: none !important; }
.cesium-widget-credits { display: none !important; }

/* Leaflet overrides */
.leaflet-container { background: #0a0a14; }
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution { background: rgba(10,10,15,0.8) !important; color: #2d3748 !important; font-size: 8px; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #0a0a12; }
::-webkit-scrollbar-thumb { background: #1e1e2e; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #2a2a3e; }

/* ===== PRINT STYLES ===== */
@media print {
  @page {
    size: A4;
    margin: 20mm 15mm 20mm 15mm;
  }

  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body.printing-report {
    background: #fff !important;
    color: #000 !important;
    overflow: visible !important;
    height: auto !important;
  }

  /* Hide everything when printing */
  body.printing-report #map,
  body.printing-report .toolbar,
  body.printing-report .tier1-menu,
  body.printing-report .tier2-menu,
  body.printing-report #sidebar,
  body.printing-report .leaflet-control-container,
  body.printing-report .panel-close-btn,
  body.printing-report #signin-overlay,
  body.printing-report .toast-notification,
  body.printing-report #panel-tides,
  body.printing-report #panel-geodesy,
  body.printing-report #panel-licensing,
  body.printing-report #panel-priority,
  body.printing-report #panel-layers,
  body.printing-report #panel-obstructions,
  body.printing-report #panel-measure,
  body.printing-report .map-control-bar,
  body.printing-report .status-bar,
  body.printing-report #layer-finish-draw-btn,
  body.printing-report #cesium-globe { display: none !important; }

  /* Show the reports panel full-page */
  body.printing-report #panel-reports {
    display: block !important;
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 999999 !important;
  }

  body.printing-report #panel-reports .panel-title {
    color: #000 !important;
    font-size: 18pt !important;
    border-bottom: 2px solid #000 !important;
    padding-bottom: 8px !important;
    margin-bottom: 10px !important;
  }

  body.printing-report #rep-generated,
  body.printing-report #rep-user {
    color: #444 !important;
    font-size: 9pt !important;
  }

  body.printing-report #report-body {
    background: #fff !important;
    border: none !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    font-size: 9pt !important;
    line-height: 1.8 !important;
    color: #000 !important;
  }

  /* Section headings */
  body.printing-report #report-body div[style*="text-transform:uppercase"] {
    color: #000 !important;
    border-bottom-color: #000 !important;
    font-size: 10pt !important;
    margin-top: 12pt !important;
  }

  /* Data rows */
  body.printing-report #report-body span,
  body.printing-report #report-body strong {
    color: #000 !important;
  }

  /* Line schedule table */
  body.printing-report #rep-line-schedule table {
    font-size: 8pt !important;
    border: 1px solid #ccc !important;
    width: 100% !important;
  }
  body.printing-report #rep-line-schedule tr {
    border-bottom: 1px solid #ddd !important;
  }
  body.printing-report #rep-line-schedule td {
    color: #000 !important;
    padding: 2pt 4pt !important;
  }

  /* Hide action buttons in print */
  body.printing-report #panel-reports > div:last-child { display: none !important; }

  /* Page break control */
  body.printing-report #rep-line-schedule { page-break-before: auto; }
}
