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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #22252f;
  --bg-input: #14161e;
  --border: #2a2d3a;
  --text: #e4e6eb;
  --text-dim: #8b8f9a;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --purple: #a855f7;
  --cyan: #06b6d4;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-hover: #eef0f5;
  --bg-input: #f0f2f7;
  --border: #d1d5e0;
  --text: #1a1d27;
  --text-dim: #6b7280;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --green: #16a34a;
  --yellow: #ca8a04;
  --orange: #ea580c;
  --red: #dc2626;
  --purple: #9333ea;
  --cyan: #0891b2;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.page { min-height: 100vh; }

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); }
.btn-theme-toggle { font-size: 1.1rem; padding: 6px 10px; border-radius: var(--radius); transition: background 0.15s; }
.btn-theme-toggle:hover { background: var(--bg-hover); }
.btn-danger {
  background: #ef444422;
  color: #ef4444;
  border: 1px solid #ef444444;
}
.btn-danger:hover { background: #ef444433; }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-full {
  width: 100%;
  justify-content: center;
  padding: 10px 16px;
}

/* ── Modal ───────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow);
}
.modal-wide { max-width: 560px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}
.hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.hint a { color: var(--primary); text-decoration: none; }

/* ── Auth Page ───────────────────────────────────────── */

.auth-container {
  max-width: 420px;
  margin: 0 auto;
  padding: 80px 24px 48px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}
.auth-logo h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.auth-logo p {
  color: var(--text-dim);
  font-size: 0.95rem;
}
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}
.auth-tab.active {
  background: var(--primary);
  color: #fff;
}
.auth-tab:hover:not(.active) { color: var(--text); }

.form-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

#auth-page .btn-full {
  margin-bottom: 8px;
}

/* ── Header ──────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}
header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-left { flex-shrink: 0; }
.header-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Tabs ────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
}
.tab {
  padding: 6px 20px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}
.tab.active {
  background: var(--primary);
  color: #fff;
}
.tab:hover:not(.active) { color: var(--text); }

.create-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
}
.create-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
}
.create-tab.active {
  background: var(--primary);
  color: #fff;
}

/* ── User Menu ───────────────────────────────────────── */

.user-menu {
  position: relative;
}
.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 300;
  overflow: hidden;
}
.dropdown a {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.1s;
}
.dropdown a:hover { background: var(--bg-hover); }
.dropdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

/* ── Usage Badge ─────────────────────────────────────── */

.usage-badge {
  font-size: 0.75rem;
  padding: 4px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  white-space: nowrap;
}
.usage-badge.warning { border-color: var(--orange); color: var(--orange); }
.usage-badge.limit { border-color: var(--red); color: var(--red); }

/* ── Filters ─────────────────────────────────────────── */

.filters-bar {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-bar select,
.filters-bar input[type="text"] {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
}
.filters-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
}
.filters-bar select:focus,
.filters-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Shipment List ───────────────────────────────────── */

.shipment-list {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-dim);
}
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-dim);
}
.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text);
}
.empty-state .btn {
  margin-top: 16px;
}

/* ── Shipment Card ───────────────────────────────────── */

.shipment-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.shipment-card:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}
.shipment-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shipment-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.shipment-id {
  font-weight: 600;
  font-size: 0.95rem;
}
.shipment-ref {
  color: var(--text-dim);
  font-size: 0.85rem;
}
.shipment-route {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.route-arrow {
  color: var(--text-dim);
  font-size: 0.8rem;
}
.shipment-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.shipment-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  justify-content: center;
}

