:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --success: #15803d;
    --danger: #b91c1c;
    --warning: #b45309;
    --sidebar-width: 260px;
    --radius: 12px;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--text);
    background: var(--surface-muted);
}

a { color: inherit; text-decoration: none; }

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.brand-icon { font-size: 1.75rem; }

.brand strong { display: block; font-size: 1.1rem; }
.brand small { color: #94a3b8; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.nav-link {
    padding: .75rem 1rem;
    border-radius: 10px;
    color: #cbd5e1;
}

.nav-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.user-chip strong { display: block; }
.user-chip small { color: #94a3b8; }

.main-content {
    padding: 1.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    margin: 0 0 .25rem;
    font-size: 1.75rem;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.stat-card .stat-label {
    display: block;
    color: var(--text-muted);
    font-size: .875rem;
    margin-bottom: .35rem;
}

.stat-card .stat-value {
    font-size: 1.35rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    border: none;
    border-radius: 10px;
    padding: .7rem 1rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: .45rem .75rem; font-size: .875rem; }
.btn-block { width: 100%; }

.alert {
    padding: .85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.alert-success { background: #dcfce7; color: var(--success); }
.alert-error { background: #fee2e2; color: var(--danger); }

.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: .75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table-sm th, .table-sm td { padding: .55rem .65rem; font-size: .925rem; }

.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-4 { margin-top: 1rem; }

.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
}

.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-info { background: #dbeafe; color: #1d4ed8; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-weight: 600;
}

.form-grid input,
.form-grid select {
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    font-weight: 600;
}

.form-actions {
    grid-column: 1 / -1;
}

.actions-row {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

.checklist-preview {
    margin: 0;
    padding-left: 1.25rem;
    line-height: 1.8;
}

.checklist-preview .done {
    color: var(--success);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0f172a, #1d4ed8);
    padding: 1rem;
}

.auth-card {
    width: min(100%, 420px);
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-brand h1 { margin: .5rem 0 .25rem; }
.auth-brand p { margin: 0; color: var(--text-muted); }

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-weight: 600;
}

.auth-form input {
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
}

.form-grid textarea {
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    resize: vertical;
}

.full-width { grid-column: 1 / -1; }
.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: .5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.card-link { text-decoration: none; color: inherit; transition: transform .15s; }
.card-link:hover { transform: translateY(-2px); }
.card-link h3 { margin: 0 0 .35rem; }

.stat-success .stat-value { color: var(--success); }
.stat-warning .stat-value { color: var(--warning); }
.stat-danger .stat-value { color: var(--danger); }

.badge-situacao-disponivel { background: #dcfce7; color: var(--success); }
.badge-situacao-em_manutencao { background: #fef3c7; color: var(--warning); }
.badge-situacao-indisponivel { background: #fee2e2; color: var(--danger); }
.badge-situacao-baixada { background: #e2e8f0; color: #475569; }

.badge-prio-urgente { background: #fee2e2; color: #b91c1c; }
.badge-prio-alta { background: #ffedd5; color: #c2410c; }
.badge-prio-media { background: #fef3c7; color: #a16207; }
.badge-prio-baixa { background: #e2e8f0; color: #475569; }

.checklist-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.checklist-item:last-child { border-bottom: none; }
.radio-group { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.radio-pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .45rem .75rem; border: 1px solid var(--border); border-radius: 999px;
    font-weight: 500; cursor: pointer;
}
.radio-pill:has(input:checked) { background: #dbeafe; border-color: #1d4ed8; }
.nc-block { margin-top: .75rem; display: flex; flex-direction: column; gap: .35rem; }

.row-nc { background: #fef2f2; }
.timeline-item { padding: .65rem 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.list-item { padding: .5rem 0; border-bottom: 1px solid var(--border); }

.filter-bar { display: flex; flex-wrap: wrap; gap: .35rem; }
.filter-bar .active { background: #dbeafe; border-color: #1d4ed8; }

.viatura-foto { max-width: 100%; max-height: 280px; border-radius: 10px; }
.btn-lg { padding: .85rem 1.25rem; font-size: 1rem; }

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.report-card form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin-top: .75rem;
}

.report-card label {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-weight: 600;
    font-size: .9rem;
}

.report-card input,
.report-card select {
    padding: .6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.report-output { overflow-x: auto; }
.report-table { font-size: .9rem; }
.print-only { display: none; }

@media print {
    .sidebar, .no-print, .alert { display: none !important; }
    .app-shell { display: block; }
    .main-content { padding: 0; }
    .print-only { display: block; margin-bottom: 1rem; }
    .report-output { box-shadow: none; border: none; }
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .grid-2 { grid-template-columns: 1fr; }
}
