/* ==========================================================================
   Cargo Agency Info CENTER — VSH-Tech huisstijl
   Teal #008675 primary, Barlow Condensed headings, left teal accents,
   near-square corners, light + dark theme.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700&family=Barlow:wght@400;500;600&display=swap');

:root {
  --vsh-teal:       #008675;
  --vsh-teal-hover: #006a5c;
  --vsh-teal-light: #e6f4f1;
  --vsh-grey:       #9A9A9A;
  --vsh-dark:       #1A1A1A;
  --vsh-light:      #F4F4F4;
  --vsh-white:      #FFFFFF;
  --font-heading:   'Barlow Condensed', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-body:      'Barlow', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  /* semantic tokens (light) */
  --bg:        var(--vsh-light);
  --surface:   var(--vsh-white);
  --surface-2: #fafafa;
  --text:      var(--vsh-dark);
  --text-soft: #5a5a5a;
  --border:    #e0e0e0;
  --sidebar-bg: var(--vsh-dark);
  --sidebar-text: #d6d6d6;
  --sidebar-muted: #8f8f8f;
  --topbar-bg: var(--vsh-white);
  --danger:    #c0392b;
  --success:   #1a7f4e;
}

html.dark {
  --bg:        #121212;
  --surface:   #1e1e1e;
  --surface-2: #262626;
  --text:      #ececec;
  --text-soft: #a8a8a8;
  --border:    #333333;
  --sidebar-bg: #0d0d0d;
  --sidebar-text: #d6d6d6;
  --sidebar-muted: #7d7d7d;
  --topbar-bg: #1e1e1e;
  /* --danger/--success are brightened in dark mode — the light-mode hex values sit at ~2.8:1
     and ~3.1:1 contrast against the dark surface, below WCAG AA's 4.5:1 for normal text. */
  --danger:    #ff6b6b;
  --success:   #4ade80;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4, .heading {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  margin: 0;
}

a, .btn-link { color: var(--vsh-teal); text-decoration: none; }
a:hover { color: var(--vsh-teal-hover); }

/* ---- App shell ----------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 20px;
  border-bottom: 3px solid var(--vsh-teal);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand img { width: 42px; height: 42px; display: block; background: #fff; padding: 2px; border-radius: 2px; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand .brand-name {
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: #fff;
}
.sidebar-brand .brand-sub { font-size: 11px; color: var(--sidebar-muted); }

.nav-section {
  padding: 14px 20px 6px;
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--sidebar-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  border-left: 3px solid transparent;
  font-size: 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active {
  background: rgba(0,134,117,.16);
  border-left-color: var(--vsh-teal);
  color: #fff;
}
.nav-item .nav-icon { width: 18px; height: 18px; flex: 0 0 18px; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  font-size: 11px;
  color: var(--sidebar-muted);
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ---- Main column --------------------------------------------------------- */
.main-col { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  min-height: 60px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .page-title { font-family: var(--font-heading); text-transform: uppercase; font-size: 20px; letter-spacing: .04em; }
.topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Hamburger toggle for the off-canvas sidebar — hidden on desktop, shown at the mobile breakpoint. */
.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: 2px;
  color: var(--text); font-size: 18px; line-height: 1; cursor: pointer;
  padding: 6px 10px; flex: 0 0 auto;
}

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 45;
}

.content { padding: 24px; flex: 1 1 auto; }
.page-lead { color: var(--text-soft); margin: 0 0 20px; max-width: 70ch; }

/* ---- Controls ------------------------------------------------------------ */
.ctl {
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 6px 10px;
}
.ctl:focus { outline: none; border-color: var(--vsh-teal); box-shadow: 0 0 0 2px var(--vsh-teal-light); }