/* ── Status Badges ───────────────────────────────────── */

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-NEW { background: #1e293b; color: var(--text-dim); }
.status-INPROGRESS { background: #1e1b4b; color: var(--purple); }
.status-BOOKED { background: #172554; color: var(--cyan); }
.status-EN_ROUTE,
.status-SAILING { background: #1e1b4b; color: var(--primary); }
.status-LOADED { background: #1a2e05; color: var(--green); }
.status-LANDED,
.status-ARRIVED { background: #422006; color: var(--orange); }
.status-DELIVERED,
.status-DISCHARGED { background: #052e16; color: var(--green); }
.status-UNTRACKED { background: #1c1917; color: var(--red); }
.status-GATE_IN { background: #172554; color: var(--cyan); }
.status-GATE_OUT { background: #422006; color: var(--orange); }
.status-EMPTY_SHIPPER { background: #1e293b; color: var(--text-dim); }
.status-EMPTY_RETURN { background: #052e16; color: var(--green); }
.status-UNKNOWN { background: #1c1917; color: var(--text-dim); }

/* ── Transit Bar ─────────────────────────────────────── */

.transit-bar {
  width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.transit-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}
.transit-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: right;
}

/* ── Pagination ──────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 24px;
  color: var(--text-dim);
  font-size: 0.875rem;
}

/* ── Detail Panel ────────────────────────────────────── */

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(680px, 100vw);
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 200;
  overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.detail-header h2 {
  font-size: 1.1rem;
  margin: 0;
}
.detail-content { padding: 24px; }

.detail-section { margin-bottom: 24px; }
.detail-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-field label,
.detail-field .detail-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-field span,
.detail-field .detail-value { font-size: 0.95rem; }

/* ── Timeline ────────────────────────────────────────── */

.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg);
}
.timeline-dot.actual { background: var(--green); }
.timeline-dot.estimated { background: var(--border); border-color: var(--text-dim); }
.timeline-event {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.timeline-location {
  font-size: 0.85rem;
  color: var(--text-dim);
}
.timeline-time {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.timeline-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 6px;
}
.badge-ACT { background: #052e16; color: var(--green); }
.badge-EST { background: #1e293b; color: var(--text-dim); }

/* ── Map ─────────────────────────────────────────────── */

.map-container {
  width: 100%;
  height: 260px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

/* ── Tags ────────────────────────────────────────────── */

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-right: 4px;
}

/* ── Forms ────────────────────────────────────────────── */

.form-group {
  margin-bottom: 14px;
}
.form-group-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--text);
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group input::placeholder {
  color: #555;
}
.required { color: var(--red); }
.or-divider { text-align: center; color: var(--muted); font-size: 0.75rem; margin: 2px 0 8px; letter-spacing: 0.05em; }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}
.error-msg {
  margin-top: 12px;
  padding: 10px;
  background: #2d0a0a;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.85rem;
}
.success-msg {
  margin-top: 12px;
  padding: 10px;
  background: #052e16;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  color: var(--green);
  font-size: 0.85rem;
}

/* ── Containers Table ────────────────────────────────── */

.containers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.containers-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.containers-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

/* ── Map Link ────────────────────────────────────────── */

.btn-map-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-map-link:hover { background: var(--border); }

/* ── Billing Page ────────────────────────────────────── */

.billing-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.billing-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.billing-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px;
}
.billing-container h2 {
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 24px;
}

.plan-current {
  text-align: center;
  margin-bottom: 16px;
}
.plan-badge {
  display: inline-block;
  padding: 4px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.plan-current p {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.usage-section {
  max-width: 400px;
  margin: 0 auto 32px;
}
.usage-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-align: center;
}
.usage-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}
.usage-fill.warn { background: var(--orange); }
.usage-fill.full { background: var(--red); }

/* ── Pricing Grid ────────────────────────────────────── */

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 32px 0;
}
.pricing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  position: relative;
  transition: border-color 0.15s;
}
.pricing-card:hover { border-color: #444; }
.pricing-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.1);
}
.popular-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pricing-card h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}
.price {
  font-size: 2.8rem;
  font-weight: 800;
  margin: 8px 0;
}
.price span {
  font-size: 1rem;
  color: var(--text-dim);
  font-weight: 400;
}
.price-desc {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 20px;
}
.pricing-card ul {
  list-style: none;
  text-align: left;
  margin-bottom: 24px;
}
.pricing-card li {
  padding: 6px 0;
  font-size: 0.875rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.pricing-card li:last-child { border-bottom: none; }
.pricing-card li::before {
  content: "✓ ";
  color: var(--green);
  font-weight: 700;
  margin-right: 6px;
}
.pricing-card .btn {
  width: 100%;
}

/* ── Account Page ───────────────────────────────────── */

.account-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px;
}
.account-container > h2 {
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 32px;
}
.account-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}
.account-section > h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Company form */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.account-section .form-group {
  margin-bottom: 16px;
}
.account-section .form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.account-section .form-group input,
.account-section .form-group textarea,
.account-section .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input, var(--card-bg));
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  box-sizing: border-box;
}
.account-section .form-group input:focus,
.account-section .form-group textarea:focus,
.account-section .form-group select:focus {
  outline: none;
  border-color: var(--primary);
}
.company-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.company-form-actions span {
  font-size: 0.85rem;
}

/* Billing history */
.invoice-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.invoice-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.invoice-row:last-child { border-bottom: none; }
.invoice-date { color: var(--text); }
.invoice-amount { font-weight: 600; }
.invoice-status { text-transform: capitalize; }
.invoice-action .btn-sm { font-size: 0.75rem; padding: 4px 10px; }

/* ── Notification Toggle ─────────────────────────────── */

.detail-notify-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.notify-bell { font-size: 1.1rem; }
.notify-label {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-dim);
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-track::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); }
.toggle-switch input:disabled + .toggle-track { opacity: 0.5; }

/* ── Dashboard Summary Cards ─────────────────────────── */

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 24px 0;
}
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.summary-val {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  order: -1;
}
#summary-in-transit .summary-val { color: var(--primary); }
#summary-delivered .summary-val { color: var(--green); }
#summary-late .summary-val { color: var(--orange); }
#summary-exceptions .summary-val { color: var(--red); }

