:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-dark: #075985;
  --secondary: #475569;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #38bdf8;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 90px;
}

/* ============================================================ */
/* NAVBAR & TAB SWITCHER                                        */
/* ============================================================ */
/* Layout rules here exist for one reason: a flex row happily squeezes a
   button below its own text width, and every label then folds onto two lines.
   So the bar is nowrap, the brand block may truncate, and everything else
   keeps its natural width. */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;          /* without this the title can never shrink or ellipsis */
}

.nav-title { min-width: 0; }

.logo-bpcl,
.logo-iocl {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 1px;
  line-height: 1;
}

.logo-box {
  background: linear-gradient(135deg, #ea580c 0%, #0284c7 100%);
  color: white;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(234, 88, 12, 0.3);
}

.logo-sub {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
  white-space: nowrap;
}

.nav-title h1 {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-title p {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tab Navigation in Navbar */
.nav-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
  flex: 0 0 auto;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

/* Job count sits in its own pill instead of "Dashboard ( 2 )", whose spaces
   let the parenthesis break onto a second line. */
.tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  color: var(--text-secondary, #475569);
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  line-height: 1.5;
}
.tab-btn.active .tab-count { background: var(--primary-light); color: var(--primary-dark); }

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex: 0 0 auto;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-success {
  background: var(--success-light);
  color: #15803d;
}

.badge-warning {
  background: var(--warning-light);
  color: #b45309;
}

.badge-info {
  background: #ede9fe;
  color: #6d28d9;
}

/* Container */
.container {
  max-width: 1240px;
  margin: 20px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================ */
/* DASHBOARD STYLES (STATS, SEARCH & DATA TABLE)                */
/* ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.stat-icon-blue { background: #e0f2fe; color: #0284c7; }
.stat-icon-green { background: #dcfce7; color: #16a34a; }
.stat-icon-purple { background: #ede9fe; color: #7c3aed; }
.stat-icon-orange { background: #ffedd5; color: #ea580c; }

.stat-data {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
}

.dash-title-box h2 {
  font-size: 17px;
  font-weight: 700;
}

.dash-title-box p {
  font-size: 12px;
  color: var(--text-muted);
}

.dash-actions {
  display: flex;
  gap: 8px;
}

/* Filter & Search Bar */
.table-filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding-left: 36px !important;
}

.filter-group select {
  min-width: 180px;
}

/* Data Table */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
}

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

.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text-main);
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.job-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: inline-block;
}

