/* ============================================================
   PTSI Fuel System v2 — Design System
   ============================================================ */

:root {
    /* Brand */
    --c-primary:       #4f46e5;   /* indigo-600 */
    --c-primary-50:    #eef2ff;
    --c-primary-100:   #e0e7ff;
    --c-primary-600:   #4338ca;
    --c-primary-700:   #3730a3;
    --c-accent:        #06b6d4;   /* cyan-500 */

    /* Semantic */
    --c-success:       #10b981;
    --c-success-50:    #ecfdf5;
    --c-warning:       #f59e0b;
    --c-warning-50:    #fffbeb;
    --c-danger:        #ef4444;
    --c-danger-50:     #fef2f2;
    --c-info:          #0ea5e9;
    --c-info-50:       #f0f9ff;

    /* Ink & surfaces */
    --c-ink:           #0f172a;   /* slate-900 */
    --c-ink-2:         #334155;   /* slate-700 */
    --c-muted:         #64748b;   /* slate-500 */
    --c-line:          #e2e8f0;   /* slate-200 */
    --c-line-strong:   #cbd5e1;   /* slate-300 */
    --c-bg:            #f8fafc;   /* slate-50 */
    --c-card:          #ffffff;

    /* Dark sidebar palette */
    --c-side-bg-1:     #0b1224;
    --c-side-bg-2:     #111b34;
    --c-side-ink:      #cbd5e1;
    --c-side-muted:    #64748b;

    /* Layout */
    --sidebar-w: 248px;
    --topbar-h:  60px;
    --radius:    14px;
    --radius-sm: 10px;
    --radius-xs: 8px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
    --shadow-sm: 0 2px 4px rgba(15,23,42,.04), 0 1px 2px rgba(15,23,42,.03);
    --shadow-md: 0 8px 24px rgba(15,23,42,.06);
    --shadow-lg: 0 24px 48px rgba(15,23,42,.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    background: var(--c-bg);
    color: var(--c-ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
    font-size: 14px;
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    letter-spacing: -0.005em;
}

code, kbd, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

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

/* ============ Sidebar collapsed state (persisted to localStorage) ============ */
html.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
}
html.sidebar-collapsed .app-main {
    margin-left: 0;
    max-width: 100vw;
}

/* =============== SIDEBAR =============== */
.app-sidebar {
    width: var(--sidebar-w);
    background:
        radial-gradient(800px 400px at -10% -20%, rgba(79,70,229,0.20), transparent 60%),
        radial-gradient(600px 300px at 110% 110%, rgba(6,182,212,0.12), transparent 60%),
        linear-gradient(180deg, var(--c-side-bg-1), var(--c-side-bg-2));
    color: var(--c-side-ink);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform .25s ease;
    border-right: 1px solid rgba(255,255,255,.04);
}
.app-sidebar .brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
    color: #fff; font-size: 20px;
    box-shadow: 0 6px 16px rgba(79,70,229,.35), inset 0 0 0 1px rgba(255,255,255,.15);
}
.brand-text .brand-title {
    color: #fff; font-weight: 700; line-height: 1;
    letter-spacing: -0.01em;
}
.brand-text .brand-sub {
    color: #94a3b8; font-size: 10px; letter-spacing: .12em;
    text-transform: uppercase; margin-top: 2px;
}

.sidebar-nav {
    flex: 1; overflow-y: auto;
    padding: 8px 12px 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.08) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

.nav-group-label {
    font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
    color: #475569; padding: 16px 12px 6px; font-weight: 600;
}
.app-sidebar .nav-link {
    display: flex; align-items: center; gap: 10px;
    color: var(--c-side-ink);
    border-radius: 10px;
    padding: 9px 12px; font-size: 13.5px;
    margin-bottom: 2px;
    font-weight: 500;
    position: relative;
    transition: background .15s ease, color .15s ease;
}
.app-sidebar .nav-link i { font-size: 16px; opacity: .9; flex-shrink: 0; }
.app-sidebar .nav-link:hover { background: rgba(255,255,255,.04); color: #fff; }
.app-sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(79,70,229,.25), rgba(6,182,212,.05));
    color: #fff;
    box-shadow: inset 2px 0 0 var(--c-primary);
}
.app-sidebar .nav-link.active i { color: var(--c-accent); opacity: 1; }

/* Collapsible groups */
.app-sidebar .nav-toggle .chev { font-size: 11px; transition: transform .2s ease; }
.app-sidebar .nav-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.app-sidebar .nav-toggle[aria-expanded="true"] { color: #fff; background: rgba(255,255,255,.04); }

.app-sidebar .sub-nav {
    margin: 2px 0 8px 0; padding-left: 24px;
    border-left: 1px dashed rgba(255,255,255,.08);
    margin-left: 18px;
}
.app-sidebar .sub-nav .nav-link.sub-link {
    padding: 6px 10px; font-size: 12.5px;
    color: #94a3b8; font-weight: 400;
}
.app-sidebar .sub-nav .nav-link.sub-link i { font-size: 13px; }
.app-sidebar .sub-nav .nav-link.sub-link:hover { color: #fff; background: rgba(255,255,255,.04); }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,.06);
    background: rgba(0,0,0,.15);
}
.user-mini { display: flex; align-items: center; gap: 10px; }
.user-mini .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--c-accent), var(--c-primary));
    color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: 13px;
    box-shadow: 0 4px 12px rgba(6,182,212,.35);
}
.user-name { color: #f1f5f9; font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role {
    color: #94a3b8; font-size: 10.5px; letter-spacing: .04em;
    text-transform: uppercase; font-weight: 600; margin-top: 1px;
}

