/* Quayside Design Tokens — see BRAND.md for full documentation */

:root {
  /* Palette */
  --ink: #0f1820;
  --paper: #e8ecf0;
  --tide: #1c2b35;
  --salt: #d0d8e0;
  --catch: #c8401a;
  --foam: #f4f6f8;
  --muted: #6a7a88;
  --rule: #c0cad4;

  /* Semantic */
  --up: #4aaa6a;
  --down: #c85040;

  /* Extended palette */
  --ink-body: #3a4a58;     /* cool dark slate — body text on light backgrounds */
  --tide-light: #7ab0c8;   /* light teal — text on dark/teal backgrounds */
  --ink-deep: #2a3a48;     /* very dark slate — footer, secondary dark text */

  /* Zone backgrounds */
  --zone-nav: #1c2b35;
  --zone-deep: #0f1820;
  --zone-mid: #162028;
  --zone-strip: #141e24;

  /* Rule weights */
  --rule-heavy: 3px solid var(--tide);
  --rule-light: 1px solid var(--rule);
  --rule-deep: 1px solid #0a1218;

  /* Typography */
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

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

body {
  font-family: var(--font-sans);
  font-weight: 300;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Nav wrapper (scroll-aware sticky container) ── */
.nav-wrapper {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}
.nav-wrapper.nav-hidden {
  transform: translateY(-100%);
}
@media (prefers-reduced-motion: reduce) {
  .nav-wrapper { transition: none; }
}
/* Ticker hidden at top of page — appears only when scrolling back up mid-page */
body.is-at-top .ticker-wrap {
  display: none;
}

/* ── Nav ── */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-bottom: none;
  background: var(--zone-nav);
}
.nav-brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #e8eef2;
  text-decoration: none;
}
.nav-brand span { color: var(--catch); }
.nav-links {
  display: flex;
  gap: 28px;
  align-items: center;
}
.nav-links a {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5a7a8a;
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover { color: #e8eef2; }

/* ── Burger ── */
.nav-burger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav-burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #e8eef2;
  border-radius: 1px;
}

/* ── Dashboard simplified nav ── */
.nav--dashboard .nav-links--dashboard {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
}
.nav--dashboard .nav-burger--visible {
  display: flex;
}
.nav--dashboard .nav-dropdown-menu--right {
  left: auto;
  right: 0;
  transform: none;
}

/* ── Nav dropdowns ── */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5a7a8a;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.nav-dropdown-toggle:hover { color: #e8eef2; }
.nav-caret {
  font-size: 8px;
  margin-left: 2px;
  transition: transform 0.2s;
}
.nav-dropdown.active .nav-caret {
  transform: rotate(180deg);
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-top: 8px;
  min-width: 140px;
  z-index: 200;
}
.nav-dropdown-menu-inner {
  background: var(--zone-mid);
  border: 1px solid #1e2e38;
  border-radius: 2px;
  overflow: hidden;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.active .nav-dropdown-menu {
  display: block;
}
.nav-dropdown-menu a {
  display: block;
  padding: 8px 16px !important;
  font-size: 11px;
  white-space: nowrap;
  color: #5a7a8a;
  border-bottom: 1px solid #1e2e38;
}
.nav-dropdown-menu a:hover {
  color: #e8eef2;
  background: rgba(255,255,255,0.05);
}
.nav-dropdown-menu a:last-child {
  border-bottom: none;
}
.nav-dropdown-sep {
  height: 1px;
  background: var(--rule);
  margin: 4px 0;
}
.nav-dropdown-header {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mid);
  padding: 0.4rem 1rem 0.2rem;
}

/* ── Sign In button ── */
.nav-signin-btn {
  font-family: var(--font-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  color: var(--catch) !important;
  border: 1px solid var(--catch) !important;
  padding: 6px 14px !important;
  border-radius: 2px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s !important;
  white-space: nowrap;
}
.nav-signin-btn:hover {
  background: var(--catch) !important;
  color: white !important;
}
.nav-signin-toggle {
  background: none;
  cursor: pointer;
}

/* ── Mobile nav ── */
@media (max-width: 768px) {
  .nav-burger { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--zone-nav);
    border-bottom: 1px solid #1e2e38;
    flex-direction: column;
    padding: 12px 32px 20px;
    gap: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a,
  .nav-dropdown-toggle {
    padding: 10px 0 !important;
    font-size: 12px;
    border-bottom: 1px solid #1e2e38;
    width: 100%;
    text-align: left;
  }
  .nav-dropdown { width: 100%; }
  .nav-dropdown-menu {
    position: static;
    transform: none;
    padding-top: 0;
    min-width: 0;
  }
  .nav-dropdown-menu-inner {
    border: none;
    border-radius: 0;
    background: transparent;
  }
  .nav-dropdown-menu a {
    padding: 8px 0 8px 20px !important;
    color: #5a7a8a;
  }
}

/* ── Container ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ── Section label ── */
.section-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
  max-width: 200px;
}

/* ── Cards ── */
.card {
  background: #ffffff;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--tide);
  border-radius: 2px;
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--tide);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 8px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
  border-bottom: 2px solid var(--tide);
}
td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--salt);
  vertical-align: middle;
}
.price {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 500;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 6px;
}
.badge-best {
  background: var(--tide);
  color: var(--foam);
}
.badge-below {
  background: rgba(200,64,26,0.1);
  color: var(--catch);
  border: 1px solid rgba(200,64,26,0.2);
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 2px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}
.btn-primary {
  background: var(--catch);
  color: white;
}
.btn-primary:hover { background: #a83010; transform: translateY(-1px); }
.btn-secondary {
  background: var(--foam);
  color: var(--tide);
  border: 1px solid var(--rule);
}
.btn-secondary:hover { background: var(--salt); }
.btn-danger {
  background: var(--catch);
  color: white;
}
.btn-ghost {
  color: var(--muted);
  background: none;
  border-bottom: 1px solid var(--rule);
  padding: 0 0 2px;
  border-radius: 0;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

/* ── Market bars ── */
.market-bar {
  height: 8px;
  background: var(--salt);
  border-radius: 2px;
  position: relative;
  margin: 4px 0;
}
.market-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--tide);
}
.market-bar-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 16px;
  background: var(--catch);
  border-radius: 2px;
}

