/* Chartroom — CT Systems product chrome
   Tokens and type match www.ctsystems.nl ("Precision at Sea"). */

:root {
  --green: #107a3e;
  --green-dk: #0b5e30;
  --green-lt: #e8f3ec;
  --green-200: #c6e0cf;
  --ink-900: #061018;
  --ink-800: #0a1824;
  --ink-700: #0f2236;
  --ink-500: #1e3a52;
  --ink-400: #3d5268;
  --sea-300: #6fa0be;
  --fog-100: #f2f5f8;
  --fog-050: #ffffff;
  --line: #d5dee6;
  --line-dk: rgba(255, 255, 255, 0.1);
  --amber: #ffb020;
  --alert: #e04f4f;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(6, 16, 24, 0.06);
  --shadow-md: 0 8px 24px rgba(6, 16, 24, 0.08);
  --sidebar: 340px;
  --topbar: 72px;
}

* { box-sizing: border-box; }

html, body, #app {
  margin: 0;
  height: 100%;
  background: var(--fog-100);
  color: var(--ink-900);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  display: grid;
  grid-template-rows: var(--topbar) 1fr;
}

/* ---------- Top bar (mirrors ctsystems.nl header) ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 0.35rem 1rem;
  min-height: var(--topbar);
  padding: 0.85rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 1300;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.brand img {
  height: 40px;
  width: auto;
  display: block;
}

.product-nav {
  display: flex;
  align-items: center;
}

.product-nav__item {
  position: relative;
  color: var(--green-dk);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.55rem 0.85rem;
  letter-spacing: -0.005em;
}

.product-nav__item::after {
  content: "";
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 2px;
  height: 2px;
  background: var(--green);
  border-radius: 2px;
}

.topbar__tag {
  margin: 0 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 0;
}

/* ---------- Sidebar ---------- */

aside {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    var(--fog-050)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 600'><g fill='none' stroke='%23107A3E' stroke-width='0.75' opacity='0.07'><path d='M-50 420 Q 150 360 300 410 T 650 400'/><path d='M-50 360 Q 150 300 300 350 T 650 340'/><path d='M-50 300 Q 150 240 300 290 T 650 280'/><path d='M-50 240 Q 150 180 300 230 T 650 220'/></g></svg>");
  background-size: 900px;
  border-right: 1px solid var(--line);
  z-index: 1100;
}

.panel-head {
  padding: 1.15rem 1.25rem 0.35rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green-dk);
  font-weight: 500;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

.lede {
  margin: 0;
  color: var(--ink-400);
  font-size: 0.875rem;
  line-height: 1.5;
}

.lede code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--ink-700);
}

.dropzone {
  margin: 0.85rem 1rem 1rem;
  padding: 1rem 0.9rem;
  border: 1px dashed var(--green-200);
  border-radius: var(--radius-lg);
  background: var(--green-lt);
  text-align: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.dropzone.dragover {
  border-color: var(--green);
  background: #d8efdf;
  box-shadow: 0 0 0 3px rgba(16, 122, 62, 0.18);
}

.dropzone p {
  margin: 0.55rem 0 0;
  color: var(--ink-400);
  font-size: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.25rem;
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
              background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

.btn--primary:hover {
  background: var(--green-dk);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(16, 122, 62, 0.22);
}

#importBtn {
  width: 100%;
}

#fileInput { display: none; }

.section-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.15rem 1.25rem 0.5rem;
}

.section-h h2 {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-400);
  font-weight: 600;
  font-family: var(--font-mono);
}

.linkish {
  background: none;
  border: 0;
  color: var(--green);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0;
}

.linkish:hover {
  color: var(--green-dk);
  text-decoration: underline;
}

.charts {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 0.85rem 0.85rem;
}

.chart {
  background: var(--fog-050);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0.85rem;
  margin-bottom: 0.55rem;
}

.chart.hidden { opacity: 0.5; }

.chart-top {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.swatches { display: flex; gap: 4px; padding-top: 3px; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  box-shadow: 0 0 0 1px rgba(6, 16, 24, 0.12);
}

.chart-name {
  flex: 1;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  word-break: break-word;
}

.chart-stats {
  margin: 0.4rem 0 0;
  color: var(--ink-400);
  font-size: 0.72rem;
  font-family: var(--font-mono);
}

.z-ramp {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.45rem 0 0.1rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-400);
}

