/* St. Paul Fleet Dashboard — dark ocean theme */
:root {
    --bg:       #0d1550;
    --surface:  #152070;
    --surface2: #1a2878;
    --border:   rgba(255,61,46,0.18);
    --accent:   #ff3d2e;
    --accent2:  #ff8c42;
    --gold:     #ffd700;
    --warn:     #ffcc00;
    --text:     #cde0f2;
    --muted:    rgba(205,224,242,0.66);
    --radius:   10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
}

/* ── Header ─────────────────────────────────────── */
header {
    background: linear-gradient(135deg, #060f1f 0%, #0c2040 100%);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.header-brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #003a5c, #005a8e);
    border: 1px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; color: var(--accent);
}
.brand-title { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.brand-sub   { font-size: 0.74rem; color: var(--muted); margin-top: 2px; }
.header-right { text-align: right; }
.clock       { font-size: 1.3rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.header-date { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.status-row  { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill {
    font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--muted);
    display: flex; align-items: center; gap: 4px;
    background: var(--surface2); border: 1px solid var(--border);
    padding: 3px 8px; border-radius: 20px;
}

/* ── Ticker banner ───────────────────────────────── */
.ticker-wrap {
    display: flex;
    align-items: center;
    background: rgba(0,200,255,0.07);
    border-bottom: 1px solid rgba(0,200,255,0.18);
    overflow: hidden;
    height: 34px;
}
.ticker-label {
    flex-shrink: 0;
    background: var(--accent);
    color: #000;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 0 12px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.ticker-track {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}
.ticker-content {
    display: inline-block;
    animation: ticker-scroll 35s linear infinite;
    font-size: 0.82rem;
    color: var(--text);
}
@keyframes ticker-scroll {
    0%   { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}

/* ── Tabs — buoy button ──────────────────────────── */
@keyframes buoyBob {
    0%,100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-5px) rotate(-1deg); }
}
/* Wrapper carries a right-edge fade so it's obvious the buoy row scrolls
   horizontally when not all tabs fit (narrow screens). */
.tab-bar-wrap { position: relative; }
.tab-bar-wrap::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 40px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(90,111,168,0), #5a6fa8);
}
@media (min-width: 920px) { .tab-bar-wrap::after { display: none; } }
.tab-bar {
    background: #5a6fa8;
    border-bottom: 2px solid rgba(0,0,0,0.3);
    display: flex;
    overflow-x: auto;
    padding: 4px 14px 2px;
    gap: 6px;
    align-items: flex-end;
}
.tab-bar::-webkit-scrollbar { height: 3px; }
.tab-bar::-webkit-scrollbar-thumb { background: #ef3a3a; border-radius: 3px; }
.tab {
    position: relative;
    display: inline-block;
    width: 120px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    animation: buoyBob 4.5s ease-in-out infinite;
    transition: transform 0.18s ease;
    flex-shrink: 0;
    opacity: 0.72;
}
.tab:hover {
    transform: translateY(-5px) scale(1.05);
    opacity: 1;
}
.tab.active {
    opacity: 1;
    transform: translateY(-3px) scale(1.08);
    animation: buoyBob 2.5s ease-in-out infinite;
}
.tab-buoy {
    width: 100%;
    height: 54px;
    object-fit: cover;
    object-position: center;
    display: block;
    filter: drop-shadow(0 8px 14px rgba(0,0,0,0.32));
}
.tab.active .tab-buoy {
    filter: drop-shadow(0 8px 18px rgba(239,58,58,0.5));
}
.tab-label {
    position: absolute;
    top: 50%;
    left: 58%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(100,0,0,0.6);
    pointer-events: none;
    font-family: inherit;
}
.tab-content  { display: none; }
.tab-content.active { display: block; }

/* ── Grid ────────────────────────────────────────── */
.grid {
    max-width: 1400px; margin: 0 auto;
    padding: 14px; display: grid;
    grid-template-columns: repeat(12, 1fr); gap: 12px;
}
.col-4  { grid-column: span 4; }
.col-6  { grid-column: span 6; }
.col-8  { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* ── Cards ───────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; overflow: hidden;
}
.card-title {
    font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--accent); margin-bottom: 12px;
    display: flex; align-items: center; gap: 6px;
}

/* ── Alert banner ────────────────────────────────── */
.alert-banner {
    background: linear-gradient(90deg, #7f1d1d, #991f1f);
    border: 1px solid #ef4444; border-radius: 8px;
    padding: 10px 16px; color: #fecaca;
    font-weight: 600; font-size: 0.88rem;
}

/* ── Big stat row (overview) ─────────────────────── */
.big-stat-row { display: flex; gap: 8px; flex-wrap: wrap; }
.big-stat { flex: 1; min-width: 70px; background: var(--surface2); border-radius: 7px; padding: 10px 12px; }
.bs-label { font-size: 0.63rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
.bs-value { font-size: 1.3rem; font-weight: 700; color: #fff; margin-top: 3px; line-height: 1.2; }
.bs-value.accent  { color: var(--accent); }
.bs-value.accent2 { color: var(--accent2); }
.bs-value.warn    { color: var(--warn); }
.bs-sub { font-size: 0.68rem; color: var(--muted); }

/* ── Detail grid (weather tab) ───────────────────── */
.detail-grid { display: flex; flex-direction: column; gap: 0; }
.dg-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.dg-row:last-child { border-bottom: none; }
.dg-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }
.dg-value { font-size: 0.95rem; font-weight: 600; color: #fff; text-align: right; }
.dg-value.big-val { font-size: 1.2rem; color: var(--accent); }
.dg-value.warn { color: var(--warn); }

/* ── Flight category badge ───────────────────────── */
.cat-badge {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 1px;
}
.vfr  { background: #14532d; color: #4ade80; }
.mvfr { background: #1e3a5f; color: #60a5fa; }
.ifr  { background: #7f1d1d; color: #f87171; }
.lifr { background: #4c1d95; color: #c084fc; }

/* ── Marine summary (overview) ───────────────────── */
.marine-summary { font-size: 0.82rem; line-height: 1.65; color: var(--text); }
.marine-period  { margin-bottom: 10px; }
.marine-period strong { color: var(--accent2); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.8px; display: block; }

/* ── Marine full (forecast tab) ──────────────────── */
.marine-full {
    font-size: 0.84rem; line-height: 1.7; color: var(--text);
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
}
.mp-card {
    background: var(--surface2); border-radius: 8px; padding: 12px;
    border-left: 3px solid var(--accent2);
}
.mp-card strong { color: var(--accent2); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.8px; display: block; margin-bottom: 5px; }

/* ── Forecast strip ──────────────────────────────── */
.forecast-strip {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px;
}
.forecast-strip::-webkit-scrollbar { height: 4px; }
.forecast-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.fc-period {
    min-width: 120px; background: var(--surface2); border-radius: 8px;
    padding: 12px; flex-shrink: 0; border-left: 3px solid var(--accent);
}
.fc-night { border-left-color: #7c3aed; }
.fc-period .fc-name { font-size: 0.68rem; color: var(--accent); font-weight: 700; text-transform: uppercase; }
.fc-night .fc-name  { color: #a78bfa; }
.fc-period .fc-temp { font-size: 1.5rem; font-weight: 700; color: #fff; margin: 5px 0 3px; }
.fc-period .fc-wind { font-size: 0.68rem; color: var(--muted); }
.fc-period .fc-precip { font-size: 0.68rem; color: #60a5fa; }
.fc-period .fc-desc { font-size: 0.72rem; color: var(--text); margin-top: 5px; }
.fc-skel { min-width: 120px; height: 100px; border-radius: 8px; }

/* ── Tides tab ───────────────────────────────────── */
.temp-display { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.temp-item { flex: 1; min-width: 120px; }
.temp-label { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.temp-big { font-size: 2.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.temp-big.accent2 { color: var(--accent2); }
.temp-unit { font-size: 1.1rem; }
.tide-table-wrap { overflow-x: auto; max-height: 340px; overflow-y: auto; }
.tide-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.tide-table th {
    text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.8px;
    color: var(--muted); padding: 8px 12px; text-align: left;
    border-bottom: 1px solid var(--border); position: sticky; top: 0;
    background: var(--surface);
}
.tide-table td { padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.tide-table tr:hover td { background: var(--surface2); }
.tide-high { color: var(--accent); font-weight: 700; }
.tide-low  { color: var(--muted); }
.tide-ht   { color: var(--gold); font-weight: 600; }
.tide-now  { background: rgba(0,200,255,0.06) !important; }

/* ── Tide history chart ──────────────────────────── */
.tide-chart-wrap { position: relative; height: 280px; width: 100%; }

/* ── Vessels tab ─────────────────────────────────── */
#ais-map {
    width: 100%; height: 360px;
    border-radius: 8px; border: 1px solid var(--border);
}
.leaflet-popup-content-wrapper {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border);
}
.leaflet-popup-tip { background: var(--surface2); }
.leaflet-container { background: #0a1628; }
.vessel-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.vessel-table th {
    text-transform: uppercase; font-size: 0.63rem; letter-spacing: 0.8px;
    color: var(--muted); padding: 7px 8px; text-align: left;
    border-bottom: 1px solid var(--border);
}
.vessel-table td { padding: 8px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.vessel-table tr:hover td { background: var(--surface2); }
.vessel-name { font-weight: 600; color: #fff; font-size: 0.82rem; }
.vessel-type { font-size: 0.62rem; padding: 1px 6px; border-radius: 10px; background: rgba(0,200,255,0.12); color: var(--accent); font-weight: 600; }
.dist-nm { color: var(--gold); font-weight: 700; }

/* ── Overview vessel quick list ──────────────────── */
.ov-vessel-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 10px; background: var(--surface2); border-radius: 7px; margin-bottom: 6px;
}
.ov-vessel-row:last-child { margin-bottom: 0; }
.ov-vname { font-weight: 600; color: #fff; font-size: 0.83rem; }
.ov-vinfo { font-size: 0.75rem; color: var(--muted); }
.ov-vdist { font-size: 0.85rem; color: var(--gold); font-weight: 700; }

/* ── Shared ──────────────────────────────────────── */
.ts { font-size: 0.63rem; color: var(--muted); margin-top: 10px; display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.live  { background: var(--accent2); box-shadow: 0 0 5px var(--accent2); animation: dpulse 2s infinite; }
.dot.stale { background: var(--warn); }
.dot.off   { background: #444; }
@keyframes dpulse { 0%,100%{opacity:1}50%{opacity:.35} }

.skel {
    background: linear-gradient(90deg, var(--surface2) 25%, rgba(255,255,255,0.04) 50%, var(--surface2) 75%);
    background-size: 400% 100%; animation: shimmer 1.5s infinite;
    border-radius: 4px; height: 1em; margin: 5px 0;
}
@keyframes shimmer { 0%{background-position:100% 50%}100%{background-position:0 50%} }

.loading-cell { color: var(--muted); padding: 18px; text-align: center; font-size: 0.82rem; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 960px) {
    .col-4, .col-6 { grid-column: span 6; }
    .col-8 { grid-column: span 12; }
}
@media (max-width: 600px) {
    .col-4, .col-6, .col-8 { grid-column: span 12; }
    header { flex-direction: column; align-items: flex-start; }
    .header-right { text-align: left; }
    .status-row { justify-content: flex-start; }
}
