/* ===== GNZ ERP — Tema Claro ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');
:root {
    --bg: #f4f6fb;
    --bg-alt: #eef1f7;
    --surface: #ffffff;
    --surface-2: #fafbfe;
    --border: #e3e7ef;
    --border-strong: #cbd2de;
    --text: #1a2232;
    --text-muted: #5e6a82;
    --text-soft: #8591a5;

    --primary: #2563eb;
    --primary-hover: #1e4fd1;
    --primary-soft: #e0ecff;
    --accent: #6366f1;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --info: #0ea5e9;
    --info-soft: #e0f2fe;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(10, 20, 40, 0.06);
    --shadow: 0 2px 8px rgba(10, 20, 40, 0.08);
    --shadow-lg: 0 10px 30px rgba(10, 20, 40, 0.12);

    --sidebar-w: 248px;
    --header-h: 60px;

    --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { font-family: var(--font); }

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 12px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100vw;
}
img, video, svg { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout principal ===== */
.app-layout { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 50;
    overflow-y: auto;
    transition: transform 0.22s ease;
}
.app-main { transition: margin-left 0.22s ease; }
.app-sidebar .logo {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 18px; font-weight: 700;
    color: var(--primary);
    display: flex; align-items: center; gap: 8px;
    justify-content: space-between;
}
.sidebar-collapse-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-soft); cursor: pointer;
    width: 26px; height: 26px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; line-height: 1; padding: 0;
    transition: background .12s, color .12s, border-color .12s;
}
.sidebar-collapse-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.header-expand-btn {
    background: var(--primary-soft); border: 1px solid var(--primary);
    color: var(--primary); cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
    display: none; align-items: center; justify-content: center;
    font-size: 15px; line-height: 1; padding: 0; margin-right: 10px;
    transition: background .12s;
}
.header-expand-btn:hover { background: var(--primary); color: #fff; }
body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); box-shadow: none; }
body.sidebar-collapsed .app-main { margin-left: 0; }
body.sidebar-collapsed .header-expand-btn { display: inline-flex; }
body.sidebar-collapsed .menu-toggle { display: none; }
.app-sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.app-sidebar .menu-search-wrap { padding: 8px 10px 0; }
.app-sidebar .menu-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}
.app-sidebar .menu-search:focus { border-color: var(--primary); background: var(--surface); }
.app-sidebar nav .menu-group { margin-bottom: 4px; }
.app-sidebar nav .group-title {
    display: flex; align-items: center; gap: 6px;
    width: 100%;
    padding: 10px 10px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    font-weight: 700;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    border-radius: var(--radius-sm);
    transition: color .12s, background .12s;
}
.app-sidebar nav .group-title:hover { color: var(--text); background: var(--bg-alt); }
.app-sidebar nav .group-title .group-arrow {
    display: inline-block;
    transition: transform .15s;
    font-size: 10px;
    color: var(--text-soft);
    width: 12px;
}
.app-sidebar nav .menu-group.collapsed .group-arrow { transform: rotate(-90deg); }
.app-sidebar nav .menu-group.collapsed .group-items { display: none; }
.app-sidebar nav .group-items { display: block; }
.app-sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.12s;
}
.app-sidebar nav a:hover { background: var(--bg-alt); text-decoration: none; }
.app-sidebar nav a.active { background: var(--primary-soft); color: var(--primary); }
.app-sidebar nav a .ico { width: 18px; display: inline-flex; font-size: 16px; }

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-height: 100vh;
}
.app-header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px;
    position: sticky; top: 0; z-index: 10;
}
.app-header .page-title { font-size: 15px; font-weight: 600; }
.app-header .user-box {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius);
}
.app-header .user-box:hover { background: var(--bg-alt); }
.app-header .user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}
.app-content { padding: 28px 32px; flex: 1; min-width: 0; max-width: 100%; }
#page-content { min-height: 0; min-width: 0; max-width: 100%; }
.app-main { min-width: 0; }
#page-content > *:first-child { margin-top: 0; }
.modal-xl .modal-body { padding: 24px 28px; }
.modal-lg .modal-body { padding: 22px 26px; }