.z-ramp__bar,
.depth-legend__bar {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    #000080 0%,
    #0000ff 14%,
    #0080ff 28%,
    #00ffff 42%,
    #00ff00 57%,
    #ffff00 71%,
    #ff8000 85%,
    #ff0000 100%
  );
  box-shadow: 0 0 0 1px rgba(6, 16, 24, 0.12);
}

.chart-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.chart-actions button {
  flex: 1;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--ink-900);
  background: transparent;
  color: var(--ink-900);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chart-actions button:hover {
  background: rgba(6, 16, 24, 0.06);
}

.chart-actions .danger:hover {
  border-color: var(--alert);
  color: var(--alert);
  background: rgba(224, 79, 79, 0.06);
}

.empty {
  color: var(--ink-400);
  font-size: 0.875rem;
  padding: 1.5rem 0.5rem;
  text-align: center;
}

.controls {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1.25rem 0.55rem;
  background: var(--fog-050);
}

.ctrl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.65rem;
  font-size: 0.75rem;
  color: var(--ink-400);
}

.ctrl--stack {
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.ctrl[hidden] { display: none; }

.ctrl input[type="range"] { width: 140px; accent-color: var(--green); }

.ctrl select,
.ctrl input[type="text"] {
  width: 100%;
  height: 34px;
  padding: 0 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--fog-050);
  color: var(--ink-900);
  font-family: inherit;
  font-size: 0.75rem;
}

.ctrl input[type="text"] {
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.ctrl select:focus,
.ctrl input[type="text"]:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 122, 62, 0.18);
}

.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--ink-400);
}

.check input { accent-color: var(--green); }

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem 1rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.45;
  background: var(--ink-900);
  color: #8fa4b5;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex: none;
}

main {
  position: relative;
  min-width: 0;
}

#map { height: 100%; background: var(--ink-900); }

.coords {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 400;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0.55rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--ink-700);
  pointer-events: none;
}

.coords-crs {
  color: var(--ink-400);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.depth-legend {
  position: absolute;
  left: 12px;
  bottom: 72px;
  z-index: 400;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0.5rem 0.7rem 0.55rem;
  min-width: 220px;
  pointer-events: none;
}

.depth-legend[hidden] {
  display: none;
}

.depth-legend__title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-400);
  margin-bottom: 0.35rem;
}

.depth-legend__scale {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-700);
}

.leaflet-image-layer.matrix-overlay {
  image-rendering: auto !important;
  image-rendering: bicubic !important;
}

.toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  background: #fff5f5;
  color: #8a2424;
  border: 1px solid #f0c4c4;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  display: none;
  max-width: min(520px, 90%);
  box-shadow: var(--shadow-md);
}

.toast.show { display: block; }

.loading {
  position: absolute;
  inset: 0;
  z-index: 450;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 16, 24, 0.28);
  color: #fff;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.loading.show { display: flex; }

.sidebar-toggle {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1200;
  height: 36px;
  padding: 0 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink-700);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.leaflet-control-layers {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-lg) !important;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96) !important;
  color: var(--ink-900);
  box-shadow: var(--shadow-sm) !important;
}

.leaflet-control-layers label { color: var(--ink-900); }

.leaflet-bar {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm) !important;
}

.leaflet-bar a {
  background: #fff !important;
  color: var(--ink-900) !important;
  border-bottom-color: var(--line) !important;
}

.leaflet-bar a:hover { background: var(--green-lt) !important; color: var(--green-dk) !important; }

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.88) !important;
  color: var(--ink-400);
}

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .topbar__tag { display: none; }
  .brand img { height: 32px; }
  .topbar { padding: 0.65rem 0.85rem; }
  aside {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(340px, 92vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  aside.open { transform: none; }
  .sidebar-toggle { display: block; }
  .leaflet-top.leaflet-left { top: 56px; }
}

@media (max-width: 480px) {
  aside { width: 100%; border-right: 0; }
  .product-nav__item { padding-left: 0.5rem; padding-right: 0.5rem; }
}
