:root {
  /* ── Color tokens (unchanged) ── */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: #e2e5e9;
  --border-light: #edf0f3;
  --text: #1a1d21;
  --text-secondary: #5f6b7a;
  --muted: #8b95a5;

  --accent: #0B5CAB;
  --accent-light: #e8f2fc;
  --accent-2: #3d7ec4;
  --warning: #d97b0d;

  --success: #1a9a5c;
  --success-light: #e6f7ef;
  --warn: #d97b0d;
  --warn-light: #fef5e6;
  --danger: #d93636;
  --danger-light: #fde8e8;

  /* ── Typography tokens ── */
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.65;

  /* ── Spacing tokens (4px grid) ── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 2.5rem;
  --space-9: 3rem;
  --space-10: 4rem;

  /* ── Radius tokens ── */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* ── Shadow tokens ── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);

  --navy-deep: #1a2f4a;

  /* Legacy aliases → map to accent/border system */
  --ocean-blue: #0B5CAB;
  --sky-blue: #0B5CAB;
  --sea-foam: #0B5CAB;
  --coral: var(--danger);
  --cream: #f7f8fa;
  --sand: #8b95a5;
}

/* ── Global typography baseline ── */
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--lh-normal);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 700;
  line-height: var(--lh-tight);
  margin-bottom: var(--space-3);
}

h1 { font-size: var(--text-2xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-lg); letter-spacing: -0.01em; }
h3 { font-size: var(--text-base); }

p, li, td, label {
  line-height: var(--lh-relaxed);
}

label {
  font-size: var(--text-sm);
  font-weight: 500;
}

.prose-width { max-width: 680px; }

/* ── UI utility classes (opt-in, additive) ── */
.ui-container {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 768px) {
  .ui-container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

.ui-section {
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
}

@media (min-width: 768px) {
  .ui-section {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
  }
}

.ui-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.ui-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  margin-bottom: var(--space-4);
}

@media (min-width: 768px) {
  .ui-title {
    font-size: var(--text-3xl);
  }
}

.ui-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--lh-normal);
  margin-bottom: var(--space-4);
}

.ui-muted {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: var(--lh-normal);
}

.ui-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.ui-stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ui-stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.ui-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.ui-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-4) 0;
  border: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-2);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Content container ── */
