:root {
    --primary:        #C0392B;
    --primary-dark:   #922B21;
    --primary-light:  #E74C3C;
    --primary-bg:     #FDECEA;
    --sidebar-bg:     #1A1A2E;
    --sidebar-text:   #C8D0E0;
    --sidebar-hover:  rgba(192,57,43,0.18);
    --sidebar-active: #C0392B;
    --sidebar-border: rgba(255,255,255,0.06);
    --body-bg:        #F0F2F5;
    --card-bg:        #FFFFFF;
    --text:           #0F172A;
    --text-muted:     #64748B;
    --border:         #E2E8F0;
    --green:          #16A34A;
    --green-bg:       #DCFCE7;
    --orange:         #EA580C;
    --orange-bg:      #FEF3C7;
    --blue:           #2563EB;
    --blue-bg:        #DBEAFE;
    --red-bg:         #FEE2E2;
    --sidebar-width:  260px;
    --radius:         8px;
    --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--body-bg);
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
    border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 18px;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }

.brand-badge {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.brand-fire {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-light);
    letter-spacing: 1px;
}
.brand-trainer {
    font-size: 11px;
    font-weight: 600;
    color: var(--sidebar-text);
    letter-spacing: 2px;
    opacity: 0.8;
}

.sidebar-section {
    padding: 18px 10px 6px;
}
.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--sidebar-text);
    opacity: 0.4;
    padding: 0 8px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
}
.nav-item svg { flex-shrink: 0; opacity: 0.75; }
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.nav-sub {
    padding-left: 14px;
}
.nav-sub .nav-item {
    font-size: 13px;
    padding: 7px 10px;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--sidebar-border);
    margin: 8px 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 10px;
    border-top: 1px solid var(--sidebar-border);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
}
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.user-info-sidebar { flex: 1; min-width: 0; }
.user-name-sidebar {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role-sidebar {
    font-size: 11px;
    color: var(--sidebar-text);
    opacity: 0.6;
}
.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
    margin-top: 4px;
}
.btn-logout:hover {
    background: rgba(192,57,43,0.25);
    color: #fff;
    text-decoration: none;
}

/* ── Main content ────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-bar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.top-bar-actions { display: flex; gap: 8px; align-items: center; }

.content-area {
    padding: 24px;
    flex: 1;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FAFBFC;
}
.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-body { padding: 20px; }

/* ── Stats ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.red    { background: var(--red-bg);    color: var(--primary); }
.stat-icon.green  { background: var(--green-bg);  color: var(--green); }
.stat-icon.blue   { background: var(--blue-bg);   color: var(--blue); }
.stat-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Tables ──────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
thead tr { background: #FAFBFC; }
th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .1s, box-shadow .15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn svg { flex-shrink: 0; }

.btn-primary   { background: var(--primary);    color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success   { background: var(--green);       color: #fff; }
.btn-success:hover { background: #138A3E; color: #fff; }
.btn-warning   { background: var(--orange);      color: #fff; }
.btn-warning:hover { background: #C44C0A; color: #fff; }
.btn-danger    { background: #DC2626;            color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-secondary { background: #F1F5F9;            color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-info      { background: var(--blue);        color: #fff; }
.btn-info:hover { background: #1D4ED8; color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 6px 8px; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}
.form-label .required { color: var(--primary); margin-left: 2px; }
.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: 13.5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-row {
    display: grid;
    gap: 16px;
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 8px;
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.badge-success   { background: var(--green-bg);   color: var(--green); }
.badge-danger    { background: var(--red-bg);      color: #B91C1C; }
.badge-info      { background: var(--blue-bg);     color: var(--blue); }
.badge-warning   { background: var(--orange-bg);   color: var(--orange); }
.badge-secondary { background: var(--border);      color: var(--text-muted); }

/* ── Alerts / Flash ──────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.alert-success { background: var(--green-bg);  border-color: #86EFAC; color: #166534; }
.alert-danger  { background: var(--red-bg);    border-color: #FCA5A5; color: #991B1B; }
.alert-info    { background: var(--blue-bg);   border-color: #93C5FD; color: #1E40AF; }
.alert-warning { background: var(--orange-bg); border-color: #FCD34D; color: #92400E; }

/* ── Modals ──────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 520px;
    margin: 16px;
    overflow: hidden;
    animation: modal-in .2s ease;
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FAFBFC;
}
.modal-title {
    font-size: 16px;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #FAFBFC;
}

/* ── Checklist / Target blocks ───────────────────────── */
.target-list { display: flex; flex-direction: column; gap: 16px; }
.target-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.target-card-header {
    padding: 12px 16px;
    background: #FAFBFC;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.target-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.target-meta {
    font-size: 12.5px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px 16px;
    background: #F8F9FA;
    border-bottom: 1px solid var(--border);
}
.target-meta-item { display: flex; align-items: center; gap: 5px; }
.target-steps { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }

.step-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #FAFBFC;
    flex-wrap: wrap;
}
.step-row.step-done {
    background: var(--green-bg);
    border-color: #86EFAC;
}
.step-row.step-pending { opacity: 0.55; }
.step-row.step-active {
    border-color: var(--primary);
    background: var(--primary-bg);
}
.step-number {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.step-row.step-done .step-number { background: var(--green); color: #fff; }
.step-row.step-active .step-number { background: var(--primary); color: #fff; }
.step-label {
    flex: 1;
    font-size: 13.5px;
    font-weight: 500;
}
.step-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}
.step-row.step-done .step-time { color: var(--green); font-weight: 600; }
.step-by { font-size: 11px; color: var(--text-muted); }

.target-times {
    padding: 12px 16px;
    background: var(--green-bg);
    border-top: 1px solid #86EFAC;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.time-stat { display: flex; flex-direction: column; }
.time-stat-label { font-size: 11px; color: #166534; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.time-stat-value { font-size: 17px; font-weight: 800; color: #166534; }

.target-card-actions {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: #FAFBFC;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* ── Vehicle log ─────────────────────────────────────── */
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-entry {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    position: relative;
}
.log-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 6px;
}
.log-entry-time {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
}
.log-entry-author { font-size: 11.5px; color: var(--text-muted); }
.log-entry-content { font-size: 13.5px; color: var(--text); white-space: pre-wrap; }

/* ── Login page ──────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1A1A2E 0%, #16213E 50%, #0F3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}
.login-header {
    background: var(--primary);
    padding: 28px 32px 24px;
    text-align: center;
}
.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 4px;
}
.login-brand-fire   { font-size: 28px; font-weight: 900; color: #fff; letter-spacing: 1px; }
.login-brand-trainer { font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.75); letter-spacing: 3px; }
.login-subtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
}
.login-body { padding: 28px 32px 32px; }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Breadcrumbs ─────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { opacity: 0.4; }
.breadcrumb-current { color: var(--text); font-weight: 600; }

/* ── Install page ────────────────────────────────────── */
.install-page {
    min-height: 100vh;
    background: var(--body-bg);
    padding: 40px 20px;
}
.install-container {
    max-width: 600px;
    margin: 0 auto;
}
.install-header {
    text-align: center;
    margin-bottom: 28px;
}
.install-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}
.install-subtitle { color: var(--text-muted); margin-top: 6px; }

/* ── Utilities ───────────────────────────────────────── */
.text-muted  { color: var(--text-muted) !important; }
.text-danger { color: var(--primary) !important; }
.text-success { color: var(--green) !important; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: 12px; }
.w-100 { width: 100%; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .main-content {
        margin-left: 0;
    }
    .app-layout {
        flex-direction: column;
    }
    .form-row.cols-2,
    .form-row.cols-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
