/* =========================================================
   1. DESIGN TOKENS
   ========================================================= */

:root {
    /* Marca */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-ring: rgba(37, 99, 235, 0.15);

    /* Feedback */
    --success: #16a34a;
    --success-dark: #15803d;
    --success-light: #f0fdf4;
    --success-border: #bbf7d0;

    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-light: #fef2f2;
    --danger-border: #fecaca;

    --warning: #d97706;
    --warning-light: #fffbeb;
    --warning-border: #fde68a;

    /* Administrativo */
    --admin: #7c3aed;
    --admin-dark: #6d28d9;
    --admin-light: rgba(124, 58, 237, 0.08);
    --admin-border: rgba(124, 58, 237, 0.25);

    /* Neutros */
    --ink: #0f172a;
    --ink-2: #1e293b;
    --text: #334155;
    --text-soft: #64748b;
    --text-mute: #94a3b8;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;

    /* Tipografia */
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Arial, sans-serif;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 1.875rem;

    /* Espaçamento */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 16px;
    --sp-4: 24px;
    --sp-5: 32px;

    /* Bordas */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;

    /* Sombras */
    --sh-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --sh-md: 0 4px 12px rgba(15, 23, 42, 0.06);
    --sh-lg: 0 12px 30px rgba(15, 23, 42, 0.10);
    --sh-focus: 0 0 0 3px var(--primary-ring);

    /* Transições */
    --tr-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --tr-md: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}


/* =========================================================
   2. DARK MODE
   ========================================================= */

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f8fafc;
        --ink-2: #e2e8f0;
        --text: #cbd5e1;
        --text-soft: #94a3b8;
        --text-mute: #64748b;

        --bg: #0f172a;
        --surface: #1e293b;
        --line: #334155;
        --line-strong: #475569;

        --primary-light: rgba(37, 99, 235, 0.15);
        --success-light: rgba(22, 163, 74, 0.15);
        --danger-light: rgba(220, 38, 38, 0.15);
        --warning-light: rgba(217, 119, 6, 0.15);

        --admin: #a78bfa;
        --admin-dark: #8b5cf6;
        --admin-light: rgba(167, 139, 250, 0.15);
        --admin-border: rgba(167, 139, 250, 0.3);
    }
}


/* =========================================================
   3. RESET
   ========================================================= */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }


/* =========================================================
   4. TOPBAR
   ========================================================= */

.topbar {
    height: 68px;
    flex-shrink: 0;
    background: var(--surface);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.3125rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
}

.logo:hover { color: var(--ink); }

.logo::before {
    content: "N";
    width: 34px;
    height: 34px;
    background: var(--primary);
    color: #fff;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 17px;
    font-weight: 800;
    flex-shrink: 0;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: var(--fs-sm);
}

.user-area span { color: var(--text-soft); }

.user-area a {
    color: var(--text);
    font-weight: 500;
    transition: color var(--tr-md);
}

.user-area a:hover { color: var(--primary); }
.user-area a.active { color: var(--primary); font-weight: 700; }


/* =========================================================
   5. CONTAINER E CABEÇALHO DE PÁGINA
   ========================================================= */

.container {
    flex: 1 0 auto;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 38px 0 40px;
}

.container > h1 {
    color: var(--ink);
    font-size: var(--fs-2xl);
    font-weight: 750;
    letter-spacing: -0.7px;
    margin-bottom: 8px;
    line-height: 1.2;
}

.description,
.welcome {
    color: var(--text-soft);
    margin-bottom: 28px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 0 0 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.page-header-text {
    flex: 1 1 320px;
    min-width: 0;
}

.page-header-text h1 {
    color: var(--ink);
    font-size: var(--fs-2xl);
    font-weight: 750;
    letter-spacing: -0.7px;
    line-height: 1.15;
    margin-bottom: 8px;
}

.page-header-text p {
    color: var(--text-soft);
    font-size: var(--fs-sm);
    line-height: 1.55;
    max-width: 640px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-top: 6px;
}

.page-header-actions .btn { margin-top: 0; }


/* =========================================================
   6. CARDS E INFO BOX
   ========================================================= */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 22px;
    margin-top: 25px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 28px;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    box-shadow: var(--sh-md);
    transition:
        transform var(--tr-md),
        box-shadow var(--tr-md),
        border-color var(--tr-md);
    display: block;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--primary);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--sh-lg);
    border-color: var(--primary);
}

