/* =======================================================================
   CemOps Design System v2
   Flat · Minimal · Semantic color · Information-first
   ======================================================================= */

/* ── 1. Variables & Reset ───────────────────────────────────────────── */

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

:root {
  /* Semantic palette — color encodes meaning only */
  --c-critical:    #dc2626;
  --c-critical-bg: #fef2f2;
  --c-critical-bd: #fecaca;

  --c-warn:        #d97706;
  --c-warn-bg:     #fffbeb;
  --c-warn-bd:     #fde68a;

  --c-ok:          #16a34a;
  --c-ok-bg:       #f0fdf4;
  --c-ok-bd:       #bbf7d0;

  --c-neutral:     #2563eb;
  --c-neutral-bg:  #eff6ff;
  --c-neutral-bd:  #bfdbfe;

  /* UI grays */
  --bg:          #f6f7f9;
  --bg-white:    #ffffff;
  --border:      #e4e7ec;
  --border-2:    #d0d5dd;

  /* Text */
  --text:        #101828;
  --text-2:      #475569;
  --text-3:      #94a3b8;

  /* Sidebar */
  --sidebar-w:   48px;
  --sidebar-bg:  #0f172a;

  /* Header */
  --header-h:    52px;

  /* Radii */
  --r:  4px;
  --r2: 6px;

  /* Fonts */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', Consolas, monospace;

  /* Backward-compat aliases for pages not yet revamped */
  --navy:        #0f172a;
  --navy-mid:    #1e3a5f;
  --navy-light:  #243f68;
  --blue:        var(--c-neutral);
  --blue-hover:  #1d4ed8;
  --blue-light:  var(--c-neutral-bg);
  --accent:      #f59e0b;
  --success:     var(--c-ok);
  --danger:      var(--c-critical);
  --warning:     var(--c-warn);
  --text-muted:  var(--text-2);
  --white:       var(--bg-white);
  --radius:      var(--r2);
  --shadow-sm:   none;
  --shadow:      none;
  --shadow-lg:   none;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body { background: var(--bg); line-height: 1.5; }

a { color: var(--c-neutral); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 2. App Shell ───────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── 3. Sidebar ─────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 100;
}

/* Brand: show only the hex icon, hide text */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  padding: 0;
}
.sidebar-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: #f59e0b;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon svg { width: 15px; height: 15px; fill: var(--sidebar-bg); }
.sidebar-brand-text { display: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

/* Section labels: hidden in 48px mode */
.sidebar-section-label { display: none; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--sidebar-w);
  height: 44px;
  color: rgba(255,255,255,.45);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color .12s, background .12s, border-color .12s;
  font-size: 0; /* hide text labels */
  position: relative;
}
.sidebar-nav a:hover {
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.06);
  text-decoration: none;
}
.sidebar-nav a.active {
  color: #fff;
  background: rgba(37,99,235,.2);
  border-left-color: var(--c-neutral);
}
.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Footer: just avatar + logout */
.sidebar-footer {
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.sidebar-user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user-info { display: none; }
.sidebar-user-name { display: none; }
.sidebar-user-role { display: none; }

.btn-logout {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: rgba(255,255,255,.3);
  border-radius: var(--r);
  transition: color .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-logout:hover { color: rgba(255,255,255,.75); }
.btn-logout svg { width: 14px; height: 14px; display: block; }

/* ── 4. Main area ───────────────────────────────────────────────────── */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--header-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ── 5. Buttons ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .1s, color .1s, border-color .1s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--text);
  color: var(--bg-white);
  border-color: var(--text);
}
.btn-primary:hover:not(:disabled) { background: #1e293b; border-color: #1e293b; }

.btn-secondary {
  background: var(--bg-white);
  color: var(--text);
  border-color: var(--border-2);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--border-2); }

