/* ============================================================================
 * Mizukoi — Design System
 * Paleta: índigo profundo → violeta → água. Fluxo de caixa.
 * ============================================================================ */

/* -----------------------------------------------------------------------------
 * Tokens
 * ----------------------------------------------------------------------------- */
:root {
    /* Cores primárias */
    --mizu-50:  #EEF2FF;
    --mizu-100: #E0E7FF;
    --mizu-200: #C7D2FE;
    --mizu-300: #A5B4FC;
    --mizu-400: #818CF8;
    --mizu-500: #6366F1;  /* Índigo base */
    --mizu-600: #4F46E5;
    --mizu-700: #4338CA;
    --mizu-800: #3730A3;
    --mizu-900: #1E1B4B;

    /* Água (accent) */
    --aqua-400: #22D3EE;
    --aqua-500: #06B6D4;
    --aqua-600: #0891B2;

    /* Violeta (accent secundário) */
    --violet-400: #A78BFA;
    --violet-500: #8B5CF6;
    --violet-600: #7C3AED;

    /* Estado */
    --green-500: #10B981;
    --green-50:  #ECFDF5;
    --red-500:   #EF4444;
    --red-50:    #FEF2F2;
    --amber-500: #F59E0B;
    --amber-50:  #FFFBEB;

    /* Neutros */
    --slate-50:  #F8FAFC;
    --slate-100: #F1F5F9;
    --slate-200: #E2E8F0;
    --slate-300: #CBD5E1;
    --slate-400: #94A3B8;
    --slate-500: #64748B;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1E293B;
    --slate-900: #0F172A;

    /* Semânticos */
    --bg:          #F5F7FB;
    --bg-card:     #FFFFFF;
    --border:      var(--slate-200);
    --text:        var(--slate-800);
    --text-soft:   var(--slate-500);
    --text-strong: var(--mizu-900);
    --primary:     var(--mizu-600);
    --primary-hover: var(--mizu-700);

    /* Tipografia */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    --font-display: "Inter", var(--font-sans);

    /* Espaçamento e radius */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Sombras */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 28px rgba(79, 70, 229, 0.12);

    /* Gradiente assinatura */
    --gradient-mizu: linear-gradient(135deg, #4F46E5 0%, #8B5CF6 45%, #06B6D4 100%);
    --gradient-soft: linear-gradient(135deg, #EEF2FF 0%, #F0F9FF 100%);

    /* Motion */
    --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* -----------------------------------------------------------------------------
 * Reset moderno
 * ----------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
input, select, textarea { font: inherit; color: inherit; }

/* -----------------------------------------------------------------------------
 * Tipografia
 * ----------------------------------------------------------------------------- */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--text-strong);
    letter-spacing: -0.01em;
    font-weight: 700;
    line-height: 1.2;
}
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
.text-soft { color: var(--text-soft); }
.text-strong { color: var(--text-strong); }
.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 20px; }

/* -----------------------------------------------------------------------------
 * Layout da app (sidebar + conteúdo)
 * ----------------------------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: #FFFFFF;
    border-right: 1px solid var(--border);
    padding: 24px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}
/* Bloco de perfil no rodapé (estilo WealthWise/Finexa) */
.sidebar-profile {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.profile-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--slate-700);
    transition: background var(--transition);
    text-decoration: none;
}
.profile-link:hover { background: var(--slate-50); color: var(--slate-800); }
.profile-link.active { background: var(--mizu-50); }
.profile-link.active .profile-name { color: var(--mizu-700); }
.profile-info { flex: 1; min-width: 0; }
.profile-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--slate-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-sub {
    font-size: 11px;
    color: var(--text-soft);
    letter-spacing: 0.02em;
}
.profile-arrow {
    width: 14px;
    height: 14px;
    color: var(--slate-400);
    flex-shrink: 0;
}
.logout-form { margin: 0; }
.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: transparent;
    color: var(--slate-500);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.logout-btn:hover { background: var(--red-50); color: var(--red-500); }