.port-tag {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.fob-cell {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: #0369a1;
  text-align: right;
}

.tbl-action-btns {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.btn-icon.btn-icon-danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-icon.btn-icon-primary:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: #bae6fd;
}

.table-footer-info {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Edit Mode Banner */
.edit-banner {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #92400e;
}

.edit-banner-text {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================ */
/* FORM SECTION STYLES                                          */
/* ============================================================ */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.step-num {
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.section-title h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.section-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Port Grid */
.port-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.port-btn {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.port-btn:hover {
  border-color: var(--primary);
  background: #f0f9ff;
  transform: translateY(-2px);
}

.port-btn.active {
  border-color: var(--primary);
  background: #e0f2fe;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.port-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.port-codes {
  font-size: 11.5px;
  color: var(--primary-dark);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

.port-dest {
  font-size: 11px;
  color: var(--text-muted);
}

/* Grid Layouts */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 900px) {
  .grid-2-col {
    grid-template-columns: 1fr;
  }
}

/* Form Controls */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

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

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }

label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.req {
  color: var(--danger);
  font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="search"],
input[type="number"],
input[type="date"],
select {
  height: 38px;
  padding: 6px 12px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="date"] {
  cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: opacity(0.65);
}

input:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

input[readonly] {
  background-color: #f1f5f9;
  color: var(--text-muted);
  cursor: not-allowed;
}

.highlight-input {
  font-weight: 700;
  color: #0284c7 !important;
  font-family: 'JetBrains Mono', monospace;
  background-color: #f0f9ff !important;
  border-color: #bae6fd !important;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.divider {
  height: 1px;
  background: #f1f5f9;
  margin: 12px 0;
}

.info-pill-box {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.info-pill {
  font-size: 11.5px;
  display: flex;
  gap: 6px;
}

.pill-lbl { color: var(--text-muted); }
.pill-val { font-weight: 600; font-family: 'JetBrains Mono', monospace; }

/* Items Section */
.items-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.title-with-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.items-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.item-card {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 14px;
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

.item-badge-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.item-moowr-tag {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.moowr-yes {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.moowr-no {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.item-calc-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #f8fafc;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  font-size: 12px;
}

.calc-stat { display: flex; gap: 5px; }
.calc-lbl { color: var(--text-muted); }
.calc-val { font-weight: 700; font-family: 'JetBrains Mono', monospace; }

.doc-party-preview {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  margin-top: 8px;
}

.doc-party-col { display: flex; gap: 8px; }
.doc-lbl { color: var(--text-muted); width: 160px; }
.doc-val { font-weight: 600; }

/* Fixed Bottom Action Bar */
.action-bar-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
  z-index: 40;
  padding: 10px 24px;
}

.action-bar {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.action-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-fob-label { font-size: 12.5px; color: var(--text-muted); }
.action-fob-val {
  font-size: 19px;
  font-weight: 800;
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
}
.action-sep { color: #cbd5e1; }
.action-wt-val {
  font-size: 14px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.action-buttons { display: flex; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
  flex: 0 0 auto;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #f1f5f9; color: var(--secondary); border-color: #cbd5e1; }
.btn-secondary:hover { background: #e2e8f0; color: var(--text-main); }

.btn-outline { background: transparent; color: var(--secondary); border-color: var(--border); }
.btn-outline:hover { background: #f8fafc; color: var(--text-main); border-color: #cbd5e1; }

.btn-danger { background: var(--danger-light); color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 9px 20px; font-size: 14px; font-weight: 700; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 850px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;   /* top-align: a centred X looks like it collides
                                with a title that wraps to three lines */
  gap: 12px;
}

.modal-header > div:first-child { flex: 1 1 auto; min-width: 0; }

.modal-header h3 { font-size: 15.5px; font-weight: 700; }
.modal-header p { font-size: 11.5px; color: var(--text-muted); }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: #f1f5f9; color: var(--text-main); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

.file-preview-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  padding: 14px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
  max-height: 480px;
  user-select: all;
}

.settings-group { margin-bottom: 18px; }
.settings-group h4 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 4px;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #0f172a;
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 200;
}

.toast.show { display: flex; }

/* ============================================================ */
/* MODERN CLUTTER-FREE CHECKLIST MODAL & PRINT STYLES           */
/* ============================================================ */
.modal-checklist {
  max-width: 980px;
  height: 94vh;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checklist-modal-body {
  background: #525659;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  overflow-y: auto;
}

/* Base Checklist Paper */
.checklist-paper {
  background: #ffffff;
  color: #000000;
  width: 210mm;
  min-height: 297mm;
  box-sizing: border-box;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  margin: 0 auto;
}
/* ============================================================ */
/* EXACT 1:1 REPLICA OF OFFICIAL ICES/E EXPORT CHECKLIST (PDF)  */
/* ============================================================ */
.orig-exact-paper {
  background: #ffffff !important;
  color: #000000 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
  font-size: 9.5px !important;
  line-height: 1.35 !important;
  padding: 30px 42px !important;
  border: 1px solid #d1d5db;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
}

.orig-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 9.5px;
  margin-bottom: 10px;
}

.orig-center-heading {
  text-align: center;
  margin-bottom: 14px;
}

.orig-title-1 {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.orig-title-2 {
  font-size: 11.5px;
  font-weight: 700;
  margin-top: 2px;
}

.orig-title-3 {
  font-size: 10.5px;
  font-weight: 600;
  margin-top: 3px;
}

.orig-title-4 {
  font-size: 10px;
  font-weight: 600;
  margin-top: 1px;
}

.orig-title-5 {
  font-size: 10px;
  font-weight: 600;
  margin-top: 6px;
}

.orig-job-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5px;
  margin-bottom: 8px;
}

.orig-job-meta-table td {
  padding: 2.5px 3px;
  vertical-align: top;
}

/* Exporter & Consignee 2-Column Table */
.orig-parties-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-size: 9.5px;
  margin-bottom: 8px;
}

.orig-parties-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 3px;
}

.orig-parties-table td {
  padding: 4px 3px;
  vertical-align: top;
  line-height: 1.4;
}

/* Shipment Table */
.orig-shipment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5px;
  margin-bottom: 10px;
}

.orig-shipment-table td {
  padding: 2.5px 3px;
  vertical-align: top;
}

/* Invoice Header Bar */
.orig-inv-header-bar {
  border-top: 2px solid #000000;
  border-bottom: 1.5px solid #000000;
  padding: 3px 0;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.orig-inv-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5px;
  margin-bottom: 6px;
}

.orig-inv-meta-table td {
  padding: 2px 3px;
  vertical-align: top;
}

/* Charges Table */
.orig-charges-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-size: 9px;
  margin-bottom: 12px;
}

.orig-charges-table th {
  padding: 3px 3px;
  font-weight: 700;
  border-bottom: 1px solid #000000;
}

.orig-charges-table td {
  padding: 2px 3px;
  vertical-align: top;
}

.orig-footer {
  font-size: 9.5px;
  color: #111827;
  margin-top: 24px;
}

/* Page 2 Specifics */
.orig-item-section {
  margin-bottom: 8px;
}

.orig-item-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-size: 8.5px;
  margin-bottom: 6px;
}

.orig-item-table th {
  padding: 3px 3px;
  font-weight: 700;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #000000;
  line-height: 1.25;
}

.orig-inv-meta-row td {
  border-bottom: 1px solid #000000 !important;
  font-size: 9px;
  padding: 3px;
}

.orig-item-data-row td {
  padding: 3px;
  vertical-align: top;
}

.orig-pmv-line {
  display: flex;
  gap: 28px;
  font-size: 9px;
  margin: 3px 0;
}

.orig-scheme-line {
  font-size: 9px;
  margin-bottom: 4px;
}

.orig-item-specs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px 10px;
  font-size: 8.5px;
  margin-bottom: 8px;
}

.orig-section-label {
  font-size: 9.5px;
  font-weight: 800;
  margin: 8px 0 2px 0;
  text-transform: uppercase;
}

.orig-bordered-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  margin-bottom: 8px;
}

.orig-bordered-table th {
  padding: 3px;
  text-align: left;
  border-bottom: 1px solid #000000;
}

/* Single Window Info with Dotted Separation */
.orig-sw-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-size: 8.5px;
  margin-bottom: 8px;
}

.orig-sw-table th {
  padding: 3px;
  text-align: left;
  border-bottom: 1px solid #000000;
  font-weight: 700;
}

.orig-sw-table td {
  padding: 2px 3px;
  border-bottom: 1px dotted #9ca3af;
}

/* Single Window Supporting Document */
.orig-sw-doc-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-size: 8px;
  margin-bottom: 12px;
}

.orig-sw-doc-table th {
  padding: 3px 2px;
  text-align: left;
  border-bottom: 1px solid #000000;
  font-weight: 700;
  vertical-align: top;
  line-height: 1.2;
}

.orig-sw-doc-table td {
  padding: 2.5px 2px;
  vertical-align: top;
}

/* Summary Grid */
.orig-summary-wrapper {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.orig-summary-tbl {
  width: 250px;
  font-size: 9px;
  border-collapse: collapse;
}

.orig-summary-tbl td {
  padding: 1.5px 2px;
}

.orig-declaration-text {
  font-size: 8.5px;
  line-height: 1.35;
  text-align: justify;
  margin-top: 12px;
  margin-bottom: 18px;
}

.orig-sig-center {
  text-align: center;
  font-size: 9.5px;
  font-weight: 600;
  margin-bottom: 16px;
}

.print-only { display: none; }

/* PRINT MEDIA QUERY FOR HIGH RESOLUTION PRINT & SAVE-TO-PDF */
/* ============================================================ */
/* AI INVOICE AUTO-FILL CARD & DROPZONE                         */
/* ============================================================ */
.ai-card {
  border: 1.5px dashed #818cf8;
  background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
  position: relative;
  overflow: hidden;
}

.ai-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.ai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ai-badge {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.25);
}

.ai-dropzone {
  position: relative;
  background: #ffffff;
  border: 2px dashed #c7d2fe;
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-dropzone:hover, .ai-dropzone.dragover {
  border-color: #6366f1;
  background: #faf5ff;
}

.ai-dropzone-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.ai-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4f46e5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-dropzone-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.ai-dropzone-text strong {
  font-size: 14px;
  color: #1e293b;
}

.ai-dropzone-text span {
  font-size: 12px;
  color: #64748b;
}

/* AI Loading Overlay */
.ai-processing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: var(--radius-md);
  z-index: 10;
}

.ai-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e7ff;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.ai-processing-status h4 {
  margin: 0 0 4px 0;
  font-size: 14px;
  color: #1e293b;
  font-weight: 600;
}

.ai-processing-status p {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}

.btn-success-subtle {
  background: #ecfdf5 !important;
  color: #059669 !important;
  border-color: #6ee7b7 !important;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.6); border-color: #4f46e5; }
  70% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0); border-color: #4f46e5; }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

.field-highlight-pulse {
  animation: pulseGlow 1.5s ease-out 2;
  background-color: #f5f3ff !important;
  transition: background-color 1s ease;
}

/* Modal Small */
.modal-sm {
  max-width: 460px !important;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html, body {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .navbar,
  .container,
  .action-bar-container,
  .modal-overlay,
  .toast {
    display: none !important;
  }

  .print-only {
    display: block !important;
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  .checklist-paper {
    display: none !important;
  }

  .ices-wrapper {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    display: block !important;
  }

  .ices-page {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 10mm 14mm 14mm 14mm !important;
    width: 210mm !important;
    height: 296.5mm !important;
    min-height: 296.5mm !important;
    max-height: 296.5mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    page-break-after: always !important;
    break-after: page !important;
    background: #ffffff !important;
  }

  .ices-page:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
}

/* ============================================================ */
/* TANKERS FLEET & MULTI-INVOICE MANAGER                        */
/* ============================================================ */
.tankers-fleet-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fleet-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.fleet-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tankers-table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.tankers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tankers-table th {
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.tankers-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tankers-table tr:hover {
  background: #f8fafc;
}

.tankers-table input,
.tankers-table select {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  transition: border-color 0.15s ease;
}

.tankers-table input:focus,
.tankers-table select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.product-select-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.badge-ms {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #ffedd5;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-hsd {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #dcfce7;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.esanchit-sync-drawer {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: 8px;
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.drawer-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.exporter-info-badge {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}

.exporter-info-badge strong {
  font-size: 14px;
  color: #0f172a;
}

.exporter-sub-details {
  font-size: 11.5px;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
}

/* ============================================================ */
/* EXACT ICES/E CHECKLIST FORMATTING (GOVERNMENT CUSTOMS COPY)  */
/* ============================================================ */
.ices-wrapper {
  background: #525659;
  padding: 24px 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.ices-page {
  width: 100%;
  max-width: 820px;
  min-height: 1140px;
  background: #ffffff;
  color: #000000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  padding: 24px 30px 45px 30px;
  box-sizing: border-box;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 10.5px;
  line-height: 1.35;
  position: relative;
  page-break-after: always;
}

.ices-page-top-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 11px;
}

.ices-page-counter {
  text-align: right;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 2px;
}

.ices-center-title {
  text-align: center;
  margin-top: -6px;
  margin-bottom: 12px;
}

.ices-center-title h2 {
  font-size: 13px;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.3px;
}

.ices-center-title h3 {
  font-size: 13px;
  font-weight: 800;
  margin: 2px 0;
}

.ices-center-title .sub {
  font-size: 11px;
  margin: 1px 0;
}

.ices-center-title .scheme {
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 5px;
}

.ices-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  margin-bottom: 4px;
}

.ices-meta-table td {
  padding: 1.5px 1px;
  vertical-align: top;
}

.ices-line {
  border-top: 1px solid #000000;
  margin: 4px 0 6px 0;
}

.ices-double-line {
  border-top: 3px double #000000;
  border-bottom: 1px solid #000000;
  padding: 2.5px 0;
  margin: 5px 0;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
}

.ices-inv-title-bar {
  border-top: 2px solid #000000;
  border-bottom: 1px solid #000000;
  padding: 2.5px 0;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  margin: 5px 0 3px 0;
}

.ices-inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5px;
  line-height: 1.35;
}

.ices-inv-table td {
  padding: 1.5px 2px;
  vertical-align: top;
}

.ices-charges-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid #000000;
  border-bottom: 1px solid #000000;
  font-size: 9px;
  margin: 4px 0;
}

.ices-charges-table th {
  padding: 2px 2px;
  font-weight: 700;
  border-bottom: 1px solid #000000;
}

.ices-charges-table td {
  padding: 1.5px 2px;
  vertical-align: top;
}

.ices-item-header-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-size: 8.5px;
  margin-bottom: 4px;
}

.ices-item-header-table th {
  padding: 2.5px 2px;
  font-weight: 700;
  text-align: left;
  vertical-align: top;
  line-height: 1.25;
}

.ices-item-inv-meta {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 700;
  border-bottom: 1px solid #000000;
  padding: 2px 0;
  margin-bottom: 2px;
}

.ices-item-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9px;
  line-height: 1.3;
}

.ices-item-data-table td {
  padding: 1.5px 2px;
  vertical-align: top;
}

.ices-item-submeta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5px;
  line-height: 1.3;
  margin-top: 2px;
}