/* ===== Cards / Boxes ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
}
.card-header .card-title { flex: 0 0 auto; }
.card-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
.card-toolbar .form-input,
.card-toolbar .form-select { width: auto; min-width: 0; flex: 1 1 180px; max-width: 260px; }
.card-toolbar .btn { flex: 0 0 auto; }
.card-title { font-size: 14px; font-weight: 600; }

/* ===== Botões ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    font-family: inherit;
}
.btn:hover { background: var(--bg-alt); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-lg { padding: 10px 18px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }

/* ===== Form ===== */
.form-group { margin-bottom: 10px; }
.form-label {
    display: block;
    font-size: 9px; font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-label .req { color: var(--danger); }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 3px 7px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 9px;
    font-family: inherit;
    line-height: 1.25;
    transition: border-color 0.12s, box-shadow 0.12s;
    height: 24px;
}
.form-textarea { height: auto; }
.form-select { padding-right: 18px !important; font-size: 9px !important; height: 22px !important; padding-top: 1px !important; padding-bottom: 1px !important; padding-left: 6px !important; }
.form-select option { font-size: 10px; padding: 2px; }
select.form-select, .form-select { line-height: 1.1 !important; }
input.form-input[type="date"], input.form-input[type="time"], input.form-input[type="datetime-local"], input.form-input[type="month"], input.form-input[type="week"] {
    font-size: 9px;
    height: 24px;
    padding: 1px 4px;
    min-width: 0;
}
input.form-input[type="date"]::-webkit-calendar-picker-indicator,
input.form-input[type="time"]::-webkit-calendar-picker-indicator,
input.form-input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input.form-input[type="month"]::-webkit-calendar-picker-indicator,
input.form-input[type="week"]::-webkit-calendar-picker-indicator {
    padding: 0; margin-left: 2px; opacity: 0.55; cursor: pointer;
    width: 12px; height: 12px;
}
input.form-input[type="date"]::-webkit-datetime-edit,
input.form-input[type="time"]::-webkit-datetime-edit,
input.form-input[type="datetime-local"]::-webkit-datetime-edit { padding: 0; }

/* File inputs (anexos, logo, certificado) — compactos */
input[type="file"] {
    font-size: 11px !important;
    padding: 3px 6px !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--surface) !important;
    color: var(--text-soft) !important;
    height: auto !important;
    line-height: 1.2 !important;
    max-width: 100%;
    cursor: pointer;
}
input[type="file"]::file-selector-button {
    font-size: 11px;
    padding: 3px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-alt);
    color: var(--text);
    cursor: pointer;
    margin-right: 8px;
    font-weight: 500;
    transition: background 0.12s;
}
input[type="file"]::file-selector-button:hover { background: var(--primary-soft); border-color: var(--primary); }
input[type="file"]::-webkit-file-upload-button {
    font-size: 11px;
    padding: 3px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-alt);
    color: var(--text);
    cursor: pointer;
    margin-right: 8px;
    font-weight: 500;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.form-textarea { min-height: 70px; resize: vertical; height: auto; }
