/* ============================================================
   ORÇAMENTO MASTER - ESTILOS CENTRALIZADOS (RESPONSIVO v3.0)
   Mobile-first com breakpoints padronizados.
   ============================================================ */

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
    --primary-blue: #1e5a96;
    --accent-green: #10b981;
    --sb-width: 260px;
    --sb-collapsed: 60px;

    /* Container responsivo */
    --container-max: 1320px;
    --container-padding: clamp(12px, 3vw, 24px);

    /* Tipografia fluida */
    --fs-body: clamp(0.875rem, 1.5vw, 1rem);
    --fs-h1: clamp(1.1rem, 2.5vw, 1.75rem);
    --fs-h2: clamp(1rem, 2vw, 1.25rem);
    --fs-h3: clamp(0.9rem, 1.5vw, 1.125rem);
    --fs-small: clamp(0.7rem, 1.1vw, 0.8rem);
    --fs-xs: clamp(0.65rem, 1vw, 0.75rem);
    --fs-label: clamp(0.7rem, 1.1vw, 0.8rem);
    --fs-btn: clamp(0.72rem, 1.1vw, 0.82rem);
    --fs-table: clamp(0.75rem, 1.2vw, 0.875rem);
    --fs-table-sm: clamp(0.65rem, 1vw, 0.75rem);

    /* Espaçamento responsivo */
    --space-section: clamp(1rem, 3vw, 2rem);
    --space-card: clamp(0.75rem, 2vw, 1.5rem);
}

/* ── RESET & BASE ─────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    font-size: var(--fs-body);
    background: #f4f6f9;
    color: #1e293b;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: #1e293b;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--primary-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

/* ── FOCUS & ACCESSIBILITY ────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-blue);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    transition: top 0.2s ease;
}
.skip-to-content:focus {
    top: 0;
}

/* ── LAYOUT: Containers ───────────────────────────────────────── */
.saas-wrap {
    margin-left: var(--sb-width, 260px);
    padding: var(--container-padding);
    padding-bottom: 2.4rem;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    overflow-x: hidden;
}

.saas-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0;
    width: 100%;
}

.main-content {
    margin-left: var(--sb-width, 260px);
    padding: var(--space-section);
    min-height: 100vh;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.wrap {
    margin-left: var(--sb-width, 260px);
    padding: 1rem;
    min-height: 100vh;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── SUB NAV ──────────────────────────────────────────────────── */
.sub-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    margin: 0 0 1.25rem var(--sb-width, 260px);
    background: rgba(255,255,255,0.92);
    border-bottom: 1px solid rgba(15,23,42,0.08);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 18px 45px rgba(15,23,42,0.08);
    transition: margin-left 0.3s ease;
}

.sub-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border-radius: 16px;
    font-size: var(--fs-small);
    font-weight: 600;
    color: #475569;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    border: 1px solid transparent;
    background: rgba(241,245,249,0.95);
}

.sub-nav a:hover {
    color: #0f172a;
    background: rgba(241,245,249,1);
    border-color: rgba(148,163,184,0.35);
    transform: translateY(-1px);
}

.sub-nav a.active {
    color: #fff;
    background: var(--primary, #1e5a96);
    border-color: var(--primary, #1e5a96);
    font-weight: 700;
    box-shadow: 0 14px 35px rgba(30,90,150,0.18);
}

.sub-nav a i {
    font-size: 0.85rem;
}

/* ── SIDEBAR PREMIUM ──────────────────────────────────────────── */
.sidebar {
    --sb-width: 260px;
    --sb-bg-start: #0a1628;
    --sb-bg-mid: #0d1f3c;
    --sb-bg-end: #0a1628;
    --sb-text: rgba(255,255,255,.55);
    --sb-text-hover: #fff;
    --sb-text-active: #fff;
    --sb-accent: #3b82f6;
    --sb-accent-glow: rgba(59,130,246,.25);
    --sb-border: rgba(255,255,255,.05);
    --sb-hover-bg: rgba(59,130,246,.1);
    --sb-active-bg: rgba(59,130,246,.15);

    background: linear-gradient(180deg, var(--sb-bg-start), var(--sb-bg-mid) 60%, var(--sb-bg-end));
    box-shadow: 4px 0 24px rgba(0,0,0,.35), inset -1px 0 0 rgba(255,255,255,.03);
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sb-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transition: width 0.3s ease, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Body lock quando sidebar aberta no mobile */
body.sidebar-open {
    overflow: hidden;
}

/* Scrollbar elegante para sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ── SIDEBAR: Brand / Logo ────────────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    min-height: 64px;
    border-bottom: 1px solid var(--sb-border);
    background: rgba(255, 255, 255, 0.015);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.sidebar-brand-logo {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-logo-full {
    max-width: 140px;
    max-height: 48px;
    height: auto;
    width: auto;
    filter: brightness(0) invert(1);
    transition: opacity 0.3s ease, max-width 0.3s ease;
    opacity: 1;
}

.sidebar-logo-icon {
    display: none;
    font-size: 1.6rem;
    color: var(--sb-accent);
    transition: all 0.3s ease;
}

/* ── SIDEBAR: Divider ─────────────────────────────────────────── */
.sidebar-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--sb-border) 20%, var(--sb-border) 80%, transparent);
    margin: 0.5rem 1rem;
    flex-shrink: 0;
}