.ctl-label { font-family: var(--font-heading); text-transform: uppercase; font-size: 11px; letter-spacing: .08em; color: var(--text-soft); margin-right: 6px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 2px; overflow: hidden; }
.seg button {
  background: var(--surface); color: var(--text-soft); border: none;
  padding: 6px 10px; font-size: 12px; cursor: pointer; font-family: var(--font-heading);
  text-transform: uppercase; letter-spacing: .05em;
}
.seg button.active { background: var(--vsh-teal); color: #fff; }

.btn-primary {
  background: var(--vsh-teal); color: #fff; border: none;
  font-family: var(--font-heading); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 8px 18px; border-radius: 2px; cursor: pointer;
}
.btn-primary:hover { background: var(--vsh-teal-hover); }

.btn-secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-family: var(--font-heading); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 8px 18px; border-radius: 2px; cursor: pointer;
}
.btn-secondary:hover { background: var(--surface-2); }

.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--vsh-teal); color: #fff;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-heading); font-weight: 700; font-size: 13px;
}

/* ---- Cards / KPIs -------------------------------------------------------- */
.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--surface);
  border-left: 4px solid var(--vsh-teal);
  border-radius: 2px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.card h3 { font-size: 15px; color: var(--text); margin-bottom: 12px; }

.kpi .kpi-label { font-family: var(--font-heading); text-transform: uppercase; font-size: 12px; letter-spacing: .06em; color: var(--text-soft); }
.kpi .kpi-value { font-family: var(--font-heading); font-weight: 700; font-size: 34px; color: var(--vsh-teal); line-height: 1.1; margin-top: 4px; }
.kpi .kpi-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.kpi.warn .kpi-value { color: var(--danger); }
.kpi { transition: box-shadow .15s, border-left-width .15s; }
.kpi:hover { box-shadow: 0 2px 8px rgba(0,0,0,.14); }

