:root {
    --bg: #0b1220;
    --sidebar: #0f172a;
    --surface: #131c31;
    --surface-2: #1c2945;
    --border: rgba(148, 163, 184, 0.16);
    --text: #f1f5f9;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
    min-height: 100vh;
}

.hidden { display: none !important; }
a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }

/* LOGIN ADMIN */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.45);
}
.login-box h1 { margin: 0 0 6px; font-size: 1.35rem; }
.login-box p { margin: 0 0 20px; color: var(--muted); font-size: 0.9rem; }

/* SHELL */
.admin-shell {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 245px;
    flex-shrink: 0;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.side-brand {
    padding: 6px 10px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.side-brand strong { display: block; font-size: 1.05rem; }
.side-brand span { font-size: 0.78rem; color: var(--muted); }

.nav-list { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    text-align: left;
    padding: 11px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.14s;
}
.side-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.side-btn.active { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }

.side-footer {
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.main-area {
    flex: 1;
    min-width: 0;
    padding: 22px 26px 40px;
}
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.page-header h2 { margin: 0; font-size: 1.35rem; }

/* CARDS & GRIDS */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.kpi-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.7rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}
.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.card-head h3 { margin: 0; font-size: 1rem; }

/* FORMULÁRIOS */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.field { margin-bottom: 12px; }
.field label {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 5px;
    font-weight: 600;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0d1526;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--primary);
}
.check-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    user-select: none;
}
.check-line input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); }

/* BOTÕES */
.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #2563eb; }
.btn-success { background: #059669; }
.btn-warning { background: #d97706; color: #fff; }
.btn-danger { background: #dc2626; }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; border-radius: 8px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* TABELAS */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}
th, td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
th {
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(15, 23, 42, 0.55);
}
tr:hover td { background: rgba(255,255,255,0.02); }

.thumb {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
    cursor: pointer;
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}
.b-ok { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.b-warn { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.b-err { background: rgba(239, 68, 68, 0.16); color: #f87171; }
.b-info { background: rgba(59, 130, 246, 0.16); color: #60a5fa; }
.b-muted { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }

/* FILTROS */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 14px;
}
.filter-bar .field { margin: 0; min-width: 145px; flex: 1; }

/* MODAIS */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(5, 10, 20, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}
.modal-card {
    width: 100%;
    max-width: 720px;
    max-height: 92vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 1.08rem; }

.photo-modal img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
}

/* SUB-ABAS */
.subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.subtab-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 9px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.86rem;
}
.subtab-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

/* TOAST */
.toast {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 120;
    max-width: 380px;
    padding: 13px 16px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}
.toast-ok { background: #065f46; border: 1px solid #10b981; color: #ecfdf5; }
.toast-err { background: #7f1d1d; border: 1px solid #ef4444; color: #fef2f2; }
.toast-info { background: #1e3a8a; border: 1px solid #3b82f6; color: #eff6ff; }

/* TABELA DE ESCALA NO MODAL */
.escala-table input[type="time"], .escala-table input[type="number"] {
    padding: 6px 8px;
    font-size: 0.82rem;
    background: #0d1526;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.mobile-bar {
    display: none;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
}

@media (max-width: 900px) {
    .admin-shell { flex-direction: column; }
    .mobile-bar { display: flex; }
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        z-index: 70;
        transition: left 0.2s;
    }
    .sidebar.open { left: 0; }
    .main-area { padding: 16px 14px 40px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
