/* ============================================
   Boat Trajectory Prediction & Live Monitoring System
   ============================================ */

:root {
    /* Dark Monitoring Palette */
    --primary: #b6ab75;
    --primary-dark: #9e9463;
    --primary-light: #d4c98f;
    --primary-glow: rgba(182, 171, 117, 0.4);
    --secondary: #003930;
    --secondary-glow: rgba(0, 57, 48, 0.3);
    --accent: #b6ab75;
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Dark Theme Surfaces */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(15, 23, 42, 0.8);
    --bg-card-solid: #0f172a;
    --bg-hover: rgba(30, 41, 59, 0.8);
    --bg-elevated: rgba(30, 41, 59, 0.6);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #8899ab;
    --border: rgba(51, 65, 85, 0.6);
    --border-light: rgba(71, 85, 105, 0.4);
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(182, 171, 117, 0.15);

    /* Input field background — separate token so light mode can flip it cleanly */
    --bg-input: rgba(15, 23, 42, 0.9);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px var(--primary-glow);
    --shadow-glow-hover: 0 0 35px var(--primary-glow);
    --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 1px rgba(182, 171, 117, 0.1);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Borders */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout — sidebar offset (rem so they scale with the root font on big screens) */
    --sidebar-width: 16.25rem;
    --header-height: 4rem;
}

/* Responsive root scale. The whole UI is rem-based — even --spacing-* and
   --radius-* — so the root font-size is the single knob that scales text,
   spacing, radius and the sidebar together.
   clamp() holds a steady 16px up to ~1600px (phones→normal desktops are
   unchanged), then grows continuously with viewport width so there's no
   dead-zone or stepped jump, and caps at 44px so an 8K wall screen doesn't
   over-inflate. Growth: ~18px@1920, ~22px@2560, ~29px@3840. */
html {
    font-size: clamp(16px, calc(16px + (100vw - 1600px) * 0.006), 44px);
    scroll-behavior: smooth;
}

/* Base & Typography */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.7;
    direction: rtl;
    margin: 0;
    overflow-x: hidden;
}

/* Animated Radar Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(182, 171, 117, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 57, 48, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 40%);
}

body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: -1;
    background: conic-gradient(from 0deg at 50% 50%, transparent 0deg, rgba(182, 171, 117, 0.03) 30deg, transparent 60deg);
}

@media (prefers-reduced-motion: no-preference) {
    body::before { animation: bgPulse 15s ease-in-out infinite alternate; }
    body::after  { animation: radarSweep 20s linear infinite; }
}

@keyframes bgPulse {
    0% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

@keyframes radarSweep {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ─── Bootstrap Icons spin modifier ─── */
@media (prefers-reduced-motion: no-preference) {
    .bi-spin {
        animation: radarSweep 1s linear infinite;
    }
}

/* ─── Container ─── */
.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

body.fullscreen {
    overflow: hidden;
}

body.fullscreen .container {
    max-width: 100%;
    padding: 0;
}

body.fullscreen header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

body.fullscreen main {
    margin-top: 70px;
}

/* ─── Header — Dark Glass ─── */
header {
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(30px) saturate(1.5);
    -webkit-backdrop-filter: blur(30px) saturate(1.5);
    border-bottom: 1px solid var(--glass-border);
    padding: var(--spacing-xs) var(--spacing-lg);
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 4000;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    transition: all var(--transition-base);
    height: var(--header-height);
    display: flex;
    align-items: center;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--secondary), var(--primary), transparent);
    background-size: 300% 100%;
    opacity: 0;
}

body.page-loading header::before {
    opacity: 1;
    animation: headerLine 4s linear infinite;
}

@keyframes headerLine {
    0% {
        background-position: 300% 0;
    }

    100% {
        background-position: -300% 0;
    }
}

header:hover {
    box-shadow: 0 8px 40px rgba(182, 171, 117, 0.15);
}

.header-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 20px var(--primary-glow);
    transition: all var(--transition-bounce);
    position: relative;
}

.header-logo-icon::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    opacity: 0;
    z-index: -1;
    transition: opacity var(--transition-base);
    filter: blur(8px);
}

.header-logo-icon:hover {
    transform: scale(1.1) rotate(5deg);
}

.header-logo-icon:hover::after {
    opacity: 0.5;
}

header h1 {
    font-size: 1.15rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 40%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-align: right;
    letter-spacing: -0.3px;
    line-height: 1.4;
}

header h1 i {
    margin-left: var(--spacing-xs);
    font-size: 1rem;
}

header h1 .subtitle {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    -webkit-text-fill-color: var(--text-muted);
    margin-top: 1px;
    letter-spacing: 0;
}