/* ── Status dots ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-confirmed { background: var(--up); }
.status-pending { background: #b8860b; }
.status-none { background: var(--rule); }
.status-stale { background: #c8941a; }
.status-offline { background: var(--down); }

/* ── Flash messages ── */
.flash {
  padding: 12px 20px;
  border-radius: 2px;
  margin-bottom: 16px;
  background: var(--foam);
  border-left: 3px solid var(--tide);
  color: var(--tide);
  font-size: 14px;
}

/* ── Forms ── */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="file"],
select {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--tide);
}

/* ── Grade badge (table-specific) ── */
.grade-badge {
  display: inline-block;
  background: var(--salt);
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  color: var(--muted);
  letter-spacing: 0.04em;
  border: 1px solid var(--rule);
}

/* ── Utilities ── */
.text-mono {
  font-family: var(--font-mono);
}
.text-serif {
  font-family: var(--font-serif);
}
.text-muted {
  color: var(--muted);
}
.text-right {
  text-align: right;
}
.change-up {
  color: var(--up);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}
.change-down {
  color: var(--down);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

/* ── Market ticker ── */
.ticker-wrap {
  background: var(--zone-deep);
  color: #a8c8d8;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  overflow: hidden;
  padding: 8px 0;
  border-bottom: 2px solid #0a1218;
}
.ticker {
  display: flex;
  white-space: nowrap;
  animation: ticker 40s linear infinite;
}
.ticker span {
  padding: 0 40px;
  color: #d0e8f0;
}
.ticker span.up { color: var(--up); }
.ticker span.down { color: var(--down); }
.ticker-label {
  color: #3a6a7a;
  padding-right: 8px;
}
@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Smart Alert Cards ── */
.alert-cards-row {
  display: flex;
  gap: 14px;
  margin-bottom: 32px;
}
@media (max-width: 768px) { .alert-cards-row { flex-direction: column; } }
.alert-card {
  flex: 1;
  min-width: 0;
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 16px 18px;
  border-left-width: 4px;
  border-left-style: solid;
}
.alert-card--spike { border-left-color: var(--tide); }
.alert-card--spread { border-left-color: #c8941a; }
.alert-card--opportunity { border-left-color: var(--up); }
.alert-card--supply { border-left-color: var(--catch); }
.alert-card--calm { border-left-color: var(--rule); }
.alert-card-title {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.alert-card-body {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
}
.alert-card-body em {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--tide);
}
.alert-card-body .alert-price {
  font-weight: 500;
}
.alert-skeleton {
  background: var(--salt);
  border-radius: 2px;
  height: 60px;
  animation: pulse-skeleton 1.5s ease-in-out infinite;
}
@keyframes pulse-skeleton {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── Watchlist Cards ── */
/* ── Watchlist: full-width rows ── */
.watchlist-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.watchlist-card {
  background: #ffffff;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--tide);
  border-radius: 2px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.watchlist-card:hover { border-color: var(--tide); }
.watchlist-card-header {
  padding: 16px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.watchlist-card-species {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--ink);
}
.watchlist-card-cat {
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--salt);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 2px;
  margin-left: 8px;
  vertical-align: middle;
}
.watchlist-card-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.watchlist-card-changes {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  gap: 12px;
}
.watchlist-card-grid {
  display: grid;
  gap: 1px;
  background: var(--rule);
}
.watchlist-port-cell {
  background: #f8fafc;
  padding: 12px 14px;
  text-align: center;
}
.watchlist-port-cell.cell-best { background: rgba(28,43,53,0.04); }
.watchlist-port-cell.no-data {
  color: var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
}
.watchlist-port-name {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.watchlist-port-price {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.watchlist-port-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}
.watchlist-port-badge {
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 2px;
  background: rgba(200,148,26,0.15);
  color: #c8941a;
}
.watchlist-card-footer {
  padding: 9px 14px;
  border-top: none;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #4a6a7a;
  background: var(--zone-deep);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.watchlist-card-footer strong {
  color: #c8d8e0;
  font-weight: 500;
}
.watchlist-dive-link {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #4a6a7a;
  text-decoration: none;
  cursor: pointer;
}
.watchlist-dive-link:hover { color: #c8d8e0; }
.watchlist-dive-link:hover { text-decoration: underline; }
@media (max-width: 520px) {
  .watchlist-card-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .watchlist-card-changes { flex-direction: column; gap: 2px; }
}

/* ── Opportunity Rows ── */
.opp-section { margin-bottom: 24px; }
.opp-rows { background: #ffffff; border: 1px solid var(--rule); border-radius: 2px; }
.opp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 16px;
  border-bottom: 1px solid var(--salt);
  cursor: pointer;
  transition: background 0.1s;
  font-family: var(--font-mono);
  font-size: 12px;
}
.opp-row:last-child { border-bottom: none; }
.opp-row:hover { background: rgba(192,202,212,0.2); }
.opp-row-species {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink);
}
.opp-row-data {
  display: flex;
  gap: 16px;
  align-items: baseline;
}
.opp-row-data span {
  font-family: var(--font-mono);
  font-size: 12px;
}
.opp-quality-warn {
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 2px;
  background: rgba(200,148,26,0.15);
  color: #c8941a;
  margin-left: 6px;
}

/* ── Floating Chat FAB ── */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 400;
}
.chat-fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--tide);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transition: background 0.15s, transform 0.15s;
  color: #d0e8f0;
}
.chat-fab-btn:hover {
  background: #24394a;
  transform: scale(1.05);
}
.chat-fab-btn svg {
  width: 24px;
  height: 24px;
}
.chat-fab-label {
  position: absolute;
  right: 64px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tide);
  white-space: nowrap;
  background: #fff;
  padding: 4px 10px;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.chat-fab:hover .chat-fab-label { opacity: 1; }

/* FAB expanded */
.chat-fab.expanded .chat-fab-btn { display: none; }
.chat-fab.expanded .chat-fab-label { display: none; }

.chat-fab-panel {
  display: none;
  width: 360px;
  max-height: 480px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  overflow: hidden;
  flex-direction: column;
}
.chat-fab.expanded .chat-fab-panel {
  display: flex;
}

.chat-fab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--tide);
  color: #d0e8f0;
  flex-shrink: 0;
}
.chat-fab-header-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.chat-fab-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.chat-fab-close:hover { color: #fff; }

.chat-fab-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--salt);
  flex-shrink: 0;
}
.chat-fab-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 4px 10px;
  background: var(--foam);
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--tide);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.chat-fab-pill:hover { background: var(--tide); color: #d0e8f0; }

.chat-fab-messages {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
  min-height: 120px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.01em;
}
.chat-msg.system-msg {
  font-size: 11px;
  color: var(--muted);
  padding: 8px 0;
  max-width: 100%;
}
.chat-msg.user {
  background: var(--tide);
  color: var(--paper);
  align-self: flex-end;
}
.chat-msg.assistant {
  background: var(--foam);
  border: 1px solid var(--rule);
  color: var(--ink);
  align-self: flex-start;
}

.chat-fab-thinking {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  padding: 4px 16px 8px;
  letter-spacing: 0.03em;
}

.chat-fab-input-row {
  display: flex;
  border-top: 1px solid var(--salt);
  flex-shrink: 0;
}
.chat-fab-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 12px 16px;
  border: none;
  color: var(--ink);
  outline: none;
  background: var(--foam);
}
.chat-fab-input::placeholder { color: var(--rule); }
.chat-fab-send {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 16px;
  background: var(--catch);
  color: white;
  border: none;
  cursor: pointer;
  transition: opacity 0.1s;
}
.chat-fab-send:hover { opacity: 0.85; }
.chat-fab-send:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 520px) {
  .chat-fab { bottom: 16px; right: 16px; }
  .chat-fab.expanded { bottom: 0; right: 0; left: 0; }
  .chat-fab-panel { width: 100%; max-height: 70vh; border-radius: 8px 8px 0 0; }
  .chat-fab-label { display: none; }
}