/* ── Modal Overlay (for webhook modal) ───────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 520px;
  width: 90%;
  box-shadow: var(--shadow);
}
.modal-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}
.modal-close {
  font-size: 1.2rem;
  padding: 4px 8px;
  line-height: 1;
}

/* ── Bulk Toolbar ─────────────────────────────────────── */

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: #1e1b4b;
  border-bottom: 1px solid var(--primary);
  font-size: 0.875rem;
}
.bulk-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-dim);
}
#bulk-count {
  color: var(--text);
  font-weight: 600;
}

/* ── Bulk Checkbox ────────────────────────────────────── */

.bulk-cb {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ── Pin Button ───────────────────────────────────────── */

.btn-pin {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-dim);
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.btn-pin:hover { color: var(--yellow); transform: scale(1.2); }
.btn-pin.pinned { color: var(--yellow); }

/* ── Pinned Card highlight ────────────────────────────── */

.pinned-card {
  border-color: var(--yellow) !important;
  box-shadow: 0 0 0 1px var(--yellow) inset;
}

/* ── Tag Chips ────────────────────────────────────────── */

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--tag-color) 18%, transparent);
  color: var(--tag-color);
  border: 1px solid color-mix(in srgb, var(--tag-color) 40%, transparent);
  margin-right: 4px;
}
.tag-chip-removable { cursor: default; }
.remove-tag {
  cursor: pointer;
  font-size: 0.65rem;
  opacity: 0.7;
  line-height: 1;
}
.remove-tag:hover { opacity: 1; }

.shipment-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

/* ── Late Badge ───────────────────────────────────────── */

.late-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: #431407;
  color: var(--orange);
  border: 1px solid var(--orange);
}

/* ── Tag Editor (detail panel) ────────────────────────── */

#tag-editor {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 42px;
}
#tag-editor:focus-within { border-color: var(--primary); }
#tag-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.875rem;
  flex: 1;
  min-width: 100px;
}
#tag-chips-live {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── Local Settings Panel ─────────────────────────────── */