/* Avatar */
.avatar {
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: var(--gradient-mizu);
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.02em;
    position: relative;
    box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(79, 70, 229, 0.18);
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar-initials {
    font-size: 0.9em;
    line-height: 1;
}
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 48px; height: 48px; font-size: 18px; }
.avatar-xl {
    width: 88px; height: 88px; font-size: 34px;
    box-shadow: 0 0 0 4px #fff, 0 8px 24px rgba(79, 70, 229, 0.22);
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.sidebar .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--gradient-mizu);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
    box-shadow: var(--shadow-sm);
    position: relative;
}
/* Marca koi: pequeno círculo coral que representa a carpa no canto superior direito */
.sidebar .brand-logo::after,
.auth-brand .logo::after {
    content: "";
    position: absolute;
    top: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    background: #FB923C;
    border-radius: 50%;
    border: 2px solid #FFFFFF;
    box-shadow: 0 1px 3px rgba(251, 146, 60, 0.4);
}
.auth-brand .logo::after {
    width: 14px;
    height: 14px;
    top: -3px;
    right: -3px;
}
.sidebar .brand-name {
    font-size: 19px;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.02em;
}
.sidebar .brand-tagline {
    font-size: 11px;
    color: var(--text-soft);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--slate-600);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--mizu-50); color: var(--mizu-700); }
.nav-item.active {
    background: var(--mizu-50);
    color: var(--mizu-700);
    font-weight: 600;
}
.nav-item .icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.9;
}
/* footer-card legado — substituído pelo sidebar-profile */

.main {
    padding: 32px 40px 48px;
    max-width: 1280px;
    width: 100%;
}
.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}
.topbar .greeting {
    font-size: 13px;
    color: var(--text-soft);
    letter-spacing: 0.02em;
    font-weight: 500;
}
.topbar h1 {
    margin-top: 4px;
    font-size: 30px;
    letter-spacing: -0.02em;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}
.topbar > div { min-width: 0; }
.topbar h1 .highlight { color: var(--mizu-600); }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* -----------------------------------------------------------------------------
 * Cards
 * ----------------------------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { border-color: var(--slate-300); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04); }