.ices-item-submeta-table td {
  padding: 1px 2px;
  vertical-align: top;
}

.ices-bordered-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-size: 8.5px;
  margin-bottom: 6px;
}

.ices-bordered-table th {
  padding: 2.5px 2px;
  font-weight: 700;
  border-bottom: 1px solid #000000;
  vertical-align: top;
  line-height: 1.2;
}

.ices-bordered-table td {
  padding: 2px 2px;
  vertical-align: top;
}

.ices-sw-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5px;
  margin-bottom: 6px;
}

.ices-sw-info-table th {
  padding: 2px 2px;
  text-align: left;
  border-bottom: 1px solid #000000;
  font-weight: 700;
}

.ices-sw-info-table td {
  padding: 1.5px 2px;
  border-bottom: 1px dotted #9ca3af;
}

.ices-sw-doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8px;
  margin-bottom: 8px;
}

.ices-sw-doc-table th {
  padding: 2.5px 2px;
  text-align: left;
  border-bottom: 1px solid #000000;
  font-weight: 700;
  vertical-align: top;
  line-height: 1.2;
}

.ices-sw-doc-table td {
  padding: 2px 2px;
  vertical-align: top;
  border-bottom: 1px dotted #cbd5e1;
}

.ices-footer-prep {
  position: absolute;
  bottom: 14mm;
  left: 18mm;
  font-size: 10px;
  font-weight: 500;
}