#local-settings-panel {
  border-top: 2px solid var(--primary);
  padding-top: 20px;
  margin-top: 24px;
}
#local-settings-panel .detail-section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 16px;
}
#local-settings-panel .form-group label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
#local-settings-panel .form-group input,
#local-settings-panel .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}
#local-settings-panel .form-group input:focus,
#local-settings-panel .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.local-settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ── Webhook Modal ────────────────────────────────────── */

#webhook-modal .modal-content { max-width: 500px; }
#webhook-form .form-group input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
}
#webhook-form .form-group input:focus {
  outline: none;
  border-color: var(--primary);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
.checkbox-row label { cursor: pointer; font-size: 0.875rem; }

/* ── Documents ────────────────────────────────────────── */

.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.doc-item:last-child { border-bottom: none; }
.doc-icon { font-size: 1rem; flex-shrink: 0; }
.doc-name {
  flex: 1;
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.doc-name:hover { text-decoration: underline; }
.doc-size {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-doc-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.1s;
}
.btn-doc-delete:hover { color: var(--red); }
.doc-upload-btn {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.doc-badge {
  font-size: 0.72rem;
  padding: 2px 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  white-space: nowrap;
}
.doc-loading {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 4px 0;
}
.doc-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
  padding: 4px 0;
}

/* ── Reports Page ─────────────────────────────────────── */

.reports-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.reports-header h1 {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}
.reports-content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.reports-loading {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 0;
  font-size: 1rem;
}
.reports-error {
  text-align: center;
  color: var(--red);
  padding: 40px 0;
}

/* Overview KPI cards */
.reports-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.reports-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  transition: border-color 0.2s;
}
.reports-kpi:hover { border-color: var(--primary); }
.reports-kpi-val {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}
.reports-kpi-val.kpi-late { color: var(--red); }
.reports-kpi-val.kpi-exception { color: var(--yellow); }
.reports-kpi-val.kpi-green { color: var(--green); }
.reports-kpi-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Section layout */
.reports-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.reports-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Reports tables */
.reports-table-wrap { overflow-x: auto; }
.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.reports-table th {
  background: var(--bg-hover);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.reports-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: middle;
}
.reports-table tr:last-child td { border-bottom: none; }
.reports-table tr:hover td { background: var(--bg-hover); }
.reports-table .td-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}
.reports-table .td-badge { }
.reports-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 32px;
  font-style: italic;
  font-size: 0.85rem;
}

/* Bar chart (CSS-only) */
.report-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.report-bar-row:last-child { border-bottom: none; }
.report-bar-label {
  width: 90px;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: right;
  flex-shrink: 0;
}
.report-bar-track {
  flex: 1;
  height: 20px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  gap: 1px;
}
.report-bar-ocean {
  background: var(--primary);
  height: 100%;
  border-radius: 2px 0 0 2px;
  transition: width 0.4s;
}
.report-bar-air {
  background: var(--cyan);
  height: 100%;
  transition: width 0.4s;
}
.report-bar-courier {
  background: var(--purple);
  height: 100%;
  border-radius: 0 2px 2px 0;
  transition: width 0.4s;
}
.report-bar-val {
  width: 36px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  flex-shrink: 0;
}

/* On-time rate mini bar */
.ontime-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
}
.ontime-track {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
}
.ontime-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
}
.ontime-fill.warn { background: var(--yellow); }
.ontime-fill.danger { background: var(--red); }
.ontime-pct {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 34px;
  text-align: right;
}

/* Volume chart legend */
.volume-legend {
  display: flex;
  gap: 16px;
  padding: 8px 20px 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.volume-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 4px;
}
.dot-ocean { background: var(--primary); }
.dot-air   { background: var(--cyan); }
.dot-courier { background: var(--purple); }

/* Type badge */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.type-badge.ocean { background: rgba(99,102,241,0.15); color: var(--primary); }
.type-badge.air   { background: rgba(6,182,212,0.15); color: var(--cyan); }
.type-badge.courier { background: rgba(168,85,247,0.15); color: var(--purple); }

/* Days late badge */
.days-late-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(239,68,68,0.12);
  color: var(--red);
}