/* ── SIDEBAR: Navegação ───────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.06); border-radius: 3px; }

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.25);
    padding: 1rem 1.25rem 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
}

.sidebar-link {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.7rem 1.25rem;
    margin: 2px 0.5rem;
    border-radius: 8px;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 400;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.2px;
    gap: 0.7rem;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
    background: transparent;
    border: none;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link i:first-child {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.sidebar-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s ease;
}

.sidebar-link:hover {
    background: var(--sb-hover-bg);
    color: var(--sb-text-hover);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.2), rgba(30, 58, 138, 0.08));
    color: var(--sb-text-active);
    font-weight: 500;
    box-shadow: 0 0 20px var(--sb-accent-glow), inset 0 0 0 1px rgba(30, 58, 138, 0.3);
}

.sidebar-link.active i:first-child {
    color: var(--sb-accent);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--sb-accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-parent {
    padding-right: 0.6rem;
}

.sidebar-arrow {
    margin-left: auto !important;
    font-size: 0.65rem !important;
    width: auto !important;
    transition: transform 0.3s ease;
    opacity: 0.4;
}

.sidebar-parent[aria-expanded="true"] .sidebar-arrow {
    transform: rotate(180deg);
    opacity: 0.7;
}

.sidebar-group {
    overflow: hidden;
}

.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-submenu.open {
    max-height: 400px;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    padding: 0.55rem 1.25rem 0.55rem 3.2rem;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    gap: 0.55rem;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin: 1px 0.75rem;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-sublink:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-sublink.active {
    color: var(--sb-accent);
    background: rgba(30, 58, 138, 0.12);
    font-weight: 500;
}

.sidebar-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.5;
    transition: all 0.2s ease;
}

.sidebar-sublink.active .sidebar-dot {
    opacity: 1;
    box-shadow: 0 0 8px var(--sb-accent-glow);
}

.sidebar-sublink:hover .sidebar-dot { opacity: 0.8; }

.sidebar-link-logout {
    color: rgba(255, 255, 255, 0.4) !important;
    margin-top: 0.25rem;
}

.sidebar-link-logout:hover {
    color: #f87171 !important;
    background: rgba(248, 113, 113, 0.08) !important;
}

.sidebar-link-logout i:first-child {
    color: rgba(248, 113, 113, 0.5);
    transition: color 0.2s ease;
}

.sidebar-link-logout:hover i:first-child { color: #f87171; }

/* ── SIDEBAR: Footer / User Badge ─────────────────────────────── */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--sb-border);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.sidebar-user-badge {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.2s ease;
}

.sidebar-user-badge:hover { background: rgba(255, 255, 255, 0.06); }

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--sb-accent), #0F172A);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    transition: opacity 0.3s ease;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
}