/* ============================================================ */
/* SIGN-IN PAGE                                                 */
/* ============================================================ */
/* Mobile-first: one column, the brand panel collapses away. */
.auth-body {
  min-height: 100vh;
  padding-bottom: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, #1c4b86 0%, transparent 60%),
    linear-gradient(160deg, #0f2d52 0%, #081b34 100%);
  color: #e8eefc;
}

.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 48px;
  align-items: center;
  max-width: 1080px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 28px;
}

.auth-brand { display: flex; flex-direction: column; gap: 26px; }
.auth-brand .logo-box { box-shadow: 0 4px 18px rgba(234, 88, 12, 0.35); }
.auth-brand .logo-iocl { color: #ffffff; }
.auth-brand .logo-sub { color: rgba(255, 255, 255, 0.85); }

.auth-product {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: #ffffff;
  margin-top: 14px;
}

.auth-tagline { font-size: 14px; color: #a9c0e4; max-width: 44ch; line-height: 1.6; }

.auth-points { list-style: none; display: flex; flex-direction: column; gap: 10px; padding: 0; }
.auth-points li { font-size: 13.5px; color: #cddcf5; display: flex; gap: 10px; align-items: flex-start; }
.auth-points .tick {
  color: #0f2d52; background: #f5a623; width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800;
  flex: 0 0 18px; margin-top: 1px;
}
.auth-points code { font-family: 'JetBrains Mono', monospace; background: rgba(255,255,255,.1); padding: 1px 5px; border-radius: 4px; }

.auth-brand-foot {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #8fa9d0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 16px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: #64748b; display: inline-block; flex: 0 0 9px; }
.dot-ok { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18); }
.dot-bad { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18); }

.auth-panel { display: flex; flex-direction: column; align-items: center; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  color: var(--text-main);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  box-shadow: 0 24px 60px -20px rgba(2, 8, 23, 0.65);
}

.auth-head { margin-bottom: 20px; }
.auth-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; }
.auth-head p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { width: 100%; padding-right: 58px; }
.pw-toggle {
  position: absolute; right: 8px; background: none; border: none; cursor: pointer;
  font-size: 11.5px; font-weight: 700; color: var(--primary); padding: 6px;
  text-transform: uppercase; letter-spacing: 0.4px;
}

.auth-error {
  background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5;
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 12.5px; margin: 12px 0;
  line-height: 1.45;
}

.btn-block { width: 100%; justify-content: center; height: 44px; font-size: 14px; margin-top: 6px; }

.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-remember {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  font-size: 12px; color: var(--text-muted); text-transform: none; letter-spacing: 0; font-weight: 500;
  cursor: pointer;
}
.auth-remember input { width: 15px; height: 15px; accent-color: var(--primary); }

.auth-foot-links {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center;
}
.auth-foot-links p { font-size: 11.5px; color: var(--text-light); }

.auth-legal { font-size: 11px; color: #7d95bd; margin-top: 22px; text-align: center; }

/* ============================================================ */
/* USER CHIP + ACCOUNT MENU                                     */
/* ============================================================ */
.user-chip { position: relative; }

.user-chip-btn {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-full);
  padding: 4px 10px 4px 4px; cursor: pointer; color: var(--text-main);
  transition: background 0.15s, border-color 0.15s;
}
.user-chip-btn:hover { background: #eef2f7; border-color: #cbd5e1; }

.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; letter-spacing: 0.3px;
}
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-name { font-size: 12px; font-weight: 700; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 9.5px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }

.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 1200;
}
.user-menu-head {
  padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.user-menu-head strong { font-size: 13px; }
.user-menu-head span { font-size: 11.5px; color: var(--text-muted); word-break: break-all; }
.user-menu-item {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px;
  background: none; border: none; border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--text-main); cursor: pointer; text-align: left;
  text-decoration: none; font-family: inherit;
}
.user-menu-item:hover { background: #f1f5f9; }
.user-menu-item.danger { color: var(--danger); justify-content: flex-start; }
.menu-pill { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-full); background: #f1f5f9; color: var(--text-muted); white-space: nowrap; flex: 0 0 auto; }
.pill-ok { background: var(--success-light); color: #15803d; }
.pill-warn { background: var(--warning-light); color: #b45309; }

/* ============================================================ */
/* MOBILE NAV TRIGGER + DRAWER SCRIM                            */
/* ============================================================ */
.nav-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 40px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-main); cursor: pointer;
}
.nav-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  z-index: 900; opacity: 0; transition: opacity 0.2s ease;
}
.nav-scrim[hidden] { display: none; }