.card:hover::before { transform: scaleY(1); }
.card:active { transform: translateY(-2px); }

.card h2 {
    color: var(--ink);
    font-size: var(--fs-lg);
    margin-bottom: 8px;
    font-weight: 700;
}

.card p {
    color: var(--text-soft);
    font-size: var(--fs-sm);
    margin-bottom: 22px;
}

.card-number {
    display: block;
    color: var(--primary);
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 5px;
}

.card > span {
    color: var(--text-soft);
    font-size: var(--fs-xs);
}

.info-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 25px;
    margin-top: 24px;
    box-shadow: var(--sh-md);
}

.info-box h3 {
    color: var(--ink);
    font-size: 1.0625rem;
    margin-bottom: 18px;
    font-weight: 700;
}

.info-box p {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-size: var(--fs-sm);
}

.info-box p:last-child { border-bottom: none; }
.info-box strong { color: var(--ink); }


/* =========================================================
   7. FORMULÁRIOS E CONTROLES
   ========================================================= */

.form-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 30px;
    max-width: 700px;
    box-shadow: var(--sh-md);
}

.form-box label,
form > label {
    display: block;
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: 600;
    margin-bottom: 7px;
    margin-top: 18px;
}

.form-box label:first-child { margin-top: 0; }

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: var(--fs-sm);
    outline: none;
    transition:
        border-color var(--tr-md),
        box-shadow var(--tr-md),
        background var(--tr-md);
}

input:hover,
select:hover,
textarea:hover { border-color: var(--text-mute); }

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--sh-focus);
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--bg);
    cursor: not-allowed;
    opacity: 0.6;
}

textarea {
    resize: vertical;
    min-height: 110px;
    font-family: inherit;
}

::placeholder { color: var(--text-mute); opacity: 1; }

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 38px;

    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
}

select:focus {
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

@media (prefers-color-scheme: dark) {
    select {
        background-image:
            url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    }
}


/* =========================================================
   8. BOTÕES
   ========================================================= */

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--r-sm);
    padding: 11px 18px;
    margin-top: 22px;
    background: var(--primary);
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background var(--tr-md),
        transform var(--tr-fast),
        box-shadow var(--tr-md);
}

button:hover,
.btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.25);
}

a.btn,
a.btn:hover { color: #fff; }

button:active,
.btn:active { transform: translateY(1px); }

button:disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    background: var(--line);
    color: var(--ink);
}

.btn-secondary:hover {
    background: var(--line-strong);
    color: var(--ink);
    box-shadow: none;
}

a.btn-secondary,
a.btn-secondary:hover { color: var(--ink); }

.btn-danger { background: var(--danger); }
.btn-danger:hover {
    background: var(--danger-dark);
    box-shadow: 0 5px 15px rgba(220, 38, 38, 0.25);
}

.btn-success { background: var(--success); }
.btn-success:hover {
    background: var(--success-dark);
    box-shadow: 0 5px 15px rgba(22, 163, 74, 0.25);
}

.btn-small {
    padding: 7px 12px;
    font-size: var(--fs-xs);
    font-weight: 600;
    margin-top: 0;
    line-height: 1.4;
    border-radius: var(--r-sm);
}


/* =========================================================
   9. ADMINISTRAÇÃO
   ========================================================= */

.admin-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0 25px;
}

.admin-card { border-color: var(--admin-border); }
.admin-card::before { background: var(--admin); }

.admin-card:hover {
    border-color: var(--admin);
    box-shadow: 0 12px 30px rgba(124, 58, 237, 0.12);
}

.admin-card strong,
.admin-card .card-number { color: var(--admin); }


/* =========================================================
   10. FILTROS, TABELA, CHECKBOX, BADGES, ALERTAS
   ========================================================= */

.filters {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: var(--sh-md);
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 14px;
    align-items: end;
}

.filters label {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-soft);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.filters button,
.filters .btn { margin-top: 0; }

.filters.filters-busca {
    grid-template-columns: 1fr 240px auto auto;
}

.table-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--sh-md);
}

table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg); }

th {
    text-align: left;
    color: var(--text-soft);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}

td {
    padding: 15px 18px;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--line);
    color: var(--text);
}

tbody tr { transition: background var(--tr-fast); }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

.checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: var(--r-pill);
    font-size: 0.6875rem;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary);
    line-height: 1.4;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