/* =============== MAIN =============== */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-height: 100vh;
    min-width: 0;          /* lets the flex child shrink below its content */
    max-width: calc(100vw - var(--sidebar-w));
}
.app-content {
    padding: 24px 28px 48px;
    max-width: 100%;
    min-width: 0;
}
.app-content > .row,
.app-content > .card-soft {
    max-width: 100%;
}
.app-topbar {
    height: var(--topbar-h);
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--c-line);
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-weight: 600; font-size: 15px; color: var(--c-ink); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.btn-icon {
    width: 36px; height: 36px;
    display: inline-grid; place-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--c-ink-2);
    font-size: 18px;
    transition: background .15s ease, color .15s ease;
}
.btn-icon:hover { background: var(--c-primary-50); color: var(--c-primary); }


/* =============== CARDS =============== */
.card-soft {
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s ease;
}
.card-soft:hover { box-shadow: var(--shadow-sm); }
.card-soft .card-body { padding: 20px; }

/* =============== KPI =============== */
.kpi {
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: 16px;
    padding: 18px 20px;
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.kpi::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(420px 200px at 100% -40%, rgba(79,70,229,.06), transparent 70%);
    pointer-events: none;
}
.kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--c-line-strong);
}
.kpi-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: grid; place-items: center;
    font-size: 24px; color: #fff;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.kpi-icon.bg-primary  { background: linear-gradient(135deg, #6366f1, var(--c-primary-700)); box-shadow: 0 8px 20px rgba(79,70,229,.30), inset 0 0 0 1px rgba(255,255,255,.15); }
.kpi-icon.bg-success  { background: linear-gradient(135deg, #34d399, #047857);              box-shadow: 0 8px 20px rgba(16,185,129,.28), inset 0 0 0 1px rgba(255,255,255,.15); }
.kpi-icon.bg-warning  { background: linear-gradient(135deg, #fbbf24, #b45309);              box-shadow: 0 8px 20px rgba(245,158,11,.28), inset 0 0 0 1px rgba(255,255,255,.15); }
.kpi-icon.bg-info     { background: linear-gradient(135deg, #38bdf8, #0369a1);              box-shadow: 0 8px 20px rgba(14,165,233,.28), inset 0 0 0 1px rgba(255,255,255,.15); }
.kpi-value {
    font-size: 26px; font-weight: 700; line-height: 1;
    color: var(--c-ink); letter-spacing: -0.02em;
    font-feature-settings: 'tnum';
}
.kpi-label {
    font-size: 11px; color: var(--c-muted);
    margin-top: 6px; letter-spacing: .06em;
    text-transform: uppercase; font-weight: 600;
}

/* =============== PAGE HEADER =============== */
.page-header {
    display: flex; align-items: flex-end; gap: 16px;
    margin-bottom: 22px; padding-bottom: 4px;
}
.page-header h1 {
    font-size: 22px; font-weight: 700;
    margin: 0; letter-spacing: -0.02em;
    color: var(--c-ink);
}
.page-header .subtitle {
    color: var(--c-muted); font-size: 13px; margin-top: 4px;
}
.page-header .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* =============== TABLES =============== */
.table-card { padding: 4px; }
.table-card .table { margin: 0; }
.table {
    --bs-table-bg: transparent;
    color: var(--c-ink);
}
.table thead th {
    background: #f8fafc;
    color: var(--c-muted);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--c-line);
    padding: 12px 12px;
    white-space: nowrap;
}
.table tbody td {
    vertical-align: middle;
    padding: 12px 12px;
    border-bottom: 1px solid var(--c-line);
    font-size: 13.5px;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: var(--c-primary-50); }
.table.dataTable { width: 100% !important; }

/* DataTables UI */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px !important;
    border: 1px solid var(--c-line) !important;
    padding: 6px 10px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--c-primary) !important;
    border-color: var(--c-primary) !important;
    color: #fff !important;
}

/* =============== BUTTONS =============== */
.btn { font-weight: 500; border-radius: 10px; padding: 8px 14px; font-size: 13.5px; transition: all .15s ease; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }

.btn-primary {
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-600));
    border-color: var(--c-primary-600);
    box-shadow: 0 4px 12px rgba(79,70,229,.25);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--c-primary-600), var(--c-primary-700));
    border-color: var(--c-primary-700);
    box-shadow: 0 6px 16px rgba(79,70,229,.35);
    transform: translateY(-1px);
}
.btn-success {
    background: linear-gradient(135deg, #10b981, #047857);
    border-color: #047857;
    box-shadow: 0 4px 12px rgba(16,185,129,.25);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16,185,129,.35); }