/* ============================================================ */
/* PWA INSTALL HELP + TOAST                                     */
/* ============================================================ */
.pwa-help {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 1400;
}
.pwa-help.open { display: flex; }
.pwa-help-card {
  background: #fff; border-radius: var(--radius-lg); padding: 24px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.pwa-help-card h3 { font-size: 17px; margin-bottom: 6px; }
.pwa-help-card > p { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.pwa-help-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.pwa-step {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.pwa-step strong { font-size: 12.5px; }
.pwa-step span { font-size: 12px; color: var(--text-muted); }
.pwa-step .arrow { color: var(--primary); font-weight: 700; }
.pwa-help-actions { display: flex; justify-content: flex-end; gap: 10px; }

.pwa-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: var(--radius-md);
  font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; transition: all 0.3s ease; z-index: 1500;
  max-width: min(92vw, 420px); text-align: center;
}
.pwa-toast.active { opacity: 1; transform: translate(-50%, 0); }

/* app.js adds .active to the toast but the original CSS only had .show - support both. */
.toast.active { display: flex; }

/* Row action buttons in the register: fixed squares so the four line up
   identically on every row, on a desktop as well as on a phone. */
.row-actions { display: inline-flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 30px; height: 30px; min-height: 30px; padding: 0;
  flex: 0 0 30px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-light); border-color: #fca5a5; }

/* ============================================================ */
/* RESPONSIVE LAYERS                                            */
/* ============================================================ */

/* --- Mid widths ---------------------------------------------- */
/* The navbar is nowrap now, so rather than let it overflow we drop the
   decorative pieces in order: the ICEGATE badge, then the account name. */
@media (max-width: 1250px) {
  .nav-title h1 .badge { display: none; }
  .navbar { gap: 12px; }
}

@media (max-width: 1180px) {
  .navbar { padding: 10px 16px; gap: 10px; }
  .nav-title p { display: none; }
  .container { padding: 0 16px; }
  .user-meta { display: none; }
  .user-chip-btn { padding: 3px; }
  .user-chip-btn > svg { display: none; }
}

/* --- Tablet -------------------------------------------------- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-tabs { order: 3; width: 100%; }
  .tab-btn { flex: 1; justify-content: center; }
  .navbar { flex-wrap: wrap; }
  .nav-right { margin-left: auto; }
  .data-table { font-size: 12px; }
}

/* --- Large phones / small tablets ---------------------------- */
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; gap: 28px; padding: 28px 18px; align-content: center; }
  .auth-brand { display: none; }
  .card { padding: 16px 14px; }
  .dashboard-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .dash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-actions .btn { width: 100%; }
}