/* ── SIDEBAR: Overlay Mobile ──────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    opacity: 0;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ── MOBILE TOGGLE ────────────────────────────────────────────── */
.mobile-toggle {
    display: none;
    background: linear-gradient(135deg, var(--primary-blue, #1e5a96), #153d6b);
    color: white;
    border: none;
    padding: 0.6rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1002;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
}

.mobile-toggle:hover {
    background: var(--accent-green, #10b981);
    transform: scale(1.05);
}

/* ── HEADER ───────────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-section);
    background: white;
    padding: var(--space-card);
    border-radius: 12px;
    border: 2px solid var(--primary-blue);
    box-shadow: 0 4px 12px rgba(30, 90, 150, 0.1);
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    color: var(--primary-blue);
    font-size: var(--fs-h1);
    font-weight: 700;
    margin: 0;
}

.back-link {
    color: var(--primary-blue);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.back-link:hover { color: var(--accent-green); }

/* ── PAGE HEADER (estilo alternativo) ─────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: var(--space-section);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.header-left h1 {
    font-size: var(--fs-h1);
    font-weight: 700;
}

.icon-box {
    width: clamp(38px, 6vw, 48px);
    height: clamp(38px, 6vw, 48px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-blue), #153d6b);
    color: #fff;
    font-size: clamp(1rem, 2vw, 1.3rem);
    flex-shrink: 0;
}

/* ── CARDS & GRIDS ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: var(--space-section);
    align-items: stretch;
}

.stat-card {
    background: white;
    padding: var(--space-card);
    border-radius: 12px;
    border-bottom: 4px solid var(--primary-blue);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100px;
}

.stat-card:hover { transform: translateY(-5px); }

.stat-title {
    color: #64748b;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    font-weight: 600;
}

.stat-value {
    color: var(--primary-blue);
    font-size: clamp(1.2rem, 2.5vw, 1.5rem);
    font-weight: 700;
    margin-top: 0.5rem;
}

.stat-sub {
    font-size: var(--fs-xs);
    color: #94a3b8;
    margin-top: 0.25rem;
}

.stat-icon {
    width: clamp(40px, 8vw, 52px);
    height: clamp(40px, 8vw, 52px);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    color: #fff;
    margin-bottom: 0.75rem;
}

/* ── CARDS WRAP (estilo de formulário) ────────────────────────── */
.card-wrap {
    background: #fff;
    border: 2px solid var(--primary-blue);
    border-radius: 12px;
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 15px rgba(30, 90, 150, 0.08);
    overflow: hidden;
}

.card-hdr {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.card-hdr-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.card-hdr-title {
    font-weight: 700;
    font-size: var(--fs-small);
    color: #1e293b;
}

.card-hdr-sub {
    font-size: var(--fs-xs);
    color: #94a3b8;
    margin-left: auto;
}

.card-body {
    padding: var(--space-card);
}

/* ── TABELAS ──────────────────────────────────────────────────── */
.recent-section {
    background: white;
    border-radius: 12px;
    border: 2px solid var(--primary-blue);
    padding: var(--space-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.recent-header h2 {
    color: var(--primary-blue);
    font-size: var(--fs-h2);
    margin: 0;
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-select {
    padding: 0.5rem;
    border: 2px solid var(--primary-blue);
    border-radius: 6px;
    font-size: var(--fs-table);
    color: var(--primary-blue);
    outline: none;
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th {
    text-align: left;
    padding: 1rem;
    background: #f8fafc;
    color: var(--primary-blue);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    font-weight: 700;
    white-space: nowrap;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: var(--fs-table);
}

/* ── TABLE: Card stacking no mobile ───────────────────────────── */
@media (max-width: 767px) {
    .table-card-stack {
        min-width: 0;
    }
    .table-card-stack thead {
        display: none;
    }
    .table-card-stack tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        padding: 0.75rem;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    .table-card-stack tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.45rem 0;
        border-bottom: 1px solid #f1f5f9;
        font-size: var(--fs-table-sm);
        text-align: right;
        gap: 0.5rem;
    }
    .table-card-stack tbody td:last-child {
        border-bottom: none;
    }
    .table-card-stack tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--primary-blue);
        font-size: var(--fs-xs);
        text-transform: uppercase;
        text-align: left;
        flex-shrink: 0;
    }
    .table-card-stack .saas-actions {
        justify-content: flex-end;
    }
}

/* ── BADGES ───────────────────────────────────────────────────── */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}

.badge-rascunho { background: #fef3c7; color: #92400e; }
.badge-enviado  { background: #dbeafe; color: #1e40af; }
.badge-aprovado { background: #d1fae5; color: #065f46; }
.badge-rejeitado{ background: #fee2e2; color: #991b1b; }

/* ── FORMS ────────────────────────────────────────────────────── */
.container-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    margin-bottom: var(--space-section);
}

.form-card {
    background: white;
    border: 2px solid var(--primary-blue);
    border-radius: 12px;
    padding: var(--space-card);
    box-shadow: 0 4px 15px rgba(30, 90, 150, 0.1);
}

.form-card h2 {
    color: var(--primary-blue);
    margin-bottom: 1.5rem;
    font-size: var(--fs-h2);
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-label {
    display: block;
    color: var(--primary-blue);
    font-size: var(--fs-label);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid var(--primary-blue);
    border-radius: 6px;
    background: rgba(30, 90, 150, 0.05);
    color: #333;
    transition: all 0.3s ease;
    font-size: var(--fs-table);
    min-height: 44px;
}

.form-input:focus,
.form-select:focus {
    background: rgba(164, 198, 57, 0.08);
    border-color: var(--accent-green);
    box-shadow: 0 0 12px rgba(164, 198, 57, 0.3);
    outline: none;
}

/* ── FORM GRIDS RESPONSIVOS ───────────────────────────────────── */
.form-grid-2, .form-grid-3, .form-grid-4, .form-grid-6,
.form-grid-8-4, .form-grid-3-9, .form-grid-9-3 {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Base mobile: 1 coluna para todos */
.form-grid-2, .form-grid-3, .form-grid-4, .form-grid-6,
.form-grid-8-4, .form-grid-3-9, .form-grid-9-3 {
    grid-template-columns: 1fr;
}

.form-section-title {
    font-size: var(--fs-small);
    font-weight: 700;
    color: var(--primary-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 0 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sticky form actions no mobile */
.form-actions-sticky {
    position: sticky;
    bottom: 0;
    background: #f4f6f9;
    padding: 0.75rem 0;
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    z-index: 10;
}

/* ── PRODUCTS LIST ────────────────────────────────────────────── */
.products-list {
    background: white;
    border: 2px solid var(--primary-blue);
    border-radius: 12px;
    padding: var(--space-card);
    box-shadow: 0 4px 15px rgba(30, 90, 150, 0.1);
}

.products-list h2 {
    color: var(--primary-blue);
    margin-bottom: 1.5rem;
    font-size: var(--fs-h2);
}

.product-item {
    background: #f9fbff;
    border: 1px solid #e0e8f2;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.product-item:hover {
    background: #f0f5ff;
    border-color: var(--primary-blue);
}

.product-info { flex: 1; min-width: 200px; }

.product-type {
    display: inline-block;
    background: var(--accent-green);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.product-desc {
    color: #333;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.product-price {
    color: var(--primary-blue);
    font-weight: 700;
    font-size: 1.1rem;
}

.product-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── BUTTONS ──────────────────────────────────────────────────── */
.btn {
    padding: 0.65rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 2px solid;
    cursor: pointer;
    font-size: var(--fs-btn);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    min-height: 44px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue), #2a6eaa);
    border-color: var(--primary-blue);
    color: white;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-green), #b8d946);
    border-color: var(--accent-green);
    box-shadow: 0 6px 20px rgba(164, 198, 57, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}
.btn-secondary:hover { background: var(--primary-blue); color: white; }

.btn-success { background: #10b981; border-color: #10b981; color: white; }
.btn-success:hover { background: #059669; border-color: #059669; color: white; transform: translateY(-2px); }

.btn-danger { background: #ef4444; border-color: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: white; transform: translateY(-2px); }

.btn-warning { background: #f59e0b; border-color: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; border-color: #d97706; color: white; transform: translateY(-2px); }

.btn-edit, .btn-view {
    background: #3b82f6; border-color: #3b82f6; color: white;
    padding: 0.5rem 0.75rem; font-size: 0.7rem; width: auto;
}
.btn-edit:hover, .btn-view:hover { background: #1d4ed8; border-color: #1d4ed8; color: white; transform: translateY(-2px); }

.btn-delete, .btn-remove {
    background: #dc2626; border-color: #dc2626; color: white;
    padding: 0.5rem 0.75rem; font-size: 0.7rem; width: auto;
}
.btn-delete:hover, .btn-remove:hover { background: #991b1b; border-color: #991b1b; color: white; transform: translateY(-2px); }

.btn-save { background: #10b981; border-color: #10b981; color: white; }
.btn-save:hover { background: #059669; border-color: #059669; color: white; transform: translateY(-2px); }

.btn-pdf { background: #f97316; border-color: #f97316; color: white; }
.btn-pdf:hover { background: #ea580c; border-color: #ea580c; color: white; transform: translateY(-2px); }

.btn-list { background: #3b82f6; border-color: #3b82f6; color: white; }
.btn-list:hover { background: #1d4ed8; border-color: #1d4ed8; color: white; transform: translateY(-2px); }

.btn-add { background: #06b6d4; border-color: #06b6d4; color: white; }
.btn-add:hover { background: #0891b2; border-color: #0891b2; color: white; transform: translateY(-2px); }

/* ── LISTA ALTERNATIVA (clientes.php style) ────────────────────── */
.list-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: 8px;
    font-weight: 700;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.list-header > * { flex: 1; min-width: 80px; }

.list-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s ease;
    flex-wrap: wrap;
}
.list-row:hover { background: #f8fafc; }
.list-row > * { flex: 1; min-width: 80px; }
.list-row .act-view, .list-row .act-danger {
    font-size: 0.9rem;
    padding: 0.35rem;
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    text-decoration: none;
    flex: 0;
}
.list-row .act-view { color: var(--primary-blue); }
.list-row .act-danger { color: #ef4444; }

/* ── MESSAGES ─────────────────────────────────────────────────── */
.success-msg {
    background: rgba(34, 197, 94, 0.1);
    border-left: 4px solid #22c55e;
    color: #15803d;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: var(--fs-small);
}

.error-msg {
    background: rgba(220, 38, 38, 0.1);
    border-left: 4px solid #dc2626;
    color: #991b1b;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: var(--fs-small);
}

.info-msg {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid #3b82f6;
    color: #1e40af;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: var(--fs-small);
}

/* ── MODAL ────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    max-width: min(500px, 95vw);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-box h3 {
    font-size: var(--fs-h3);
    margin-bottom: 1rem;
}

/* ── PAGINATION ───────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 0.5rem;
    border: 1.5px solid #e2e8f0;
    color: #475569;
    border-radius: 8px;
    text-decoration: none;
    font-size: var(--fs-xs);
    font-weight: 500;
    transition: all 0.15s ease;
    background: #fff;
}
.pagination a:hover { background: #f1f5f9; border-color: #cbd5e1; }
.pagination a.active, .pagination span.active {
    background: var(--primary-blue);
    color: #fff;
    border-color: var(--primary-blue);
}

/* ── FILTER BAR ───────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filter-bar > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.filter-bar label {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: #64748b;
}

/* ── UTILITY ──────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-4xl { font-size: 2.25rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-8 { margin-bottom: 2rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-6 { gap: 1.5rem; }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: 1fr; }
.opacity-20 { opacity: 0.2; }
.w-full { width: 100%; }

/* ── SIDEBAR COLLAPSE ─────────────────────────────────────────── */
.sidebar[data-collapsed],
.sidebar.collapsed {
    width: 60px;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar[data-collapsed] .sidebar-brand,
.sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    justify-content: center;
    padding: 0.85rem 0.5rem 0.65rem;
    gap: 6px;
}
.sidebar[data-collapsed] .sidebar-logo-full,
.sidebar.collapsed .sidebar-logo-full { display: none; }
.sidebar[data-collapsed] .sidebar-logo-icon,
.sidebar.collapsed .sidebar-logo-icon {
    display: flex;
    justify-content: center;
    margin: 0;
}
.sidebar[data-collapsed] .sidebar-logo-icon i,
.sidebar.collapsed .sidebar-logo-icon i { font-size: 1.3rem; }
.sidebar[data-collapsed] .sidebar-nav,
.sidebar.collapsed .sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
    gap: 2px;
}
.sidebar[data-collapsed] .sidebar-section-label,
.sidebar.collapsed .sidebar-section-label { display: none; }
.sidebar[data-collapsed] .sidebar-link,
.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 0.65rem 0;
    gap: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    margin: 0 auto;
    position: relative;
}
.sidebar[data-collapsed] .sidebar-link::after,
.sidebar.collapsed .sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 9999;
}
.sidebar[data-collapsed] .sidebar-link::before,
.sidebar.collapsed .sidebar-link::before {
    content: '';
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1e293b;
    opacity: 0;
    transition: opacity 0.2s ease 0.3s;
    z-index: 9999;
}
.sidebar[data-collapsed] .sidebar-link:hover::after,
.sidebar.collapsed .sidebar-link:hover::after,
.sidebar[data-collapsed] .sidebar-link:hover::before,
.sidebar.collapsed .sidebar-link:hover::before { opacity: 1; }
.sidebar[data-collapsed] .sidebar-link:hover,
.sidebar.collapsed .sidebar-link:hover {
    background: rgba(59,130,246,0.12);
    border-radius: 12px;
}
.sidebar[data-collapsed] .sidebar-link.active,
.sidebar.collapsed .sidebar-link.active {
    background: rgba(59,130,246,0.18);
    box-shadow: inset 3px 0 0 var(--sb-accent, #3b82f6);
}
.sidebar[data-collapsed] .sidebar-link span,
.sidebar.collapsed .sidebar-link span { display: none; }
.sidebar[data-collapsed] .sidebar-link > i:first-child,
.sidebar.collapsed .sidebar-link > i:first-child {
    font-size: 1.25rem;
    margin: 0;
}
.sidebar[data-collapsed] .sidebar-link:hover > i:first-child,
.sidebar.collapsed .sidebar-link:hover > i:first-child { color: #fff; }
.sidebar[data-collapsed] .sidebar-arrow,
.sidebar.collapsed .sidebar-arrow { display: none; }
.sidebar[data-collapsed] .sidebar-submenu,
.sidebar.collapsed .sidebar-submenu { display: none !important; }
.sidebar[data-collapsed] .sidebar-divider,
.sidebar.collapsed .sidebar-divider {
    margin: 0.35rem 0.6rem;
    width: 30px;
    margin-left: auto;
    margin-right: auto;
}
.sidebar[data-collapsed] .sidebar-group,
.sidebar.collapsed .sidebar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.sidebar[data-collapsed] .sidebar-link-logout,
.sidebar.collapsed .sidebar-link-logout {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}
.sidebar[data-collapsed] .sidebar-footer,
.sidebar.collapsed .sidebar-footer { padding: 0.5rem; }
.sidebar[data-collapsed] .sidebar-user-info,
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar[data-collapsed] .sidebar-user-badge,
.sidebar.collapsed .sidebar-user-badge {
    justify-content: center;
    padding: 0.35rem;
}
.sidebar[data-collapsed] .sidebar-user-avatar,
.sidebar.collapsed .sidebar-user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
    border-radius: 10px;
}
.sidebar[data-collapsed] .sidebar-collapse-btn,
.sidebar.collapsed .sidebar-collapse-btn {
    display: flex;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
}
.sidebar[data-collapsed] .sidebar-collapse-btn:hover,
.sidebar.collapsed .sidebar-collapse-btn:hover { background: rgba(255,255,255,0.15); }
.sidebar[data-collapsed] .sidebar-collapse-btn i,
.sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
    font-size: 0.8rem;
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
}
.sidebar-collapse-btn i { transition: transform 0.3s ease; }

.main-content.sidebar-collapsed { margin-left: 60px; }
.wrap.sidebar-collapsed { margin-left: 60px; }
.saas-wrap.sidebar-collapsed { margin-left: 60px; }
.sub-nav.sidebar-collapsed { margin-left: 60px; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVO - MOBILE-FIRST
   Breakpoints: xs(0) → sm(576px) → md(768px) → lg(992px) → xl(1200px) → xxl(1400px)
   ═══════════════════════════════════════════════════════════════ */

/* ── xs (0px+) - MOBILE BASE ──────────────────────────────────── */
/* Todas as regras acima já são mobile-first. Aqui ficam os overrides. */

/* Sidebar: oculta por padrão no mobile, visível com toggle */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(280px, 85vw);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), width 0.35s ease;
    }

    .sidebar.mobile-open,
    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Garantir que sidebar colapsada também funcione no mobile */
    .sidebar[data-collapsed],
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: min(280px, 85vw);
    }
    .sidebar[data-collapsed].mobile-open,
    .sidebar[data-collapsed].active,
    .sidebar.collapsed.mobile-open,
    .sidebar.collapsed.active {
        transform: translateX(0);
        width: min(280px, 85vw);
    }
    .sidebar[data-collapsed].mobile-open .sidebar-logo-full,
    .sidebar[data-collapsed].active .sidebar-logo-full,
    .sidebar.collapsed.mobile-open .sidebar-logo-full,
    .sidebar.collapsed.active .sidebar-logo-full { display: block; }
    .sidebar[data-collapsed].mobile-open .sidebar-logo-icon,
    .sidebar[data-collapsed].active .sidebar-logo-icon,
    .sidebar.collapsed.mobile-open .sidebar-logo-icon,
    .sidebar.collapsed.active .sidebar-logo-icon { display: none; }
    .sidebar[data-collapsed].mobile-open .sidebar-link,
    .sidebar[data-collapsed].active .sidebar-link,
    .sidebar.collapsed.mobile-open .sidebar-link,
    .sidebar.collapsed.active .sidebar-link {
        justify-content: flex-start;
        padding: 0.65rem 1rem;
        gap: 0.75rem;
        width: 100%;
        height: auto;
    }
    .sidebar[data-collapsed].mobile-open .sidebar-link span,
    .sidebar[data-collapsed].active .sidebar-link span,
    .sidebar.collapsed.mobile-open .sidebar-link span,
    .sidebar.collapsed.active .sidebar-link span { display: inline; }
    .sidebar[data-collapsed].mobile-open .sidebar-section-label,
    .sidebar[data-collapsed].active .sidebar-section-label,
    .sidebar.collapsed.mobile-open .sidebar-section-label,
    .sidebar.collapsed.active .sidebar-section-label { display: block; }
    .sidebar[data-collapsed].mobile-open .sidebar-user-info,
    .sidebar[data-collapsed].active .sidebar-user-info,
    .sidebar.collapsed.mobile-open .sidebar-user-info,
    .sidebar.collapsed.active .sidebar-user-info { display: flex; }
    .sidebar[data-collapsed].mobile-open .sidebar-submenu.open,
    .sidebar[data-collapsed].active .sidebar-submenu.open,
    .sidebar.collapsed.mobile-open .sidebar-submenu.open,
    .sidebar.collapsed.active .sidebar-submenu.open { display: block !important; }

    /* Layout: sem margem da sidebar */
    .saas-wrap,
    .main-content,
    .wrap,
    .sub-nav {
        margin-left: 0 !important;
    }

    .saas-wrap { padding: 0.85rem; }
    .main-content { padding: 4.5rem 1rem 1rem 1rem; }

    .sub-nav { margin-left: 0 !important; padding: 0.65rem 0.9rem; gap: 0.35rem; overflow-x: auto; }
    .sub-nav a { font-size: 0.75rem; padding: 0.45rem 0.8rem; }

    /* Header: empilhar */
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }

    /* Page Header: empilhar */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-left { flex-direction: column; align-items: flex-start; }

    /* Stats grid: 1 coluna */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Container grid: 1 coluna */
    .container-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Form grids: todos 1 coluna */
    .form-grid-2, .form-grid-3, .form-grid-4, .form-grid-6,
    .form-grid-8-4, .form-grid-3-9, .form-grid-9-3 {
        grid-template-columns: 1fr !important;
    }

    /* Tabelas */
    .recent-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .filter-container {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .filter-select, #searchInput {
        width: 100%;
        padding: 0.75rem;
        min-height: 44px;
    }

    table { font-size: 0.75rem; min-width: 500px; }
    th, td { padding: 0.75rem 0.5rem; }

    /* List rows: empilhar */
    .list-header { display: none; }
    .list-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        padding: 0.75rem;
    }
    .list-row > * { flex: none; width: 100%; }

    /* Product items */
    .product-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .product-actions {
        width: 100%;
        margin-top: 0.5rem;
    }

    /* Buttons: full width em ações principais */
    .saas-header-actions { width: 100%; }
    .saas-header-actions .btn,
    .saas-header-actions .saas-btn {
        flex: 1;
        min-width: 0;
    }

    /* Card wrap */
    .card-wrap { border-radius: 10px; }
    .card-hdr { padding: 0.75rem 1rem; }
    .card-body { padding: 0.75rem; }

    /* Forms: inputs maiores para touch */
    .form-input, .form-select, .saas-input, .saas-select {
        font-size: 1rem !important;
        min-height: 44px;
    }

    /* Modal: full width no mobile */
    .modal-box {
        max-width: 95vw;
        padding: 1rem;
        border-radius: 12px;
    }
}

/* ── xs-small (< 380px) ───────────────────────────────────────── */
@media (max-width: 379px) {
    .header h1 { font-size: 1rem; }
    .header-left h1 { font-size: 1rem; }
    .stat-card { padding: 0.65rem; }
    .stat-value { font-size: 1rem; }
    .stat-title { font-size: 0.65rem; }
    .btn { padding: 0.5rem 0.75rem; font-size: 0.7rem; min-height: 40px; }
    table { font-size: 0.65rem; min-width: 400px; }
    th, td { padding: 0.5rem 0.25rem; }
    .badge { font-size: 0.6rem; padding: 0.2rem 0.35rem; }
    .sidebar { width: min(280px, 95vw); }
    .sidebar-link { padding: 0.6rem 0.8rem; font-size: 0.78rem; }
}

/* ── sm (576px+) - SMARTPHONE GRANDE / LANDSCAPE ──────────────── */
@media (min-width: 576px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid-2 { grid-template-columns: repeat(2, 1fr); }

    .filter-container {
        flex-direction: row;
        align-items: center;
    }
    .filter-select, #searchInput { width: auto; }

    .saas-wrap { padding: 1.25rem; }
    .main-content { padding: 1.5rem; }
}

/* ── md (768px+) - TABLET ─────────────────────────────────────── */
@media (min-width: 768px) {
    /* Sidebar: sempre visível */
    .sidebar {
        transform: translateX(0);
        width: var(--sb-width, 260px);
    }
    .sidebar.mobile-open,
    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-toggle { display: none; }

    /* Layout: restaurar margem da sidebar */
    .saas-wrap { margin-left: var(--sb-width, 260px); padding: 1.5rem 1.5rem 2rem; }
    .main-content { margin-left: var(--sb-width, 260px); padding: 2rem; }
    .wrap { margin-left: var(--sb-width, 260px); padding: 1rem; }
    .sub-nav { margin-left: var(--sb-width, 260px); }

    /* Header: voltar ao flex row */
    .header { flex-direction: row; text-align: left; }
    .page-header { flex-direction: row; align-items: center; }
    .header-left { flex-direction: row; align-items: center; }

    /* Stats: 2 colunas no tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Container grid: restaurar 2 colunas */
    .container-grid {
        grid-template-columns: 1fr 1.5fr;
        gap: 1.5rem;
    }

    /* Form grids */
    .form-grid-2 { grid-template-columns: repeat(2, 1fr); }
    .form-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .form-grid-8-4 { grid-template-columns: 5fr 1fr; }
    .form-grid-3-9 { grid-template-columns: 1fr 3fr; }
    .form-grid-9-3 { grid-template-columns: 3fr 1fr; }

    /* List: restaurar flex row */
    .list-header { display: flex; }
    .list-row {
        flex-direction: row;
        align-items: center;
        border: none;
        border-bottom: 1px solid #f1f5f9;
        border-radius: 0;
        margin-bottom: 0;
        padding: 0.75rem 1rem;
    }
    .list-row > * { flex: 1; width: auto; }

    /* Tabelas: restaurar tabelas normais */
    table { min-width: 0; }
    .table-card-stack thead { display: table-header-group; }
    .table-card-stack tbody tr {
        display: table-row;
        margin: 0;
        border: none;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
    }
    .table-card-stack tbody td {
        display: table-cell;
        padding: 0.5rem 0.75rem;
        text-align: left;
        border-bottom: 1px solid #f1f5f9;
    }
    .table-card-stack tbody td::before { display: none; }

    /* Card wrap */
    .card-body { padding: 1.25rem; }

    /* Saas actions */
    .saas-header-actions { width: auto; }
    .saas-header-actions .btn,
    .saas-header-actions .saas-btn { flex: none; }

    /* Product items */
    .product-item { flex-direction: row; align-items: center; }
    .product-actions { width: auto; margin-top: 0; }

    /* Modal */
    .modal-box { padding: 1.5rem; }
}

/* ── lg (992px+) - NOTEBOOK ───────────────────────────────────── */
@media (min-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .form-grid-4 { grid-template-columns: repeat(4, 1fr); }
    .form-grid-6 { grid-template-columns: repeat(6, 1fr); }

    .saas-wrap { padding: 1.8rem 1.8rem 2.4rem; }
    .saas-container { max-width: var(--container-max); }
}

/* ── xl (1200px+) - DESKTOP ───────────────────────────────────── */
@media (min-width: 1200px) {
    .saas-container { max-width: var(--container-max); }
}

/* ── xxl (1400px+) - MONITOR GRANDE ────────────────────────────── */
@media (min-width: 1400px) {
    .saas-container { max-width: 1320px; }
}

/* ═══════════════════════════════════════════════════════════════
   IMPRESSÃO
   ═══════════════════════════════════════════════════════════════ */

@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    /* Oculta elementos de UI */
    .sidebar,
    .mobile-toggle,
    .sidebar-overlay,
    .sub-nav,
    .navbar,
    .saas-page-header,
    .saas-header-actions,
    .saas-card-header,
    .page-header,
    .header,
    nav,
    header,
    footer,
    .no-print,
    .filter-bar,
    .filter-container,
    .periodo-tabs,
    form,
    .table-actions,
    .saas-btn,
    .saas-input,
    .kpi-grid,
    .kpi-card,
    .btn,
    .product-actions,
    .pagination,
    .mobile-toggle,
    .sidebar-overlay {
        display: none !important;
    }

    /* Conteúdo principal limpo */
    .saas-wrap,
    .saas-container,
    .saas-card,
    .saas-card-body,
    .main-content,
    .wrap,
    .card-wrap,
    .card-body {
        background: #fff !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Remove scroll de containers */
    .saas-card-body[style*="overflow"],
    .table-container {
        overflow: visible !important;
        max-height: none !important;
    }

    /* Tabelas limpas */
    table {
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: collapse !important;
        page-break-inside: auto !important;
    }
    table thead { display: table-header-group !important; }
    table tr { page-break-inside: avoid !important; }
    table th, table td {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #ddd !important;
        padding: 4px 6px !important;
        font-size: 9pt !important;
    }
    table th {
        background: #f0f0f0 !important;
        font-weight: 700 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Badges em escala de cinza */
    .badge, .badge-tipo, .badge-status, .badge-receita, .badge-despesa {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #ddd !important;
    }

    /* Restaurar tabelas card-stack para tabela normal */
    .table-card-stack thead { display: table-header-group !important; }
    .table-card-stack tbody tr {
        display: table-row !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        page-break-inside: avoid !important;
    }
    .table-card-stack tbody td {
        display: table-cell !important;
        padding: 4px 6px !important;
        text-align: left !important;
        border: 1px solid #ddd !important;
    }
    .table-card-stack tbody td::before { display: none !important; }

    h1, h2, h3 { page-break-after: avoid; }
    .card-wrap, .stat-card { page-break-inside: avoid; }

    * {
        transition: none !important;
        animation: none !important;
    }
}