.form-hint { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }
/* ===== Order cards (lista) ===== */
.ord-card { padding:0; margin:0; overflow:hidden; display:flex; flex-direction:column; }
.ord-card .ord-topbar { height:4px; }
.ord-card .ord-body { padding:12px 14px; display:grid; gap:10px; }
.ord-card[data-view="list"] .ord-body { grid-template-columns: minmax(240px, 1.2fr) minmax(280px, 1.6fr) minmax(260px, 1.4fr); align-items:stretch }
.ord-card[data-view="list"] .ord-section { min-width:0; padding:8px 10px; border:1px solid var(--border); border-radius:6px; background:var(--surface) }
.ord-card[data-view="list"] .ord-section + .ord-section { margin-top:0 }
.ord-card[data-view="grid"] .ord-body { grid-template-columns: 1fr }
.ord-card[data-view="grid"] .ord-section { padding:0 }
.ord-card .ord-section-title { font-size:10px; color:var(--text-muted); text-transform:uppercase; letter-spacing:.04em; font-weight:700; margin-bottom:5px; display:flex; justify-content:space-between; align-items:center; gap:4px }
.ord-parcelas-list { display:flex; flex-direction:column; gap:4px }
.ord-parc-row { display:grid; grid-template-columns: auto 1fr auto; gap:6px; align-items:center; padding:4px 6px; border:1px solid var(--border); border-radius:5px; background:var(--surface); font-size:10.5px; line-height:1.2 }
.ord-parc-row.pago { background:#ecfdf5; border-color:#a7f3d0 }
.ord-parc-row.atrasado { background:#fef2f2; border-color:#fecaca }
.ord-parc-row .ord-parc-head { display:flex; align-items:center; gap:3px; white-space:nowrap }
.ord-parc-row .ord-parc-num { font-weight:700; color:var(--primary); font-size:10px; background:var(--primary-soft); padding:1px 5px; border-radius:999px }
.ord-parc-row .ord-parc-mid { min-width:0; display:flex; flex-wrap:wrap; align-items:center; gap:3px 8px }
.ord-parc-row .ord-parc-venc { color:var(--text-soft); white-space:nowrap }
.ord-parc-row .ord-parc-valor { font-weight:700; white-space:nowrap }
.ord-parc-row .ord-parc-forma { display:inline-flex; align-items:center; gap:3px; min-width:0; overflow:hidden }
.ord-parc-row .ord-parc-forma img { width:14px; height:14px; object-fit:contain; border-radius:2px; background:#fff; border:1px solid var(--border); flex-shrink:0 }
.ord-parc-row .ord-parc-forma span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; color:var(--text-muted) }
.ord-parc-row .ord-parc-status { display:inline-flex; align-items:center; padding:0 5px; border-radius:999px; font-size:9px; font-weight:700; color:#fff; height:14px }
.ord-parc-row .ord-parc-action { display:flex; gap:3px; align-items:center }
.ord-parc-row .ord-parc-action .btn { font-size:9px; padding:1px 5px; line-height:1.2 }
.ord-card .ord-footer { padding:8px 12px; border-top:1px solid var(--border); background:var(--surface); display:flex; flex-wrap:wrap; gap:6px }
@media (max-width: 1100px) { .ord-card[data-view="list"] .ord-body { grid-template-columns: 1fr 1fr } .ord-card[data-view="list"] .ord-section-parcelas { grid-column: 1 / -1 } }
@media (max-width: 780px) { .ord-card[data-view="list"] .ord-body { grid-template-columns: 1fr } }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.form-row-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
@media (max-width: 900px) {
    .col-span-2, .col-span-3, .col-span-4 { grid-column: auto; }
}

/* Section title (subtítulo dentro do form) */
.section-title {
    margin: 18px 0 10px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }

/* People form layout */
.people-form-head {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 18px;
    align-items: start;
    margin-bottom: 14px;
}
.people-photo-box {
    width: 110px; height: 110px;
    border-radius: 50%;
    background: var(--bg-alt);
    border: 2px solid var(--border);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-soft);
    font-size: 11px;
}
.people-photo-box img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 600px) {
    .people-form-head {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
    .people-photo-box { margin: 0 auto; }
}

/* Action buttons em rows de tabela */
.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.row-actions .btn { padding: 4px 8px; font-size: 11px; }
.btn-icon {
    width: 28px; height: 28px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; line-height: 1;
}
@media (max-width: 600px) {
    .row-actions { gap: 6px; }
    .row-actions .btn { padding: 5px 9px; font-size: 11px; }
}

/* ===== Tabela ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.table th {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.table tbody tr:hover { background: var(--bg-alt); }
.table tbody tr:last-child td { border-bottom: none; }

/* ===== Badges (pills) — SEMPRE com fundo de cor sólida e texto branco ===== */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #fff !important;
    background-color: var(--text-soft);
    background-image: none !important;
    border: none;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    line-height: 1.4;
    vertical-align: middle;
}
.badge-primary { background-color: var(--primary); }
.badge-success { background-color: var(--success); }
.badge-warning { background-color: var(--warning); }
.badge-danger  { background-color: var(--danger); }
.badge-info    { background-color: var(--info); }
.badge-muted   { background-color: var(--text-soft); }
.badge-dark    { background-color: #334155; }

/* Bloqueia qualquer tentativa de tornar o pill transparente/translúcido */
.badge[style*="opacity"], .badge[style*="rgba"] { opacity: 1 !important; }

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 500;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.modal-lg { max-width: 900px; }
.modal-xl { max-width: min(1600px, 96vw); max-height: 95vh; }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 22px; line-height: 1;
    padding: 0; width: 32px; height: 32px;
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg-alt); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
    background: var(--surface-2);
}

/* ===== Utilitários ===== */
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.hidden { display: none !important; }
@media (max-width: 600px) {
    .hide-sm { display: none !important; }
}
@media (min-width: 601px) {
    .show-sm { display: none !important; }
}