.btn-danger { background: var(--c-critical); color: #fff; border-color: var(--c-critical); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── 6. Form elements ───────────────────────────────────────────────── */

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-white);
  transition: border-color .1s, box-shadow .1s;
  outline: none;
  line-height: 1.4;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--c-neutral);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-group input::placeholder { color: var(--text-3); }
.form-group textarea { resize: vertical; min-height: 72px; }

.form-section { margin-bottom: 20px; }
.form-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid .form-group { margin-bottom: 0; }
.form-grid .span-2 { grid-column: span 2; }

.form-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.form-check input[type="checkbox"] { width: 14px; height: 14px; cursor: pointer; }

.error-message {
  background: var(--c-critical-bg);
  color: var(--c-critical);
  border: 1px solid var(--c-critical-bd);
  border-radius: var(--r);
  padding: 9px 12px;
  font-size: 12px;
  margin-bottom: 10px;
}
.success-message {
  background: var(--c-ok-bg);
  color: var(--c-ok);
  border: 1px solid var(--c-ok-bd);
  border-radius: var(--r);
  padding: 9px 12px;
  font-size: 12px;
}

/* ── 7. Chips / Badges ──────────────────────────────────────────────── */

/* New chip system */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.6;
}

.chip-critical { background: var(--c-critical-bg); color: var(--c-critical); }
.chip-high     { background: #fff7ed;               color: #c2410c; }
.chip-medium   { background: var(--c-warn-bg);      color: var(--c-warn); }
.chip-low      { background: #f1f5f9;               color: var(--text-2); }

.chip-open     { background: var(--c-neutral-bg);   color: var(--c-neutral); }
.chip-partial  { background: var(--c-warn-bg);      color: var(--c-warn); }
.chip-shipped  { background: var(--c-ok-bg);        color: var(--c-ok); }
.chip-closed   { background: #f1f5f9;               color: var(--text-2); }
.chip-disputed { background: var(--c-critical-bg);  color: var(--c-critical); }
.chip-draft    { background: #f1f5f9;               color: var(--text-3); }
.chip-released { background: var(--c-ok-bg);        color: var(--c-ok); }
.chip-pending  { background: #f1f5f9;               color: var(--text-2); }
.chip-active   { background: var(--c-neutral-bg);   color: var(--c-neutral); }
.chip-done     { background: var(--c-ok-bg);        color: var(--c-ok); }
.chip-cancelled{ background: #f1f5f9;               color: var(--text-3); }
.chip-expected { background: #f1f5f9;               color: var(--text-2); }
.chip-received { background: var(--c-ok-bg);        color: var(--c-ok); }
.chip-rejected { background: var(--c-critical-bg);  color: var(--c-critical); }

/* Voyage stage chips */
.chip-stage-1  { background: #f1f5f9;               color: var(--text-2); }   /* nominated */
.chip-stage-2  { background: var(--c-neutral-bg);   color: var(--c-neutral); }/* fixed */
.chip-stage-3  { background: #fff7ed;               color: #c2410c; }          /* loading */
.chip-stage-4  { background: #fefce8;               color: #a16207; }          /* laden */
.chip-stage-5  { background: #fff7ed;               color: #c2410c; }          /* discharging */
.chip-stage-6  { background: var(--c-ok-bg);        color: var(--c-ok); }     /* completed */

/* Backward-compat badge classes — same visual effect, different name */
.badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 3px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-open       { background: var(--c-neutral-bg);  color: var(--c-neutral); }
.badge-released   { background: var(--c-ok-bg);       color: var(--c-ok); }
.badge-shipped    { background: var(--c-warn-bg);      color: var(--c-warn); }
.badge-closed     { background: #f1f5f9;              color: var(--text-2); }
.badge-disputed   { background: var(--c-critical-bg); color: var(--c-critical); }
.badge-critical   { background: var(--c-critical-bg); color: var(--c-critical); }
.badge-high       { background: #fff7ed;              color: #c2410c; }
.badge-medium     { background: var(--c-warn-bg);     color: var(--c-warn); }
.badge-low        { background: #f1f5f9;              color: var(--text-2); }

/* ── 8. KPI Strip Cards ─────────────────────────────────────────────── */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  margin-bottom: 20px;
}

.kpi {
  background: var(--bg-white);
  padding: 14px 16px;
  position: relative;
}

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-3);
}

/* Top border accent */
.kpi--alert { border-top: 3px solid var(--c-critical); }
.kpi--warn  { border-top: 3px solid var(--c-warn); }
.kpi--ok    { border-top: 3px solid var(--c-ok); }
.kpi--neutral { border-top: 3px solid var(--c-neutral); }
.kpi--plain { border-top: 3px solid var(--border); }

.kpi--alert .kpi-value { color: var(--c-critical); }
.kpi--warn  .kpi-value { color: var(--c-warn); }

/* Backward compat */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 14px 16px;
  border-top: 3px solid var(--border);
}
.stat-card.danger  { border-top-color: var(--c-critical); }
.stat-card.warning { border-top-color: var(--c-warn); }
.stat-card.success { border-top-color: var(--c-ok); }
.stat-card.info    { border-top-color: var(--c-neutral); }
.stat-label { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ── 9. Tables ──────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--bg-white);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
}

.table-fixed { table-layout: fixed; }

thead th {
  background: #fafbfc;
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text-2); }

tbody td {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
tbody tr[style*="cursor:pointer"]:hover td { background: var(--bg); }

.tr-overdue td { background: var(--c-critical-bg) !important; }
.tr-warn    td { background: var(--c-warn-bg) !important; }

/* Deficit/surplus table rows */
.deficit-row td { background: var(--c-critical-bg) !important; }
.surplus-row td { background: var(--c-ok-bg) !important; }

/* ── 10. Progress Bars ──────────────────────────────────────────────── */

.progress {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}
.progress-fill--ok       { background: var(--c-ok); }
.progress-fill--warn     { background: var(--c-warn); }
.progress-fill--critical { background: var(--c-critical); }
.progress-fill--neutral  { background: var(--c-neutral); }
.progress-fill--gray     { background: var(--border-2); }

/* Voyage stage progress bar */
.voyage-bar {
  display: flex;
  align-items: center;
  gap: 2px;
}
.voyage-seg {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  transition: background .2s;
}
.voyage-seg.v-done   { background: var(--c-ok); }
.voyage-seg.v-active { background: var(--c-neutral); }

/* ── 11. Cargo Cards ────────────────────────────────────────────────── */

.cargo-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.cargo-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--r2);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: border-color .1s;
}
.cargo-card:hover { border-color: var(--border-2); border-left-color: inherit; }

.cargo-card--overdue { border-left-color: var(--c-critical); }
.cargo-card--warning { border-left-color: var(--c-warn); }
.cargo-card--ok      { border-left-color: var(--c-ok); }
.cargo-card--neutral { border-left-color: var(--c-neutral); }
.cargo-card--done    { border-left-color: var(--border); opacity: .7; }

.cargo-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.cargo-card-vessel {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.cargo-card-ref {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
  margin-top: 2px;
}
.cargo-card-meta {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cargo-card-sep { color: var(--border-2); }
.cargo-card-eta {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
}
.cargo-card-eta.overdue { color: var(--c-critical); }
.cargo-card-eta.soon    { color: var(--c-warn); }
.cargo-card-eta.ok      { color: var(--text-2); }

/* ── 12. Pipeline / Kanban ──────────────────────────────────────────── */

.pipeline {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: flex-start;
}
.pipeline::-webkit-scrollbar { height: 4px; }
.pipeline::-webkit-scrollbar-track { background: var(--border); border-radius: 2px; }
.pipeline::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.pipeline-col {
  flex-shrink: 0;
  width: 240px;
}
.pipeline-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 8px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.pipeline-col-header.stage-1 { border-bottom-color: #cbd5e1; }
.pipeline-col-header.stage-2 { border-bottom-color: var(--c-neutral); }
.pipeline-col-header.stage-3 { border-bottom-color: #f97316; }
.pipeline-col-header.stage-4 { border-bottom-color: #eab308; }
.pipeline-col-header.stage-5 { border-bottom-color: #f97316; }
.pipeline-col-header.stage-6 { border-bottom-color: var(--c-ok); }
.pipeline-col-title { font-size: 12px; font-weight: 600; color: var(--text-2); }
.pipeline-col-count { font-size: 11px; color: var(--text-3); background: var(--bg); padding: 1px 6px; border-radius: 10px; }

.pipeline-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--r);
  padding: 10px 10px 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .1s;
  font-size: 12px;
}
.pipeline-card:hover { border-color: var(--border-2); }
.pipeline-card--overdue { border-left-color: var(--c-critical); }
.pipeline-card--warn    { border-left-color: var(--c-warn); }
.pipeline-card--ok      { border-left-color: var(--c-ok); }
.pipeline-card-vessel   { font-weight: 600; color: var(--text); font-size: 12px; }
.pipeline-card-trade    { color: var(--text-3); font-family: var(--mono); font-size: 11px; margin-top: 1px; }
.pipeline-card-route    { color: var(--text-2); margin-top: 4px; font-size: 11px; }
.pipeline-card-eta      { margin-top: 5px; display: flex; align-items: center; justify-content: space-between; }
.pipeline-card-flag     { margin-top: 4px; font-size: 11px; color: var(--c-critical); display: flex; align-items: center; gap: 3px; }

/* ── 13. Cards ──────────────────────────────────────────────────────── */

.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 16px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Two-column dashboard grid */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-grid .card { margin-bottom: 0; }

/* ── 14. Slide-over Panel ───────────────────────────────────────────── */

.slideover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 200;
  display: none;
}
.slideover-overlay.open { display: block; }

.slideover {
  position: fixed;
  top: 0;
  right: 0;
  width: 500px;
  max-width: 100vw;
  height: 100%;
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.slideover.open { transform: translateX(0); }

.slideover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.slideover-title { font-size: 14px; font-weight: 600; color: var(--text); }
.slideover-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--r);
}
.slideover-close:hover { background: var(--bg); color: var(--text); }

.slideover-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.slideover-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: #fafbfc;
}
.slideover-footer .spacer { flex: 1; }

/* ── 15. List Toolbar ───────────────────────────────────────────────── */

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.list-search {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  padding: 7px 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  font-size: 13px;
  font-family: var(--font);
  background: var(--bg-white);
  outline: none;
  color: var(--text);
}
.list-search:focus { border-color: var(--c-neutral); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.list-filter {
  padding: 7px 9px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  font-size: 13px;
  font-family: var(--font);
  background: var(--bg-white);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.list-filter:focus { border-color: var(--c-neutral); }

/* ── 16. Empty States ───────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  color: var(--text-3);
  text-align: center;
}
.empty-state svg { width: 32px; height: 32px; margin-bottom: 10px; opacity: .3; }
.empty-state p { font-size: 13px; max-width: 260px; line-height: 1.6; }
.empty-state strong { color: var(--text-2); }

/* Inline empty — used in table cells */
.empty-inline { padding: 32px 12px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ── 17. Toast Notifications ────────────────────────────────────────── */

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r);
  background: var(--text);
  color: var(--bg-white);
  font-size: 13px;
  font-family: var(--font);
  max-width: 320px;
  pointer-events: auto;
  animation: toast-in .16s ease;
}
.toast.success { background: var(--c-ok); }
.toast.error   { background: var(--c-critical); }
.toast.warning { background: var(--c-warn); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(4px); }
}

/* ── 18. Notification Bell ──────────────────────────────────────────── */

.notif-bell { position: relative; display: inline-flex; align-items: center; }
.notif-bell-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 7px;
  border-radius: var(--r);
  color: var(--text-2);
  display: flex;
  align-items: center;
  transition: background .1s;
}
.notif-bell-btn:hover { background: var(--bg); }
.notif-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  background: var(--c-critical);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 300px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  z-index: 300;
}
.notif-item { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--c-neutral-bg); }
.notif-msg { font-size: 12px; color: var(--text); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.notif-loading, .notif-empty { padding: 16px; text-align: center; font-size: 12px; color: var(--text-3); }
.notif-footer { padding: 7px 12px; text-align: center; font-size: 12px; border-top: 1px solid var(--border); background: #fafbfc; }

/* ── 19. Release Banner ─────────────────────────────────────────────── */

.release-banner {
  background: var(--c-warn-bg);
  border: 1px solid var(--c-warn-bd);
  border-radius: var(--r);
  padding: 9px 12px;
  font-size: 12px;
  color: #78350f;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.release-banner svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── 20. Deficit/Surplus Indicators ────────────────────────────────── */

.deficit-badge {
  background: var(--c-critical-bg);
  color: var(--c-critical);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}
.surplus-badge {
  background: var(--c-ok-bg);
  color: var(--c-ok);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── 21. Commodity Summary Cards ────────────────────────────────────── */

.commodity-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.com-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 14px;
  border-top: 3px solid var(--border);
}
.com-card--deficit { border-top-color: var(--c-critical); }
.com-card--surplus { border-top-color: var(--c-ok); }
.com-card--warn    { border-top-color: var(--c-warn); }

.com-card-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.com-card-code { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.com-card-row  { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.com-card-label { font-size: 11px; color: var(--text-3); }
.com-card-value { font-size: 13px; font-weight: 600; color: var(--text); }
.com-card-value.deficit { color: var(--c-critical); }
.com-card-value.surplus { color: var(--c-ok); }
.com-card-bar { margin-top: 8px; }

/* ── 22. Trade Action Flags ─────────────────────────────────────────── */

.flag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 1px 5px; border-radius: 2px; }
.flag-issue  { background: var(--c-critical-bg); color: var(--c-critical); }
.flag-doc    { background: var(--c-warn-bg);     color: var(--c-warn); }
.flag-ok     { background: var(--c-ok-bg);       color: var(--c-ok); }
.flag-info   { background: var(--c-neutral-bg);  color: var(--c-neutral); }

/* ── 23. Margin / Financial Card ────────────────────────────────────── */

.margin-card {
  background: var(--text);
  border-radius: var(--r2);
  padding: 14px 16px;
  color: var(--bg-white);
}
.margin-card-row       { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.margin-card-label     { font-size: 11px; color: rgba(255,255,255,.5); }
.margin-card-value     { font-size: 13px; font-weight: 600; }
.margin-card-divider   { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 8px 0; }
.margin-card-total-label { font-size: 11px; color: rgba(255,255,255,.6); }
.margin-card-total-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.margin-card-total-value.positive { color: #4ade80; }
.margin-card-total-value.negative { color: #f87171; }
.margin-card-sub       { font-size: 11px; color: rgba(255,255,255,.35); margin-top: 2px; }

/* ── 24. Vessel Status Chip (dashboard compat) ──────────────────────── */

.vessel-status-chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  background: var(--c-neutral-bg);
  color: var(--c-neutral);
  white-space: nowrap;
}

/* ── 25. File Upload ────────────────────────────────────────────────── */

.file-upload-wrap { position: relative; }
.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px dashed var(--border-2);
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  background: var(--bg);
  transition: border-color .1s, color .1s;
  width: 100%;
  justify-content: center;
}
.file-upload-btn:hover { border-color: var(--c-neutral); color: var(--c-neutral); }
.file-upload-btn svg { width: 14px; height: 14px; }
.file-upload-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-current {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12px;
  color: var(--text);
  margin-top: 5px;
}
.file-current a { color: var(--c-neutral); word-break: break-all; }
.file-current-remove { margin-left: auto; background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 15px; padding: 0 2px; line-height: 1; flex-shrink: 0; }
.file-current-remove:hover { color: var(--c-critical); }

/* ── 26. Inline Status Dropdown (Issues) ───────────────────────────── */

.status-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 3px 22px 3px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  background-repeat: no-repeat;
  background-position: right 5px center;
  background-size: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
}
.status-select.open     { background-color: var(--c-neutral-bg); color: var(--c-neutral); border-color: var(--c-neutral-bd); }
.status-select.in_progress { background-color: var(--c-warn-bg); color: var(--c-warn); border-color: var(--c-warn-bd); }
.status-select.resolved { background-color: var(--c-ok-bg); color: var(--c-ok); border-color: var(--c-ok-bd); }
.status-select.closed   { background-color: #f1f5f9; color: var(--text-2); border-color: var(--border); }

/* ── 27. Login page ─────────────────────────────────────────────────── */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--sidebar-bg);
}
.login-container {
  width: 100%;
  max-width: 380px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.login-brand { text-align: center; color: var(--bg-white); }
.login-brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: #f59e0b;
  border-radius: 10px;
  margin-bottom: 10px;
}
.login-brand .brand-mark svg { width: 26px; height: 26px; fill: var(--sidebar-bg); }
.login-brand h1 { font-size: 24px; font-weight: 700; }
.login-brand p  { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 2px; }
.login-card {
  width: 100%;
  background: var(--bg-white);
  border-radius: var(--r2);
  padding: 24px 22px;
  border: 1px solid rgba(255,255,255,.08);
}
.login-card h2 { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.login-footer { font-size: 11px; color: rgba(255,255,255,.25); }

/* ── 28. Utility ────────────────────────────────────────────────────── */

.hidden   { display: none !important; }
.text-muted  { color: var(--text-2); }
.text-small  { font-size: 12px; }
.text-mono   { font-family: var(--mono); font-size: 12px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-bold   { font-weight: 600; }
.text-critical { color: var(--c-critical); }
.text-warn     { color: var(--c-warn); }
.text-ok       { color: var(--c-ok); }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.flex         { display: flex; }
.items-center { align-items: center; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.justify-between { justify-content: space-between; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--c-neutral);
  border-radius: 50%;
  animation: spin .55s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Loading state for page body */
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-3);
  gap: 10px;
  font-size: 13px;
}

/* Section header inside page */
.section-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  margin-top: 24px;
}
.section-hdr:first-child { margin-top: 0; }
.section-hdr h3 { font-size: 13px; font-weight: 600; color: var(--text); }
.section-hdr p  { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.section-hdr-left { display: flex; flex-direction: column; }

/* ── 29. Responsive ─────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .cargo-board { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .cargo-board { grid-template-columns: 1fr; }
  .slideover { width: 100vw; }
}

/* ── 30. Animations ─────────────────────────────────────────────────── */

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Module placeholder (pages not yet revamped) */
.module-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 320px; text-align: center; color: var(--text-3);
}
.module-placeholder .placeholder-icon {
  width: 52px; height: 52px; background: var(--c-neutral-bg); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.module-placeholder .placeholder-icon svg { width: 26px; height: 26px; color: var(--c-neutral); }
.module-placeholder h2 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.module-placeholder p { font-size: 13px; max-width: 320px; line-height: 1.6; }

/* Stock-specific */
.deficit-alert-banner {
  background: var(--c-critical-bg);
  border: 1px solid var(--c-critical-bd);
  border-radius: var(--r);
  padding: 10px 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: #991b1b;
}
.deficit-alert-banner svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.deficit-alert-banner-title { font-weight: 600; margin-bottom: 3px; }
.deficit-alert-item { font-size: 12px; margin-bottom: 1px; }

.proj-positive { color: var(--c-ok); font-weight: 600; }
.proj-negative { color: var(--c-critical); font-weight: 600; }
.proj-neutral  { color: var(--text-3); }

/* Topbar actions */
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