/* ── Deep Dive Section ── */
.deepdive-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.deepdive-species-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 24px;
  color: var(--tide);
}
.deepdive-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.deepdive-kpi {
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 14px 16px;
}
.deepdive-kpi-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 2px;
}
.deepdive-kpi-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.deepdive-kpi-change {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

/* ── Stat Strip ── */
.stat-strip {
  background: var(--zone-strip);
  border-bottom: var(--rule-deep);
  padding: 10px 20px;
  display: flex;
  gap: 0;
}
.stat-item {
  flex: 1;
  padding-right: 20px;
  border-right: 1px solid #1e2e38;
}
.stat-item:first-child { padding-left: 0; }
.stat-item:not(:first-child) { padding-left: 20px; }
.stat-item:last-child { border-right: none; }
.stat-label {
  font-size: 8px;
  letter-spacing: 0.2em;
  color: #2a4a5a;
  text-transform: uppercase;
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 18px;
  font-weight: 500;
  color: #c8d8e0;
  font-family: var(--font-mono);
}
.stat-value--species em {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: #c8d8e0;
}
.stat-spread { color: var(--down); margin-left: 8px; }
.stat-sub {
  font-size: 9px;
  color: #2a4a5a;
  margin-top: 2px;
  font-family: var(--font-mono);
}
.stat-delta-up { color: var(--up); }
@media (max-width: 768px) {
  .stat-strip { flex-wrap: wrap; }
  .stat-item { flex: 1 1 45%; border-right: none; margin-bottom: 8px; }
}

/* ── Page Header Double-Rule ── */
.page-header {
  padding-bottom: 14px;
  margin-bottom: 0;
  border-bottom: var(--rule-heavy);
}
.page-header-rule {
  height: 1px;
  background: var(--rule);
  margin-bottom: 18px;
}

/* ── Species Summary Bar ── */
.species-summary-bar {
  padding: 9px 14px;
  font-size: 10px;
  color: #4a6a7a;
  background: var(--zone-deep);
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
}
.species-summary-bar .summary-value {
  color: #c8d8e0;
  font-weight: 500;
}
.species-summary-bar .summary-divider {
  color: #1e2e3a;
}

/* ── Port signup modal (nav trigger) ─────────────────────────────────────── */
.port-signup-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,24,32,0.72);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}
.port-signup-modal.active { display: flex; }
.port-signup-modal-inner {
  background: var(--foam);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  position: relative;
}
.port-signup-modal-inner h3 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--tide);
  margin: 0 0 4px;
}
.port-signup-modal-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}
.port-signup-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.port-signup-modal-close:hover { color: var(--ink); }
.psm-field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.psm-field label { font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.psm-field input {
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.psm-field input:focus { outline: none; border-color: var(--tide); }
.psm-field-row { display: flex; gap: 12px; margin-bottom: 12px; }
.psm-field { margin-bottom: 12px; }
.psm-field-row .psm-field { margin-bottom: 0; }
.psm-submit {
  width: 100%;
  background: var(--catch);
  color: #fff;
  border: none;
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 2px;
  margin-top: 4px;
}
.psm-submit:hover { opacity: 0.9; }

/* ── Upload first / loading / review pages ───────────────────────────────── */
.upload-first-wrap {
  max-width: 680px;
  margin: 60px auto;
  padding: 0 24px;
}
.upload-first-wrap h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--tide);
  margin: 0 0 8px;
}
.upload-first-wrap .uf-sub {
  color: var(--muted);
  margin: 0 0 32px;
}
.upload-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
@media (max-width: 520px) { .upload-cards { grid-template-columns: 1fr; } }
.upload-card {
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 24px;
  background: #fff;
}
.upload-card h3 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tide);
  margin: 0 0 10px;
}
.upload-card p { font-size: 0.9rem; color: var(--ink-body); margin: 0 0 16px; }
.dropzone {
  border: 2px dashed var(--rule);
  border-radius: 2px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}