/* ===== Alertas ===== */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); color: #14532d; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-soft); color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--warning-soft); color: #78350f; border-color: #fde68a; }
.alert-info { background: var(--info-soft); color: #075985; border-color: #bae6fd; }

/* ===== Toast ===== */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    min-width: 260px; max-width: 400px;
    font-size: 13px;
    animation: slideIn 0.2s ease-out;
}
.toast-success { border-left-color: var(--success); }
.toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Responsivo ===== */

/* Botão hamburguer (visível só no mobile) */
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    margin-right: 10px;
}
.menu-toggle:hover { background: var(--bg-alt); }

/* Backdrop quando sidebar abre no mobile */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 49;
}
.sidebar-backdrop.active { display: block; }

/* ===== Tablet (≤ 900px) ===== */
@media (max-width: 900px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        width: 260px;
    }
    .app-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-main { margin-left: 0; }
    .menu-toggle { display: inline-flex; align-items: center; }

    .form-row, .form-row-3, .form-row-4, .form-row-5 { grid-template-columns: 1fr; gap: 10px; }

    .app-content { padding: 20px 18px; }
    .app-header { padding: 0 16px; }
    .card { padding: 16px 18px; }

    .table-wrap { overflow: visible; }
    .table { min-width: 0; width: 100%; }
}

/* ===== Mobile (≤ 600px) ===== */
@media (max-width: 600px) {
    :root {
        --header-h: 52px;
        --radius: 8px;
        --radius-lg: 10px;
    }
    html, body { font-size: 11px; }

    .app-content { padding: 14px 12px; }
    .app-header { padding: 0 10px; }
    .app-header .page-title { font-size: 12px; }
    .app-header .user-avatar { width: 26px; height: 26px; font-size: 11px; }
    .app-header .user-box { padding: 3px 5px; gap: 5px; }
    .app-header .user-box > div:not(.user-avatar) > div:first-child { font-size: 11px !important; }
    .app-header .user-box > div:not(.user-avatar) > div:last-child { display: none; }

    .card { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; }
    .card-header { margin-bottom: 8px; padding-bottom: 6px; }
    .card-title { font-size: 12px; }

    /* Botões */
    .btn { padding: 5px 9px; font-size: 10px; }
    .btn-sm { padding: 3px 7px; font-size: 9px; }
    .btn-lg { padding: 7px 12px; font-size: 11px; }

    /* Form — compactação forçada em mobile */
    .form-group { margin-bottom: 5px; }
    .form-label,
    .form-group > label { font-size: 8px !important; margin-bottom: 2px !important; letter-spacing: 0.02em; }
    .form-input, .form-select, .form-textarea,
    input[type="text"], input[type="number"], input[type="email"],
    input[type="password"], input[type="search"], input[type="tel"],
    input[type="url"], textarea, select {
        font-size: 11px !important;
        padding: 3px 6px !important;
        height: 26px !important;
        line-height: 1.2 !important;
    }
    textarea, .form-textarea { height: auto !important; min-height: 48px !important; padding: 4px 6px !important; }
    .form-select, select {
        font-size: 10px !important; height: 24px !important;
        padding: 1px 18px 1px 6px !important;
    }
    input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"], input[type="week"],
    input.form-input[type="date"], input.form-input[type="time"], input.form-input[type="datetime-local"], input.form-input[type="month"], input.form-input[type="week"] {
        font-size: 10px !important; height: 24px !important;
        padding: 1px 4px !important; min-width: 0;
    }
    input[type="date"]::-webkit-calendar-picker-indicator,
    input[type="time"]::-webkit-calendar-picker-indicator,
    input[type="datetime-local"]::-webkit-calendar-picker-indicator,
    input[type="month"]::-webkit-calendar-picker-indicator,
    input[type="week"]::-webkit-calendar-picker-indicator {
        width: 10px; height: 10px; margin-left: 0; opacity: 0.55;
    }
    .form-hint, .form-error { font-size: 8px !important; margin-top: 2px; }

    /* Menu search lateral também compacto */
    .app-sidebar .menu-search { font-size: 10px !important; padding: 5px 8px !important; height: 26px !important; }

    /* Tabela → cards empilhados (sem scroll horizontal) */
    .table-wrap { background: transparent; border: none; overflow: visible; }
    .table { display: block; }
    .table thead { display: none; }
    .table tbody { display: block; }
    .table tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 10px 12px;
        margin-bottom: 8px;
        box-shadow: var(--shadow-sm);
    }
    .table tbody tr:last-child td { border-bottom: 1px dashed var(--border); }
    .table tbody tr:last-child td:last-child { border-bottom: none; }
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
        padding: 5px 0;
        border-bottom: 1px dashed var(--border);
        font-size: 11px;
        text-align: right;
        word-break: break-word;
        min-width: 0;
    }
    .table td:last-child { border-bottom: none; }
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 9px;
        letter-spacing: 0.04em;
        text-align: left;
        flex: 0 0 38%;
        max-width: 40%;
    }
    .table td:not([data-label])::before { display: none; }
    .table td:not([data-label]) { text-align: left; }
    .table tbody tr:hover { background: var(--surface); }

    /* Badges */
    .badge { font-size: 9px; padding: 2px 6px; }

    /* Modal */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        width: 100%;
    }
    .modal-lg, .modal-xl { max-width: 100%; }
    .modal-header { padding: 10px 12px; }
    .modal-title { font-size: 13px; }
    .modal-body { padding: 12px; }
    .modal-footer { padding: 9px 12px; flex-wrap: wrap; gap: 6px; }
    .modal-footer .btn { flex: 1; min-width: 90px; }

    /* Sidebar mais compacta */
    .app-sidebar { width: 230px; }
    .app-sidebar .logo { padding: 12px 14px; font-size: 14px; }
    .app-sidebar nav a { padding: 7px 9px; font-size: 12px; }
    .app-sidebar nav .group-title { padding: 9px 7px 3px; font-size: 9px; }
    .app-sidebar .menu-search { font-size: 11px; padding: 6px 9px; }

    /* Toast */
    .toast-container { top: 10px; right: 10px; left: 10px; }
    .toast { min-width: 0; max-width: 100%; font-size: 11px; padding: 9px 11px; }

    /* Alertas */
    .alert { padding: 8px 10px; font-size: 11px; }

    /* Texto geral */
    h1 { font-size: 17px; }
    h2 { font-size: 15px; }
    h3 { font-size: 13px; }
    h4, h5, h6 { font-size: 12px; }
    .text-soft, .text-muted { font-size: inherit; }
    .section-title { font-size: 10px; }
}