/* Two-col layout for mid-sized sections */
.reports-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .reports-two-col { grid-template-columns: 1fr; }
}

/* ── Admin Panel ─────────────────────────────────────── */

.admin-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}

.admin-stat-card {
  background: #1a1d27;
  border: 1px solid #2a2d3a;
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-stat-val {
  font-size: 28px;
  font-weight: 800;
}

.admin-stat-label {
  font-size: 12px;
  color: #8b8f9a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-mrr {
  text-align: center;
  margin: 18px 0 0;
  padding: 14px;
  background: #1a1d27;
  border: 1px solid #2a2d3a;
  border-radius: 12px;
  color: #8b8f9a;
  font-size: 15px;
}

.admin-mrr strong {
  color: #22c55e;
  font-size: 22px;
}

.admin-table-wrap {
  overflow-x: auto;
}

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

.admin-users-table th {
  text-align: left;
  padding: 10px 12px;
  color: #8b8f9a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #2a2d3a;
  position: sticky;
  top: 0;
  background: #0f1117;
  white-space: nowrap;
}

.admin-users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #2a2d3a22;
  color: #e4e6eb;
  white-space: nowrap;
}

.admin-users-table tbody tr:hover {
  background: #1a1d2788;
}

.admin-tier-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid;
}

@media (max-width: 900px) {
  .admin-stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-stat-val { font-size: 22px; }
}

/* ── Responsive ──────────────────────────────────────── */

/* ── Hamburger Button (app dashboard) ──────────────────── */
.app-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  margin-left: 12px;
}
.app-nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.app-nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.app-nav-toggle.open span:nth-child(2) { opacity: 0; }
.app-nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Filters: collapsible on mobile ───────────────────── */
.filters-toggle { display: none; }
.filters-collapsible {
  display: contents;
}