.content-container {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary:hover {
  background: var(--accent-2);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--accent-light);
  color: var(--accent-2);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #c52f2f;
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.card-body {
  padding: 1.25rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  position: relative;
  border-top: 2px solid var(--accent);
}

/* ── Tags ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.tag-accent {
  background: var(--accent-light);
  color: var(--accent);
  border-color: transparent;
}

.tag-success {
  background: var(--success-light);
  color: var(--success);
  border-color: transparent;
}

.tag-warn {
  background: var(--warn-light);
  color: var(--warn);
  border-color: transparent;
}

.tag-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: transparent;
}

/* ── Page title ── */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

@media (min-width: 768px) {
  .page-title {
    font-size: 2rem;
  }
}

/* ── Topbar / Header ── */
.topbar {
  background: var(--navy-deep);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.topbar a,
.topbar button {
  color: rgba(255,255,255,0.85);
  transition: color 0.15s ease, background 0.15s ease;
}

.topbar a:hover,
.topbar button:hover {
  color: #fff;
}

.nav-item {
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* ── Language toggle pill ── */
.lang-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 2px;
  gap: 0;
}

.lang-pill a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.15s ease;
  color: rgba(255,255,255,0.55);
}

.lang-pill a:hover {
  color: rgba(255,255,255,0.85);
}

.lang-pill a.lang-active {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ── User email truncate ── */
.user-email-truncate {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

@media (min-width: 1024px) {
  .user-email-truncate {
    max-width: 180px;
  }
}

/* ── Legacy class overrides ── */
.ocean-gradient {
  background: var(--navy-deep);
  color: #fff;
}

.porthole-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.maritime-header {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.wave-border {
  position: relative;
  border-bottom: none;
}

.wave-border::after {
  display: none;
}

.rope-divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

/* ── Dashboard tiles ── */
.dash-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.dash-tile:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

.dash-tile .tile-icon {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
  opacity: 0.55;
}

.dash-tile .tile-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}

.dash-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.dash-hero:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

.dash-hero-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.dash-hero-primary:hover {
  background: var(--accent-2);
  color: #fff;
}

/* ── Inverted text on colored backgrounds ──
   Apply .text-on-color to ANY element with a blue/accent/dark background.
   Forces all children (headings, links, paragraphs, spans, etc.) to white.
   This prevents global rules like h1-h6{color:var(--text)} from showing
   dark text on colored surfaces. */
.text-on-color,
.text-on-color *,
.dash-hero-primary,
.dash-hero-primary * {
  color: #fff !important;
}

.text-on-color a,
.dash-hero-primary a {
  color: #fff !important;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.4);
}

.text-on-color a:hover,
.dash-hero-primary a:hover {
  text-decoration-color: #fff;
}

.text-on-color .opacity-80,
.dash-hero-primary .opacity-80 {
  color: rgba(255,255,255,0.8) !important;
}

.text-on-color .opacity-50,
.dash-hero-primary .opacity-50 {
  color: rgba(255,255,255,0.5) !important;
}

.text-on-color .opacity-60,
.dash-hero-primary .opacity-60 {
  color: rgba(255,255,255,0.6) !important;
}

.text-on-color .text-secondary,
.dash-hero-primary .text-secondary,
.text-on-color .ui-muted,
.dash-hero-primary .ui-muted {
  color: rgba(255,255,255,0.7) !important;
}

/* ── Form inputs ── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  outline: none;
}

/* ── Dropdowns ── */
.dropdown-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: fadeSlideIn 0.15s ease;
}

.dropdown-content a:hover,
.dropdown-content button:hover {
  background: var(--surface-2);
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Login surface ── */
.login-surface {
  background: linear-gradient(180deg, var(--navy-deep) 0%, #0d3b5e 100%);
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

tr:hover td {
  background: var(--surface-2);
}

/* ── Alerts ── */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(26,154,92,0.2);
}

.alert-warn {
  background: var(--warn-light);
  color: var(--warn);
  border: 1px solid rgba(217,123,13,0.2);
}

.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(217,54,54,0.2);
}

/* ── Footer ── */
.footer-bar {
  background: var(--navy-deep);
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  padding: 1.5rem 0;
  text-align: center;
  margin-top: 3rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.footer-bar strong {
  color: rgba(255,255,255,0.85);
}

/* ── Global overrides: remap old gradient action buttons to solid accent ── */
button[style*="linear-gradient"],
a[style*="linear-gradient"] {
  background: var(--accent) !important;
  border: none !important;
}

div[style*="linear-gradient"]:not(.login-surface) {
  background: var(--accent) !important;
}

/* ── Off-canvas drawer ── */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.nav-overlay.overlay-visible {
  opacity: 1;
  visibility: visible;
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--navy-deep);
  color: rgba(255,255,255,0.85);
  z-index: 999;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(0,0,0,0.25);
}

.nav-drawer.drawer-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drawer-brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  opacity: 0.85;
}

.drawer-brand span {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

.drawer-brand .drawer-boat-name {
  font-weight: 500;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
}

.drawer-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s ease;
}

.drawer-close-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  -webkit-overflow-scrolling: touch;
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  border-radius: 0;
}

.drawer-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.drawer-link-active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left: 3px solid var(--accent);
  padding-left: calc(1.15rem - 3px);
}

.drawer-link .drawer-icon {
  font-size: 1.05rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.drawer-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.35rem 0;
}