/* ===== Mobile pequeno (≤ 380px) ===== */
@media (max-width: 380px) {
    html, body { font-size: 10px; }
    .app-header .user-box > div:not(.user-avatar) { display: none; }
    .app-header .page-title { font-size: 11px; }
    .card { padding: 10px 11px; }
    .card-title { font-size: 11px; }
    .table th, .table td { padding: 5px 7px; }
    .table td { font-size: 10px; }
    .table td::before { font-size: 8px; }
    .btn { padding: 5px 8px; font-size: 9px; }
    .btn-sm { padding: 2px 6px; font-size: 9px; }
    .badge { font-size: 8px; padding: 1px 5px; }
    h1 { font-size: 15px; }
    h2 { font-size: 13px; }
    h3 { font-size: 12px; }
    .form-label, .form-group > label { font-size: 7px !important; }
    .form-hint, .form-error { font-size: 7px !important; }
    .form-input, .form-textarea,
    input[type="text"], input[type="number"], input[type="email"],
    input[type="password"], input[type="search"], input[type="tel"],
    input[type="url"], textarea {
        font-size: 10px !important; height: 24px !important; padding: 2px 5px !important;
    }
    .form-select, select { font-size: 9px !important; height: 22px !important; padding: 1px 16px 1px 5px !important; }
    input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"], input[type="week"],
    input.form-input[type="date"], input.form-input[type="time"], input.form-input[type="datetime-local"], input.form-input[type="month"], input.form-input[type="week"] {
        font-size: 9px !important; height: 22px !important; padding: 1px 3px !important;
    }
    .app-sidebar .menu-search { font-size: 9px !important; padding: 4px 7px !important; height: 24px !important; }
    .alert { font-size: 10px; padding: 7px 9px; }
    .toast { font-size: 10px; }
    .modal-title { font-size: 12px; }
    .modal-body { padding: 10px; }
}

/* ===== Responsividade das páginas de Notas Fiscais (NFe / NFSe / CT-e / análise por produto) ===== */
/* Tablet: 2x2 pros KPIs + filtros mais respiráveis */
@media (max-width: 900px) {
    .form-row-4 { grid-template-columns: repeat(2, 1fr); }
    .nf-range-bar, .nfs-range-bar, .cte-range-bar, .range-bar {
        padding: 10px;
    }
    .nf-range-bar > div[style*="flex:1"],
    .nfs-range-bar > div[style*="flex:1"],
    .cte-range-bar > div[style*="flex:1"],
    .range-bar > div[style*="flex:1"] { display: none; }
}