.alert {
    padding: 14px 16px;
    border-radius: var(--r-sm);
    margin-bottom: 20px;
    font-size: var(--fs-sm);
    font-weight: 500;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert.success {
    background: var(--success-light);
    color: #166534;
    border-color: var(--success-border);
}

.alert.error {
    background: var(--danger-light);
    color: #991b1b;
    border-color: var(--danger-border);
}

.alert.warning {
    background: var(--warning-light);
    color: #92400e;
    border-color: var(--warning-border);
}

@media (prefers-color-scheme: dark) {
    .alert.success { color: #86efac; }
    .alert.error   { color: #fca5a5; }
    .alert.warning { color: #fcd34d; }
}


/* =========================================================
   11. LOGIN
   ========================================================= */

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, #dbeafe 0, transparent 35%),
        radial-gradient(circle at bottom right, #e0e7ff 0, transparent 35%),
        var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

@media (prefers-color-scheme: dark) {
    .login-body {
        background:
            radial-gradient(circle at top left, rgba(37, 99, 235, 0.15) 0, transparent 35%),
            radial-gradient(circle at bottom right, rgba(99, 102, 241, 0.15) 0, transparent 35%),
            var(--bg);
    }
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 38px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

.login-box h1 {
    color: var(--ink);
    text-align: center;
    font-size: 1.75rem;
    letter-spacing: -0.6px;
    margin-bottom: 5px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-soft);
    font-size: var(--fs-sm);
    margin-bottom: 30px;
}

.login-box label {
    display: block;
    color: var(--ink);
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 7px;
    margin-top: 18px;
}

.login-box label:first-of-type { margin-top: 0; }

.login-box button {
    width: 100%;
    margin-top: 25px;
    padding: 13px;
}


/* =========================================================
   12. FOOTER
   ========================================================= */

.footer {
    flex-shrink: 0;
    text-align: center;
    color: var(--text-mute);
    font-size: var(--fs-xs);
    padding: 20px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.footer a { color: var(--primary); font-weight: 600; }
.footer a:hover { color: var(--primary-dark); }


/* =========================================================
   13. REGIÕES
   ========================================================= */

.rg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.rg-toolbar button { margin-top: 0; }

.rg-footer {
    position: relative;
    margin: 24px auto 16px auto;
    width: min(900px, calc(100% - 24px));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.rg-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 14px;
    width: 100%;
}

.rg-row + .rg-row {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.rg-footer button,
.rg-footer .btn,
.rg-dialog button { margin-top: 0; }

.rg-info { font-size: var(--fs-sm); color: var(--text-soft); }

.rg-per {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    color: var(--text-soft);
    margin: 0;
}

.rg-per select {
    width: auto;
    padding: 6px 30px 6px 10px;
}

.rg-pill {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--r-pill);
    padding: 8px 16px;
    font-size: var(--fs-sm);
}

.rg-pill:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: none;
}

.rg-pill b { font-size: var(--fs-md); }

.rg-dirty {
    display: none;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--warning);
    background: var(--warning-light);
    border: 1px solid var(--warning-border);
    border-radius: var(--r-pill);
    padding: 4px 10px;
}

#rg-toasts {
    position: fixed;
    right: var(--sp-3);
    bottom: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100vw - 32px);
}

.rg-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 260px;
    max-width: 380px;
    padding: 12px 14px;
    background: var(--ink);
    color: var(--surface);
    border-radius: var(--r-md);
    border-left: 5px solid var(--success);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    font-size: var(--fs-sm);
    animation: rgIn 0.25s ease-out;
}

.rg-toast.remove { border-left-color: var(--danger); }
.rg-toast.out    { animation: rgOut 0.2s ease-in forwards; }

.rg-toast .ico {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--success);
    color: #fff;
    font-weight: 700;
}

.rg-toast.remove .ico { background: var(--danger); }
.rg-toast .txt { flex: 1; line-height: 1.3; }

.rg-toast .txt small {
    display: block;
    opacity: 0.7;
    font-size: var(--fs-xs);
}

.rg-toast button {
    margin-top: 0;
    background: transparent;
    color: #93c5fd;
    padding: 4px 6px;
    font-size: var(--fs-xs);
    font-weight: 700;
}

.rg-toast button:hover {
    background: transparent;
    color: #fff;
    box-shadow: none;
}

@keyframes rgIn  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes rgOut { to   { opacity: 0; transform: translateY(12px); } }

#rg-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    padding: var(--sp-3);
}

#rg-modal.open { display: flex; }