.drawer-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.7rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.drawer-section-toggle:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.drawer-section-toggle .drawer-icon {
  font-size: 1.05rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.drawer-section-toggle .drawer-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.drawer-arrow {
  transition: transform 0.2s ease;
  opacity: 0.5;
}

.drawer-sub-links {
  padding-left: 1rem;
}

.drawer-sub-links .drawer-link {
  font-size: 0.82rem;
  padding: 0.55rem 1.15rem;
  color: rgba(255,255,255,0.6);
}

.drawer-sub-links .drawer-link:hover {
  color: rgba(255,255,255,0.9);
}

.drawer-sub-links .drawer-link-active {
  color: #fff;
}

.drawer-footer {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.drawer-user-info {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-user-info strong {
  color: rgba(255,255,255,0.85);
}

.drawer-logout-btn {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
}

.drawer-logout-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.drawer-scroll-lock {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* ── Desktop: hide drawer, show horizontal nav ── */
@media (min-width: 1024px) {
  .nav-drawer,
  .nav-overlay,
  #drawer-open {
    display: none !important;
  }
}

/* ── Mobile: hide desktop horizontal nav ── */
@media (max-width: 1023px) {
  .desktop-nav {
    display: none !important;
  }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .page-title {
    font-size: 1.25rem;
  }

  .card-body {
    padding: 1rem;
  }

  .btn {
    padding: 0.55rem 1rem;
  }
}

/* ══════════════════════════════════════════
   MOBILE TOUCH ERGONOMICS (<1024px)
   ══════════════════════════════════════════ */
@media (max-width: 1023px) {

  /* A) Touch targets: min 44px height for all interactive elements */
  .btn,
  button,
  input[type="submit"],
  a.btn,
  .maneuver-btn,
  .touch-action {
    min-height: 44px;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea {
    min-height: 44px;
    padding: 0.55rem 0.75rem;
  }

  /* Checkbox/radio hit areas */
  label:has(input[type="checkbox"]),
  label:has(input[type="radio"]) {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.35rem 0;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
  }

  /* Form spacing */
  .space-y-6 > * + * {
    margin-top: 1.25rem;
  }

  /* Grid: single column on mobile, 2-col for maneuver tiles */
  .grid.grid-cols-2.md\\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* H1 sizing */
  h1 {
    font-size: 1.35rem !important;
  }

  /* Labels readable */
  label {
    font-size: 0.88rem;
  }

  /* Avoid light grey on important text */
  .font-medium,
  .font-semibold,
  .font-bold {
    color: var(--text);
  }

  /* Reef radio pills: taller on mobile */
  .peer-checked\\:bg-blue-600 + div,
  label:has(input[type="radio"].peer) {
    min-height: 44px;
  }
}

/* ══════════════════════════════════════════
   LOGBOOK MOBILE SECTIONS (accordions)
   ══════════════════════════════════════════ */
.logbook-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.logbook-section > summary {
  padding: 0.85rem 1rem;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-user-select: none;
  user-select: none;
  color: var(--text);
  background: var(--surface);
  transition: background 0.15s ease;
}

.logbook-section > summary:hover {
  background: var(--surface-2);
}

.logbook-section > summary::-webkit-details-marker {
  display: none;
}

.logbook-section > summary::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.logbook-section[open] > summary::after {
  transform: rotate(45deg);
}

.logbook-form-wrapper details.porthole-card > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.logbook-form-wrapper details.porthole-card > summary::-webkit-details-marker {
  display: none;
}

.logbook-form-wrapper details.porthole-card > summary::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.logbook-form-wrapper details.porthole-card[open] > summary::after {
  transform: rotate(45deg);
}

.logbook-section > .logbook-section-body {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border-light);
}

/* ══════════════════════════════════════════
   LOGBOOK STICKY ACTION BAR (mobile)
   ══════════════════════════════════════════ */
.logbook-sticky-bar {
  display: none;
}

@media (max-width: 1023px) {
  .logbook-sticky-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: rgba(255,255,255,0.92);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
    padding: 0.6rem 0.75rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    gap: 0.5rem;
    align-items: center;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

  .logbook-sticky-bar .btn {
    flex: 1;
    min-height: 44px;
    justify-content: center;
    font-size: 0.82rem;
    padding: 0.5rem 0.5rem;
    white-space: nowrap;
  }

  .logbook-sticky-bar .sticky-back {
    flex: 0 0 auto;
    min-width: 44px;
    padding: 0.5rem;
  }

  .logbook-form-wrapper {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  .has-sticky-actions .js-original-quick-fill {
    display: none;
  }

  .has-sticky-actions .logbook-bottom-actions {
    display: none;
  }
}

/* ══════════════════════════════════════════
   DESKTOP UI REFINEMENT (>=1024px)
   Pure visual pass — no layout/logic changes
   ══════════════════════════════════════════ */
@media (min-width: 1024px) {

  /* ── 1) Header: compact 56px, refined nav ── */
  .topbar {
    padding-top: 0;
    padding-bottom: 0;
  }

  .topbar > div {
    min-height: 56px;
  }

  .nav-item {
    background: none;
    border-radius: 0;
    padding: 0.5rem 0.65rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: 0.82rem;
  }

  .nav-item:hover {
    background: none;
    color: #fff;
    border-bottom-color: rgba(255,255,255,0.35);
  }

  .nav-item.nav-active,
  .nav-item[aria-current="page"] {
    background: none;
    color: #fff;
    border-bottom-color: var(--accent);
  }

  .nav-item .drawer-icon,
  .nav-item > span:first-child {
    opacity: 0.85;
  }

  .nav-item:hover .drawer-icon,
  .nav-item:hover > span:first-child {
    opacity: 1;
  }

  /* ── 2) Typography: SyntechAI heading scale ── */
  h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    color: #0f172a;
  }

  h2 {
    font-size: 1.5rem;
    font-weight: 650;
    line-height: 1.25;
    color: #0f172a;
  }

  h3 {
    font-size: 1.175rem;
    font-weight: 600;
    line-height: 1.3;
    color: #0f172a;
  }

  .ui-title {
    font-size: 2rem;
  }

  /* ── 3) Card system: unified, subtle ── */
  .card,
  .porthole-card,
  .dash-tile,
  .dash-hero,
  .ui-card {
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .card:hover,
  .porthole-card:hover,
  .dash-tile:hover,
  .dash-hero:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  }

  .kpi-card {
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    border-top: 2px solid var(--accent);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  }

  /* Card internal padding consistency */
  .card-body,
  .porthole-card > .p-6,
  .porthole-card > div {
    padding: 1.25rem;
  }

  /* ── 4) Form inputs: 44px height, 10px radius, focus glow ── */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea {
    border: 1px solid #D1D5DB;
    border-radius: 10px;
    background: #ffffff;
    min-height: 44px;
    font-size: 0.95rem;
  }

  input[type="text"]:focus,
  input[type="email"]:focus,
  input[type="password"]:focus,
  input[type="number"]:focus,
  input[type="date"]:focus,
  input[type="time"]:focus,
  input[type="datetime-local"]:focus,
  select:focus,
  textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    outline: none;
  }

  ::placeholder {
    color: #94a3b8;
    opacity: 0.6;
  }

  label {
    font-weight: 500;
    color: #1e293b;
  }

  .space-y-4 > * + * {
    margin-top: 1.15rem;
  }

  /* ── 5) Section headings ── */
  .maritime-header {
    font-size: 20px;
    font-weight: 600;
    color: #1F2937;
  }

  h2.maritime-header {
    margin-top: 32px;
    margin-bottom: 16px;
  }

  .rope-divider {
    background: #E5E7EB;
    height: 1px;
  }

  /* ── 6) Table refinement ── */
  th {
    background: #F8FAFC;
    color: #334155;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.82rem;
  }

  tr:nth-child(even) td {
    background: #FAFBFC;
  }

  tr:hover td {
    background: #F1F5F9;
  }

  /* ── 7) Buttons: 12px radius, 44px height, crisp ── */
  .btn {
    border-radius: 12px;
    font-weight: 600;
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
    border-radius: 10px;
  }

  .btn-primary {
    background: #1F4E8C;
    border-color: #1F4E8C;
  }

  .btn-primary:hover {
    background: #173B6B;
    border-color: #173B6B;
  }

  .btn-secondary {
    background: #ffffff;
    color: #1F2937;
    border-color: #E5E7EB;
  }

  .btn-secondary:hover {
    background: #F3F4F6;
  }

  .btn-danger {
    background: #DC2626;
    border-color: #DC2626;
    border-radius: 12px;
  }

  .btn-danger:hover {
    background: #B91C1C;
    border-color: #B91C1C;
  }

  .ocean-gradient {
    background: #1F4E8C !important;
    border-radius: 12px;
  }

  .ocean-gradient:hover {
    background: #173B6B !important;
  }

  /* ── 8) Status badges / pills ── */
  .tag,
  .tag-accent,
  .tag-success,
  .tag-warn,
  .tag-danger,
  span[class*="bg-green"],
  span[class*="bg-red"],
  span[class*="bg-yellow"],
  span[class*="bg-blue"] {
    border-radius: 12px;
    padding: 0.25rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .tag-success,
  span[class*="bg-green"] {
    background: #dcfce7;
    color: #15803d;
  }

  .tag-danger,
  span[class*="bg-red"] {
    background: #fee2e2;
    color: #b91c1c;
  }

  .tag-warn,
  span[class*="bg-yellow"] {
    background: #fef3c7;
    color: #92400e;
  }

  .tag-accent,
  span[class*="bg-blue"] {
    background: #dbeafe;
    color: #1e40af;
  }

  /* ── 9) Language toggle refinement ── */
  .lang-pill {
    background: rgba(255,255,255,0.1);
    border-radius: 999px;
    padding: 3px;
  }

  .lang-pill a {
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 999px;
    transition: all 0.15s ease;
  }

  .lang-pill a.lang-active {
    background: rgba(255,255,255,0.22);
    color: #fff;
  }

  /* ── 10) User/logout chip: calmer ── */
  .user-email-truncate {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.7);
  }

  /* Logbook sections: unified card on desktop */
  .logbook-section {
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  }
}