.card h2, .card h3 { margin-bottom: 6px; }
.card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}
.card-title h3 { font-size: 15px; color: var(--slate-700); font-weight: 600; }
.grid { display: grid; gap: 18px; }
.grid-kpi {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid-2 { grid-template-columns: 1.5fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1024px) {
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2   { grid-template-columns: 1fr; }
    .grid-3   { grid-template-columns: 1fr; }
}

.kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
    border-color: var(--slate-300);
}
.kpi .label {
    font-size: 12px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.kpi .value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-strong);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.kpi .hint {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 4px;
}
.kpi.positive .value { color: var(--green-500); }
.kpi.negative .value { color: var(--red-500); }
.kpi.pending  .value { color: var(--amber-500); }
.kpi::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--gradient-mizu);
    opacity: 0.85;
}
.kpi.positive::before { background: linear-gradient(90deg, #10B981, #06B6D4); }
.kpi.negative::before { background: linear-gradient(90deg, #EF4444, #F59E0B); }
.kpi.pending::before  { background: linear-gradient(90deg, #F59E0B, #8B5CF6); }

/* -----------------------------------------------------------------------------
 * Botões
 * ----------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    line-height: 1.2;
}
.btn-primary {
    background: var(--gradient-mizu);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-lg); color: #fff; transform: translateY(-1px); }
.btn-secondary {
    background: #fff;
    color: var(--slate-700);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--slate-50); color: var(--slate-800); }
.btn-ghost {
    background: transparent;
    color: var(--slate-600);
}
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-800); }
.btn-danger {
    background: #fff;
    color: var(--red-500);
    border-color: var(--border);
}
.btn-danger:hover { background: var(--red-50); border-color: var(--red-500); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* -----------------------------------------------------------------------------
 * Formulários
 * ----------------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 6px;
}
.input, .select, .textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-size: 14px;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--mizu-400);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.input.error, .select.error, .textarea.error { border-color: var(--red-500); }
.input-hint { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.input-error { font-size: 12px; color: var(--red-500); margin-top: 4px; font-weight: 500; }

.radio-pills { display: inline-flex; padding: 4px; background: var(--slate-100); border-radius: var(--radius); gap: 4px; }
.radio-pills input { display: none; }
.radio-pills label {
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-600);
    cursor: pointer;
    transition: all var(--transition);
}
.radio-pills input:checked + label {
    background: #fff;
    color: var(--mizu-700);
    box-shadow: var(--shadow-xs);
    font-weight: 600;
}

/* -----------------------------------------------------------------------------
 * Tabela
 * ----------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: #fff; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--slate-100);
}
.table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-500);
    font-weight: 600;
    background: var(--slate-50);
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--slate-50); }
.table td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .muted { color: var(--text-soft); }

/* -----------------------------------------------------------------------------
 * Badges e status
 * ----------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.badge-receita { background: var(--green-50); color: var(--green-500); }
.badge-despesa { background: var(--red-50);   color: var(--red-500); }
.badge-pago    { background: var(--green-50); color: var(--green-500); }
.badge-pendente{ background: var(--amber-50); color: var(--amber-500); }
.badge-fixa    { background: var(--mizu-50);  color: var(--mizu-700); }
.badge-variavel{ background: var(--slate-100);color: var(--slate-600); }
.badge-dot::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--slate-700);
}
.category-chip .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* -----------------------------------------------------------------------------
 * Toast / flash
 * ----------------------------------------------------------------------------- */
.flash-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    max-width: 360px;
}
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: slideIn 220ms cubic-bezier(0.4, 0, 0.2, 1);
}
.flash::before {
    content: "";
    width: 4px;
    align-self: stretch;
    border-radius: 2px;
    background: var(--mizu-500);
    flex-shrink: 0;
}
.flash-success::before { background: var(--green-500); }
.flash-error::before   { background: var(--red-500); }
.flash-warning::before { background: var(--amber-500); }
.flash-info::before    { background: var(--aqua-500); }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(18px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* -----------------------------------------------------------------------------
 * Empty state
 * ----------------------------------------------------------------------------- */
.empty {
    padding: 44px 24px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-soft);
    background: #fff;
}
.empty h3 { color: var(--slate-700); margin-bottom: 4px; }
.empty p { font-size: 14px; max-width: 320px; margin: 0 auto 14px; }

/* -----------------------------------------------------------------------------
 * Auth (telas de login / cadastro)
 * ----------------------------------------------------------------------------- */
body.auth {
    background: radial-gradient(1200px 600px at 15% -5%, rgba(99,102,241,0.18), transparent 60%),
                radial-gradient(900px 500px at 90% 110%, rgba(6,182,212,0.18), transparent 60%),
                #F8FAFC;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-wrap {
    width: 100%;
    max-width: 420px;
}
.auth-card {
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}
.auth-brand .logo {
    width: 54px; height: 54px;
    border-radius: var(--radius-lg);
    background: var(--gradient-mizu);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    letter-spacing: -0.03em;
}
.auth-brand .title { font-size: 22px; font-weight: 700; color: var(--text-strong); }
.auth-brand .subtitle { font-size: 13px; color: var(--text-soft); }
.auth-card h1 {
    font-size: 20px;
    margin-bottom: 4px;
    text-align: center;
}
.auth-card > p { text-align: center; color: var(--text-soft); font-size: 14px; margin-bottom: 22px; }
.auth-footer { text-align: center; margin-top: 18px; color: var(--text-soft); font-size: 14px; }

/* -----------------------------------------------------------------------------
 * Filtros (select de mês)
 * ----------------------------------------------------------------------------- */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    background: #fff;
    border: 1px solid var(--border);
}
.filter-bar .select, .filter-bar .input { width: auto; min-width: 150px; }
.filter-bar label { font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

/* -----------------------------------------------------------------------------
 * Toggle switch (marcar pago/pendente)
 * ----------------------------------------------------------------------------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0;
    background: var(--slate-300);
    border-radius: 22px;
    transition: var(--transition);
    cursor: pointer;
}
.switch .slider::before {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: var(--shadow-xs);
}
.switch input:checked + .slider { background: var(--green-500); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* -----------------------------------------------------------------------------
 * Lista compacta (próximas / atrasadas)
 * ----------------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 2px; }
.list-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 4px;
    border-bottom: 1px solid var(--slate-100);
    font-size: 14px;
}
.list-item:last-child { border-bottom: 0; }
.list-item .dot { width: 8px; height: 8px; border-radius: 50%; }
.list-item .label { font-weight: 500; color: var(--slate-700); }
.list-item .meta { font-size: 12px; color: var(--text-soft); }
.list-item .amount { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--slate-800); }

/* -----------------------------------------------------------------------------
 * Menu mobile (hambúrguer + backdrop) — escondido no desktop
 * ----------------------------------------------------------------------------- */
.menu-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 70;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--border);
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    color: var(--slate-700);
    transition: background var(--transition), color var(--transition);
}
.menu-toggle:hover { background: var(--mizu-50); color: var(--mizu-700); }
.menu-toggle svg { width: 22px; height: 22px; }
.menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms cubic-bezier(0.4, 0, 0.2, 1);
}
.menu-backdrop.is-visible { opacity: 1; pointer-events: auto; }
.sidebar-close {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    color: var(--slate-500);
    background: transparent;
}
.sidebar-close:hover { background: var(--slate-100); color: var(--slate-800); }
.sidebar-close svg { width: 18px; height: 18px; }

/* -----------------------------------------------------------------------------
 * Responsivo — Desktop pequeno (≤1280px)
 * ----------------------------------------------------------------------------- */
@media (max-width: 1280px) {
    .main { padding: 28px 28px 48px; max-width: 100%; }
    .topbar h1 { font-size: 26px; }
    .grid-kpi { gap: 14px; }
}

/* -----------------------------------------------------------------------------
 * Responsivo — Tablet (≤1024px) — sidebar vira drawer
 * ----------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    /* Sidebar vira drawer fixo deslizando da esquerda */
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 60;
        padding: 22px 16px;
        transform: translateX(-100%);
        transition: transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 8px 32px rgba(15, 23, 42, 0.18);
        border-right: 1px solid var(--border);
        border-bottom: 0;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-close { display: inline-flex; }
    .menu-toggle { display: inline-flex; }
    .menu-backdrop { display: block; }

    /* Empurra topbar pra baixo do botão de menu */
    .main { padding: 64px 24px 60px; }
    .topbar { margin-bottom: 22px; }
    .topbar h1 { font-size: 24px; }

    /* KPIs em 2 colunas */
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    /* Cards mais compactos */
    .card { padding: 20px; }
    .card-title { margin-bottom: 14px; }
    .kpi { padding: 18px; }
    .kpi .value { font-size: 24px; }

    /* Filter bar com wrap natural */
    .filter-bar { padding: 12px 14px; }
    .filter-bar .select, .filter-bar .input { min-width: 130px; flex: 1; }

    /* Auth — mantém centralização */
    body.auth { padding: 24px 16px; }
}