/* Mobile: barras de filtro viram colunas e controles ocupam 100% */
@media (max-width: 600px) {
    .form-row-4 { grid-template-columns: 1fr; }

    .nf-range-bar, .nfs-range-bar, .cte-range-bar, .range-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        gap: 8px;
    }
    .nf-range-quick, .nfs-range-quick, .cte-range-quick, .range-quick {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .nf-range-quick button, .nfs-range-quick button, .cte-range-quick button, .range-quick button {
        white-space: nowrap;
        flex-shrink: 0;
    }
    /* Linha de inputs de data + selects */
    .nf-range-bar > .flex,
    .nfs-range-bar > .flex,
    .cte-range-bar > .flex,
    .range-bar > .flex {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        width: 100%;
        font-size: 11px !important;
    }
    .nf-range-bar > .flex > label,
    .nfs-range-bar > .flex > label,
    .cte-range-bar > .flex > label,
    .range-bar > .flex > label {
        flex: 0 0 auto;
        align-self: center;
        font-size: 11px;
    }
    .nf-range-bar > .flex > input[type="date"],
    .nfs-range-bar > .flex > input[type="date"],
    .cte-range-bar > .flex > input[type="date"],
    .range-bar > .flex > input[type="date"] {
        flex: 1 1 110px;
        min-width: 0 !important;
        width: auto !important;
    }
    .nf-range-bar > .flex > button,
    .nfs-range-bar > .flex > button,
    .cte-range-bar > .flex > button,
    .range-bar > .flex > button,
    .nf-range-bar > .flex > select,
    .nfs-range-bar > .flex > select,
    .cte-range-bar > .flex > select,
    .range-bar > .flex > select,
    .nf-range-bar > .flex > input[type="text"],
    .range-bar > .flex > input[type="text"] {
        flex: 1 1 100%;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
    }

    /* Search bar produto/NCM ocupa largura total */
    .np-search { padding: 8px; }
    .np-search > input { min-width: 0 !important; width: 100% !important; }

    /* Regime banner empilha no mobile */
    .regime-banner { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
    .regime-banner > span:first-child { font-size: 20px !important; }

    /* Card toolbar (filtros de status das notas) quebra em duas linhas legíveis */
    .card-toolbar { gap: 5px; }
    .card-toolbar .btn-sm { padding: 3px 6px; font-size: 10px; }
    .card-toolbar input[type="file"] + button,
    .card-toolbar > button { flex: 0 1 auto; }

    /* Gráfico de barras de NF — reduz altura pra não tomar metade da tela */
    .nf-bars, .nfs-bars, .cte-bars { height: 130px; gap: 2px; }

    /* Tabelas grandes dentro de modais/páginas (NFe detalhes, análise por produto) —
       força scroll horizontal em vez de empilhar td em mobile */
    .table-scroll-mobile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-scroll-mobile table.table,
    .table-scroll-mobile .np-table {
        display: table;
        min-width: 720px;
    }
    .table-scroll-mobile table.table thead,
    .table-scroll-mobile table.table tbody,
    .table-scroll-mobile table.table tr {
        display: revert;
    }
    .table-scroll-mobile table.table thead { display: table-header-group; }
    .table-scroll-mobile table.table tbody { display: table-row-group; }
    .table-scroll-mobile table.table tr { display: table-row; }
    .table-scroll-mobile table.table td,
    .table-scroll-mobile table.table th {
        display: table-cell;
        text-align: left;
        padding: 6px 8px;
        font-size: 10px;
    }
    .table-scroll-mobile table.table td::before { display: none; }
    .table-scroll-mobile table.table tr {
        background: transparent;
        border: 0;
        border-bottom: 1px solid var(--border);
        padding: 0;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
    }

    /* Grid de cards de NF/NFSe/CT-e — 1 coluna */
    #nfes-grid, #nfs-grid, #ctes-grid {
        grid-template-columns: 1fr !important;
    }
    #nfes-grid > *, #nfs-grid > *, #ctes-grid > * { min-width: 0; max-width: 100%; }

    /* Form-row grids permitem os filhos encolherem */
    .form-row > *, .form-row-3 > *, .form-row-4 > *, .form-row-5 > * { min-width: 0; }

    /* Rank rows (top transportadoras, emissores, prestadores) */
    .cte-rank-row, .nf-rank-row, .nfs-rank-row { min-width: 0; }
    .cte-rank-row .valor, .nf-rank-row .valor, .nfs-rank-row .valor {
        font-size: 11px;
        flex-shrink: 0;
    }

    /* Cards dentro de grids respeitam 100% */
    #nfes-grid > .card, #nfs-grid > .card, #ctes-grid > .card { width: 100%; }
}