/* ══════════════════════════════════════════════════════════ */
/* ── MOBILE: 768px (tablet) ──────────────────────────── */
/* ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Header ── */
  header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
  }
  .header-left {
    display: flex;
    align-items: center;
    width: auto;
  }
  .app-nav-toggle { display: flex; }
  .tabs {
    display: none;
    width: 100%;
    order: 10;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
  }
  .tabs.tabs-open { display: flex; }
  .tab { padding: 12px 16px; text-align: left; font-size: 1rem; }
  .header-right {
    margin-left: auto;
    gap: 6px;
  }
  .header-right .usage-badge { display: none; }
  #btn-user-menu span { display: none; }

  /* ── Filters ── */
  .filters-bar {
    padding: 12px 16px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .filters-bar input[type="text"] {
    min-width: unset;
    width: 100%;
    flex: 1 1 100%;
    min-height: 44px;
    font-size: 16px;
  }
  .filters-toggle { display: inline-flex; }
  .filters-collapsible {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }
  .filters-collapsible.filters-expanded {
    display: flex;
  }
  .filters-collapsible select,
  .filters-collapsible .btn {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  /* ── Dashboard Summary ── */
  .dashboard-summary { grid-template-columns: repeat(2, 1fr); }

  /* ── Shipment Cards ── */
  .shipment-list { padding: 0 12px; }
  .shipment-card {
    grid-template-columns: 1fr;
    padding: 14px 14px;
  }
  .shipment-right { flex-direction: row; align-items: center; }
  .shipment-meta { flex-wrap: wrap; gap: 8px; }

  /* ── Detail Panel ── */
  .detail-panel {
    width: 100vw;
    border-left: none;
  }
  .detail-header {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .detail-content { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }

  /* ── Tables ── */
  .containers-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .containers-table { min-width: 500px; }

  /* ── Modals ── */
  .modal-content {
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
  }

  /* ── Forms ── */
  .form-row { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .invoice-row { grid-template-columns: 1fr 1fr; gap: 4px; }

  /* ── Auth ── */
  .auth-container { padding-top: 48px; padding-left: 16px; padding-right: 16px; }

  /* ── Bulk Toolbar ── */
  .bulk-toolbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }

  /* ── Vessels ── */
  .vessel-grid { grid-template-columns: 1fr; }
  .vessel-card { flex-direction: column; }
  .vessel-card-img { width: 100%; height: 140px; border-radius: 12px 12px 0 0; }
  .vessel-detail-photo img { height: 180px; }
  .vessel-specs-grid { grid-template-columns: 1fr !important; }
  .vessel-modal-tabs { gap: 6px; }

  /* ── Pagination ── */
  .pagination { padding: 12px 16px; }

  /* ── Dashboard Widgets ── */
  .dashboard-widgets { grid-template-columns: 1fr; }

  /* ── Reports ── */
  .reports-two-col { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════ */
/* ── MOBILE: 480px (small phones) ────────────────────── */
/* ══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* ── Header ── */
  header { padding: 10px 12px; }
  header h1 { font-size: 1rem; }
  .header-right { gap: 4px; }
  #btn-create { font-size: 0.8rem; padding: 8px 12px; }

  /* ── Full-screen modals ── */
  .modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }
  .modal-content .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
  }
  .modal-content .form-group,
  .modal-content .create-tabs {
    flex-shrink: 0;
  }
  .modal-content .modal-actions {
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  /* ── Cards ── */
  .shipment-list { padding: 0 8px; }
  .shipment-card { padding: 12px; }
  .shipment-top { gap: 6px; }

  /* ── Summary ── */
  .dashboard-summary { gap: 8px; padding: 8px 12px; }
  .summary-card { padding: 12px 10px; }
  .summary-val { font-size: 1.4rem; }

  /* ── Detail Panel ── */
  .detail-content { padding: 12px; }
}

/* ══════════════════════════════════════════════════════════ */
/* ── MOBILE: Global touch & accessibility ─────────────── */
/* ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Touch targets */
  .btn, button, select, .tab, .shipment-card input[type="checkbox"] {
    min-height: 44px;
  }
  .shipment-card input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  /* Touch feedback */
  * { -webkit-tap-highlight-color: rgba(99, 102, 241, 0.15); }
  /* Safe area padding for notched phones */
  header { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  main { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── Notify Emails Editor ───────────────────────────── */

.notify-email-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 12px;
}
.notify-email-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.3);
  color: var(--primary);
  border-radius: 20px;
  padding: 3px 10px 3px 12px;
  font-size: 0.8rem;
  font-weight: 500;
}
.notify-email-remove {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.notify-email-remove:hover { opacity: 1; }

.notify-email-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.notify-email-input-row input {
  flex: 1;
}

/* ══════════════════════════════════════════════════════ */
/* ── Vessel Tracking ─────────────────────────────── */
/* ══════════════════════════════════════════════════════ */

.vessel-toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.vessel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.vessel-card {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.vessel-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.vessel-card-img {
  width: 120px;
  min-height: 100px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}
.vessel-card-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: var(--bg);
  color: var(--text-dim);
}

.vessel-card-body {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.vessel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.vessel-card-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-vessel-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.btn-vessel-remove:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

.vessel-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.8rem;
}
.vessel-flag {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.vessel-type-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.vessel-imo {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: monospace;
}

.vessel-card-footer {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: auto;
}

/* Vessel Detail */
.vessel-detail-photo {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.vessel-detail-photo img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}

.vessel-position-card {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  padding: 20px;
}

.vessel-refresh-btn {
  margin-top: 12px;
}

.vessel-specs-grid {
  grid-template-columns: repeat(2, 1fr) !important;
}

.vessel-marker {
  background: none;
  border: none;
}

/* Vessel Modal */
.vessel-modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.vessel-modal-tab {
  flex: 1;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}
.vessel-modal-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.vessel-modal-tab:hover:not(.active) {
  border-color: var(--primary);
  color: var(--text);
}

/* Search results */
.vessel-search-result {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.vessel-search-result:hover {
  border-color: var(--primary);
}
.vessel-search-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 2px;
}
.vessel-search-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── AIS Freshness Indicators ────────────────────────── */
.ais-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.ais-dot-fresh {
  background-color: #22c55e;
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
}
.ais-dot-stale {
  background-color: #f59e0b;
}
.vessel-ais-badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: 8px;
}
.refresh-limit-info {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.refresh-limit-info .credit-count {
  color: var(--primary);
  font-weight: 600;
}
.btn-sm {
  padding: 4px 12px;
  font-size: 0.78rem;
}

/* ── Vessel Additional Data (Full Data + Inspection) ─── */

.vessel-extras-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.vessel-extras-grid > div.has-data {
  grid-column: 1 / -1;
}
@media (max-width: 700px) {
  .vessel-extras-grid {
    grid-template-columns: 1fr;
  }
}
.inspection-locked h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}
.inspection-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 16px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.inspection-lock-icon {
  font-size: 2.5rem;
}
.inspection-locked p {
  color: var(--text-dim);
  max-width: 340px;
  margin: 0;
  font-size: 0.9rem;
}
.inspection-note {
  font-size: 0.78rem !important;
  color: var(--text-dim);
}
.inspection-purchased-badge {
  display: inline-block;
  background: rgba(34,197,94,0.15);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.8rem;
  margin-bottom: 12px;
}
.inspection-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}
.inspection-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
  transition: background 0.15s;
}
.inspection-section-header:hover {
  background: var(--bg-hover);
}
.inspection-toggle {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.inspection-section-body {
  padding: 12px 16px;
  background: var(--bg);
}
.inspection-section-body.hidden {
  display: none;
}
.inspection-sub-table {
  overflow-x: auto;
  margin-top: 10px;
}
.inspection-sub-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.inspection-sub-table th {
  text-align: left;
  padding: 6px 10px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.inspection-sub-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
.inspection-sub-table tr:last-child td {
  border-bottom: none;
}
.inspection-sub-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.psc-detained {
  color: #ef4444;
  font-weight: 700;
}
.psc-ok {
  color: #22c55e;
}
.inspection-success-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #22c55e;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: fadeInDown 0.3s ease;
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Cookie Consent Banner ───────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #13151d;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 16px 24px;
  z-index: 10000;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  animation: cookieSlideUp 0.3s ease;
}
@keyframes cookieSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.cookie-banner-content {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.cookie-banner-text {
  margin: 0;
  font-size: 14px;
  color: #b0b4c0;
  line-height: 1.5;
  flex: 1;
}
.cookie-banner-text a {
  color: #818cf8;
  text-decoration: underline;
}
.cookie-banner-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.cookie-btn {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.cookie-btn-accept {
  background: #818cf8;
  color: #fff;
}
.cookie-btn-accept:hover {
  background: #6366f1;
}
.cookie-btn-reject {
  background: transparent;
  color: #b0b4c0;
  border: 1px solid rgba(255,255,255,0.15);
}
.cookie-btn-reject:hover {
  background: rgba(255,255,255,0.05);
}
@media (max-width: 600px) {
  .cookie-banner-content {
    flex-direction: column;
    text-align: center;
  }
  .cookie-banner-actions {
    width: 100%;
    justify-content: center;
  }
}

/* ── Dashboard Analytics Widgets ────────────────────────── */
.dashboard-widgets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px 24px;
}
.widget-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  max-height: 160px;
  overflow: hidden;
}
.widget-card canvas {
  max-height: 90px !important;
}
.widget-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.widget-ontime-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
}
.ontime-svg {
  display: block;
}

/* ── Reports Date Filter ────────────────────────────────── */
.reports-date-filter {
  display: flex;
  gap: 6px;
  padding: 0 0 16px;
  flex-wrap: wrap;
}
.date-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.date-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-dim);
}
.date-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Responsive: Widgets ────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .dashboard-widgets {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-widgets .widget-card:last-child {
    grid-column: 1 / -1;
    max-width: 50%;
    justify-self: center;
  }
}