.btn-light {
    background: #f1f5f9;
    border-color: var(--c-line);
    color: var(--c-ink-2);
}
.btn-light:hover { background: #e2e8f0; color: var(--c-ink); }

/* =============== FORMS =============== */
.form-control, .form-select {
    border-radius: var(--radius-xs);
    border-color: var(--c-line);
    font-size: 13.5px;
    padding: 8px 12px;
    color: var(--c-ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.form-control:disabled, .form-control[readonly], .bg-light {
    background-color: #f1f5f9 !important;
    color: var(--c-ink-2);
}
.form-label {
    font-weight: 500; font-size: 12.5px;
    color: var(--c-ink-2); margin-bottom: 4px;
    letter-spacing: -0.005em;
}
.input-group-text {
    background: #f8fafc;
    border-color: var(--c-line);
    color: var(--c-muted);
}
.form-check-input {
    width: 16px; height: 16px;
    border-color: var(--c-line-strong);
}
.form-check-input:checked {
    background-color: var(--c-primary);
    border-color: var(--c-primary);
}
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

/* =============== BADGES =============== */
.badge {
    font-weight: 600; font-size: 11px;
    letter-spacing: .02em; padding: 4px 8px;
    border-radius: 6px;
}
.text-bg-light { background: #f1f5f9 !important; color: var(--c-ink-2) !important; }

/* =============== MODALS =============== */
.modal-content {
    border: none; border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--c-line); padding: 16px 20px;
}
.modal-header .modal-title { font-weight: 600; font-size: 15px; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--c-line); padding: 14px 20px; }

/* =============== CHARTS =============== */
.chart-wrap { position: relative; height: 280px; width: 100%; }
.chart-wrap canvas { display: block; }

/* =============== EQUIPMENT SEARCHABLE DROPDOWN =============== */
.equipment-dropdown .equipment-toggle {
    background-color: #fff;
    border-color: var(--c-line);
    color: var(--c-ink);
    font-weight: 400;
    text-align: left;
    padding: 8px 12px;
    display: flex; align-items: center; justify-content: space-between;
}
.equipment-dropdown .equipment-toggle:hover,
.equipment-dropdown .equipment-toggle.show,
.equipment-dropdown .equipment-toggle[aria-expanded="true"] {
    background-color: #fff;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
    color: var(--c-ink);
}
.equipment-menu {
    border: 1px solid var(--c-line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-width: 100%;
}
.equipment-menu .equipment-option {
    display: flex; align-items: center;
    padding: 8px 14px;
    font-size: 13.5px;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.equipment-menu .equipment-option:hover {
    background: var(--c-primary-50);
    color: var(--c-primary);
}

/* =============== EMPTY STATE =============== */
.empty-state {
    text-align: center; padding: 32px 16px;
    color: var(--c-muted);
}
.empty-state i { font-size: 32px; color: var(--c-line-strong); }
.empty-state p { margin: 10px 0 0; font-size: 13px; }

/* =============== ALERTS =============== */
.alert {
    border-radius: var(--radius-xs);
    border: 1px solid transparent;
    padding: 10px 14px;
    font-size: 13.5px;
}
.alert-success { background: var(--c-success-50); color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: var(--c-warning-50); color: #78350f; border-color: #fde68a; }
.alert-danger  { background: var(--c-danger-50);  color: #7f1d1d; border-color: #fecaca; }
.alert-info    { background: var(--c-info-50);    color: #0c4a6e; border-color: #bae6fd; }

/* =============== RESPONSIVE =============== */
@media (max-width: 992px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 16px; }
}

/* =============== LOGIN =============== */
.login-shell {
    min-height: 100vh;
    display: grid; place-items: center;
    background:
        radial-gradient(1000px 600px at 10% -10%, rgba(79,70,229,.22), transparent 60%),
        radial-gradient(800px 500px at 110% 110%, rgba(6,182,212,.20), transparent 60%),
        radial-gradient(600px 400px at 50% 110%, rgba(168,85,247,.10), transparent 60%),
        #0b1224;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.login-shell::before {
    content: ''; position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 70%);
}
.login-card {
    width: 100%; max-width: 440px;
    background: #fff;
    border-radius: 18px;
    box-shadow:
        0 0 0 1px rgba(255,255,255,.08),
        0 32px 64px rgba(0,0,0,.40);
    padding: 36px;
    position: relative;
    z-index: 1;
}
.login-brand {
    display: flex; align-items: center; gap: 14px; margin-bottom: 24px;
}
.login-brand .brand-mark { width: 48px; height: 48px; font-size: 24px; border-radius: 14px; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.login-brand small { color: var(--c-muted); display: block; font-size: 12.5px; }
