:root {
    --navy: #0b1f3a;
    --navy-2: #12294d;
    --blue: #1d4ed8;
    --blue-light: #3b82f6;
    --cyan: #0891b2;
    --gray-bg: #eef1f5;
    --gray-border: #d7dde5;
    --gray-text: #4b5563;
    --danger: #b91c1c;
    --success: #15803d;
    --warning: #b45309;
    --radius: 5px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--gray-bg);
    color: #1f2937;
}

a { color: inherit; text-decoration: none; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--navy);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 18px 16px;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    background: var(--navy-2);
    letter-spacing: .3px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.sidebar-nav a, .sidebar-nav .nav-heading {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
}

.sidebar-nav .nav-heading {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .6px;
    color: #64748b;
    margin-top: 10px;
}

.sidebar-nav a {
    border-left: 3px solid transparent;
    color: #cbd5e1;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.06);
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.08);
    border-left-color: var(--cyan);
    color: #fff;
}

/* Main area */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--gray-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.topbar .page-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--navy);
}

.content {
    padding: 20px;
    flex: 1;
}

/* Metro blocks */
.metro-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metro-block {
    background: var(--blue);
    color: #fff;
    border-radius: var(--radius);
    padding: 16px 18px;
}

.metro-block .metro-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    opacity: .85;
}

.metro-block .metro-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 6px;
}

.metro-block.cyan { background: var(--cyan); }
.metro-block.navy { background: var(--navy); }
.metro-block.danger { background: var(--danger); }
.metro-block.gray { background: #64748b; }

/* Cards / panels */
.panel {
    background: #fff;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-border);
    font-weight: 600;
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-body { padding: 16px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    background: #fff;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-light); }
.btn-outline { background: #fff; border-color: var(--blue); color: var(--blue); }
.btn-outline:hover { background: #eff6ff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-text); margin-bottom: 4px; }
.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    font-size: 14px;
}
.form-control:focus { outline: none; border-color: var(--blue); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Tables */
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
    text-align: left;
    background: #eaf1fb;
    color: var(--navy);
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-border);
}
table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eef1f5;
}

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-gray { background: #e5e7eb; color: #374151; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; }

/* Pagination */
.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.pagination-info {
    font-size: 13px;
    color: var(--gray-text);
}

.pagination-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.pagination-links .btn {
    padding: 5px 10px;
    min-width: 34px;
    text-align: center;
}

.pagination-disabled {
    opacity: .5;
    cursor: not-allowed;
}

.pagination-dots {
    padding: 0 4px;
    color: var(--gray-text);
    font-size: 13px;
}

/* Auth page */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
}

.auth-box {
    width: 360px;
    background: #fff;
    border-radius: var(--radius);
    padding: 28px 26px;
}

.auth-box h1 {
    font-size: 18px;
    color: var(--navy);
    margin: 0 0 20px;
}

/* Modal / offcanvas */
.modal-backdrop-custom {
    position: fixed; inset: 0; background: rgba(11,31,58,0.55);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-backdrop-custom.open { display: flex; }
.modal-box {
    background: #fff; border-radius: var(--radius); width: 480px; max-width: 92vw;
    max-height: 88vh; overflow-y: auto;
}
.offcanvas-panel {
    position: fixed; top: 0; right: -420px; width: 420px; max-width: 92vw; height: 100vh;
    background: #fff; transition: right .2s ease; z-index: 1001; overflow-y: auto;
    box-shadow: -2px 0 12px rgba(0,0,0,0.15);
}
.offcanvas-panel.open { right: 0; }

/* Sidebar toggle (mobile) */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--navy);
    cursor: pointer;
    padding: 4px 2px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11,31,58,0.5);
    z-index: 999;
}

/* Responsive */
@media (max-width: 860px) {
    .sidebar-toggle { display: inline-block; }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 240px;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 1000;
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .topbar {
        height: auto;
        min-height: 56px;
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .topbar-actions {
        flex-wrap: wrap;
        gap: 8px !important;
    }

    .content {
        padding: 12px;
    }

    .metro-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
    }

    .metro-block {
        padding: 12px 14px;
    }

    .metro-block .metro-value {
        font-size: 20px;
    }

    .panel-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .panel-body {
        padding: 12px;
    }

    /* Let wide tables scroll horizontally instead of squeezing columns */
    .panel {
        overflow-x: auto;
    }

    table.data-table {
        min-width: 640px;
        font-size: 13px;
    }

    .auth-box {
        width: 92vw;
        padding: 22px 18px;
    }
}