/* ---- Performance monitor -------------------------------------------------- */
.perf-metrics-row {
  display: flex;
  gap: 22px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.perf-metric { display: flex; flex-direction: column; }
.perf-metric-n { font-family: var(--font-heading); font-weight: 700; font-size: 20px; color: var(--text); }
.perf-metric-l { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.perf-rec {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 3px;
  background: var(--surface-2);
  border-left: 3px solid var(--text-soft);
}
.perf-rec-warn { border-left-color: var(--danger); background: #fdecea; color: #c0392b; }
.perf-rec-active { border-left-color: #97650f; background: #fdf3de; color: #97650f; }
:root.dark .perf-rec-warn { background: rgba(255,107,107,.12); color: #ff8a8a; }
:root.dark .perf-rec-active { background: rgba(214,158,46,.12); color: #e0b256; }
.kpi.kpi-active { border-left-width: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.14); }

/* ---- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl thead th {
  background: var(--vsh-teal); color: #fff; text-align: left;
  font-family: var(--font-heading); text-transform: uppercase; font-size: 12px; letter-spacing: .05em;
  padding: 9px 12px; white-space: nowrap;
}
.tbl tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.tbl tbody tr:nth-child(even) { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
.pager-info { font-size: 12px; color: var(--text-soft); }
.pager-nav { display: flex; align-items: center; gap: 6px; }
.pager-nav .ctl { padding: 4px 10px; cursor: pointer; line-height: 1; }
.pager-nav .ctl:disabled { opacity: .4; cursor: default; }
.pager-page { font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; padding: 0 4px; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 2px; font-size: 11px; font-family: var(--font-heading); text-transform: uppercase; letter-spacing: .04em; }
.badge.ok { background: var(--vsh-teal-light); color: var(--vsh-teal-hover); }
.badge.warn, .badge.cancelled { background: #fdecea; color: #c0392b; }
.badge.info { background: #eef2f4; color: #4a5b63; }
.badge.active { background: #fdf3de; color: #97650f; }
.badge.planned { background: #e8f1fc; color: #2f6fb0; }
.badge.registered { background: #f1ebfb; color: #6c3fb5; }
.badge.flow-import { background: #e6f4f1; color: var(--vsh-teal-hover); }
.badge.flow-export { background: #fdf1e6; color: #b5651d; }

.demo-banner {
  background: #fff7e6; border-left: 4px solid #e0a800; color: #7a5c00;
  padding: 10px 16px; border-radius: 2px; font-size: 13px; margin-bottom: 18px;
}
html.dark .demo-banner { background: #2b2405; color: #e6c65c; }

/* ---- Bars (simple inline chart) ----------------------------------------- */
.bar-row { display: grid; grid-template-columns: 130px 1fr 46px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; color: var(--text); }
.bar-track { background: var(--surface-2); border: 1px solid var(--border); border-radius: 2px; height: 18px; overflow: hidden; }
.bar-fill { background: var(--vsh-teal); height: 100%; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-soft); }

/* ---- Score card ---------------------------------------------------------- */
.score-hero { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.score-circle {
  width: 120px; height: 120px; border-radius: 50%;
  background: conic-gradient(var(--vsh-teal) calc(var(--pct) * 1%), var(--surface-2) 0);
  display: flex; align-items: center; justify-content: center; flex: 0 0 120px;
}
.score-circle .inner {
  width: 92px; height: 92px; border-radius: 50%; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-circle .inner .val { font-family: var(--font-heading); font-weight: 700; font-size: 34px; color: var(--vsh-teal); }
.score-circle .inner .lbl { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .06em; }
.grade-pill { font-family: var(--font-heading); font-weight: 700; font-size: 22px; color: #fff; background: var(--vsh-teal); border-radius: 2px; padding: 4px 14px; }

/* ---- Arrivals board (vessel schedule) ----------------------------------- */
.board {
  background: #0d1117;
  border-radius: 4px;
  border-top: 4px solid var(--vsh-teal);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  min-width: 1260px;
}
.board-head {
  display: grid;
  grid-template-columns: 96px 1.3fr 84px 1.3fr 120px 88px 120px 120px 116px 44px;
  gap: 14px;
  background: #010409;
  color: #7d8590;
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid #21262d;
}
.board-row {
  display: grid;
  grid-template-columns: 96px 1.3fr 84px 1.3fr 120px 88px 120px 120px 116px 44px;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #161b22;
  color: #e6edf3;
  font-size: 15px;
}
.board-row .marine-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--vsh-teal);
  text-decoration: none;
  font-size: 16px;
  border: 1px solid #21262d;
  background: none;
  cursor: pointer;
}
.board-row .marine-link:hover { background: #161b22; color: #fff; }
.board-row-expanded {
  background: #010409;
  border-bottom: 1px solid #161b22;
  padding: 10px 18px 16px;
}
.live-map-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #7d8590;
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  margin-bottom: 8px;
}
.live-map-frame {
  width: 100%;
  height: 400px;
  border: 1px solid #21262d;
  border-radius: 4px;
}
.board-head > div, .board-row > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.board-row:hover { background: #161b22; }
.board-row .clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-row .eta-date { font-family: var(--font-heading); font-weight: 700; font-size: 15px; color: #fff; letter-spacing: .02em; }
.board-row .eta-time { font-family: var(--font-heading); font-weight: 700; font-size: 20px; color: var(--vsh-teal); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.board-row .vessel { font-family: var(--font-heading); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 17px; color: #fff; }
.board-row .sub { color: #8b949e; font-size: 12px; }
.board-row .mono { font-variant-numeric: tabular-nums; letter-spacing: .03em; }

.board-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-heading); text-transform: uppercase; letter-spacing: .06em;
  font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 2px;
}
.board-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.board-status.ok        { color: #3fb950; background: rgba(63,185,80,.12); }
.board-status.ok .dot        { background: #3fb950; }
.board-status.active    { color: #d29922; background: rgba(210,153,34,.14); }
.board-status.active .dot    { background: #d29922; animation: blink 1.2s steps(2,start) infinite; }
.board-status.planned   { color: #58a6ff; background: rgba(88,166,255,.12); }
.board-status.planned .dot   { background: #58a6ff; }
.board-status.registered { color: #a371f7; background: rgba(163,113,247,.14); }
.board-status.registered .dot { background: #a371f7; }
.board-status.cancelled { color: #f85149; background: rgba(248,81,73,.14); }
.board-status.cancelled .dot { background: #f85149; }
@keyframes blink { 50% { opacity: .25; } }

.board-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; color: var(--text-soft); }
.board-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.board-legend .dot { width: 9px; height: 9px; border-radius: 50%; }

.edi-phase-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 8px 0 14px; font-size: 12px; color: var(--text-soft); }
.edi-phase-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.edi-phase-legend-dot { width: 18px; height: 18px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }

.item-status-badge { display: inline-flex; align-items: center; gap: 5px; }
.item-status-icon { display: inline-flex; }
.item-status-icon svg { width: 13px; height: 13px; }

.status-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 8px 0 14px; font-size: 12px; color: var(--text-soft); }
.status-legend-item { display: inline-flex; align-items: center; gap: 6px; }

.journey { position: relative; padding: 4px 0; }
.journey-row { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 0 0 18px 34px; }
.journey-row:last-child { padding-bottom: 0; }
.journey-row::before {
  content: ''; position: absolute; left: 11px; top: 22px; bottom: -18px; width: 2px;
  background: var(--vsh-teal-light);
}
.journey-row.dotted::before { background: none; border-left: 2px dotted var(--text-soft); left: 11px; width: 0; }
.journey-row:last-child::before { display: none; }
.journey-icon {
  position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--vsh-teal-light); color: var(--vsh-teal-hover);
}
.journey-icon svg { width: 13px; height: 13px; }
.journey-row.port .journey-icon { background: var(--vsh-teal); color: #fff; }
.journey-row.transit .journey-icon { background: var(--surface-2); color: var(--text-soft); }
.journey-row.origin .journey-icon, .journey-row.dest .journey-icon { background: var(--surface-2); color: var(--vsh-teal-hover); }
.journey-body { flex: 1; min-width: 0; }
.journey-title { font-size: 13px; font-weight: 600; }
.journey-row.port .journey-title, .journey-row.origin .journey-title, .journey-row.dest .journey-title {
  font-family: var(--font-heading); font-size: 14px; text-transform: uppercase; letter-spacing: .02em;
}
.journey-row.event .journey-title { font-weight: 400; color: var(--text-soft); }
.journey-row.transit .journey-title { color: var(--text-soft); font-style: italic; }
.journey-subtitle { font-size: 11px; color: var(--text-soft); margin-top: 1px; }
.journey-date { flex-shrink: 0; font-size: 12px; color: var(--text-soft); white-space: nowrap; padding-top: 1px; }

.error-ui { position: fixed; bottom: 0; left: 0; right: 0; background: #c0392b; color: #fff; padding: 10px 16px; z-index: 1000; }
.error-ui .dismiss { position: absolute; right: 16px; top: 8px; cursor: pointer; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200;
  display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto;
}
.modal-panel {
  background: var(--surface); border-radius: 8px; width: 100%; max-width: 1200px;
  max-height: calc(100vh - 60px); display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-close {
  background: none; border: none; font-size: 18px; line-height: 1; cursor: pointer;
  color: var(--text-soft); padding: 4px 8px; flex-shrink: 0;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }

@media (max-width: 820px) {
  .modal-overlay { padding: 0; }
  .modal-panel { max-width: 100%; max-height: 100vh; border-radius: 0; }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed; z-index: 50; top: 0; left: 0;
    width: 82vw; max-width: 300px; flex: 0 0 auto;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 2px 0 12px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .main-col { width: 100%; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 10px 14px; }
  .topbar .page-title { font-size: 16px; }
  .content { padding: 14px; }
  .topbar-actions .ctl-label { display: none; }
  .user-chip span:not(.avatar) { display: none; }
}
