/* ── THEME TOKENS ── */
:root {
    /* Dark Theme (Default) */
    --bg-canvas: #070D1B;
    --bg-sidebar: #0B132B;
    --bg-card: #0F1D38;
    --bg-surface: #172748;
    --bg-input: #101E38;
    --border-subtle: #1E345D;
    --border-focus: #38BDF8;
    --ocean-blue: #0284C7;
    --ocean-teal: #0EA5E9;
    --cyan-accent: #38BDF8;
    --emerald: #10B981;
    --amber: #F59E0B;
    --rose: #F43F5E;
    --purple: #A855F7;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --shadow-card: 0 10px 30px rgba(0,0,0,0.45);
    --badge-text-weight: 800;
}

/* Light Theme */
[data-theme="light"] {
    --bg-canvas: #F1F5F9;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-surface: #F8FAFC;
    --bg-input: #FFFFFF;
    --border-subtle: #E2E8F0;
    --border-focus: #0284C7;
    --ocean-blue: #0284C7;
    --ocean-teal: #0284C7;
    --cyan-accent: #0284C7;
    --emerald: #059669;
    --amber: #D97706;
    --rose: #E11D48;
    --purple: #7C3AED;
    --text-main: #0F172A;
    --text-muted: #475569;
    --text-dim: #94A3B8;
    --shadow-card: 0 4px 20px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; transition: background-color 0.25s ease, border-color 0.25s ease, color 0.15s ease; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

body {
    background: var(--bg-canvas);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ── Layout Shell ── */
.app-shell { display: flex; width: 100vw; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: 270px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
    box-shadow: 2px 0 16px rgba(0,0,0,0.03);
}

.sidebar-brand {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
}
.brand-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0284C7, #38BDF8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}
.brand-text h1 { font-size: 15px; font-weight: 900; letter-spacing: 0.5px; color: var(--text-main); line-height: 1.2; }
.brand-text span { font-size: 10px; font-weight: 800; color: var(--cyan-accent); letter-spacing: 1px; }

.nav-section-title {
    padding: 18px 20px 8px;
    font-size: 10px;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-menu { list-style: none; padding: 0 10px 20px; }
.nav-item { margin-bottom: 4px; }
.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}
.nav-link-content { display: flex; align-items: center; gap: 10px; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
    background: var(--bg-surface);
    color: var(--cyan-accent);
    border: 1px solid var(--border-subtle);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 100px;
}
.nav-link:hover {
    background: var(--bg-surface);
    color: var(--text-main);
    border-color: rgba(56, 189, 248, 0.2);
    transform: translateX(3px);
}
.nav-link.active {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.25), rgba(14, 165, 233, 0.12));
    color: var(--text-main);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.15);
}
.nav-link.active .nav-badge {
    background: var(--cyan-accent);
    color: #FFFFFF;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 14px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0EA5E9, #6366F1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 800; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--cyan-accent); font-weight: 700; }

/* ── Main Content Area ── */
.main-content {
    margin-left: 270px;
    flex: 1;
    padding: 24px 32px 48px;
    max-width: calc(100vw - 270px);
}

/* ── Top Header Bar ── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 14px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    gap: 16px;
    flex-wrap: wrap;
}
.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    width: 320px;
    max-width: 100%;
}
.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 13px;
    width: 100%;
}
.search-box input::placeholder { color: var(--text-dim); }
.top-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    padding: 7px 13px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.theme-toggle-btn:hover {
    border-color: var(--cyan-accent);
}

.badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--emerald);
    border: 1px solid rgba(16, 185, 129, 0.35);
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--emerald);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--emerald);
    animation: pulseAnim 1.8s infinite;
}
@keyframes pulseAnim {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 14px var(--emerald); }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* ── Alerts ── */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.alert-success { background: rgba(16, 185, 129, 0.15); border: 1px solid var(--emerald); color: var(--emerald); }
.alert-danger { background: rgba(244, 63, 94, 0.15); border: 1px solid var(--rose); color: var(--rose); }
.alert-info { background: rgba(14, 165, 233, 0.15); border: 1px solid var(--ocean-teal); color: var(--cyan-accent); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    border: none;
    line-height: 1;
}
.btn-primary {
    background: linear-gradient(135deg, #0284C7, #0EA5E9);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}
.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
}
.btn-secondary:hover { background: var(--border-subtle); }
.btn-success { background: rgba(16, 185, 129, 0.15); color: var(--emerald); border: 1px solid var(--emerald); }
.btn-success:hover { background: var(--emerald); color: #FFF; }
.btn-danger { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid var(--rose); }
.btn-danger:hover { background: var(--rose); color: #FFF; }
.btn-sm { padding: 6px 12px; font-size: 11px; border-radius: var(--radius-sm); }

/* ── Metric Cards ── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px 18px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    cursor: pointer;
}
.metric-card:hover { transform: translateY(-2px); border-color: var(--cyan-accent); }
.metric-card::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--ocean-blue), var(--cyan-accent));
}
.metric-icon { font-size: 20px; margin-bottom: 8px; }
.metric-value { font-size: 26px; font-weight: 900; color: var(--text-main); letter-spacing: -0.5px; }
.metric-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 4px; }

/* ── Tabs & Sections ── */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 14px;
}
.section-title {
    font-size: 18px;
    font-weight: 900;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title span.icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
}
.section-subtitle { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ── Grids & Cards ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.data-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
}
.data-card:hover { border-color: var(--cyan-accent); }
.card-header-flex { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 800; color: var(--text-main); margin-bottom: 3px; }
.card-subtitle { font-size: 12px; color: var(--cyan-accent); font-weight: 700; }

.info-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 12px;
    border: 1px solid var(--border-subtle);
}
.info-item span { display: block; font-size: 10px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.info-item strong { color: var(--text-main); font-weight: 700; word-break: break-word; }

.card-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
    padding-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Tables ── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow-x: auto;
    margin-bottom: 32px;
    box-shadow: var(--shadow-card);
}
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; min-width: 650px; }
th {
    background: var(--bg-surface);
    padding: 16px 20px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 800;
    border-bottom: 1px solid var(--border-subtle);
}
td { padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; color: var(--text-main); }
tr:hover td { background: var(--bg-surface); }

/* ── Badges & Status ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.status-underway, .status-active, .status-completed, .status-approved, .status-on_board, .status-resolved {
    background: rgba(16, 185, 129, 0.15); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.4);
}
.status-moored, .status-inProgress, .status-pending, .status-training {
    background: rgba(14, 165, 233, 0.15); color: var(--cyan-accent); border: 1px solid rgba(14, 165, 233, 0.4);
}
.status-dryDock, .status-open, .status-local_job {
    background: rgba(245, 158, 11, 0.15); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.4);
}
.status-maintenance, .status-critical, .status-rejected, .status-off_board {
    background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.4);
}

/* ── Modals ── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 18, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 24px;
    backdrop-filter: blur(8px);
}
.modal.active { display: flex; animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 650px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    position: relative;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: 18px; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.modal-close {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
}
.modal-close:hover { background: var(--rose); color: #FFF; border-color: var(--rose); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--cyan-accent);
    margin: 16px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-section-title:first-of-type { margin-top: 0; }
label { font-size: 11px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15); }
textarea { resize: vertical; min-height: 90px; }

/* ── Lightbox Modal ── */
.lightbox-box {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    border: 2px solid var(--ocean-teal);
    box-shadow: 0 15px 50px rgba(0,0,0,0.9);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .sidebar { width: 70px; }
    .sidebar .brand-text, .sidebar .nav-section-title, .sidebar .nav-link-content span, .sidebar .nav-badge, .sidebar .user-meta { display: none; }
    .sidebar .nav-link { justify-content: center; padding: 12px 0; }
    .main-content { margin-left: 70px; max-width: calc(100vw - 70px); padding: 16px; }
}