/* -----------------------------------------------------------------------------
 * Responsivo — Mobile / Tablet pequeno (≤900px)
 * Modo mobile cheio: 1 col, tabelas viram cards, filtros empilham
 * ----------------------------------------------------------------------------- */
@media (max-width: 900px) {
    /* Tipografia menor */
    h1 { font-size: 24px; }
    h2 { font-size: 19px; }
    h3 { font-size: 17px; }

    /* Main com padding mais apertado */
    .main { padding: 64px 16px 80px; }

    /* Topbar empilha */
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 20px;
    }
    .topbar h1 { font-size: 23px; }
    .topbar .greeting { font-size: 12px; }
    .topbar-actions { width: 100%; flex-wrap: wrap; }
    .topbar-actions .btn { flex: 1; justify-content: center; min-width: 0; }

    /* KPIs em 1 coluna */
    .grid-kpi { grid-template-columns: 1fr; gap: 12px; }
    .grid { gap: 14px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    /* Cards compactos */
    .card { padding: 18px; border-radius: 12px; }
    .card-title { margin-bottom: 14px; }
    .card-title h3 { font-size: 14px; }
    .kpi { padding: 18px; }
    .kpi .value { font-size: 23px; }
    .kpi .label { font-size: 11px; }

    /* Filter bar — vira coluna full-width */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }
    .filter-bar form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
    .filter-bar > div { width: 100%; }
    .filter-bar .select, .filter-bar .input { width: 100%; min-width: 0; flex: 0 1 auto; }
    .filter-bar label { font-size: 11px; }

    /* Inputs touch-friendly e sem zoom no iOS (≥16px) */
    .input, .select, .textarea {
        padding: 12px 14px;
        font-size: 16px;
    }
    .form-group { margin-bottom: 14px; }

    /* Botões — área de toque maior */
    .btn { padding: 11px 16px; font-size: 14px; min-height: 44px; }
    .btn-sm { padding: 9px 12px; font-size: 13px; min-height: 38px; }
    .btn-block { width: 100%; }

    /* Form-row — sempre 1 col em mobile */
    .form-row { grid-template-columns: 1fr; }

    /* Radio pills — wrap se necessário */
    .radio-pills { flex-wrap: wrap; width: 100%; }
    .radio-pills label { flex: 1; text-align: center; min-width: max-content; }

    /* Sidebar drawer mais largo no mobile */
    .sidebar { width: 86%; max-width: 320px; }

    /* Auth — card menor */
    .auth-card { padding: 28px 24px; border-radius: 16px; }
    .auth-wrap { max-width: 100%; }
    .auth-brand { margin-bottom: 18px; }
    .auth-brand .logo { width: 48px; height: 48px; font-size: 20px; }
    .auth-brand .title { font-size: 20px; }
    .auth-brand .subtitle { font-size: 12px; }
    .auth-card h1 { font-size: 19px; }

    /* Avatar grande mais discreto */
    .avatar-xl { width: 72px; height: 72px; font-size: 28px; }

    /* Flash stack mobile — full width */
    .flash-stack {
        top: 14px;
        right: 14px;
        left: 14px;
        max-width: none;
    }
    .flash { font-size: 13px; padding: 11px 14px; }

    /* Tabela vira cards — usa atributo data-label nos <td> */
    .table-cards { overflow: visible; border: 0; background: transparent; padding: 0; }
    .table-cards .table { background: transparent; }
    .table-cards .table thead { display: none; }
    .table-cards .table tbody,
    .table-cards .table tr { display: block; width: 100%; }
    .table-cards .table tr {
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    }
    .table-cards .table tr:hover { background: #fff; }
    .table-cards .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 7px 0;
        border-bottom: 0;
        text-align: right;
        white-space: normal;
    }
    .table-cards .table td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--text-soft);
        flex-shrink: 0;
        text-align: left;
    }
    .table-cards .table td.actions {
        justify-content: flex-end;
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid var(--slate-100);
        gap: 8px;
    }
    .table-cards .table td.actions::before { display: none; }
    .table-cards .table td.num { font-weight: 600; }

    /* Listas compactas — descer infos da meta */
    .list-item { grid-template-columns: auto 1fr auto; gap: 10px; }
    .list-item .label { font-size: 13.5px; }

    /* Profile page — empilha colunas */
    .grid-2 > div { width: 100%; }

    /* Empty state */
    .empty { padding: 32px 18px; }
    .empty p { font-size: 13px; }

    /* Charts — altura menor */
    .card canvas { max-height: 240px !important; height: 240px !important; }
}