/* ─── Navigation ─── */
header nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px var(--spacing-md);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--primary-light);
    background: rgba(182, 171, 117, 0.1);
    border-color: rgba(182, 171, 117, 0.2);
    transform: translateY(-2px);
}

.nav-link.active {
    color: white;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: 0 4px 15px var(--primary-glow);
    border-color: transparent;
    transform: translateY(-2px);
}

.nav-link.active i {
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    }

    50% {
        text-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    }
}

.nav-link i {
    font-size: 0.85rem;
    transition: transform var(--transition-base);
}

.nav-link:hover i {
    transform: scale(1.15);
}

/* ─── Main Content ─── */
main {
    padding: var(--spacing-md);
    padding-top: calc(var(--header-height) + var(--spacing-md));
    margin-top: 0;
    animation: fadeIn 0.6s ease;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Cards — Glass Morphism ─── */
.card,
.training-card {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.card::before,
.training-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card:hover::before,
.training-card:hover::before {
    opacity: 1;
}

.card:hover,
.training-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(182, 171, 117, 0.08);
    border-color: rgba(182, 171, 117, 0.25);
}

.card h2,
.training-card h2 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.card h2 i,
.training-card h2 i {
    color: var(--primary);
}

.card h3 {
    color: var(--primary);
    margin-bottom: var(--spacing-sm);
    font-size: 1.2rem;
    font-weight: 600;
}

/* Feature Cards */
.feature-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--primary);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    display: inline-block;
    transition: all var(--transition-bounce);
}

.feature-card:hover .feature-icon {
    transform: scale(1.15) rotate(5deg);
}

.feature-card:nth-child(1) .feature-icon {
    color: var(--primary);
}

.feature-card:nth-child(2) .feature-icon {
    color: var(--success);
}

.feature-card:nth-child(3) .feature-icon {
    color: var(--warning);
}

.feature-card:nth-child(4) .feature-icon {
    color: var(--accent);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(-1px);
}

.btn i {
    transition: transform var(--transition-base);
}

.btn:hover i {
    transform: scale(1.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 25px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(182, 171, 117, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: 0 4px 15px var(--success-glow);
}

.btn-success:hover {
    box-shadow: 0 6px 25px var(--success-glow);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: white;
}

.btn-warning:hover {
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--error), #dc2626);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-large {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.05rem;
}

.btn-small {
    padding: 6px var(--spacing-md);
    font-size: 0.85rem;
}

/* Full Screen Button */
.btn-fullscreen {
    position: fixed;
    top: 75px;
    right: 20px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-fullscreen:hover {
    transform: scale(1.1);
}

/* ─── Forms ─── */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px var(--spacing-md);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-base);
    font-family: inherit;
}

.form-control:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(182, 171, 117, 0.15), 0 0 20px rgba(182, 171, 117, 0.1);
    background: rgba(15, 23, 42, 1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* File Inputs */
input[type="file"] {
    padding: var(--spacing-sm);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-primary);
}

input[type="file"]:hover {
    border-color: var(--primary);
    border-style: solid;
}

input[type="file"]::file-selector-button {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    border: none;
    padding: 6px var(--spacing-md);
    border-radius: var(--radius-sm);
    margin-left: var(--spacing-sm);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
}

/* Folder Selection */
.folder-selector {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.folder-selector input[type="file"] {
    flex: 1;
}

.folder-path {
    padding: var(--spacing-sm);
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: var(--spacing-xs);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
}

/* Fixed two-column form grid that collapses to one column on small screens.
   Use for forms that want a deliberate 2-up layout (not auto-fit). */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

@media (max-width: 600px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ─── Status Messages ─── */
.status-message {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-md);
    border-right: 3px solid;
    animation: slideIn 0.4s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.status-message.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: #6ee7b7;
}

.status-message.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: #fca5a5;
}

.status-message.info {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--info);
    color: #93c5fd;
}

/* ─── Progress Bar ─── */
.progress-bar {
    width: 100%;
    height: 44px;
    background: var(--bg-hover);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: var(--spacing-md);
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary), var(--primary-light));
    background-size: 200% 100%;
    animation: progressShimmer 2s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    transition: width var(--transition-slow);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@keyframes progressShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ─── Status Badges ─── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 4px var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.info {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ─── Statistics Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    width: 100%;
}

.stat-card {
    background: linear-gradient(135deg, rgba(182, 171, 117, 0.15) 0%, rgba(0, 57, 48, 0.1) 100%);
    border: 1px solid rgba(182, 171, 117, 0.2);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    text-align: center;
    color: white;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(182, 171, 117, 0.08) 0%, transparent 70%);
    animation: statRotate 25s linear infinite;
}

