/* ============================================================
   Meus Apês — Design System (glassmorphism)
   ============================================================ */

:root {
    --primary: #1A2A3A;
    --primary-light: #2C4A6E;
    --primary-lighter: #4A7A9C;
    --secondary: #E8A87C;
    --secondary-light: #F5D4B8;
    --accent: #34D399;
    --accent-warning: #FBBF24;
    --accent-danger: #EF4444;
    --neutral-900: #0F172A;
    --neutral-700: #334155;
    --neutral-500: #64748B;
    --neutral-300: #CBD5E1;
    --neutral-200: #E2E8F0;
    --neutral-100: #F1F5F9;
    --white: #FFFFFF;
    --sidebar-w: 256px;
    --radius: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: 0 4px 6px rgba(15, 23, 42, .07);
    --shadow-lg: 0 10px 15px rgba(15, 23, 42, .10);
    --shadow-xl: 0 20px 25px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--neutral-100);
    color: var(--neutral-900);
    font-size: 15px;
    line-height: 1.5;
}

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

h1, h2, h3, h4 { margin: 0 0 .25em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

/* ---------------- Layout ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--neutral-900);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    z-index: 40;
}

.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1.25rem; font-size: 1.15rem; font-weight: 700; }
.brand .logo { width: 36px; height: 36px; border-radius: 12px; background: linear-gradient(135deg, var(--secondary), var(--primary-lighter)); display: grid; place-items: center; font-size: 1.1rem; }

.nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; overflow-y: auto; }
.nav a {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem; border-radius: 12px;
    color: rgba(255,255,255,.75); font-weight: 500; font-size: .92rem;
    text-decoration: none; transition: all .15s ease;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(232,168,124,.18); color: var(--secondary); border-right: 2px solid var(--secondary); }
.nav a .ico { width: 20px; text-align: center; }
.nav .section { margin: 1rem .75rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.35); }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding-top: .9rem; margin-top: .5rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--primary-lighter), var(--secondary)); display: grid; place-items: center; font-weight: 700; color: #fff; }
.user-chip .meta { line-height: 1.2; overflow: hidden; }
.user-chip .meta strong { display: block; font-size: .85rem; }
.user-chip .meta span { font-size: .72rem; color: rgba(255,255,255,.5); }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .9rem 1.75rem;
    background: rgba(255,255,255,.8); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--neutral-200);
}
.topbar h1 { font-size: 1.35rem; margin: 0; }
.topbar .sub { font-size: .82rem; color: var(--neutral-500); }

.content { padding: 1.75rem; max-width: 1400px; width: 100%; }

/* ---------------- Componentes ---------------- */
.card {
    background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.6);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 1.25rem; transition: box-shadow .2s ease, transform .2s ease;
}
.card.hover:hover { box-shadow: var(--shadow-xl); transform: translateY(-2px); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.card-header h3 { margin: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-metrics { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.metric { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.metric .label { font-size: .8rem; color: var(--neutral-500); }
.metric .value { font-size: 1.65rem; font-weight: 700; margin-top: .15rem; }
.metric .trend { font-size: .75rem; color: var(--accent); font-weight: 600; }
.metric .icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.icon-primary { background: rgba(44,74,110,.12); }
.icon-secondary { background: rgba(232,168,124,.18); }
.icon-accent { background: rgba(52,211,153,.15); }
.icon-warning { background: rgba(251,191,36,.18); }
.icon-danger { background: rgba(239,68,68,.14); }

/* Botões */
.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem .95rem; border-radius: 12px; border: 1px solid transparent;
    font-weight: 600; font-size: .88rem; cursor: pointer; font-family: inherit;
    text-decoration: none; transition: all .15s ease; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { filter: brightness(.95); }
.btn-outline { border-color: var(--neutral-300); color: var(--neutral-700); background: #fff; }
.btn-outline:hover { background: var(--neutral-100); }
.btn-ghost { color: var(--neutral-700); background: transparent; }
.btn-ghost:hover { background: var(--neutral-100); }
.btn-danger { background: var(--accent-danger); color: #fff; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge-verde { background: #D1FAE5; color: #047857; }
.badge-amarelo { background: #FEF3C7; color: #B45309; }
.badge-cinza { background: var(--neutral-100); color: var(--neutral-500); }
.badge-vermelho { background: #FEE2E2; color: #B91C1C; }
.badge-azul { background: #DBEAFE; color: #1D4ED8; }

/* Tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--neutral-200); border-radius: 12px; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table thead th {
    text-align: left; padding: .7rem .9rem; background: var(--neutral-100);
    font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--neutral-500); font-weight: 700;
    white-space: nowrap;
}
.table tbody td { padding: .7rem .9rem; border-top: 1px solid var(--neutral-200); vertical-align: middle; }
.table tbody tr:hover { background: rgba(241,245,249,.7); }
.table .right { text-align: right; }
.table .actions { display: flex; gap: .35rem; justify-content: flex-end; }

/* Formulários */
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.full { grid-column: 1 / -1; }
label { font-size: .8rem; font-weight: 600; color: var(--neutral-700); }
input, select, textarea {
    font-family: inherit; font-size: .9rem; padding: .55rem .7rem;
    border: 1px solid var(--neutral-300); border-radius: 10px; background: #fff; color: var(--neutral-900);
    transition: border-color .15s ease, box-shadow .15s ease; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-lighter); box-shadow: 0 0 0 3px rgba(74,122,156,.15); }
textarea { resize: vertical; min-height: 90px; }
.hint { font-size: .74rem; color: var(--neutral-500); }
.required::after { content: ' *'; color: var(--accent-danger); }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 140px; }

/* Alertas */
.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .88rem; border: 1px solid transparent; }
.alert-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.alert-error { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }
.alert-info { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }

/* Vazio */
.empty { text-align: center; padding: 3rem 1rem; color: var(--neutral-500); }
.empty .big { font-size: 2.5rem; margin-bottom: .5rem; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(4px); z-index: 60; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-xl); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 1.5rem; animation: slideUp .22s ease-out; }
.modal h3 { margin-top: 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }

@keyframes slideUp { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Paginação */
.pagination { display: flex; gap: .3rem; justify-content: center; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .4rem .7rem; border-radius: 9px; border: 1px solid var(--neutral-200); background: #fff; font-size: .85rem; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--neutral-900), var(--primary-light)); padding: 1rem; }
.auth-card { background: rgba(255,255,255,.96); backdrop-filter: blur(16px); border-radius: 22px; box-shadow: var(--shadow-xl); padding: 2rem; width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; color: var(--neutral-900); padding-bottom: 1.25rem; }

/* Toast */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .6rem; }
.toast { background: var(--neutral-900); color: #fff; padding: .8rem 1rem; border-radius: 12px; box-shadow: var(--shadow-xl); font-size: .86rem; display: flex; gap: .6rem; align-items: center; animation: slideUp .2s ease-out; max-width: 360px; }
.toast button { background: none; border: none; color: rgba(255,255,255,.6); cursor: pointer; margin-left: auto; }

/* Barras e gráficos */
.bar { height: 8px; background: var(--neutral-200); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-lighter)); border-radius: 999px; }
.chart-bars { display: flex; align-items: flex-end; gap: .5rem; height: 160px; padding-top: 1rem; }
.chart-bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: .4rem; height: 100%; }
.chart-bars .col .bar-v { width: 100%; max-width: 42px; background: linear-gradient(180deg, var(--primary-lighter), var(--primary)); border-radius: 8px 8px 0 0; min-height: 4px; transition: height .3s ease; }
.chart-bars .col small { font-size: .68rem; color: var(--neutral-500); }

/* Calendário */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar .dow { text-align: center; font-size: .7rem; font-weight: 700; color: var(--neutral-500); text-transform: uppercase; padding: .3rem; }
.calendar .day { min-height: 74px; border: 1px solid var(--neutral-200); border-radius: 10px; padding: .3rem; background: #fff; }
.calendar .day.today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(44,74,110,.15); }
.calendar .day.muted { background: var(--neutral-100); color: var(--neutral-300); }
.calendar .day .num { font-size: .74rem; font-weight: 600; color: var(--neutral-500); }
.calendar .day .dot { height: 5px; border-radius: 999px; margin-top: 3px; }

/* Utilitários */
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--neutral-500); }
.small { font-size: .8rem; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .content { padding: 1rem; }
    .menu-toggle { display: inline-flex !important; }
    .table .hide-mobile { display: none; }
}
.menu-toggle { display: none; }