@media (max-width: 380px) {
    .nf-bars, .nfs-bars, .cte-bars { height: 110px; }
    .regime-banner { padding: 8px 10px; font-size: 11px; }
}

/* ===== Toggle switch GLOBAL — substitui qualquer <input type="checkbox"> por toggle ===== */
input[type="checkbox"]:not(.cb-native) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 34px;
    height: 18px;
    background: var(--border-strong);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    vertical-align: middle;
    margin: 0 6px 0 0;
    border: 1px solid var(--border);
    padding: 0;
    flex-shrink: 0;
    display: inline-block;
    box-sizing: border-box;
}
input[type="checkbox"]:not(.cb-native)::after {
    content: "";
    position: absolute;
    top: 1px; left: 1px;
    width: 14px; height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
input[type="checkbox"]:not(.cb-native):checked {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}
input[type="checkbox"]:not(.cb-native):checked::after {
    transform: translateX(16px);
}
input[type="checkbox"]:not(.cb-native):disabled {
    opacity: .55;
    cursor: not-allowed;
}
input[type="checkbox"]:not(.cb-native):focus-visible {
    outline: 2px solid var(--primary-soft);
    outline-offset: 2px;
}
/* Dentro do componente .toggle-switch (sectores coloridos) o input fica oculto e o slider é o visível */
.toggle-switch input[type="checkbox"]:not(.cb-native) {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    width: 0; height: 0;
    margin: 0;
    border: 0;
    background: transparent;
}
.toggle-switch input[type="checkbox"]:not(.cb-native)::after { display: none; }

/* ===== Toggle switch (componente com slider explícito) ===== */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--surface);
    transition: background .15s, border-color .15s;
    user-select: none;
}
.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
    pointer-events: none;
}
.toggle-switch .toggle-slider {
    position: relative;
    display: inline-block;
    width: 30px; height: 16px;
    background: var(--border-strong);
    border-radius: 999px;
    transition: background .15s;
    flex-shrink: 0;
}
.toggle-switch .toggle-slider::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 12px; height: 12px;
    background: #fff;
    border-radius: 50%;
    transition: transform .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(14px); }
.toggle-switch .toggle-label { font-size: 12px; line-height: 1.2; }
.toggle-switch:has(input:disabled) { opacity: .55; cursor: not-allowed; }

/* Variantes por setor */
.toggle-switch.tg-impressao input:checked + .toggle-slider { background: #2563eb; }
.toggle-switch.tg-impressao:has(input:checked) { background: #e0ecff; border-color: #2563eb; }
.toggle-switch.tg-acabamento input:checked + .toggle-slider { background: #6366f1; }
.toggle-switch.tg-acabamento:has(input:checked) { background: #eef0ff; border-color: #6366f1; }
.toggle-switch.tg-urgencia input:checked + .toggle-slider { background: #f59e0b; }
.toggle-switch.tg-urgencia:has(input:checked) { background: #fef3c7; border-color: #f59e0b; }
.toggle-switch.tg-outros input:checked + .toggle-slider { background: #64748b; }
.toggle-switch.tg-outros:has(input:checked) { background: #e5e7eb; border-color: #64748b; }

/* Grupos de tipos de produção */
.tipos-grupo { margin-top: 10px; }
.tipos-grupo + .tipos-grupo { margin-top: 12px; }
.tipos-grupo-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 3px 9px;
    border-radius: 999px;
    margin-bottom: 6px;
}
.tipos-grupo-header.tg-impressao { background: #e0ecff; color: #1e4fd1; }
.tipos-grupo-header.tg-acabamento { background: #eef0ff; color: #4f46e5; }
.tipos-grupo-header.tg-urgencia { background: #fef3c7; color: #b45309; }
.tipos-grupo-header.tg-outros { background: #e5e7eb; color: #475569; }
.tipos-grupo-items { display: flex; flex-wrap: wrap; gap: 6px; }