@keyframes statRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.stat-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--primary);
}

.stat-icon {
    font-size: 2.2rem;
    margin-bottom: var(--spacing-sm);
    display: inline-block;
    transition: transform var(--transition-bounce);
}

.stat-card:hover .stat-icon {
    transform: scale(1.2);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    margin: var(--spacing-xs) 0;
    position: relative;
    z-index: 1;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.85;
    position: relative;
    z-index: 1;
    font-weight: 600;
}

/* Stat Card Variants */
.stat-card.primary {
    background: linear-gradient(135deg, rgba(182, 171, 117, 0.2), rgba(8, 145, 178, 0.1));
    border-color: rgba(182, 171, 117, 0.3);
}

.stat-card.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.1));
    border-color: rgba(16, 185, 129, 0.3);
}

.stat-card.warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.1));
    border-color: rgba(245, 158, 11, 0.3);
}

.stat-card.info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.1));
    border-color: rgba(59, 130, 246, 0.3);
}

.stat-card.accent {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.2), rgba(190, 24, 93, 0.1));
    border-color: rgba(244, 114, 182, 0.3);
}

.stat-card.secondary {
    background: linear-gradient(135deg, rgba(0, 57, 48, 0.2), rgba(124, 58, 237, 0.1));
    border-color: rgba(0, 57, 48, 0.3);
}

/* ─── Model Cards ─── */
.models-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-md);
}

.model-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-base);
    position: relative;
}

.model-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), 0 0 25px rgba(182, 171, 117, 0.1);
}

.model-card h3 {
    color: var(--primary);
    margin-bottom: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 700;
}

/* ─── Tooltips ─── */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    margin-right: 5px;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 260px;
    background: var(--bg-card-solid);
    color: var(--text-primary);
    text-align: center;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    position: absolute;
    z-index: 1000;
    bottom: 130%;
    right: 50%;
    margin-right: -130px;
    opacity: 0;
    transition: opacity var(--transition-base);
    font-size: 0.8rem;
    line-height: 1.5;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-xl);
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 50%;
    margin-right: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--bg-card-solid) transparent transparent transparent;
}

/* ─── Welcome Section ─── */
.welcome-section {
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-lg);
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    margin-bottom: var(--spacing-lg);
    width: 100%;
}

.welcome-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(182, 171, 117, 0.04) 0%, transparent 60%);
    animation: statRotate 40s linear infinite;
}

.welcome-section h2 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.welcome-section ul {
    list-style: none;
    text-align: right;
    max-width: 600px;
    margin: var(--spacing-lg) auto;
    position: relative;
    z-index: 1;
}

.welcome-section li {
    padding: var(--spacing-sm);
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

/* Cards Grid */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
    width: 100%;
}

.card {
    text-align: center;
}

/* ─── Info Box ─── */
.info-box {
    background: rgba(182, 171, 117, 0.08);
    border: 1px solid rgba(182, 171, 117, 0.2);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.info-box h4 {
    color: var(--primary);
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
}

.info-box ul {
    list-style: none;
    padding-right: var(--spacing-lg);
}

.info-box li {
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
    position: relative;
    padding-right: var(--spacing-md);
    font-size: 0.9rem;
}

.info-box li::before {
    content: '›';
    position: absolute;
    right: 0;
    color: var(--primary);
    font-weight: bold;
    font-size: 1.1rem;
}

/* ─── Validation Section ─── */
.validation-section {
    background: rgba(182, 171, 117, 0.06);
    border: 1px solid rgba(182, 171, 117, 0.2);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.file-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.file-item {
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition-fast);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-xs);
}

.file-item:hover {
    background: var(--bg-hover);
}

.file-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* ─── Logs Container ─── */
.logs-container {
    background: rgba(0, 0, 0, 0.5);
    color: #00ff88;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 0.85rem;
    margin-top: var(--spacing-md);
    border: 1px solid rgba(0, 255, 136, 0.15);
}

.log-entry {
    margin-bottom: var(--spacing-xs);
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.03);
}

.log-entry.error {
    color: #ff6b6b;
    background: rgba(239, 68, 68, 0.1);
}

.log-entry.success {
    color: #51cf66;
    background: rgba(16, 185, 129, 0.1);
}

.log-entry.info {
    color: #74c0fc;
    background: rgba(59, 130, 246, 0.1);
}

.log-entry.warning {
    color: #ffd43b;
    background: rgba(245, 158, 11, 0.1);
}

