:root {
    /* Dark Mode Defaults */
    --bg-main: #0B0F19;
    --bg-panel: #1A1F2C;
    --border-color: #2A303C;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    --primary: #3B82F6;
    --primary-light: rgba(59, 130, 246, 0.1);
    
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --accent: #8B5CF6;

    --row-bg: rgba(255, 255, 255, 0.02);
    --row-hover: rgba(255, 255, 255, 0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.5);
}

.light-mode {
    --bg-main: #F1F5F9;
    --bg-panel: #FFFFFF;
    --border-color: #E2E8F0;
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    --primary: #2563EB;
    --primary-light: rgba(37, 99, 235, 0.1);
    
    --row-bg: #FFFFFF;
    --row-hover: #F8FAFC;
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.bg-layer {
    position: fixed; inset: 0; z-index: -1;
    background-color: var(--bg-main);
    transition: background-color 0.3s ease;
}

.hidden { display: none !important; }

/* Buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--text-main); background: var(--border-color); }

/* Header */
.topbar {
    padding: 1.5rem 3rem;
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    z-index: 10;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.brand { display: flex; align-items: center; gap: 1rem; }
.pulse-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.brand h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: 1px; color: var(--text-main); }

.header-right { display: flex; align-items: center; gap: 2rem; }
.stats { display: flex; gap: 2rem; align-items: center; }
.stat-box { display: flex; flex-direction: column; align-items: flex-end; }
.stat-box .label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.stat-box .value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }

.clock { font-size: 2rem; font-weight: 600; color: var(--text-main); font-variant-numeric: tabular-nums; border-left: 1px solid var(--border-color); padding-left: 2rem; }

/* Main Board */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.board-container {
    flex: 1; margin: 2rem 3rem;
    display: flex; flex-direction: column;
    overflow: hidden;
}

.board-header {
    display: grid; grid-template-columns: 1.5fr 1fr 2fr 2fr 1.5fr 1.5fr 120px;
    padding: 1.25rem 2rem;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.75rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.05em; text-transform: uppercase;
}

.board-body { flex: 1; overflow-y: auto; padding: 1rem; }

.feed-row {
    display: grid; grid-template-columns: 1.5fr 1fr 2fr 2fr 1.5fr 1.5fr 120px;
    padding: 1.25rem 2rem; margin-bottom: 0.5rem;
    background: var(--row-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    align-items: center;
    transition: all 0.3s ease;
    font-size: 1rem; font-weight: 500; color: var(--text-main);
}
.feed-row:hover { background: var(--row-hover); transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }

/* Update Animation highlight */
.feed-row.updated {
    animation: highlight 2s ease-out;
}
@keyframes highlight {
    0% { background: var(--primary-light); border-color: var(--primary); }
    100% { background: var(--row-bg); border-color: var(--border-color); }
}

.cell-ref { font-family: monospace; font-size: 1.1rem; font-weight: 600; }
.cell-type { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 4px; font-size: 0.85rem; font-weight: 600; }
.type-Import { color: var(--accent); background: rgba(139, 92, 246, 0.1); }
.type-Export { color: var(--warning); background: rgba(245, 158, 11, 0.1); }
.type-Transit { color: var(--primary); background: rgba(59, 130, 246, 0.1); }

.cell-vessel { font-weight: 600; }
.cell-company { color: var(--text-muted); }
.cell-port { font-weight: 400; }

.cell-status span {
    display: inline-block; padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; border: 1px solid transparent;
}
.status-Pending { color: var(--warning); background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); }
.status-InPort { color: var(--primary); background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.2); }
.status-Cleared { color: var(--success); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.status-Dispatched { color: var(--text-main); background: var(--border-color); }
.status-OnHold { color: var(--danger); background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); }

/* Loader */
.loader-container { display: flex; justify-content: center; padding: 3rem; }
.loader { width: 40px; height: 40px; border: 3px solid var(--border-color); border-radius: 50%; border-top-color: var(--primary); animation: spin 1s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Buttons */
.btn-primary, .btn-outline {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-light); color: var(--primary); }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: var(--border-color); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
.modal-content {
    position: relative; width: 100%; max-width: 800px; max-height: 90vh;
    display: flex; flex-direction: column; background: var(--bg-panel);
    border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.modal-header { padding: 1.5rem 2rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 1.25rem; font-weight: 600; }
.modal-body { padding: 2rem; overflow-y: auto; }
.detail-section { margin-bottom: 2rem; }
.detail-section h3 { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.detail-item { display: flex; flex-direction: column; gap: 0.25rem; }
.detail-item label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.detail-item span { font-size: 1rem; font-weight: 500; color: var(--text-main); }

/* ---------------------------------------------------
   Mobile & Tablet Responsiveness
   --------------------------------------------------- */
@media (max-width: 768px) {
    /* Topbar */
    .topbar {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-right {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .stats {
        justify-content: space-between;
        width: 100%;
    }
    .clock {
        border-left: none;
        padding-left: 0;
        font-size: 1.5rem;
    }

    /* Board layout */
    .board-container {
        margin: 1rem;
        border-radius: 8px;
    }
    .board-header {
        display: none; /* Hide grid headers on mobile */
    }

    /* Feed Row Mobile Card Layout */
    .feed-row {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1rem;
        position: relative;
    }
    .feed-row > div {
        width: 100%;
    }
    
    /* Reposition Status to top right */
    .cell-status {
        position: absolute;
        top: 1rem;
        right: 1rem;
        width: auto !important;
        text-align: right;
    }
    
    .cell-ref {
        margin-bottom: 0.25rem;
    }
    
    /* Action Button row */
    .feed-row > div:last-child {
        margin-top: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-color);
        display: flex;
        justify-content: flex-end;
    }

    /* Modal */
    .modal-content {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
}