/* -----------------------------------------------------------------------------
 * Responsivo — Mobile (≤640px) — ajustes finos
 * ----------------------------------------------------------------------------- */
@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .main { padding: 60px 14px 80px; }
    .topbar h1 { font-size: 22px; }
    .card { padding: 16px; }
    .kpi { padding: 16px; }
    .kpi .value { font-size: 22px; }
    .auth-card { padding: 26px 22px; }
    .card canvas { max-height: 220px !important; height: 220px !important; }
}

/* -----------------------------------------------------------------------------
 * Mobile pequeno (≤380px) — ajustes finais para celulares estreitos
 * ----------------------------------------------------------------------------- */
@media (max-width: 380px) {
    .main { padding: 60px 12px 80px; }
    .card { padding: 14px; }
    .kpi .value { font-size: 20px; }
    .topbar h1 { font-size: 20px; }
    .auth-card { padding: 22px 18px; }
}

/* -----------------------------------------------------------------------------
 * Canvas dos gráficos — previne crescimento infinito do Chart.js
 * ----------------------------------------------------------------------------- */
.card canvas {
    max-height: 260px !important;
    height: 260px !important;
}

/* -----------------------------------------------------------------------------
 * Impressão (para exportar PDF via window.print)
 * ----------------------------------------------------------------------------- */
@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .print-page {
        padding: 0;
        max-width: 100%;
    }
    .card, .kpi { box-shadow: none; border-color: #CBD5E1; break-inside: avoid; }
    .table tbody tr:hover { background: transparent; }
}
.print-page { padding: 40px; max-width: 900px; margin: 0 auto; background: #fff; }
.print-header { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--mizu-600); padding-bottom: 14px; margin-bottom: 24px; }
.print-header .brand-line { font-size: 13px; color: var(--text-soft); }