.rg-dialog {
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    animation: rgIn 0.2s ease-out;
}

.rg-dh {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.rg-dh h2 {
    margin: 0;
    font-size: var(--fs-lg);
    color: var(--ink);
}

.rg-x {
    background: transparent;
    color: var(--text-soft);
    padding: 0 6px;
    font-size: 1.5rem;
    line-height: 1;
}

.rg-x:hover {
    background: transparent;
    color: var(--ink);
    box-shadow: none;
}

.rg-ds { padding: 12px 20px 0; }

.rg-list {
    padding: 8px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 120px;
}

.rg-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.rg-item:last-child { border-bottom: 0; }

.rg-sigla {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: var(--fs-xs);
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 44px;
    text-align: center;
}

.rg-nome { flex: 1; font-size: var(--fs-sm); color: var(--ink); }

.rg-rm {
    background: var(--danger-light);
    color: var(--danger);
    padding: 6px 10px;
    font-size: var(--fs-xs);
}

.rg-rm:hover {
    background: var(--danger-border);
    color: var(--danger-dark);
    box-shadow: none;
}

.rg-empty { text-align: center; padding: 30px 0; color: var(--text-mute); }

.rg-df {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    flex-wrap: wrap;
    border-top: 1px solid var(--line);
}


/* =========================================================
   14. MAPA
   ========================================================= */

.mp-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-md);
    padding: 20px;
    margin-bottom: 22px;
}

.mp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 16px;
}

.mp-head h2 {
    font-size: var(--fs-lg);
    color: var(--ink);
    font-weight: 700;
    margin: 0;
}

.mp-head-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: auto;
}

.mp-toggle {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 3px;
    gap: 2px;
}

.mp-toggle-btn {
    border: 0;
    background: transparent;
    padding: 7px 16px;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-soft);
    cursor: pointer;
    font-family: inherit;
    margin: 0;
    transition:
        background var(--tr-md),
        color var(--tr-md),
        box-shadow var(--tr-md);
}

.mp-toggle-btn:hover {
    color: var(--ink);
    background: transparent;
    box-shadow: none;
}

.mp-toggle-btn.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--sh-sm);
}

.mp-combo { position: relative; }
.mp-combo > button { margin-top: 0; }

.mp-count {
    display: inline-block;
    margin-left: 6px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--r-pill);
    padding: 1px 8px;
    font-size: var(--fs-xs);
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.mp-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: min(360px, calc(100vw - 48px));
    max-height: 440px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
    z-index: 950;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mp-panel[hidden] { display: none; }

.mp-panel input[type="text"] {
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 12px 14px;
    font-size: var(--fs-sm);
    outline: none;
    background: var(--surface);
    color: var(--ink);
}

.mp-panel input[type="text"]:focus {
    box-shadow: none;
    border-color: var(--primary);
}

.mp-lista { overflow-y: auto; max-height: 380px; padding: 6px 0; }

.mp-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    font-size: var(--fs-sm);
    color: var(--ink);
    cursor: pointer;
    transition: background var(--tr-fast);
}

.mp-item:hover { background: var(--bg); }
.mp-item input[type="checkbox"] { flex-shrink: 0; margin: 0; }

.mp-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-item small {
    color: var(--text-mute);
    font-size: var(--fs-xs);
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-weight: 600;
}

.mp-vazio {
    padding: 16px;
    text-align: center;
    color: var(--text-mute);
    font-size: var(--fs-xs);
}

.mp-map {
    width: 100%;
    height: 480px;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--bg);
    position: relative;
}

.mp-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    text-align: center;
    color: var(--text-soft);
    font-size: var(--fs-sm);
}

.mp-hint {
    margin-top: 12px;
    font-size: var(--fs-xs);
    color: var(--text-soft);
}

.mp-legenda {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: var(--fs-xs);
}

.mp-legenda[hidden] { display: none; }

.mp-legenda-titulo { font-weight: 700; color: var(--ink); }
.mp-legenda-itens { display: flex; flex-wrap: wrap; gap: 10px; }

.mp-legenda-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    padding: 3px 8px;
    border-radius: var(--r-pill);
    transition:
        background var(--tr-fast),
        opacity var(--tr-fast);
}

.mp-legenda-item:hover { background: var(--surface); }
.mp-legenda-item.is-off { opacity: 0.35; }

.mp-legenda-item.is-eu { font-weight: 700; color: var(--ink); }