/* --- Phones -------------------------------------------------- */
@media (max-width: 720px) {
  body { padding-bottom: 76px; }

  .nav-menu-btn { display: inline-flex; }
  .nav-left { flex: 1; min-width: 0; }
  .nav-title h1 { font-size: 13.5px; line-height: 1.25; }
  .logo-box { padding: 4px 8px; }
  .logo-sub { display: none; }

  /* Tabs become a thumb-reachable bottom bar. */
  .nav-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
    width: auto; margin: 0; border-radius: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #ffffff; border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px -8px rgba(15, 23, 42, 0.3);
    gap: 8px;
  }
  .tab-btn { height: 44px; font-size: 13px; }

  .nav-right { gap: 6px; }
  .nav-btn-label { display: none; }
  #configBtn { padding: 8px 10px; }

  /* Account menu centres itself so it can never overflow the viewport. */
  .user-chip-btn { padding: 3px 8px 3px 3px; }
  .user-meta { display: none; }
  .user-menu { position: fixed; left: 12px; right: 12px; top: 66px; min-width: 0; width: auto; }

  .container { margin: 14px auto; gap: 14px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-val { font-size: 17px; }
  .stat-label { font-size: 10px; }

  /* Every form row stacks; labels stay above their field. */
  .form-row { flex-direction: column; gap: 10px; }
  .grid-2-col { grid-template-columns: 1fr; }
  .table-filter-bar { flex-direction: column; align-items: stretch; }
  .filter-group select { width: 100%; }

  input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
  input[type="search"], input[type="number"], input[type="date"], select, textarea {
    font-size: 16px;   /* under 16px iOS Safari zooms the whole page on focus */
    height: 44px;
  }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }

  /* Header: one tight line, badge drops out on the narrowest screens. */
  .nav-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-title h1 .badge { display: none; }
  .logo-box { flex: 0 0 auto; }

  /* Account chip: initials only, the chevron reads as clutter at 390px. */
  .user-chip-btn > svg { display: none; }

  /* Step badges must not squash when a heading wraps to two lines. */
  .section-title { align-items: flex-start; flex-wrap: wrap; }
  .step-num { flex: 0 0 24px; margin-top: 1px; }
  /* The hint text is a sentence, not a label - give it its own line instead of
     squeezing it next to a heading that is already wrapping. */
  .section-title .section-hint { flex: 1 1 100%; margin-left: 34px; margin-top: 2px; }
  .title-with-badge { align-items: flex-start; }

  /* AI card header stacks; the API-key button becomes a full-width row. */
  .ai-card-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .ai-header-right .btn { width: 100%; }
  .section-hint { margin-left: 0; }

  /* Row action buttons: fixed squares so the four stay aligned. */
  .row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .icon-btn { width: 36px; height: 36px; padding: 0; flex: 0 0 36px; }

  /* The fleet grid is genuinely wide; keep it scrollable inside its card
     instead of letting it push the page sideways. */
  .tankers-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
  }
  .tankers-table-container table { min-width: 900px; }

  /* The register turns into stacked cards; each cell prints its own header
     from the data-label attribute added by renderDashboardTable(). */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    margin-bottom: 10px; padding: 2px; background: #fff; box-shadow: var(--shadow-sm);
  }
  .data-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 7px 12px; border-bottom: 1px solid #f1f5f9; text-align: right;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--text-muted); text-align: left; flex: 0 0 40%;
  }
  .data-table td.cell-actions { justify-content: flex-end; }
  .data-table td:last-child { border-bottom: none; }
  .data-table tbody tr:hover { background: #fff; }

  /* Modals become bottom sheets. The real class is .modal-card (the old
     .modal-content name never existed), and the overlay must sit ABOVE the
     fixed bottom tab bar, which is at z-index 950. */
  .modal-overlay { padding: 0; align-items: flex-end; z-index: 1100; }
  .modal-card, .modal-checklist {
    max-width: 100%; width: 100%; max-height: 92vh; height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-footer { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .modal-close { width: 40px; height: 40px; flex-basis: 40px; font-size: 24px; }

  /* Checklist header: the footer already has Close / Print / Download, so on a
     phone the header keeps only the X. Four buttons in a 390px bar is unreadable. */
  .modal-header-actions .btn { display: none; }
  #checklistModalSub { display: none; }
  .modal-header h3 { font-size: 14.5px; }
  .toast { left: 12px; right: 12px; top: auto; bottom: 78px; justify-content: center; z-index: 1600; }
}

/* --- A4 checklist pages on narrow screens --------------------- */
/* The ICES checklist is laid out on real 210mm paper, which is ~794px wide and
   simply gets cut off inside a phone modal. zoom shrinks the laid-out box (so
   no negative-margin hacks are needed) and the print stylesheet is unaffected
   because these rules are screen-only. If a browser ignores zoom entirely, the
   body still scrolls sideways. */
@media screen and (max-width: 1100px) {
  .checklist-modal-body { padding: 16px; overflow: auto; }
  .ices-page { zoom: 0.78; }
}
@media screen and (max-width: 880px) {
  .ices-page { zoom: 0.62; }
}
@media screen and (max-width: 720px) {
  .ices-page { zoom: 0.46; }
  .checklist-modal-body { padding: 10px; gap: 12px; }
}
@media screen and (max-width: 420px) {
  .ices-page { zoom: 0.42; }
}

/* --- Very small phones --------------------------------------- */
@media (max-width: 420px) {
  /* Two stat cards still fit at 390px - the values are short. Only below
     340px (old Androids) do they need to stack. */
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  /* Stack icon above the text: side by side leaves ~120px for a label like
     "TOTAL FOB EXPORT VALUE", which then wraps three times. */
  .stat-card { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }
  .stat-icon { width: 30px; height: 30px; font-size: 14px; }
  .stat-data { width: 100%; }
  .stat-label { font-size: 9.5px; line-height: 1.25; }
  .stat-val { font-size: 15px; white-space: nowrap; letter-spacing: -0.3px; }
  .dash-actions { grid-template-columns: 1fr; }
  .nav-title h1 { font-size: 12.5px; }
  .auth-card { padding: 22px 18px; }
  .data-table td { font-size: 12.5px; }
}

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

/* --- Landscape phones: bottom bar back into the header ------- */
@media (max-height: 500px) and (orientation: landscape) {
  .nav-tabs { position: static; border-top: none; box-shadow: none; width: auto; order: 0; padding: 4px; }
  body { padding-bottom: 0; }
  .modal-card, .modal-checklist { max-height: 96vh; height: 96vh; }
}

/* --- Touch devices: no phantom hover, press feedback --------- */
@media (hover: none) {
  .data-table tbody tr:hover { background: #fff; }
  .btn:active { transform: scale(0.98); }
}

/* --- Reduced motion ------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}