.dropzone.dragover { border-color: var(--tide); background: var(--salt); }
.dropzone input[type=file] { display: none; }
.uf-submit-btn {
  display: block;
  width: 100%;
  background: var(--catch);
  color: #fff;
  border: none;
  padding: 13px 20px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 2px;
  margin-top: 16px;
  text-align: center;
}
.uf-submit-btn:hover { opacity: 0.9; }
.uf-template-link {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--tide);
  text-decoration: underline;
}

/* Loading screen */
.loading-wrap {
  max-width: 480px;
  margin: 100px auto;
  padding: 0 24px;
  text-align: center;
}
.loading-wrap h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--tide);
  margin: 0 0 32px;
}
.loading-stages { list-style: none; padding: 0; margin: 0 0 40px; text-align: left; }
.loading-stages li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.95rem;
  transition: color 0.3s;
}
.loading-stages li.active { color: var(--tide); font-weight: 500; }
.loading-stages li.done { color: var(--up); }
.stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rule);
  flex-shrink: 0;
  transition: background 0.3s;
}
.loading-stages li.active .stage-dot { background: var(--tide); }
.loading-stages li.done .stage-dot { background: var(--up); }
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--salt);
  border-top-color: var(--tide);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Review page */
.review-wrap {
  max-width: 860px;
  margin: 48px auto;
  padding: 0 24px 80px;
}
.review-wrap h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--tide);
  margin: 0 0 4px;
}
.review-sub { color: var(--muted); margin: 0 0 28px; font-size: 0.95rem; }
.review-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 16px; }
.review-table th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 2px solid var(--rule);
  text-align: left;
  background: var(--foam);
}
.review-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-body);
  vertical-align: middle;
}
.review-table td[contenteditable=true]:focus {
  outline: 2px solid var(--tide);
  border-radius: 2px;
  background: #fff;
}
.review-table .del-row {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 2px;
}
.review-table .del-row:hover { color: var(--down); }
.review-add-row {
  background: none;
  border: 1px dashed var(--rule);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 7px 14px;
  cursor: pointer;
  border-radius: 2px;
  margin-bottom: 28px;
}
.review-add-row:hover { border-color: var(--tide); color: var(--tide); }
.review-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.review-publish-btn {
  background: var(--catch);
  color: #fff;
  border: none;
  padding: 13px 28px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 2px;
}
.review-publish-btn:hover { opacity: 0.9; }
.review-back-link { color: var(--muted); font-size: 0.875rem; text-decoration: underline; }