.mp-legenda-cor {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--line-strong);
    flex-shrink: 0;
}

.mp-legenda-item.is-eu .mp-legenda-cor {
    box-shadow: 0 0 0 2px var(--ink);
}

.mp-legenda-item small { color: var(--text-mute); font-weight: 600; }

tbody tr.row-ocupada {
    opacity: 0.6;
    background: var(--warning-light) !important;
}

tbody tr.row-ocupada:hover {
    background: var(--warning-light) !important;
    opacity: 0.85;
}

tbody tr.row-ocupada .chk-cidade { cursor: not-allowed; opacity: 0.7; }

tbody tr.row-ocupada .badge {
    font-size: 0.6875rem;
    padding: 3px 8px;
    vertical-align: middle;
}

.mp-item-ocupada {
    opacity: 0.55;
    cursor: not-allowed !important;
    background: var(--warning-light);
}

.mp-item-ocupada:hover { background: var(--warning-light); }
.mp-item-ocupada input[type="checkbox"] { cursor: not-allowed; }


/* =========================================================
   15. LISTA PÚBLICA (KPIs, SUPERVISOR TAG, PAGINAÇÃO)
   ========================================================= */

.idx-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.idx-kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 20px 22px;
    box-shadow: var(--sh-sm);
}

.idx-kpi span {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.idx-kpi strong {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.idx-kpi small {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-mute);
    margin-top: 4px;
}

.sup-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: var(--fs-sm);
    color: var(--ink);
    font-weight: 500;
}

.sup-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--line-strong);
}

.sup-vazio {
    color: var(--text-mute);
    font-size: var(--fs-sm);
    font-style: italic;
}

.idx-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 22px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-sm);
}

.idx-pag {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.idx-pag a,
.idx-pag span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: 600;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    transition: all var(--tr-fast);
}

.idx-pag a:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.idx-pag .is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.idx-pag .is-dots {
    background: transparent;
    border: 0;
    color: var(--text-mute);
}


/* =========================================================
   16. RESPONSIVO
   ========================================================= */

@media (max-width: 800px) {

    .topbar { padding: 0 18px; }

    .user-area { gap: 10px; }
    .user-area span { display: none; }

    .container {
        width: min(100% - 24px, 1180px);
        padding-top: 25px;
    }

    .container > h1 { font-size: 1.5625rem; }

    .cards { grid-template-columns: 1fr; }

    .filters,
    .filters.filters-busca { grid-template-columns: 1fr; }
    .filters button,
    .filters .btn { width: 100%; }

    .table-box { overflow-x: auto; }
    table { min-width: 650px; }

    .form-box { padding: 22px; }

    .admin-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-actions .btn,
    .admin-actions button { width: 100%; }

    #rg-toasts { bottom: 20px; right: 12px; left: 12px; }
    .rg-toast { min-width: 0; max-width: none; }

    .mp-head { flex-direction: column; align-items: stretch; }
    .mp-head-actions { margin-left: 0; width: 100%; }

    .mp-toggle { width: 100%; justify-content: space-between; }
    .mp-toggle-btn { flex: 1; text-align: center; }

    .mp-combo { width: 100%; }
    .mp-combo > button { width: 100%; justify-content: space-between; }
    .mp-panel { width: 100%; right: auto; left: 0; }

    .mp-map { height: 340px; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding-bottom: 20px;
    }

    .page-header-text h1 { font-size: 1.625rem; }

    .page-header-actions {
        padding-top: 0;
    }

    .page-header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .idx-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .idx-pag { justify-content: center; }
}

@media (max-width: 500px) {

    .topbar { height: 60px; }
    .logo { font-size: 1.125rem; }
    .logo::before { width: 30px; height: 30px; }

    .login-box { padding: 28px 22px; }
    .card { padding: 22px; }
    .container { padding-bottom: 40px; }
}


/* =========================================================
   17. SCROLLBAR
   ========================================================= */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }

::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: var(--r-pill);
}

::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }


/* =========================================================
   18. PRINT
   ========================================================= */

@media print {
    .topbar,
    .footer,
    .filters,
    .rg-footer,
    .rg-toolbar,
    #rg-toasts,
    #rg-modal,
    .mp-box,
    .page-header-actions,
    .idx-footer,
    button,
    .btn { display: none !important; }

    body { background: #fff; display: block; }

    .card,
    .table-box,
    .form-box,
    .info-box,
    .idx-kpi {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