/* ─── Expandable Sections ─── */
.expandable-section {
    margin-top: var(--spacing-md);
}

.expandable-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--bg-hover);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--border);
    transition: all var(--transition-base);
    font-weight: 600;
    color: var(--text-primary);
}

.expandable-header:hover {
    border-color: var(--primary);
    background: rgba(182, 171, 117, 0.08);
}

.expandable-content {
    display: none;
    padding: var(--spacing-md);
    animation: slideDown 0.3s ease;
}

.expandable-content.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Status Indicators ─── */
.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: var(--spacing-xs);
    animation: statusPulse 2s infinite;
}

.status-indicator.status-connected {
    background: var(--success);
    box-shadow: 0 0 12px var(--success);
}

.status-indicator.status-disconnected {
    background: var(--error);
    box-shadow: 0 0 12px var(--error);
}

.status-indicator.status-predicting {
    background: var(--primary);
    box-shadow: 0 0 12px var(--primary);
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* Boat Status */
.boat-status {
    display: inline-block;
    padding: 4px var(--spacing-sm);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.8rem;
}

.status-connected {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-signal_lost {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-predicting {
    background: rgba(182, 171, 117, 0.15);
    color: #67e8f9;
    border: 1px solid rgba(182, 171, 117, 0.3);
}

.status-reconnected {
    background: rgba(0, 57, 48, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(0, 57, 48, 0.3);
}

/* ─── Map Styles ─── */
#map {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
}

#map:hover {
    box-shadow: var(--shadow-xl), 0 0 20px rgba(182, 171, 117, 0.1);
}

/* ─── Modal System ─── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg-card-solid);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 40px rgba(182, 171, 117, 0.1);
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--glass-border);
    margin: auto;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-card-solid);
    z-index: 10;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.modal-header h2 i {
    color: var(--primary);
}

.modal-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border-color: var(--error);
    transform: rotate(90deg);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: var(--bg-card-solid);
}

/* ─── Side Panels ─── */
.side-panel {
    position: fixed;
    top: 60px;
    bottom: 0;
    width: 380px;
    max-width: 90vw;
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    transition: all var(--transition-base);
    border: 1px solid var(--glass-border);
}

.side-panel.right {
    right: var(--sidebar-width);
    transform: translateX(100%);
    border-right: 2px solid var(--primary);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

body.sidebar-collapsed .side-panel.right {
    right: 0;
}

.side-panel.right.open {
    transform: translateX(0);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
}

@media (max-width: 900px) {
    .side-panel.right {
        right: 0 !important;
    }
}

.side-panel.left {
    left: 0;
    right: auto;
    transform: translateX(-100%);
    border-left: 2px solid var(--secondary);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
}

.side-panel.left.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.5);
}

.side-panel-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(10, 14, 26, 0.95);
    z-index: 10;
    backdrop-filter: blur(15px);
}

.side-panel-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.side-panel-header h2 i {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.side-panel-header .modal-close {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.side-panel-header .modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border-color: var(--error);
}

.side-panel-body {
    padding: var(--spacing-lg);
}

/* Side Panel Toggle Buttons */
.side-panel-toggle {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-md);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 80px;
    color: var(--text-secondary);
}

.side-panel-toggle.left {
    left: 0;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.side-panel-toggle.right {
    right: 0;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.side-panel-toggle:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.side-panel-toggle i {
    font-size: 1.1rem;
    transition: transform var(--transition-base);
}

.side-panel-toggle:hover i {
    transform: scale(1.2);
}

/* ─── Map Layout ─── */
.map-container {
    position: fixed;
    top: var(--header-height);
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 1;
    height: auto;
}

.map-container #map {
    height: 100%;
    width: 100%;
    border-radius: 0;
    margin: 0;
    border: none;
}

.map-controls {
    position: fixed;
    top: 75px;
    left: 20px;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.map-control-btn {
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    color: var(--text-secondary);
    font-size: 1rem;
}

.map-control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 20px var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
}

.map-control-btn i {
    transition: transform var(--transition-base);
}

.map-control-btn:hover i {
    transform: scale(1.1);
}

/* ─── Table Responsiveness ─── */
table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    white-space: nowrap;
}

.table-scroll,
div[style*="overflow-x: auto"] > table {
    min-width: 640px;
}

/* Admin page header row (title + action button) */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-bottom: var(--spacing-lg);
}

/* ─── Responsive ─── */
/* Small-screen safety net: any table (wrapped or not) scrolls horizontally
   instead of overflowing the viewport (body has overflow-x:hidden). Cells keep
   white-space:nowrap so columns don't collapse into unreadable stacks. */