/* Register confirm page */
.register-confirm-wrap {
  max-width: 420px;
  margin: 80px auto;
  padding: 0 24px;
}
.register-confirm-wrap h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--tide);
  margin: 0 0 6px;
}
.register-confirm-wrap .rc-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 28px;
}
.rc-readonly-block {
  background: var(--salt);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.rc-readonly-block .rc-row {
  display: flex;
  gap: 8px;
  font-size: 0.875rem;
  margin-bottom: 4px;
}
.rc-readonly-block .rc-row:last-child { margin-bottom: 0; }
.rc-readonly-block .rc-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-width: 70px;
}
.rc-readonly-block .rc-val { color: var(--ink); font-weight: 500; }
.rc-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.rc-field label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.rc-field input {
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
}
.rc-field input:focus { outline: none; border-color: var(--tide); }
.rc-submit {
  width: 100%;
  background: var(--catch);
  color: #fff;
  border: none;
  padding: 13px 20px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 2px;
  margin-top: 6px;
}
.rc-submit:hover { opacity: 0.9; }
.rc-expiry-wrap {
  max-width: 420px;
  margin: 80px auto;
  padding: 24px;
  text-align: center;
}
.rc-expiry-wrap h2 {
  font-family: var(--font-serif);
  color: var(--tide);
  margin-bottom: 12px;
}
.rc-expiry-wrap p { color: var(--ink-body); margin-bottom: 20px; }