@media (max-width: 768px) {
    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Tables already inside a scroll wrapper keep normal table layout. */
    .table-scroll > table,
    div[style*="overflow-x: auto"] > table {
        display: table;
    }
}

@media (max-width: 1200px) {
    .side-panel {
        width: 350px;
    }
}

@media (max-width: 900px) {
    :root {
        --header-height: 60px;
    }

    header h1 {
        font-size: 0.95rem;
    }

    header h1 .subtitle {
        font-size: 0.62rem;
    }

    .header-logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .header-container {
        padding-right: 56px;
    }
}

@media (max-width: 768px) {
    header {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    header h1 {
        font-size: 0.9rem;
    }

    header h1 .subtitle {
        display: none;
    }

    .welcome-section {
        padding: var(--spacing-xl) var(--spacing-md);
    }

    .welcome-section h2 {
        font-size: 1.6rem;
    }

    main {
        padding: var(--spacing-sm);
        padding-top: calc(var(--header-height) + var(--spacing-sm));
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .stat-card {
        padding: var(--spacing-md);
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .models-list {
        grid-template-columns: 1fr;
    }

    .card,
    .training-card {
        padding: var(--spacing-md);
    }

    .card h2,
    .training-card h2 {
        font-size: 1.15rem;
    }

    .modal {
        max-width: 95vw;
        max-height: 90vh;
    }

    .modal-overlay {
        padding: var(--spacing-sm);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--spacing-md);
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .side-panel {
        width: 100%;
        max-width: 100%;
        top: var(--header-height);
        border-radius: 0 !important;
    }

    .map-controls {
        top: calc(var(--header-height) + 8px);
        left: 10px;
    }

    .map-control-btn {
        width: 40px;
        height: 40px;
    }

    .folder-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .folder-selector > * {
        flex: 1 1 auto !important;
    }

    .btn-fullscreen {
        top: calc(var(--header-height) + 10px);
        right: 10px;
        width: 38px;
        height: 38px;
    }

    /* Forms inside cards become single-column on mobile */
    .training-card form div[style*="display: flex"][style*="flex: 1"] {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 0.85rem;
    }

    .welcome-section h2 {
        font-size: 1.3rem;
    }

    .welcome-section p {
        font-size: 1rem !important;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: 0.9rem;
    }

    .btn-large {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: 0.95rem;
    }

    .card h2,
    .training-card h2 {
        font-size: 1.05rem;
    }

    .sidebar-brand h2 {
        font-size: 0.95rem;
    }

    .tooltip .tooltiptext {
        width: 200px;
        margin-right: -100px;
    }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* ─── Legend ─── */
.legend {
    background: var(--bg-card);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    margin-top: var(--spacing-md);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.legend-color {
    width: 24px;
    height: 4px;
    border-radius: 2px;
}

/* ─── Utilities ─── */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: var(--spacing-xs);
}

.mt-2 {
    margin-top: var(--spacing-sm);
}

.mt-3 {
    margin-top: var(--spacing-md);
}

.mt-4 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-xs);
}

.mb-2 {
    margin-bottom: var(--spacing-sm);
}

.mb-3 {
    margin-bottom: var(--spacing-md);
}

.mb-4 {
    margin-bottom: var(--spacing-lg);
}

/* Smooth transitions */
a,
button,
input,
select,
textarea {
    transition: color var(--transition-base), background-color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base), opacity var(--transition-base);
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ─── Boats List (Monitoring) ─── */
.boats-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* ─── Print-safe hidden class ─── */
.hidden {
    display: none !important;
}

/* ─── Drawing Tools ─── */
.drawing-toolset {
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: 8px;
    display: flex;
    gap: 10px;
    z-index: 2000;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.tool-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.tool-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--primary-glow);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
}

.tool-btn.delete:hover {
    background: var(--error);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

/* Zone Labels */
.zone-label {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ─── Enhanced Map Viewer Styles ─── */
.glass-sidebar {
    background: rgba(10, 14, 26, 0.8) !important;
    backdrop-filter: blur(25px) saturate(1.8) !important;
    -webkit-backdrop-filter: blur(25px) saturate(1.8) !important;
    border-left: 1px solid var(--glass-border) !important;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--spacing-sm);
}

.sidebar-section-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.track-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.track-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.track-card:hover {
    background: rgba(182, 171, 117, 0.1);
    border-color: var(--primary);
    transform: translateX(-5px);
}

.track-card.active {
    background: rgba(182, 171, 117, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.track-card .track-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
}

.track-card .track-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}

.track-card .track-meta i {
    color: var(--primary-light);
    width: 14px;
}

.layer-item-modern {
    background: rgba(30, 41, 59, 0.3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.layer-item-modern:hover {
    border-color: var(--primary-light);
}

.layer-item-modern .layer-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.layer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.layer-actions-modern {
    display: flex;
    gap: 8px;
}

.layer-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px;
}

.layer-action-btn:hover {
    color: var(--primary-light);
}

.layer-action-btn.delete:hover {
    color: var(--error);
}

.data-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-real {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.badge-pred {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.badge-bridge {
    background: rgba(236, 72, 153, 0.2);
    color: #ec4899;
}

/* Pulse Animation for active track */
@keyframes pulseActive {
    0% {
        box-shadow: 0 0 0 0 rgba(182, 171, 117, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(182, 171, 117, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(182, 171, 117, 0);
    }
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT MODE — overrides all dark CSS variables when
   body.theme-light is set by the sidebar theme toggle.
   ═══════════════════════════════════════════════════════════════ */

body.theme-light {
    /* Surfaces */
    --bg-primary:    #f0f4f8;
    --bg-secondary:  #e8edf3;
    --bg-card:       rgba(255, 255, 255, 0.92);
    --bg-card-solid: #ffffff;
    --bg-hover:      rgba(226, 232, 240, 0.9);
    --bg-elevated:   rgba(203, 213, 225, 0.7);

    /* Input */
    --bg-input: #ffffff;

    /* Text */
    --text-primary:   #0f172a;
    --text-secondary: #374151;
    --text-muted:     #6b7280;

    /* Borders */
    --border:         rgba(100, 116, 139, 0.35);
    --border-light:   rgba(100, 116, 139, 0.2);

    /* Glass */
    --glass-bg:     rgba(255, 255, 255, 0.88);
    --glass-border: rgba(182, 171, 117, 0.3);

    /* Shadows — lighter for white backgrounds */
    --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg:   0 10px 25px rgba(0, 0, 0, 0.12);
    --shadow-xl:   0 20px 40px rgba(0, 0, 0, 0.14);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08), 0 0 1px rgba(182, 171, 117, 0.15);

    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Kill the animated radar background in light mode */
body.theme-light::before,
body.theme-light::after {
    display: none;
}

/* ── Cards & panels (white glass) ── */
body.theme-light .card,
body.theme-light .training-card,
body.theme-light .feature-card,
body.theme-light .model-card,
body.theme-light .rpt-card,
body.theme-light .rpt-panel,
body.theme-light .rpt-controls,
body.theme-light .rpt-status-bar,
body.theme-light .rpt-video-progress,
body.theme-light .glass-sidebar {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow-card) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ── stat-card: keep the colored gradient, just make text readable ──
   The inline-style gradient (e.g. rgba(182, 171, 117,.2)) looks fine on a
   light page—it becomes a soft pastel tint.  The only problem was that
   color: white (set globally on .stat-card) was invisible on that light
   tint.  Fix: switch to dark text + add a shadow so the card lifts off
   the page.  Do NOT touch background. */
body.theme-light .stat-card {
    color: var(--text-primary) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04) !important;
}

body.theme-light .stat-card::before {
    display: none !important;
}

body.theme-light .stat-value {
    color: var(--text-primary) !important;
}

body.theme-light .stat-label {
    color: var(--text-secondary) !important;
    opacity: 1 !important;
}

body.theme-light .stat-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
}

/* ── Tables ── */
body.theme-light .rpt-trips-table thead th {
    background: rgba(241, 245, 249, 0.9);
    color: var(--primary);
    border-bottom-color: var(--border);
}

body.theme-light .rpt-trips-table tbody td {
    color: var(--text-primary);
    border-bottom-color: var(--border-light);
}

body.theme-light .rpt-trips-table tbody tr:hover td {
    background: rgba(182, 171, 117, 0.06);
}

body.theme-light .rpt-trips-table tbody tr.rpt-row-active td {
    background: rgba(182, 171, 117, 0.1) !important;
}

/* ── Forms & inputs ── */
body.theme-light input[type="date"],
body.theme-light input[type="week"],
body.theme-light input[type="month"],
body.theme-light input[type="text"],
body.theme-light input[type="email"],
body.theme-light input[type="password"],
body.theme-light input[type="number"],
body.theme-light select,
body.theme-light textarea {
    background: #ffffff;
    border-color: var(--border);
    color: var(--text-primary);
    color-scheme: light;
}

body.theme-light .rpt-pickers input {
    background: #ffffff !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
    color-scheme: light !important;
}

/* ── Buttons ── */
body.theme-light .rpt-btn-secondary {
    background: rgba(241, 245, 249, 0.9);
    border-color: var(--border);
    color: var(--text-primary);
}

body.theme-light .rpt-btn-secondary:hover:not(:disabled) {
    background: rgba(226, 232, 240, 0.95);
}

/* ── Tabs ── */
body.theme-light .rpt-tabs {
    background: rgba(241, 245, 249, 0.8);
    border-color: var(--border-light);
}

body.theme-light .period-tab {
    color: var(--text-secondary);
}

/* ── Status text colors stay semantic — no override needed ── */

/* ── Permissions dashboard & list pages ── */
body.theme-light .welcome-section {
    background: linear-gradient(135deg, rgba(182, 171, 117,0.08), rgba(0, 57, 48,0.06)) !important;
    border-color: rgba(182, 171, 117,0.2) !important;
}

body.theme-light .feature-card,
body.theme-light .perm-card {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
}

/* ── Map containers — keep dark regardless of theme ── */
body.theme-light #rpt-map,
body.theme-light .map-container,
body.theme-light .maplibregl-map {
    /* Maps stay dark — light tiles load via OSM */
}

/* ── Scrollbars ── */
body.theme-light ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

body.theme-light ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #94a3b8, #64748b);
}

/* ── Modals (jobs history) ── */
body.theme-light #jobs-modal {
    background: var(--bg-card);
    border-color: var(--border);
}

body.theme-light .jm-job {
    border-bottom-color: var(--border-light);
}

body.theme-light .jm-period,
body.theme-light .jm-job-meta {
    color: var(--text-primary);
}

/* ── Chart.js canvas — re-colour via JS themechange event in reports.js ── */

/* ── Sidebar — light mode ── */
body.theme-light .app-sidebar {
    background: rgba(248, 250, 252, 0.98);
    border-left-color: rgba(100, 116, 139, 0.25);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.theme-light .sidebar-link {
    color: #374151;
}

body.theme-light .sidebar-link:hover {
    background: rgba(182, 171, 117, 0.1);
    color: #0369a1;
}

body.theme-light .sidebar-link.active {
    background: rgba(182, 171, 117, 0.14);
    color: #0284c7;
    border-right-color: #0284c7;
}

body.theme-light .sidebar-section-title {
    color: #6b7280;
}

body.theme-light .sidebar-footer {
    border-top-color: rgba(100, 116, 139, 0.2);
}

body.theme-light .sidebar-brand {
    border-bottom-color: rgba(100, 116, 139, 0.2);
}

/* ── Header — light mode ── */
body.theme-light header {
    background: rgba(255, 255, 255, 0.96);
    border-bottom-color: rgba(100, 116, 139, 0.22);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Sidebar & theme toggle buttons — light mode ── */
body.theme-light .sidebar-toggle-btn,
body.theme-light .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(100, 116, 139, 0.25);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

/* ── Flash messages — light mode ── */
body.theme-light .flash-stack .status-message {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(100, 116, 139, 0.25);
    color: var(--text-primary);
}

/* ── Status message text — fix contrast in light mode ── */
body.theme-light .status-message.success {
    background: rgba(16, 185, 129, 0.08);
    border-color: #059669;
    color: #065f46;
}

body.theme-light .status-message.error {
    background: rgba(239, 68, 68, 0.08);
    border-color: #dc2626;
    color: #7f1d1d;
}

body.theme-light .status-message.info {
    background: rgba(59, 130, 246, 0.08);
    border-color: #2563eb;
    color: #1e3a8a;
}

/* ── Status badges — fix contrast in light mode ── */
body.theme-light .status-badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.35);
}

body.theme-light .status-badge.error {
    background: rgba(239, 68, 68, 0.1);
    color: #7f1d1d;
    border-color: rgba(239, 68, 68, 0.35);
}

body.theme-light .status-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #78350f;
    border-color: rgba(245, 158, 11, 0.35);
}

body.theme-light .status-badge.info {
    background: rgba(59, 130, 246, 0.1);
    color: #1e3a8a;
    border-color: rgba(59, 130, 246, 0.35);
}

/* ── Boat status chips — fix contrast in light mode ── */
body.theme-light .status-connected {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.35);
}

body.theme-light .status-signal_lost {
    background: rgba(245, 158, 11, 0.1);
    color: #78350f;
    border-color: rgba(245, 158, 11, 0.35);
}

body.theme-light .status-predicting {
    background: rgba(182, 171, 117, 0.1);
    color: #164e63;
    border-color: rgba(182, 171, 117, 0.35);
}

body.theme-light .status-reconnected {
    background: rgba(0, 57, 48, 0.1);
    color: #3b0764;
    border-color: rgba(0, 57, 48, 0.35);
}

/* ── Form control ── */
body.theme-light .form-control {
    background: #ffffff;
    border-color: rgba(100, 116, 139, 0.4);
    color: var(--text-primary);
}

body.theme-light .form-control:focus-visible {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(182, 171, 117, 0.12);
}

/* ── Side panels — light mode ── */
body.theme-light .side-panel {
    background: rgba(248, 250, 252, 0.97);
    border-color: rgba(100, 116, 139, 0.25);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
}

body.theme-light .side-panel-header {
    background: rgba(248, 250, 252, 0.99);
    border-bottom-color: rgba(100, 116, 139, 0.2);
}

/* ── Modal — light mode ── */
body.theme-light .modal {
    background: #ffffff;
    border-color: rgba(100, 116, 139, 0.2);
}

body.theme-light .modal-header,
body.theme-light .modal-footer {
    background: #ffffff;
    border-color: rgba(100, 116, 139, 0.15);
}

body.theme-light .modal-close {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(100, 116, 139, 0.2);
    color: #374151;
}

/* ── Map viewer track / layer cards — light mode ── */
body.theme-light .track-card {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(100, 116, 139, 0.2);
}

body.theme-light .track-card:hover {
    background: rgba(182, 171, 117, 0.08);
    border-color: var(--primary);
}

body.theme-light .track-card.active {
    background: rgba(182, 171, 117, 0.12);
    border-color: var(--primary);
}

body.theme-light .layer-item-modern {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(100, 116, 139, 0.18);
}

/* ── Log container — light mode ── */
body.theme-light .logs-container {
    background: #f8f9fa;
    color: #1a7f37;
    border-color: rgba(26, 127, 55, 0.25);
}

body.theme-light .log-entry.error { color: #b91c1c; background: rgba(239, 68, 68, 0.07); }
body.theme-light .log-entry.success { color: #166534; background: rgba(16, 185, 129, 0.07); }
body.theme-light .log-entry.info { color: #1d4ed8; background: rgba(59, 130, 246, 0.07); }
body.theme-light .log-entry.warning { color: #92400e; background: rgba(245, 158, 11, 0.07); }

/* ── Zone labels — keep visible in light mode ── */
body.theme-light .zone-label {
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    border-color: var(--primary);
}

/* ── Drawing toolset — light mode ── */
body.theme-light .drawing-toolset {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(100, 116, 139, 0.25);
}

body.theme-light .tool-btn {
    background: rgba(241, 245, 249, 0.9);
    color: #374151;
}

/* ── Expandable headers — light mode ── */
body.theme-light .expandable-header {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(100, 116, 139, 0.2);
    color: var(--text-primary);
}

/* ── Map control buttons — light mode ── */
body.theme-light .map-control-btn {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(100, 116, 139, 0.25);
    color: #374151;
}

/* ── Table rows — light mode ── */
body.theme-light table thead tr {
    background: rgba(241, 245, 249, 0.95);
}

body.theme-light table tbody tr:hover td {
    background: rgba(182, 171, 117, 0.05);
}

/* ── Row items inside cards that use near-invisible white tint ── */
/* These inline-styled separator rows use rgba(255,255,255,0.03) on dark bg */
body.theme-light [style*="rgba(255,255,255,0.03)"] {
    background: rgba(182, 171, 117, 0.04) !important;
}

/* ── Inline-styled status badges — fix contrast on light backgrounds ── */
body.theme-light .status-badge[style*="rgba(16,185,129"],
body.theme-light .status-badge[style*="var(--success)"] {
    color: #065f46 !important;
    background: rgba(16, 185, 129, 0.12) !important;
}

body.theme-light .status-badge[style*="rgba(245,158,11"],
body.theme-light .status-badge[style*="var(--warning)"] {
    color: #78350f !important;
    background: rgba(245, 158, 11, 0.12) !important;
}

body.theme-light .status-badge[style*="rgba(239,68,68"],
body.theme-light .status-badge[style*="var(--error)"] {
    color: #7f1d1d !important;
    background: rgba(239, 68, 68, 0.12) !important;
}

body.theme-light .status-badge[style*="rgba(182, 171, 117"],
body.theme-light .status-badge[style*="var(--primary)"] {
    color: #164e63 !important;
    background: rgba(182, 171, 117, 0.12) !important;
}

/* ── Inline alert/result divs (hardware dashboard command feedback) ── */
body.theme-light [style*="var(--success)"][style*="border"],
body.theme-light [style*="var(--error)"][style*="border"] {
    color: var(--text-primary) !important;
}