@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ==========================================================================
   NR.COM Digital — Design System v3
   Layout: Top Navbar + Tab Bar
   ========================================================================== */

/* === Design Tokens ======================================================= */
:root {
    /* Brand */
    --brand:       #3b82f6;
    --brand-mid:   #2563eb;
    --brand-dark:  #1d4ed8;
    --brand-soft:  rgba(59, 130, 246, 0.08);
    --brand-muted: #60a5fa;

    /* Accent */
    --accent:      #f97316;
    --accent-dark: #ea580c;
    --accent-soft: rgba(249, 115, 22, 0.08);

    /* Feedback */
    --ok:         #10b981;
    --ok-soft:    rgba(16, 185, 129, 0.1);
    --warn:       #f59e0b;
    --warn-soft:  rgba(245, 158, 11, 0.1);
    --danger:     #ef4444;
    --danger-soft:rgba(239, 68, 68, 0.1);

    /* Neutrals - Light Mode Default */
    --bg:          #f4f7fa;
    --surface:     #ffffff;
    --surface-alt: #f8fafc;
    --border:      #e2e8f0;
    --border-strong: #cbd5e1;
    --text:        #0f172a;
    --text-2:      #334155;
    --muted:       #64748b;
    --muted-2:     #94a3b8;

    /* Layout */
    --sidebar-bg:  #0c1829;
    --sidebar-w:   240px;
    --header-h:    56px;

    /* Radii */
    --r-xs: 4px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 24px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

    /* Typography */
    --font-ui:   "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", monospace;
}

.theme-dark {
    --bg:          #040c1a;
    --surface:     #0c1829;
    --surface-alt: #132033;
    --border:      rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --text:        #f8fafc;
    --text-2:      #e2e8f0;
    --muted:       #94a3b8;
    --muted-2:     #64748b;
    --sidebar-bg:  #020814;
    --brand-soft:  rgba(59, 130, 246, 0.15);
    --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.3);
}

/* === Animações ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.anim-fade-up   { animation: fadeInUp 0.32s ease both; }
.anim-fade-in   { animation: fadeIn 0.28s ease both; }
.anim-scale-in  { animation: scaleIn 0.26s ease both; }
.anim-slide-left{ animation: slideInLeft 0.30s ease both; }

.anim-d1 { animation-delay: 0.04s; }
.anim-d2 { animation-delay: 0.08s; }
.anim-d3 { animation-delay: 0.12s; }
.anim-d4 { animation-delay: 0.16s; }
.anim-d5 { animation-delay: 0.20s; }
.anim-d6 { animation-delay: 0.24s; }

/* === Reset =============================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    font-family: var(--font-ui);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.mono, [class*="kpi-value"], [class*="stat strong"] {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* === App Shell =========================================================== */
.app-shell {
    display: flex;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar ============================================================= */
.sidebar {
    width: 216px;
    flex-shrink: 0;
    background: #0c1829;
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 1100;
    transition: transform 280ms ease;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}
.sidebar-logo img {
    height: 26px;
    width: 26px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}
.sidebar-logo-text {
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.01em;
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sidebar-section-label {
    padding: 10px 16px 3px;
    font-size: 0.60rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: rgba(255,255,255,0.26);
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 500;
    color: rgba(255,255,255,0.58);
    text-decoration: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: color 120ms, background 120ms;
    white-space: nowrap;
}
.sidebar-item svg { flex-shrink: 0; opacity: 0.65; transition: opacity 120ms; }
.sidebar-item:hover { color: rgba(255,255,255,0.90); background: rgba(255,255,255,0.06); }
.sidebar-item:hover svg { opacity: 1; }
.sidebar-item.is-active {
    color: #fff;
    background: rgba(255,255,255,0.10);
    font-weight: 600;
    border-right: 3px solid #f0753a;
}
.sidebar-item.is-active svg { opacity: 1; }
.sidebar-toggle { justify-content: flex-start; }
.sidebar-caret {
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 180ms ease;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0.5;
}
.sidebar-group.is-open > .sidebar-toggle .sidebar-caret {
    transform: rotate(225deg);
    opacity: 0.8;
}
.sidebar-group.is-open > .sidebar-toggle {
    color: rgba(255,255,255,0.82);
}
.sidebar-submenu {
    overflow: hidden;
    max-height: 0;
    transition: max-height 240ms ease;
}
.sidebar-group.is-open > .sidebar-submenu { max-height: 500px; }
.sidebar-sub-item {
    display: flex;
    align-items: center;
    padding: 6px 16px 6px 41px;
    font-size: 0.79rem;
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    transition: color 110ms, background 110ms;
}
.sidebar-sub-item:hover { color: rgba(255,255,255,0.82); background: rgba(255,255,255,0.04); }
.sidebar-sub-item.is-active { color: #f0a060; font-weight: 600; }
.sidebar-dd-separator { height: 1px; background: rgba(255,255,255,0.06); margin: 3px 16px; }
.sidebar-dd-label {
    padding: 6px 16px 2px 41px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(255,255,255,0.22);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.18);
}
.sidebar-tools {
    display: grid;
    gap: 8px;
    padding: 10px 14px 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
}
.sidebar-tools-label {
    padding: 0;
    color: rgba(255,255,255,0.18);
    font-size: 0.56rem;
    letter-spacing: 0.12em;
}
.sidebar-release-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(148,163,184,0.10);
    background: rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.72);
    font-size: 0.72rem;
}
.sidebar-release-card strong {
    font-size: 0.80rem;
    letter-spacing: 0.02em;
    color: rgba(255,255,255,0.88);
}
.release-chip-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.42);
}
.sidebar-tool-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}
.sidebar-tool-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    height: 34px;
    border-radius: 9px;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.56);
    cursor: pointer;
    transition: background 140ms, color 140ms, border-color 140ms, transform 140ms;
}
.sidebar-tool-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.84);
    transform: translateY(-1px);
}
.sidebar-panel-anchor {
    position: relative;
}
.sidebar-tools + .sidebar-user {
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
    font-size: 0.80rem;
    font-weight: 600;
    color: rgba(255,255,255,0.88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 0.68rem; color: rgba(255,255,255,0.35); }

/* === Main Area =========================================================== */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* === Topbar (compact, search + actions) ================================== */
/* .topbar {
    display: flex;
    align-items: center;
    height: 52px;
    padding: 0 16px;
    background: #0c1829;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    gap: 10px;
    position: relative;
    z-index: 1000;
} */

.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--danger);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1;
    margin-left: auto;
    flex-shrink: 0;
}
.topbar-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    padding: 0 12px;
    max-width: 540px;
    height: 34px;
    transition: background 150ms, border-color 150ms;
}
.topbar-search:focus-within {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.20);
}
.topbar-search svg { color: rgba(255,255,255,0.35); flex-shrink: 0; }
.topbar-search input {
    background: transparent;
    border: none;
    outline: none;
    color: rgba(255,255,255,0.85);
    font-size: 0.82rem;
    width: 100%;
    font-family: inherit;
    padding: 0;
    margin: 0;
    min-height: unset;
}
.topbar-search input::placeholder { color: rgba(255,255,255,0.30); }
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.release-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border: 1px solid rgba(148,163,184,0.28);
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.92);
    font-size: 0.72rem;
    line-height: 1;
    margin-right: 6px;
}
.release-chip-label {
    color: rgba(255,255,255,0.58);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.62rem;
}
.topbar-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255,255,255,0.50);
    cursor: pointer;
    transition: background 140ms, color 140ms, border-color 140ms;
    font-family: inherit;
}
.topbar-action-btn:hover {
    background: rgba(255,255,255,0.09);
    border-color: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.88);
}

/* === User Avatar ========================================================= */
.user-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #e86b3a 0%, #e03e1e 100%);
    color: #fff;
    font-size: 0.70rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* === Menu Toggle (mobile) ================================================ */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    cursor: pointer;
    color: rgba(255,255,255,0.75);
    flex-shrink: 0;
    font-family: inherit;
}
.menu-toggle-floating {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1250;
    background: rgba(12,24,41,0.94);
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 10px 24px rgba(15,23,42,0.24);
}

/* === Mobile overlay ====================================================== */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4,12,26,0.60);
    z-index: 1090;
    backdrop-filter: blur(2px);
}
.mobile-nav-overlay.is-open { display: block; }

.simulado-grid-top {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 10px;
}
.simulado-field-sm { grid-column: span 3; }
.simulado-field-md { grid-column: span 3; }
.simulado-field-full { grid-column: span 3; }
.simulado-participants-list {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}
.simulado-participant-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: #f8fbff;
}
.simulado-participant-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text);
}
.simulado-participant-toggle span {
    line-height: 1.35;
}
.simulado-participant-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
}
.simulado-participant-row input[type="number"] {
    margin-top: 0;
}
.simulado-grid-textareas {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.simulado-field-block {
    display: block;
    margin-top: 4px;
}
.simulado-photo-section {
    margin-top: 6px;
}
.simulado-signature-layout {
    display: grid;
    gap: 14px;
}

.simulado-signature-form-grid {
    display: grid;
    gap: 12px;
}

.simulado-signature-card {
    display: grid;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid #dbe5f1;
    border-radius: 14px;
    background: #f8fafc;
}

.simulado-signature-card--saved {
    background: linear-gradient(180deg, #f8fbff 0%, #f8fafc 100%);
}

.simulado-signature-card__header,
.simulado-signature-card__empty,
.simulado-signature-card__actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.simulado-signature-card__kicker {
    font-size: 0.76rem;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.simulado-signature-card__title {
    font-size: 0.96rem;
    font-weight: 700;
    color: #0f172a;
    margin-top: 2px;
}

.simulado-signature-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.simulado-span-2 {
    grid-column: 1 / -1;
}

.simulado-signature-toggles {
    display: grid;
    gap: 8px;
    min-width: min(100%, 280px);
}

.simulado-inline-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 600;
    color: #0f172a;
}

.simulado-inline-check--danger {
    color: #b91c1c;
}

@media (max-width: 900px) {
    .simulado-signature-fields {
        grid-template-columns: 1fr;
    }

    .simulado-span-2 {
        grid-column: auto;
    }
}

.simulado-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}
.simulado-photo-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: #f8fbff;
}
.simulado-photo-card strong {
    font-size: 0.83rem;
    color: var(--text);
}
.simulado-photo-preview {
    border: 1px solid #dbe5f1;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    min-height: 140px;
    display: grid;
    place-items: center;
}
.simulado-photo-preview img {
    display: block;
    width: 100%;
    height: 160px;
    object-fit: cover;
}
.simulado-logo-preview img {
    object-fit: contain;
    background: #fff;
    padding: 12px;
}

.pibi-wizard-shell {
    padding: 18px 20px;
    background:
        linear-gradient(180deg, rgba(255, 108, 43, 0.08) 0%, rgba(255,255,255,0.92) 70%),
        #fff;
    border-color: rgba(255, 108, 43, 0.22);
}
.pibi-wizard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}
.pibi-wizard-title {
    margin: 0 0 4px;
    font-size: 1.08rem;
    color: #12233d;
}
.pibi-wizard-subtitle {
    margin: 0;
    max-width: 640px;
}
.pibi-wizard-progress {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
.pibi-step-chip {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid #d6e0ec;
    background: #fff;
    color: #41556f;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: border-color 120ms, background 120ms, color 120ms, transform 120ms;
}
.pibi-step-chip:hover {
    border-color: #ff7a45;
    color: #d84c16;
}
.pibi-step-chip.is-active {
    background: linear-gradient(135deg, #ff6a2c 0%, #ff4d1f 100%);
    border-color: #ff5c25;
    color: #fff;
    box-shadow: 0 12px 24px rgba(255, 92, 37, 0.18);
}
.pibi-stage-card {
    border-color: rgba(255, 129, 60, 0.28);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
    background:
        linear-gradient(180deg, rgba(255, 162, 99, 0.08) 0%, rgba(255,255,255,0.98) 70%),
        #fff;
}
.pibi-stage-card > h3 {
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 1rem;
    color: #0f172a;
}
.pibi-stage-card > .muted {
    margin-top: 0;
    margin-bottom: 14px;
}
.pibi-client-grid,
.pibi-ident-grid,
.pibi-brigade-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}
.pibi-span-1 { grid-column: span 1; }
.pibi-span-2 { grid-column: span 2; }
.pibi-span-3 { grid-column: span 3; }
.pibi-span-4 { grid-column: span 4; }
.pibi-span-5 { grid-column: span 5; }
.pibi-field-full {
    display: block;
    margin-top: 8px;
}
.pibi-field-full textarea {
    min-height: 78px;
}
.pibi-client-card > label,
.pibi-ident-card > label {
    margin-bottom: 0;
}
.pibi-client-hint {
    align-self: stretch;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 1px dashed #d6e0ec;
    border-radius: 12px;
    background: rgba(255,255,255,0.72);
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.45;
}
.pibi-ident-card textarea[name="pibi_objetivo"] {
    min-height: 76px;
}
.pibi-brigade-grid textarea {
    min-height: 84px;
}

/* === PIBI Form: Field Highlighting ======================================= */
.pibi-stage-card label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #1a3558;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}
.pibi-stage-card input,
.pibi-stage-card select,
.pibi-stage-card textarea {
    background: #eef5ff;
    border: 1.5px solid #b5cff0;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 0.83rem;
    color: #0f172a;
    transition: border-color 130ms, box-shadow 130ms, background 130ms;
}
.pibi-stage-card input:focus,
.pibi-stage-card select:focus,
.pibi-stage-card textarea:focus {
    background: #fff;
    border-color: #ff6a2c;
    box-shadow: 0 0 0 3px rgba(255, 106, 44, 0.13);
    outline: none;
}
.pibi-stage-card input[readonly] {
    background: #f1f5fb;
    border-color: #d0dce8;
    color: #64748b;
    cursor: default;
}
.pibi-stage-card input::placeholder,
.pibi-stage-card textarea::placeholder {
    color: #94a3b8;
    font-style: italic;
    font-size: 0.82rem;
}
.pibi-stage-card select option {
    background: #fff;
    color: #0f172a;
}

.pibi-systems-shell {
    margin: 14px 0 10px;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(248,250,252,0.98) 0%, rgba(255,255,255,0.96) 100%);
}
.pibi-systems-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}
.pibi-systems-topbar strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.96rem;
    color: #0f172a;
}
.pibi-system-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.pibi-system-chip {
    border: 1.5px solid rgba(21, 96, 168, 0.22);
    background: #eef5ff;
    color: #1a4a8a;
    border-radius: 999px;
    padding: 8px 12px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}
.pibi-system-chip:hover {
    background: #ddeafb;
    border-color: rgba(21, 96, 168, 0.38);
}
.pibi-systems-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.pibi-system-stat {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1.5px solid #c8ddf2;
    background: #f0f7ff;
    display: flex;
    align-items: center;
    gap: 14px;
}
.pibi-system-stat span {
    display: block;
    font-size: 0.74rem;
    color: #4a6fa5;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
}
.pibi-system-stat strong {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1a3d6b;
    line-height: 1;
    display: block;
}
.pibi-system-stat::before {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.75;
}
.pibi-systems-stats .pibi-system-stat:nth-child(1)::before { content: "🧯"; }
.pibi-systems-stats .pibi-system-stat:nth-child(2)::before { content: "🔢"; }
.pibi-systems-stats .pibi-system-stat:nth-child(3)::before { content: "📋"; }

/* === Equipment list ====================================================== */
.pibi-equipment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    counter-reset: equip-counter;
}
.pibi-equipment-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(120px, 1.1fr) minmax(130px, 1.5fr) minmax(0, 2fr) 76px minmax(0, 1.4fr) minmax(0, 1.5fr);
    gap: 10px 12px;
    align-items: start;
    padding: 10px 12px 10px 46px;
    border-radius: 12px;
    border: 1.5px solid #c4d8f2;
    border-left: 4px solid #3b82f6;
    background: linear-gradient(135deg, #f0f7ff 0%, #fafcff 100%);
    counter-increment: equip-counter;
}
.pibi-equipment-row::before {
    content: counter(equip-counter);
    position: absolute;
    top: 10px;
    left: 12px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pibi-equipment-row label {
    margin-bottom: 0;
    font-size: 0.68rem;
}
.pibi-equipment-row input,
.pibi-equipment-row select {
    padding: 5px 8px;
    font-size: 0.82rem;
    min-height: unset;
    border-radius: 6px;
    margin-top: 2px;
}
.pibi-hidrant-kit label {
    font-size: 0.68rem;
}
.pibi-hidrant-kit input {
    padding: 5px 8px;
    font-size: 0.82rem;
    min-height: unset;
    border-radius: 6px;
    margin-top: 2px;
}
.pibi-equipment-row > label:nth-child(1) { grid-column: 1; }
.pibi-equipment-row > label:nth-child(2) { grid-column: 2; }
.pibi-equipment-row > label:nth-child(3) { grid-column: 3; }
.pibi-equipment-row > label:nth-child(4) { grid-column: 4; }
.pibi-equipment-row > label:nth-child(5) { grid-column: 5; }
.pibi-equipment-row > label:nth-child(6) { grid-column: 6; }
.pibi-equip-subtype-field[hidden],
.pibi-hidrant-kit[hidden] {
    display: none;
}
.pibi-hidrant-kit {
    grid-column: 1 / -1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1.5px solid #a8c8ea;
    border-left: 3px solid #0ea5e9;
    background: #e5f3ff;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    align-items: end;
}
.pibi-hidrant-kit-title {
    grid-column: 1 / -1;
    margin: 0 0 4px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #0369a1;
}
.pibi-hidrant-kit-inline {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 8px;
}
.pibi-equipment-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: auto;
    padding: 3px 10px;
    font-size: 0.72rem;
    border-radius: 8px;
    color: #dc2626;
    border: 1px solid #fecaca;
    background: #fff5f5;
    line-height: 1.6;
    cursor: pointer;
}
.pibi-equipment-remove:hover {
    background: #fee2e2;
    border-color: #f87171;
}
.pibi-equipment-footer {
    display: flex;
    justify-content: flex-start;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}
.pibi-import-shell {
    margin: 14px 0 10px;
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.98) 0%, rgba(255,255,255,0.96) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}
.pibi-import-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}
.pibi-import-hero strong,
.pibi-roster-header strong {
    display: block;
    font-size: 0.96rem;
    color: #0f172a;
    margin-bottom: 4px;
}
.pibi-import-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.pibi-import-badges span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(21, 96, 168, 0.08);
    border: 1px solid rgba(21, 96, 168, 0.16);
    color: #0d4580;
    font-size: 0.78rem;
    font-weight: 700;
}
.pibi-import-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 0.95fr);
    gap: 18px;
    align-items: start;
}
.pibi-import-grid .pibi-field-full {
    margin-top: 0;
}
.pibi-import-grid textarea {
    min-height: 210px;
    font-size: 0.9rem;
    line-height: 1.45;
}
.pibi-import-input,
.pibi-import-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.pibi-import-hint-card {
    padding: 14px;
    border: 1px dashed #d6e0ec;
    border-radius: 14px;
    background: rgba(255,255,255,0.9);
}
.pibi-import-hint-title {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #334155;
    margin-bottom: 10px;
}
.pibi-import-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.pibi-import-columns span {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #dbe5f0;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 600;
}
.pibi-import-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pibi-import-actions .btn {
    width: 100%;
}
.pibi-import-preview {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px dashed #d6e0ec;
    background: rgba(248, 250, 252, 0.9);
    color: #475569;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-line;
}
.pibi-import-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.pibi-import-stat {
    padding: 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #d9e6f4;
}
.pibi-import-stat-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.pibi-import-stat strong {
    font-size: 1.35rem;
    color: #0d4580;
}
.pibi-roster-shell {
    margin-top: 18px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 20px;
    background: rgba(255,255,255,0.92);
    overflow: hidden;
}
.pibi-roster-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px 10px;
}
.pibi-roster-table-wrap {
    overflow: auto;
    border-top: 1px solid #edf2f7;
    border-bottom: 1px solid #edf2f7;
}
.pibi-roster-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}
.pibi-roster-table th,
.pibi-roster-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
    font-size: 0.84rem;
    vertical-align: top;
}
.pibi-roster-table th {
    background: #f8fafc;
    color: #334155;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.pibi-roster-table tbody tr:nth-child(even) td {
    background: rgba(248, 250, 252, 0.55);
}
.pibi-roster-empty {
    text-align: center;
    color: #64748b;
    padding: 18px;
}
.pibi-roster-raw {
    padding: 16px 18px 18px;
}
.pibi-roster-raw summary {
    cursor: pointer;
    font-weight: 700;
    color: #0d4580;
    margin-bottom: 10px;
}
.pibi-roster-raw[open] summary {
    margin-bottom: 12px;
}
.pibi-wizard-footer {
    position: sticky;
    bottom: 0;
    z-index: 6;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
}
.pibi-wizard-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.pibi-wizard-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-left: auto;
}
.pibi-btn-next,
.pibi-wizard-footer [data-pibi-submit] {
    min-width: 168px;
    background: linear-gradient(135deg, #ff6a2c 0%, #ff4d1f 100%);
    border-color: #ff5c25;
    box-shadow: 0 12px 28px rgba(255, 92, 37, 0.2);
}
.pibi-btn-next:hover,
.pibi-wizard-footer [data-pibi-submit]:hover {
    background: linear-gradient(135deg, #ff7a45 0%, #f44917 100%);
}
/* === Configurações — Page Layout ========================================= */
.cfg-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px 22px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.cfg-header-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cfg-page-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}
.cfg-page-subtitle {
    margin: 3px 0 0;
    font-size: 0.78rem;
    color: var(--muted);
}

/* Tabs */
.cfg-tabs {
    display: flex;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 6px;
    gap: 4px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.cfg-tab {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-radius: 7px;
    transition: background 130ms, color 130ms;
    white-space: nowrap;
}
.cfg-tab:hover { background: var(--bg); color: var(--text); }
.cfg-tab.is-active {
    background: #fff;
    color: #0f172a;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.05);
}

/* Sections */
.cfg-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 20px 22px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.cfg-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--brand);
    margin-bottom: 16px;
}
.cfg-section-icon {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
}
.cfg-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
}
.cfg-label .field-required {
    display: inline;
}

/* Toggle switch */
.cfg-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
}
.cfg-toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}
.cfg-toggle-switch input { opacity: 0; width: 0; height: 0; }
.cfg-toggle-track {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: #cbd5e1;
    transition: background 200ms;
}
.cfg-toggle-track::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    left: 3px;
    top: 3px;
    transition: transform 200ms;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cfg-toggle-switch input:checked + .cfg-toggle-track { background: var(--brand); }
.cfg-toggle-switch input:checked + .cfg-toggle-track::before { transform: translateX(18px); }

/* Upload area */
.cfg-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 24px;
    background: var(--bg);
    cursor: pointer;
    margin-bottom: 16px;
    transition: border-color 150ms, background 150ms;
}
.cfg-upload-area:hover { border-color: var(--brand); background: var(--brand-soft); }

/* Grid helpers inside cfg-sections */
.cfg-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cfg-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.cfg-grid-col-auto { display: grid; gap: 14px; }

/* Form footer */
.cfg-form-footer {
    display: flex;
    justify-content: flex-end;
    padding: 4px 0 8px;
}

/* Info card (SMTP) */
.cfg-info-card {
    background: #1e293b;
    border-radius: var(--r-md);
    padding: 20px;
    color: #fff;
}
.cfg-info-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.cfg-provider-list { display: flex; flex-direction: column; gap: 6px; }
.cfg-provider-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
}
.cfg-provider-row code {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.74rem;
    color: rgba(255,255,255,0.85);
    font-family: monospace;
}

/* === Tab Bar ============================================================= */
.tab-bar {
    display: flex;
    align-items: center;
    background: #f4f7fb;
    border-bottom: 1px solid var(--border);
    padding: 0 8px;
    flex-shrink: 0;
    height: 28px;
    min-height: 28px;
    gap: 4px;
    overflow: hidden;
}
.tab-list {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0;
}
.tab-list::-webkit-scrollbar { display: none; }

.app-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 12px;
    height: 26px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    max-width: 180px;
    transition: 120ms ease;
    flex-shrink: 0;
}
.app-tab:hover { background: #eaeff8; color: var(--text); }
.app-tab.is-active {
    background: linear-gradient(135deg, #1560a8 0%, var(--brand-dark) 100%);
    border-color: var(--brand-dark);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(8,53,99,0.22);
}
.app-tab.is-active .app-tab-close { color: rgba(255,255,255,0.7); }
.app-tab.is-active .app-tab-close:hover { background: rgba(255,255,255,0.18); color: #fff; }
.app-tab-title {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.app-tab-close {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
    transition: 100ms ease;
}
.app-tab-close:hover { background: #dde4ef; color: var(--text); }

.tab-add-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 120ms ease;
}
.tab-add-btn:hover { background: var(--brand-soft); color: var(--brand); border-color: #b8d4f4; }

/* === Content ============================================================= */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
/* === Toasts ============================================================= */
.toast-stack {
    position: fixed;
    top: 46px;
    right: 18px;
    z-index: 1200;
    display: grid;
    gap: 10px;
    pointer-events: none;
}
.toast {
    min-width: 280px;
    max-width: min(420px, calc(100vw - 32px));
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
    background: #ffffff;
    color: #0f172a;
    pointer-events: auto;
    animation: toast-in 180ms ease-out;
}
.toast-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}
.toast-error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}
.toast-warning {
    background: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}
.toast-info {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}
.toast-body {
    flex: 1 1 auto;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.45;
}
.toast-close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: currentColor;
    opacity: 0.72;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}
.toast-close:hover {
    opacity: 1;
    background: rgba(15, 23, 42, 0.08);
}
.toast.is-hiding {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 180ms ease, transform 180ms ease;
}
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === App Modal ========================================================== */
.app-modal {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(3px);
}
.app-modal.is-open {
    display: flex;
}
.app-modal-dialog {
    width: min(920px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    overflow: hidden;
    background: #f8fbff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}
.app-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(180deg, #16385c 0%, #0d2340 100%);
    color: #fff;
}
.app-modal-title {
    margin: 0;
    font-size: 0.96rem;
    font-weight: 700;
}
.app-modal-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}
.app-modal-close:hover {
    background: rgba(255,255,255,0.2);
}
.app-modal-frame {
    width: 100%;
    height: 0;
    min-height: 520px;
    max-height: calc(100vh - 116px);
    border: none;
    background: #f1f5fb;
}
.email-modal-body {
    margin: 0;
    min-height: 0;
    background: #f1f5fb;
    overflow: hidden;
}
.email-modal-page {
    padding: 20px 22px 22px;
}
.email-compose-shell {
    max-width: 600px;
    position: relative;
}
.email-compose-shell.is-modal {
    max-width: 100%;
}
.email-compose-card.is-modal {
    margin-bottom: 0;
    padding: 18px 18px 16px;
    border-radius: 16px;
}
.email-compose-card.is-modal form {
    gap: 10px !important;
}
.email-compose-card.is-modal textarea {
    min-height: 124px;
}
.email-compose-card.is-modal .btn {
    min-width: 92px;
}
.email-compose-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 10px;
    padding: 24px;
    text-align: center;
    background: rgba(241, 245, 251, 0.92);
    backdrop-filter: blur(2px);
    border-radius: 18px;
}
.email-compose-loading[hidden] {
    display: none;
}
.email-compose-loading strong {
    font-size: 1rem;
    color: #0f172a;
}
.email-compose-loading span {
    max-width: 320px;
    font-size: 0.84rem;
    line-height: 1.45;
    color: #64748b;
}
.email-compose-loading-spinner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(13, 78, 145, 0.18);
    border-top-color: #0d4e91;
    animation: email-compose-spin 0.9s linear infinite;
}
body.is-email-submitting {
    cursor: progress;
}
@keyframes email-compose-spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Cards =============================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
}
.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--brand-muted);
    transform: translateY(-1px);
}
.card:last-child { margin-bottom: 0; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.card-title { margin: 0; font-size: 0.9rem; font-weight: 700; color: var(--text); }

/* === Metric Cards ======================================================== */
.metrics-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 12px;
}
.metric-card {
    border-radius: var(--r-lg);
    padding: 16px 14px;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-md);
}
.metric-card-label { font-size: 0.72rem; font-weight: 700; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.04em; }
.metric-card-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.metric-card-sub   { font-size: 0.7rem; opacity: 0.65; }

.metric-blue   { background: linear-gradient(135deg, #1560a8 0%, var(--brand-dark) 100%); }
.metric-indigo { background: linear-gradient(135deg, #4338ca 0%, #312e81 100%); }
.metric-green  { background: linear-gradient(135deg, #16a34a 0%, #14532d 100%); }
.metric-amber  { background: linear-gradient(135deg, #d97706 0%, #92400e 100%); }
.metric-red    { background: linear-gradient(135deg, #ef4444 0%, var(--accent-dark) 100%); }

/* === Dashboard =========================================================== */
.dashboard-hero {
    position: relative;
    display: grid;
    place-items: center;
    min-height: calc(100vh - 120px);
    border-radius: var(--r-lg);
    overflow: hidden;
    margin-bottom: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(13,78,145,0.10), transparent 28%),
        radial-gradient(circle at 85% 78%, rgba(233,59,59,0.07), transparent 30%),
        linear-gradient(135deg, #f7fbff 0%, #edf4fc 50%, #f8fbff 100%);
}
.dashboard-hero .hero-logo {
    width: min(380px, 55vw);
    opacity: 0.09;
    filter: saturate(0.6);
    position: absolute;
}
.dashboard-welcome {
    position: relative;
    text-align: center;
    padding: 24px;
}
.dashboard-welcome h2 { margin: 0 0 6px; font-size: 1.5rem; color: var(--brand-dark); }
.dashboard-welcome p  { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* === Grids =============================================================== */
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.grid-company  { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.grid-building { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.field-span-2 { grid-column: span 2; }

/* === Forms (compact) ===================================================== */
label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #344563;
    margin-bottom: 1px;
}
input, select, textarea {
    display: block;
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 0.84rem;
    color: var(--text);
    background: #fff;
    margin-top: 3px;
    transition: border-color 110ms, box-shadow 110ms;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #5b8fd6;
    box-shadow: 0 0 0 3px rgba(13,78,145,0.10);
}
textarea { min-height: 76px; resize: vertical; }

.form-section {
    border: 1px solid #d6e3f2;
    border-radius: var(--r-md);
    padding: 12px 10px 10px;
    margin: 0;
    background: linear-gradient(180deg, #f9fcff 0%, #f4f9ff 100%);
}
.form-section legend {
    color: #123d69;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0 6px;
    margin-left: 4px;
}
.form-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 6px;
    font-size: 0.9rem;
}
.form-section-note { margin: 3px 0 10px; font-size: 0.77rem; color: var(--muted); }
.form-intro { margin: -2px 0 0; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}
.inline-action { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: end; }
.field-required { color: #c02e2e; margin-left: 3px; font-weight: 700; }

/* === Buttons ============================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 7px 14px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: 130ms ease;
    white-space: nowrap;
    line-height: 1.2;
    min-height: 34px;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, #1560a8 0%, var(--brand-dark) 100%);
    color: #fff;
    border-color: var(--brand-dark);
    box-shadow: 0 3px 8px rgba(8,53,99,0.20);
}
.btn-primary:hover { background: linear-gradient(135deg, #1a6ab8 0%, #0a3d72 100%); }

.btn-soft {
    background: var(--brand-soft);
    color: #0d4580;
    border-color: #c4d9f5;
}
.btn-soft:hover { background: #d6e8ff; }

.btn-danger {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-color: #fdc0c0;
}
.btn-danger:hover { background: #ffe4e4; }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* === Tables ============================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th {
    background: #f8fafd;
    color: #3d5875;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 9px 10px;
    border-bottom: 1px solid #f0f4f9;
    color: var(--text);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafcff; }

/* === Status Badges ======================================================= */
.status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
}
.status::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.status-elaboracao { background: #fef9ec; color: #92610a; }
.status-pendente   { background: #eff6ff; color: #2563eb; }
.status-concluido  { background: #f0fdf4; color: #16a34a; }
.status-excluido   { background: #fef2f2; color: #dc2626; }

/* Prospect statuses */
.status-frio          { background: #f1f5f9; color: #475569; }
.status-morno         { background: #fff7ed; color: #c2410c; }
.status-quente        { background: #fef2f2; color: #dc2626; }
.status-em_negociacao { background: #faf5ff; color: #7c3aed; }
.status-cliente       { background: #f0fdf4; color: #16a34a; }
.status-descartado    { background: #f8fafc; color: #94a3b8; }

/* === Utility ============================================================= */
.muted   { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.preview { background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; line-height: 1.5; }
.pdf-export-body {
    margin: 0;
    background: #fff;
}
.pdf-export-main {
    padding: 0;
}
.preview-document {
    position: relative;
    overflow: hidden;
    padding: 0;
    box-shadow: var(--shadow-md);
}
.preview-document-body {
    position: relative;
    z-index: 1;
    padding: 28px 32px 34px;
}
.preview-watermark {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    z-index: 0;
}
.preview-watermark img {
    width: min(520px, 62%);
    max-width: 100%;
    opacity: 0.05;
    filter: grayscale(1);
}
.preview-header {
    display: grid;
    gap: 8px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 2px solid #dbe5f1;
}
.preview-cover-header {
    gap: 0;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid #cbd5e1;
}
.preview-cover-topline {
    height: 3px;
    margin-bottom: 6px;
    border-top: 2px solid rgba(51, 65, 85, 0.7);
    border-bottom: 1px solid rgba(51, 65, 85, 0.55);
}
.preview-cover-main {
    display: grid;
    grid-template-columns: var(--preview-cover-logo-column, 140px) 1fr;
    align-items: center;
    gap: 16px;
    padding-bottom: 6px;
    border-bottom: 1px solid #94a3b8;
}
.preview-cover-logo {
    min-height: var(--preview-cover-logo-height, 90px);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}
.preview-cover-logo img {
    max-width: 100%;
    max-height: var(--preview-cover-logo-height, 90px);
    width: auto;
    display: block;
    object-fit: contain;
}
.preview-cover-logo.is-wide img,
.preview-cover-logo.is-ultra-wide img {
    width: 100%;
}
.preview-cover-logo-fallback {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    line-height: 1.05;
    word-break: break-word;
}
.preview-cover-title {
    text-align: left;
}
.preview-cover-title h2 {
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.08;
    letter-spacing: 0.02em;
    color: #334155;
}
.preview-cover-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid #cbd5e1;
}
.preview-cover-meta > div {
    padding: 4px 6px;
    text-align: center;
}
.preview-cover-meta span {
    display: block;
    color: #64748b;
    font-size: 0.58rem;
}
.preview-cover-meta strong {
    display: block;
    margin-top: 1px;
    color: #334155;
    font-size: 0.68rem;
}
.preview-header h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.2rem;
    line-height: 1.2;
}
.preview-meta-inline,
.preview-client-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0;
    color: #334155;
    font-size: 0.87rem;
}
.preview-document h3 {
    margin-top: 26px;
    margin-bottom: 10px;
    color: #0f172a;
    font-size: 1rem;
}
.preview-document p,
.preview-document li {
    color: #1e293b;
    font-size: 0.92rem;
    line-height: 2.0;
}
.preview-document p {
    margin: 0 0 18px;
    text-align: justify;
}
.pdf-export-body .preview-cover-main {
    grid-template-columns: var(--preview-cover-logo-column, 56px) 1fr;
}
.pdf-export-body .preview-cover-meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.preview-document ul {
    margin: 8px 0 14px 18px;
    padding: 0;
}
.preview-document .sim-sub + ul {
    margin-left: calc(2em + 18px);
}
.preview-document li + li {
    margin-top: 4px;
}
/* Simulado IN31: títulos de seção e sub-itens */
.preview-document p:has(> b:only-child) {
    margin-top: 20px;
    margin-bottom: 2px;
}
.preview-document .sim-sub {
    padding-left: 2em;
    margin-bottom: 4px;
}

.preview-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin: 12px 0 24px;
}
.preview-photo-page {
    margin-top: 24px;
}
.preview-photo-page h3 {
    margin-top: 0;
}
.preview-photo-card {
    margin: 0;
    border: 1px solid #dbe5f1;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    break-inside: avoid;
    page-break-inside: avoid;
}
.preview-photo-media {
    position: relative;
    min-height: 0;
}
.preview-photo-media img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: cover;
}
.preview-photo-stamp {
    position: absolute;
    right: 10px;
    bottom: 10px;
    color: rgba(255, 255, 255, 0.96);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.9), 0 0 8px rgba(15, 23, 42, 0.55);
    font-variant-numeric: tabular-nums;
}
.preview-photo-caption {
    padding: 10px 12px;
    font-size: 0.82rem;
    color: #334155;
}
.preview-photo-empty {
    height: 220px;
    margin: 12px 0 24px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
}
.preview-signatures {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid #dbe5f1;
}
.preview-signature-page {
    min-height: 420px;
}
.preview-signature-stack {
    display: grid;
    gap: 72px;
    padding-top: 36px;
}
.preview-signature-block {
    max-width: 460px;
}
.preview-signature-block p {
    margin: 0;
    text-align: left;
    line-height: 1.35;
}
.preview-signature-image {
    height: 100px;
    width: 320px;
    display: flex;
    align-items: end;
    justify-content: flex-start;
    margin: 0 0 -10px 4px;
}
.preview-signature-image img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: left bottom;
}
.preview-signature-line {
    margin-bottom: 12px !important;
    margin-top: 0 !important;
}
.preview-digital-signature {
    margin: 8px 0 28px;
    padding: 10px 12px;
    border: 1px solid #dbe5f1;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.88);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.preview-digital-signature-content {
    min-width: 0;
    flex: 1 1 auto;
}
.preview-digital-signature-qr {
    flex: 0 0 auto;
    margin-left: auto;
    align-self: flex-start;
}
.preview-digital-signature p {
    margin: 0 0 5px;
    font-size: 0.82rem;
    line-height: 1.3;
}
.preview-digital-signature p:last-child {
    margin-bottom: 0;
}
.preview-digital-signature code {
    font-size: 0.74rem;
    word-break: break-all;
}
.preview-digital-signature img {
    display: block;
    width: 84px;
    height: 84px;
}
.preview-print-markers,
.preview-page-number {
    display: none;
}

.clients-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.clients-toolbar h3 { margin: 0; font-size: 0.92rem; }
.clients-toolbar .muted { margin: 3px 0 0; font-size: 0.8rem; }

.client-form-card {
    overflow: hidden;
    transition: max-height 240ms ease, opacity 180ms ease, margin-bottom 240ms ease, padding 240ms ease, border-width 240ms ease;
    max-height: 3000px;
    opacity: 1;
}
.client-form-card.is-collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    margin-bottom: 0;
}

/* Workspace tabs (document form) */
.workspace { display: grid; gap: 10px; }
.workspace-tabs {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.workspace-tabs::-webkit-scrollbar { display: none; }
.workspace-tab {
    border: 1px solid var(--border);
    background: #f0f4fa;
    color: #2c4a6e;
    border-radius: var(--r-sm);
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    transition: 120ms ease;
    min-height: 34px;
}
.workspace-tab:hover { background: var(--brand-soft); }
.workspace-tab.is-active {
    background: linear-gradient(135deg, #1560a8 0%, var(--brand-dark) 100%);
    color: #fff;
    border-color: var(--brand-dark);
}
.workspace-panel[hidden] { display: none; }
.tab-close { margin-left: 6px; font-weight: 700; }

/* === Clients Form: Fixed Desktop Layout ================================= */
@media (min-width: 1200px) and (min-height: 700px) {
    .content.client-form-mode {
        overflow: hidden;
    }

    #client-workspace[data-active-panel="novo"] {
        height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    #client-workspace[data-active-panel="novo"] .workspace-panel[data-panel="novo"] {
        flex: 1;
        min-height: 0;
    }

    #client-workspace[data-active-panel="novo"] #client-form.client-form-layout {
        height: 100%;
        min-height: 0;
        display: grid;
        grid-template-columns: repeat(12, minmax(0, 1fr));
        gap: 8px;
        align-content: start;
    }

    #client-workspace[data-active-panel="novo"] #client-form .card {
        margin-bottom: 0;
        padding: 12px 14px;
    }

    #client-workspace[data-active-panel="novo"] #client-form label {
        font-size: 0.74rem;
    }

    #client-workspace[data-active-panel="novo"] #client-form input,
    #client-workspace[data-active-panel="novo"] #client-form select {
        padding: 6px 8px;
        font-size: 0.8rem;
        margin-top: 2px;
    }

    #client-workspace[data-active-panel="novo"] #client-form .form-section-header {
        margin-bottom: 10px !important;
    }

    #client-workspace[data-active-panel="novo"] #client-form .section-icon {
        width: 24px;
        height: 24px;
        font-size: 0.82rem;
    }

    #client-workspace[data-active-panel="novo"] #client-form .btn {
        min-height: 32px;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .client-card-cnpj { grid-column: 1 / -1; }
    .client-card-company { grid-column: 1 / span 7; }
    .client-card-cbmsc { grid-column: 8 / span 5; }
    .client-card-building { grid-column: 1 / span 7; }
    .client-card-responsavel { grid-column: 8 / span 5; }

    .client-grid-company {
        grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .client-field-nome-fantasia { grid-column: span 3; order: 1; }
    .client-field-razao-social { grid-column: span 6; order: 2; }
    .client-field-telefone { grid-column: span 3; order: 3; }
    .client-field-email { grid-column: span 4; order: 4; }
    .client-field-cep { grid-column: span 3; order: 5; }
    .client-field-logradouro { grid-column: span 5 !important; order: 6; }
    .client-field-numero { grid-column: span 2; order: 7; }
    .client-field-bairro { grid-column: span 3; order: 8; }
    .client-field-complemento { grid-column: span 3; order: 9; }
    .client-field-cidade { grid-column: span 3; order: 10; }
    .client-field-uf { grid-column: span 1; order: 11; }

    .client-grid-cbmsc-top {
        grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
        gap: 8px !important;
        margin-bottom: 8px !important;
    }

    .client-field-cbmsc-grupo { grid-column: span 6; }
    .client-field-cbmsc-divisao { grid-column: span 6; }

    .client-grid-cbmsc-bottom,
    .client-grid-building,
    .client-grid-responsavel {
        gap: 8px !important;
    }

    .client-grid-cbmsc-bottom {
        grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    }

    .client-field-cbmsc-atividade { grid-column: span 6; }
    .client-field-cbmsc-complexidade { grid-column: span 6; }
    .client-field-cbmsc-tipo { grid-column: span 6; }
    .client-field-cbmsc-registro { grid-column: span 6; }

    .client-field-cbmsc-atividade input,
    .client-field-cbmsc-complexidade select,
    .client-field-cbmsc-tipo select,
    .client-field-cbmsc-registro input {
        width: 100%;
    }

    .client-grid-building {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
    }

    .client-grid-responsavel {
        grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    }

    .client-field-responsavel-nome { grid-column: span 6; }
    .client-field-responsavel-cpf { grid-column: span 6; }
    .client-field-responsavel-cargo { grid-column: span 4; }
    .client-field-responsavel-email { grid-column: span 8; }
    .client-field-responsavel-telefone { grid-column: span 6; }

    .client-field-responsavel-email input,
    .client-field-responsavel-nome input,
    .client-field-responsavel-cpf input,
    .client-field-responsavel-cargo input,
    .client-field-responsavel-telefone input {
        width: 100%;
    }

    .client-form-actions {
        grid-column: 1 / -1;
        margin-top: 0;
        padding-top: 10px;
        align-self: end;
    }
}

/* === Login Page ========================================================== */
.login-page {
    margin: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 10% 10%, rgba(255,255,255,0.12), transparent 36%),
        radial-gradient(ellipse at 90% 90%, rgba(255,255,255,0.10), transparent 34%),
        linear-gradient(145deg, #07274a 0%, #0f4a8a 52%, #1a6aaf 100%);
    padding: 20px;
    overflow: auto;
}
.login-box {
    width: min(400px, 96vw);
    background: #fff;
    border-radius: 18px;
    padding: 28px 24px 24px;
    box-shadow: 0 28px 56px rgba(5,22,48,0.32);
}
.login-brand { display: flex; justify-content: center; margin-bottom: 18px; }
.login-brand img { width: min(190px, 68%); height: auto; object-fit: contain; }
.login-box h2 { margin: 0 0 3px; text-align: center; color: #0d2846; font-size: 1.1rem; }
.login-box .muted { display: block; margin: 0 0 18px; text-align: center; font-size: 0.82rem; }
.login-box .btn { width: 100%; margin-top: 6px; padding: 10px; }

/* === Responsive: Tablet landscape (≤1100px) ============================== */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* === Responsive: Tablet / Mobile (≤900px) ================================ */
@media (max-width: 900px) {
    body { overflow: auto; }

    .app-shell {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* Sidebar becomes full-screen overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 240px;
        transform: translateX(-100%);
        z-index: 1200;
        box-shadow: none;
    }
    .sidebar.is-mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,0.45);
    }

    .main-area {
        min-height: 100vh;
    }

    .menu-toggle { display: flex; }
    .sidebar-tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .sidebar-panel-anchor #release-update-panel,
    .sidebar-panel-anchor #crm-notifications-panel {
        left: 0 !important;
        top: calc(100% + 10px) !important;
        width: min(320px, calc(100vw - 28px)) !important;
    }

    .content {
        height: auto;
        overflow: visible;
        padding: 12px 12px 28px;
    }

    .pibi-client-grid,
    .pibi-ident-grid,
    .pibi-brigade-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 10px;
    }

    .pibi-span-1 { grid-column: span 1; }
    .pibi-span-2 { grid-column: span 2; }
    .pibi-span-3 { grid-column: span 3; }
    .pibi-span-4 { grid-column: span 4; }
    .pibi-span-5 { grid-column: span 6; }

    .pibi-client-hint {
        grid-column: span 3;
    }
    .pibi-import-grid {
        grid-template-columns: 1fr;
    }
    .pibi-systems-topbar {
        flex-direction: column;
    }
    .pibi-systems-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    .pibi-equipment-row {
        grid-template-columns: minmax(110px, 1fr) minmax(120px, 1.4fr) minmax(0, 1.8fr) 70px minmax(0, 1.3fr) minmax(0, 1.4fr);
        padding: 14px 14px 14px 48px;
    }
    .pibi-hidrant-kit {
        grid-column: 1 / -1;
        grid-template-columns: 1fr 1fr;
    }
    .pibi-import-hero {
        flex-direction: column;
    }
    .pibi-import-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .pibi-import-actions .btn {
        width: auto;
    }
    .pibi-import-summary {
        grid-template-columns: 1fr;
    }
    .tab-bar { overflow-x: auto; }

    .clients-toolbar { flex-direction: column; align-items: stretch; }
    .clients-toolbar .btn { width: 100%; }

    .inline-action { grid-template-columns: 1fr; }
    .field-span-2  { grid-column: auto; }

    .form-actions { justify-content: stretch; }
    .form-actions .btn { flex: 1; text-align: center; }

    /* Stack grids on tablet portrait */
    .grid-company, .grid-building, .grid-4 {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .simulado-grid-top,
    .simulado-grid-textareas {
        grid-template-columns: 1fr;
    }

    .pibi-wizard-header,
    .pibi-wizard-footer-inner,
    .pibi-wizard-footer-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .pibi-wizard-progress {
        justify-content: flex-start;
    }

    .pibi-step-chip,
    .pibi-btn-next,
    .pibi-wizard-footer [data-pibi-submit] {
        width: 100%;
    }

    .simulado-participant-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .simulado-field-sm,
    .simulado-field-md,
    .simulado-field-full {
        grid-column: auto;
    }

    .preview-meta-inline,
    .preview-client-inline {
        gap: 8px;
    }

    .preview-cover-main,
    .preview-cover-meta {
        grid-template-columns: 1fr;
    }

    .preview-cover-title {
        text-align: left;
    }
}

/* === Responsive: Tablet Portrait / PIBI (≤768px) ======================== */
@media (max-width: 768px) {
    .pibi-client-grid,
    .pibi-ident-grid,
    .pibi-brigade-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .pibi-span-1 { grid-column: span 1; }
    .pibi-span-2,
    .pibi-span-3,
    .pibi-span-4,
    .pibi-span-5 { grid-column: span 2; }

    .pibi-client-hint { grid-column: span 2; }

    .pibi-stage-card input,
    .pibi-stage-card select,
    .pibi-stage-card textarea {
        padding: 8px 10px;
        font-size: 0.88rem;
        min-height: 42px;
    }

    .pibi-stage-card label {
        font-size: 0.72rem;
        margin-bottom: 2px;
    }

    .pibi-wizard-shell { padding: 14px 14px; }
    .pibi-stage-card { padding: 16px; }

    /* Equipment rows: 2 cols no tablet portrait */
    .pibi-equipment-row {
        grid-template-columns: 1fr 1fr;
        padding: 14px 14px 14px 46px;
    }
    .pibi-equipment-row > label:nth-child(1) { grid-column: 1; }
    .pibi-equipment-row > label:nth-child(2) { grid-column: 2; }
    .pibi-equipment-row > label:nth-child(3) { grid-column: 1; }
    .pibi-equipment-row > label:nth-child(4) { grid-column: 2; }
    .pibi-equipment-row > label:nth-child(5) { grid-column: 1; }
    .pibi-equipment-row > label:nth-child(6) { grid-column: 2; }
    .pibi-hidrant-kit { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
    .pibi-systems-stats { grid-template-columns: repeat(3, 1fr); }
}

/* === Responsive: Mobile (≤600px) ======================================== */
@media (max-width: 600px) {
    .card { padding: 12px; border-radius: var(--r-md); }
    .content { padding: 10px 10px 24px; }

    th, td { padding: 7px 8px; font-size: 0.78rem; }

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

    .dashboard-welcome h2 { font-size: 1.1rem; }

    /* Single column forms on mobile */
    .grid-2, .grid-3, .grid-4, .grid-company, .grid-building {
        grid-template-columns: 1fr;
    }
    .field-span-2 { grid-column: auto; }

    .topbar { height: 48px; padding: 0 12px; }
    .page-title { font-size: 0.85rem; }

    /* Bigger touch targets on mobile */
    .btn { min-height: 40px; }
    .nav-item { min-height: 44px; }
    .app-tab { height: 34px; }
    input, select { padding: 9px 10px; font-size: 0.9rem; }

    /* PIBI: single column no mobile */
    .pibi-client-grid,
    .pibi-ident-grid,
    .pibi-brigade-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .pibi-span-1,
    .pibi-span-2,
    .pibi-span-3,
    .pibi-span-4,
    .pibi-span-5 { grid-column: span 1; }
    .pibi-client-hint { grid-column: span 1; }
    .pibi-stage-card input,
    .pibi-stage-card select,
    .pibi-stage-card textarea {
        padding: 9px 10px;
        font-size: 0.9rem;
        min-height: 44px;
    }
    .pibi-stage-card label { font-size: 0.73rem; }
    .pibi-stage-card { padding: 14px 12px; }
    .pibi-wizard-shell { padding: 12px; }
    .pibi-step-chip { padding: 10px 14px; font-size: 0.84rem; }

    /* Equipment rows: 1 coluna no mobile */
    .pibi-equipment-row {
        grid-template-columns: 1fr;
        padding: 42px 12px 14px 12px;
    }
    .pibi-equipment-row > label:nth-child(n) { grid-column: 1; }
    .pibi-hidrant-kit { grid-column: 1; grid-template-columns: 1fr; }
    .pibi-systems-stats { grid-template-columns: 1fr; }

    /* Tables as Cards */
    .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
    .table-wrap thead { display: none; }
    .table-wrap tr {
        margin-bottom: 12px;
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        padding: 4px 6px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    }
    .table-wrap td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        padding: 8px 6px;
        border-bottom: 1px solid #f0f4f9;
    }
    .table-wrap td:last-child {
        border-bottom: none;
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
        gap: 6px;
        padding-top: 10px;
        padding-bottom: 4px;
    }
    .table-wrap td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.65rem;
        color: var(--muted);
        text-transform: uppercase;
        margin-bottom: 4px;
        letter-spacing: 0.03em;
    }
    .table-wrap td:last-child::before { display: none; }
}

@media print {
    .preview-document-pibi {
        border: none;
        box-shadow: none;
    }

    .preview-document-body-pibi {
        padding: 0;
    }

    .pibi-print-document {
        display: block;
        padding: 0;
        background: #fff;
    }
    @page {
        size: A4;
        margin: 14mm 12mm 16mm;
        @bottom-right {
            content: "Página " counter(page) " de " counter(pages);
            font-size: 8pt;
            color: #64748b;
            font-family: "Inter", "Segoe UI", sans-serif;
        }
    }

    html,
    body {
        height: auto;
        overflow: visible !important;
        background: #fff;
    }

    body,
    .app-shell,
    .main-wrapper,
    .content {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .topbar,
    .tab-bar,
    .actions,
    .mobile-nav-overlay,
    .menu-toggle {
        display: none !important;
    }

    .preview {
        border: none !important;
        box-shadow: none !important;
    }

    .preview-document {
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    .preview-document-body {
        padding: 0 !important;
    }

    .preview-watermark {
        position: fixed;
        inset: 0;
    }

    .preview-watermark img {
        width: 58%;
        opacity: 0.06;
    }

    .preview-cover-main {
        grid-template-columns: var(--preview-cover-logo-column, 160px) 1fr !important;
    }

    .preview-cover-logo {
        min-height: var(--preview-cover-logo-height, 110px) !important;
    }

    .preview-cover-logo img {
        max-height: var(--preview-cover-logo-height, 110px) !important;
    }

    .preview-cover-meta {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .preview-photo-page {
        break-before: page;
        page-break-before: always;
        break-after: page;
        page-break-after: always;
        min-height: auto;
        margin-top: 0;
    }

    .preview-header,
    .preview-client-bar,
    .preview-photo-page,
    .preview-photo-card,
    .preview-signatures,
    .preview-document h3,
    .preview-document p,
    .preview-document ul {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .preview-photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto auto;
        gap: 8px;
        align-content: start;
        align-items: start;
        margin: 8px 0 0;
    }

    .preview-photo-card {
        height: auto;
    }

    .preview-photo-media {
        min-height: auto;
    }

    .preview-photo-media img {
        height: 96mm;
        min-height: auto;
        object-fit: contain;
        object-position: center;
        background: #f8fafc;
    }

    .preview-photo-caption {
        padding: 6px 8px 7px;
        font-size: 0.68rem;
        line-height: 1.25;
    }

    .preview-signature-page {
        break-before: page;
        page-break-before: always;
        min-height: calc(297mm - 30mm);
        margin-top: 0;
        padding-top: 0;
    }

    .preview-signature-stack {
        gap: 100px;
        padding-top: 116px;
    }

    .preview-signature-line {
        margin-bottom: 18px !important;
    }

    .preview-digital-signature {
        margin: 6px 0 24px;
        padding: 8px 10px;
        gap: 12px;
    }

    .preview-digital-signature p {
        margin-bottom: 4px;
        font-size: 0.74rem;
        line-height: 1.25;
    }

    .preview-digital-signature code {
        font-size: 0.68rem;
    }

    .preview-digital-signature img {
        width: 72px;
        height: 72px;
    }

    .preview-cover-header {
        break-after: avoid;
        page-break-after: avoid;
    }

    .preview-print-markers {
        display: block;
        position: absolute;
        inset: 0;
        pointer-events: none;
        z-index: 20;
    }

    .preview-page-number {
        display: block;
        position: absolute;
        right: 4mm;
        font-size: 0.72rem;
        color: #64748b;
        font-variant-numeric: tabular-nums;
        transform: translateY(-100%);
    }
}

/* PIBI document tables */
.preview-document-pibi > .preview-watermark {
    display: none;
}

.preview-document-body-pibi {
    padding: 0;
}

.pibi-print-document {
    color: #111827;
    font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
    display: grid;
    gap: 18px;
    justify-items: center;
    padding: 18px;
    background: #eef3f9;
}

.pibi-print-page {
    position: relative;
    width: 794px;
    min-height: 1123px;
    padding: 42px 46px 88px;
    page-break-after: always;
    break-after: page;
    background: #fff;
    color: #000;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.pibi-print-page:last-child {
    page-break-after: auto;
    break-after: auto;
}

.pibi-print-page::before,
.pibi-print-page::after,
.pibi-print-page:before,
.pibi-print-page:after {
    display: none !important;
    content: none !important;
    border: none !important;
}

.pibi-print-watermark {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    user-select: none;
    opacity: 1;
    z-index: 0;
    filter: grayscale(100%) opacity(4%);
}
.pibi-print-watermark img {
    width: 420px;
    height: auto;
    display: block;
}

.pibi-print-title,
.pibi-print-section-heading,
.pibi-print-section-subheading {
    position: relative;
    z-index: 1;
    text-align: center;
    color: #000;
}

.pibi-print-title {
    margin: 44px 0 36px;
    font-size: 1.22rem;
    font-weight: 700;
}

.pibi-print-section-heading {
    margin: 34px 0 10px;
    font-size: 1.15rem;
    font-weight: 700;
}

.pibi-print-section-subheading {
    margin: 0 0 26px;
    font-size: 1rem;
    font-weight: 700;
}

.pibi-print-table,
.pibi-brigade-print-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 28px;
    position: relative;
    z-index: 1;
    font-size: 0.92rem;
    line-height: 1.2;
}

.pibi-print-table th,
.pibi-brigade-print-table th {
    border: 1px solid #111827;
    background: #ececec;
    padding: 3px 6px;
    text-align: center;
    font-weight: 700;
}

.pibi-print-table td,
.pibi-brigade-print-table td {
    border: 1px solid #111827;
    padding: 4px 6px;
    vertical-align: top;
}

.pibi-print-table tr:last-child td,
.pibi-brigade-print-table tr:last-child td {
    border-bottom: 1px solid #111827;
}

.pibi-procedure-block,
.pibi-system-block {
    position: relative;
    z-index: 1;
    margin-bottom: 30px;
}

.pibi-procedure-block h4,
.pibi-system-title {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 700;
}

.pibi-procedure-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 20px;
}

.pibi-procedure-list li {
    position: relative;
    margin: 0 0 11px;
    line-height: 1.48;
}

.pibi-procedure-list li::before {
    content: "✓";
    position: absolute;
    left: -18px;
    top: 0;
    color: #0f172a;
    font-weight: 700;
}

.pibi-system-list {
    padding-left: 22px;
}

.pibi-print-page--brigade {
    padding-top: 26px;
    padding-left: 18px;
    padding-right: 18px;
    overflow: visible;
}

/* Área inferior da página de brigadistas: assinatura + bloco digital */
.pibi-brigade-bottom {
    position: relative;
    z-index: 1;
    margin-top: 24px;
    padding-bottom: 48px; /* folga para o rodapé absoluto */
}

.pibi-print-page--brigade .pibi-print-watermark {
    top: 64%;
}

.pibi-brigade-print-table {
    table-layout: fixed;
    width: 100%;
    margin: 10px auto 0;
    font-size: 0.75rem;
}

.pibi-brigade-print-table td,
.pibi-brigade-print-table th {
    text-align: center;
    line-height: 1.22;
    word-break: normal;
    overflow-wrap: break-word;
    padding: 6px 6px;
}

.pibi-brigade-print-table td:first-child,
.pibi-brigade-print-table th:first-child {
    text-align: left;
}

.pibi-brigade-print-table thead th {
    font-size: 0.74rem;
    letter-spacing: 0;
    white-space: normal;
}

.pibi-brigade-print-table .pibi-col-name     { width: 20%; }
.pibi-brigade-print-table .pibi-col-cpf      { width: 18%; }
.pibi-brigade-print-table .pibi-col-turno    { width: 13%; }
.pibi-brigade-print-table .pibi-col-funcao   { width: 22%; }
.pibi-brigade-print-table .pibi-col-telefone { width: 16%; }
.pibi-brigade-print-table .pibi-col-nivel    { width: 11%; }

/* CPF = 2ª col, TELEFONE = 5ª col — sem quebra de linha */
.pibi-brigade-print-table td:nth-child(2),
.pibi-brigade-print-table th:nth-child(2),
.pibi-brigade-print-table td:nth-child(5),
.pibi-brigade-print-table th:nth-child(5) {
    white-space: nowrap;
    overflow: hidden;
}

.pibi-head-name,
.pibi-head-cpf,
.pibi-head-turno,
.pibi-head-funcao {
    white-space: nowrap;
}

.pibi-head-telefone {
    white-space: normal;
    line-height: 1.08;
}

.pibi-head-nivel {
    white-space: normal;
    line-height: 1.08;
}

.pibi-cell-name {
    text-align: left !important;
    font-weight: 400;
    white-space: normal;
    font-size: 0.79rem;
}

.pibi-cell-cpf,
.pibi-cell-turno,
.pibi-cell-telefone,
.pibi-cell-nivel {
    font-variant-numeric: tabular-nums;
    white-space: normal;
}

.pibi-cell-cpf {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: keep-all;
}

.pibi-cell-telefone {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.pibi-cell-turno,
.pibi-cell-telefone,
.pibi-cell-nivel {
    font-size: 0.76rem;
}

.pibi-cell-funcao {
    font-size: 0.77rem;
}

.pibi-brigade-total-row {
    text-align: left !important;
    font-size: 0.84rem;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

.pibi-signature-sheet {
    position: relative;
    z-index: 1;
    margin: 18px auto 0;
    max-width: 360px;
    text-align: center;
    font-size: 0.92rem;
}

/* ── Bloco de assinatura digital ─────────────────────────────── */
.pibi-dig-sig-block {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1.5px solid #14314b;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 16px auto 0;
    max-width: 580px;
    background: #f8fafc;
    font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
    font-size: 0.75rem;
    color: #1e293b;
    page-break-inside: avoid;
    break-inside: avoid;
}

.pibi-dig-sig-left {
    flex: 1;
    min-width: 0;
}

.pibi-dig-sig-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.pibi-dig-sig-check {
    width: 24px;
    height: 24px;
    background: #14314b;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.pibi-dig-sig-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #14314b;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pibi-dig-sig-chain {
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 1px;
}

/* Dados do signatário */
.pibi-dig-sig-person {
    margin: 8px 0 6px;
    border-left: 2px solid #14314b;
    padding-left: 8px;
}
.pibi-dig-sig-person-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}
.pibi-dig-sig-person-roles {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 2px;
}
.pibi-dig-sig-person-roles span {
    font-size: 0.68rem;
    color: #475569;
    line-height: 1.4;
}

/* Linha de metadados (data + hash) */
.pibi-dig-sig-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 0.66rem;
    color: #64748b;
}
.pibi-dig-sig-hash {
    font-family: monospace;
    font-size: 0.66rem;
    color: #475569;
}

.pibi-dig-sig-verify-url {
    margin-top: 6px;
    font-size: 0.63rem;
    color: #94a3b8;
    word-break: break-all;
    line-height: 1.4;
}
.pibi-dig-sig-verify-url span {
    color: #3b82f6;
}

.pibi-dig-sig-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.pibi-dig-sig-right canvas,
.pibi-dig-sig-right img {
    width: 72px !important;
    height: 72px !important;
    display: block;
}

.pibi-dig-sig-qr-label {
    font-size: 0.58rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.3;
    max-width: 72px;
}

.pibi-dig-sig-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.8rem;
    color: #92400e;
    margin: 20px auto 0;
    max-width: 420px;
}
.pibi-dig-sig-pending a {
    color: #1d4ed8;
    text-decoration: underline;
    margin-left: 8px;
}

/* (pibi-print-page--signature removida — assinatura integrada à página de brigadistas) */

.pibi-signature-image {
    height: 88px;
    display: flex;
    align-items: end;
    justify-content: center;
    margin-bottom: 4px;
}

.pibi-signature-image img {
    max-height: 100%;
    max-width: 220px;
    object-fit: contain;
}
.cfg-signature-preview {
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 8px;
    background: #f8fafc;
}

.cfg-signature-preview img {
    max-height: 72px;
    max-width: 240px;
    object-fit: contain;
}

.cfg-signature-empty {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 16px 24px;
    background: #f8fafc;
    font-size: 0.78rem;
    color: #94a3b8;
}

.pibi-signature-line {
    border-top: 1px solid #111827;
    margin: 0 auto 8px;
    width: 78%;
}

.pibi-signature-name {
    font-weight: 700;
}

.pibi-signature-digital-note {
    margin-top: 8px;
    font-size: 0.78rem;
    color: #475569;
}

.pibi-print-footer {
    position: absolute;
    left: 46px;
    right: 46px;
    bottom: 26px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: #14314b;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    z-index: 2;
}

.pibi-info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 0.85rem;
}
.pibi-info-table td {
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
    vertical-align: top;
}
.pibi-info-table td:first-child {
    width: 50%;
}

.pibi-brigade-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 0.82rem;
}
.pibi-brigade-table th,
.pibi-brigade-table td {
    border: 1px solid #cbd5e1;
    padding: 4px 6px;
    text-align: left;
    vertical-align: top;
}
.pibi-brigade-table thead th {
    background: #1e3a5f;
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
}

@media print {
    /* Remove decoração de interface */
    .preview-document-pibi,
    .preview-document-body-pibi {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .pibi-print-document {
        display: block;
        padding: 0;
        margin: 0;
        background: #fff;
    }

    /* Cada section = exatamente uma folha A4 */
    .pibi-print-page {
        position: relative;
        width: 210mm;
        height: 297mm;
        min-height: 297mm;
        max-height: 297mm;
        padding: 18mm 16mm 24mm;
        box-sizing: border-box;
        box-shadow: none;
        overflow: hidden;
        page-break-after: always;
        break-after: always;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* A última página não força quebra extra */
    .pibi-print-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    /* Rodapé sempre no canto inferior direito da folha */
    .pibi-print-footer {
        position: absolute;
        left: 16mm;
        right: 16mm;
        bottom: 8mm;
    }

    /* Página da brigade: cresce para acomodar tabela + bloco de assinatura */
    .pibi-print-page--brigade {
        height: auto !important;
        min-height: 297mm;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Bloco de assinatura digital dentro da brigade não força nova página */
    .pibi-print-page--brigade .pibi-brigade-bottom {
        break-before: avoid;
        page-break-before: avoid;
        padding-bottom: 40px; /* folga para o rodapé absoluto */
    }
    .pibi-print-page--brigade .pibi-dig-sig-block {
        break-inside: avoid;
        page-break-inside: avoid;
        break-before: avoid;
        page-break-before: avoid;
    }

    /* Assinatura e total de brigadistas nunca quebram no meio */
    .pibi-signature-sheet,
    .pibi-brigade-total-row {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Marca d'água */
    .pibi-print-watermark img {
        width: 520px;
    }

    /* Tabelas */
    .pibi-info-table,
    .pibi-brigade-table,
    .pibi-brigade-print-table,
    .pibi-print-table {
        font-size: 0.78rem;
        page-break-inside: avoid;
        break-inside: avoid;
        width: 100%;
    }

    /* Células da brigade table não quebram */
    .pibi-brigade-print-table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Garante @page sem margens extras do browser */
    @page {
        size: A4 portrait;
        margin: 0;
    }
}

/* === In Loco Tablet/Mobile Specifics === */
@media (max-width: 1024px) {
    /* Touch targets improvement */
    input, select, textarea, .btn, .app-tab {
        min-height: 48px;
    }
    
    .nav-item, .tnav-item, .tnav-dd-item {
        min-height: 48px;
        padding-top: 12px;
        padding-bottom: 12px;
    }
    
    /* Fixed Bottom Action Bar for long forms */
    .form-actions-fixed {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 12px 16px;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 12px;
        border-top: 1px solid var(--border);
    }
    
    /* Give form bottom padding so it can scroll past fixed bar */
    .document-form-container {
        padding-bottom: 80px; 
    }
    
}

/* ===== Brigadistas - novo card compacto + modal ===== */
.pibi-brig-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.pibi-brig-header h3 { margin: 0 0 2px; }
.pibi-brig-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.pibi-brig-count {
    font-size: 0.82rem;
    color: var(--muted, #888);
    white-space: nowrap;
}
.pibi-brig-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 6px;
}
.pibi-brig-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.pibi-brig-table th {
    background: var(--surface-alt, #f6f7f9);
    padding: 7px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border, #e0e0e0);
}
.pibi-brig-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
    vertical-align: middle;
}
.pibi-brig-table tr:last-child td { border-bottom: none; }
.pibi-brig-table tr:nth-child(even) td { background: var(--surface-alt, #f9f9fb); }
.pibi-brig-table input {
    width: 100%;
    min-width: 80px;
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.87rem;
    transition: border-color .15s, background .15s;
}
.pibi-brig-table input:hover { border-color: var(--border, #ddd); }
.pibi-brig-table input:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
    background: #fff;
}
.pibi-brig-remove {
    padding: 3px 8px !important;
    font-size: 0.78rem !important;
    color: var(--muted, #888) !important;
    border: none !important;
}
.pibi-brig-remove:hover { color: var(--danger, #e53e3e) !important; }

/* Modal de importação */
.pibi-brig-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.pibi-brig-modal[hidden] { display: none; }
.pibi-brig-modal-panel {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 620px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}
.pibi-brig-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #e0e0e0);
    font-size: 1rem;
}
.pibi-brig-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--muted, #888);
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.pibi-brig-modal-close:hover { background: var(--surface-alt, #f0f0f0); color: #333; }
.pibi-brig-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}
.pibi-brig-modal-body label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 0.9rem; }
.pibi-brig-modal-body textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.87rem;
    resize: vertical;
    margin-bottom: 12px;
    font-family: inherit;
}
.pibi-brig-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.pibi-brig-modal-btns { display: flex; gap: 8px; }

/* === Dashboard v2 ======================================================== */
.dash-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* KPI Grid */
.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow 200ms ease, transform 200ms ease;
}
.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--brand);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.kpi-card.kpi-warn::before  { background: var(--warn); }
.kpi-card.kpi-danger::before{ background: var(--danger); }
.kpi-card.kpi-ok::before    { background: var(--ok); }
.kpi-card.kpi-accent::before{ background: var(--accent); }

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kpi-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.kpi-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}
.kpi-card.kpi-warn  .kpi-icon { background: var(--warn-soft);   color: var(--warn); }
.kpi-card.kpi-danger .kpi-icon{ background: var(--danger-soft); color: var(--danger); }
.kpi-card.kpi-ok    .kpi-icon { background: var(--ok-soft);     color: var(--ok); }
.kpi-card.kpi-accent .kpi-icon{ background: var(--accent-soft); color: var(--accent); }

.kpi-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}
.kpi-sub {
    font-size: 0.72rem;
    color: var(--muted-2);
}
.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 99px;
}
.kpi-trend.up   { background: var(--ok-soft);     color: var(--ok); }
.kpi-trend.down { background: var(--danger-soft); color: var(--danger); }
.kpi-trend.neutral { background: var(--surface-alt); color: var(--muted); }

.kpi-progress {
    margin-top: 4px;
    background: var(--border);
    border-radius: 99px;
    height: 4px;
    overflow: hidden;
}
.kpi-progress-fill {
    height: 4px;
    border-radius: 99px;
    background: var(--brand);
    transition: width 0.8s ease;
}

/* Dashboard Body (panels) */
.dash-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.dash-body-3col {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 14px;
}
@media (max-width: 900px) {
    .dash-body, .dash-body-3col { grid-template-columns: 1fr; }
}

.dash-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.dash-panel-head {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.dash-panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin: 0;
}
.dash-panel-link {
    font-size: 0.72rem;
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
}
.dash-panel-link:hover { text-decoration: underline; }
.dash-panel-body {
    padding: 14px 18px;
    flex: 1;
    overflow-y: auto;
}

/* Pipeline bars */
.pip2-item {
    display: grid;
    grid-template-columns: 100px 1fr 32px;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.pip2-item:last-child { margin-bottom: 0; }
.pip2-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-2);
}
.pip2-bar {
    background: var(--surface-alt);
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
}
.pip2-fill { height: 8px; border-radius: 99px; }
.pip2-fill.frio         { background: #94a3b8; }
.pip2-fill.morno        { background: #fb923c; }
.pip2-fill.quente       { background: #ef4444; }
.pip2-fill.em_negociacao{ background: #7c3aed; }
.pip2-fill.cliente      { background: #16a34a; }
.pip2-fill.descartado   { background: #e2e8f0; }
.pip2-count {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    text-align: right;
}

/* Doc type breakdown */
.doctype-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.doctype-item:last-child { border-bottom: none; }
.doctype-name {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text);
}
.doctype-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted-2);
}
.doctype-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.dbadge {
    padding: 2px 7px;
    border-radius: 99px;
    font-size: 0.66rem;
    font-weight: 700;
    white-space: nowrap;
}
.dbadge-elab { background: #fef9ec; color: #92610a; border: 1px solid #fde68a; }
.dbadge-pend { background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-muted); }
.dbadge-conc { background: var(--ok-soft); color: var(--ok); border: 1px solid #86efac; }

/* Follow-up timeline */
.fup2-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.fup2-item:last-child { border-bottom: none; }
.fup2-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    flex-shrink: 0;
    margin-top: 5px;
}
.fup2-dot.is-hoje { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.fup2-body { flex: 1; min-width: 0; }
.fup2-nome {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fup2-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.fup2-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--brand);
}
.fup2-date.is-hoje { color: var(--danger); }

/* Recent documents table */
.rec2-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.rec2-table th {
    text-align: left;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 10px 8px;
    border-bottom: 2px solid var(--border);
    vertical-align: middle;
}
.rec2-table td {
    padding: 9px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.rec2-table tr:last-child td { border-bottom: none; }
.rec2-table tr:hover td { background: var(--surface-alt); }
.rec2-title {
    font-weight: 600;
    color: var(--text);
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.rec2-client {
    font-size: 0.72rem;
    color: var(--muted-2);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.rec2-type {
    font-size: 0.66rem;
    font-weight: 700;
    background: var(--surface-alt);
    color: var(--muted);
    padding: 2px 6px;
    border-radius: var(--r-xs);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.rec2-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted-2);
    white-space: nowrap;
}
.rec2-action {
    font-size: 0.7rem;
    padding: 3px 9px;
}

/* Empty state */
.dash-empty {
    text-align: center;
    padding: 28px 0;
    color: var(--muted-2);
    font-size: 0.82rem;
}
.dash-empty svg {
    display: block;
    margin: 0 auto 8px;
    opacity: 0.3;
}

/* === CRM Kanban Pipeline ================================================= */
.kanban-wrapper {
    padding: 18px 20px 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--tabbar-h, 38px));
    min-height: 0;
}
.kanban-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-shrink: 0;
}
.kanban-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 16px;
    flex: 1;
    min-height: 0;
    scroll-snap-type: x proximity;
}
.kanban-board::-webkit-scrollbar { height: 6px; }
.kanban-board::-webkit-scrollbar-track { background: transparent; }
.kanban-board::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

.kanban-col {
    min-width: 260px;
    max-width: 260px;
    background: var(--surface-alt);
    border-radius: var(--r-lg);
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    transition: outline 150ms ease;
}
.kanban-col.drag-over {
    outline: 2px dashed var(--brand);
    outline-offset: -2px;
    background: var(--brand-soft);
}

.kanban-col-head {
    padding: 12px 14px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 2px solid transparent;
}
.kanban-col-head.col-frio          { border-color: #94a3b8; }
.kanban-col-head.col-morno         { border-color: #fb923c; }
.kanban-col-head.col-quente        { border-color: #ef4444; }
.kanban-col-head.col-em_negociacao { border-color: #7c3aed; }
.kanban-col-head.col-cliente       { border-color: #16a34a; }
.kanban-col-head.col-descartado    { border-color: #cbd5e1; }

.kanban-col-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-2);
}
.kanban-col-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    background: var(--border);
    color: var(--muted);
    padding: 1px 7px;
    border-radius: 99px;
    min-width: 22px;
    text-align: center;
}

.kanban-col-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kanban-col-body::-webkit-scrollbar { width: 4px; }
.kanban-col-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* Kanban Card */
.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 11px 13px;
    cursor: grab;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 150ms ease, transform 150ms ease, opacity 150ms ease;
    user-select: none;
}
.kanban-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.kanban-card.is-dragging {
    opacity: 0.45;
    cursor: grabbing;
}

.kcard-company {
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kcard-contact {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
}
.kcard-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.kcard-date {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--r-xs);
}
.kcard-date.overdue  { background: var(--danger-soft); color: var(--danger); }
.kcard-date.today    { background: var(--warn-soft);   color: var(--warn); }
.kcard-date.upcoming { background: var(--brand-soft);  color: var(--brand); }
.kcard-date.none     { background: var(--surface-alt); color: var(--muted-2); }

.kcard-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 150ms ease;
}
.kanban-card:hover .kcard-actions { opacity: 1; }
.kcard-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--r-xs);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 120ms, color 120ms;
}
.kcard-btn:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-muted); }

/* Segmento chip */
.kcard-segment {
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--surface-alt);
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: var(--r-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* Quick-add card (collapsed column footer) */
.kanban-add-btn {
    margin: 4px 10px 12px;
    padding: 7px 12px;
    background: transparent;
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 150ms, color 150ms;
    text-decoration: none;
    display: block;
    flex-shrink: 0;
}
.kanban-add-btn:hover {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: var(--brand-muted);
}

/* === Google Antigravity Premium Components =========================== */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.theme-dark .glass-card {
    background: rgba(12, 24, 41, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}
.glass-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    pointer-events: none;
}
.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--brand-muted);
}

.topbar {
    display: flex;
    align-items: center;
    min-height: var(--header-h);
    padding: 0 16px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 10px;
    position: relative;
    z-index: 1000;
    transition: background 0.3s ease;
}
.topbar:empty {
    display: none !important;
}

.tab-bar {
    background: var(--surface-alt);
    padding: 8px 12px 0;
    display: flex;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.app-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.3);
    border: 1px solid transparent;
    border-radius: var(--r-md) var(--r-md) 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 200px;
    position: relative;
}
.theme-dark .app-tab {
    background: rgba(255,255,255,0.05);
}
.app-tab:hover {
    background: rgba(255,255,255,0.6);
    color: var(--text);
}
.theme-dark .app-tab:hover {
    background: rgba(255,255,255,0.1);
}
.app-tab.is-active {
    background: var(--surface);
    color: var(--brand);
    font-weight: 600;
    border: 1px solid var(--border);
    border-bottom-color: var(--surface);
}
.tab-list {
    display: flex;
    gap: 4px;
    align-items: flex-end;
}
.tab-add-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}
.tab-add-btn:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

/* ==========================================================================
   FINAL PRINT OVERRIDES (Ensures correct alignment and no clipping)
   ========================================================================== */
@media print {
    @page { 
        margin: 10mm !important; 
        size: A4 portrait !important; 
    }
    
    html, body {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Reset de todos os possíveis containers que causam deslocamento */
    .app-shell, .main-area, .content, .main-wrapper, #sidebar, .sidebar, .topbar, .tab-bar {
        display: block !important;
        position: static !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        flex: none !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* Esconder UI de forma definitiva */
    .sidebar, #sidebar, .topbar, .tab-bar, .actions, #menu-toggle, .no-print, .sidebar-tools, aside {
        display: none !important;
    }

    /* Documento Preview: Garantir que ele ocupe a largura total e não tenha sombras */
    .preview-document {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: #fff !important;
        transform: none !important;
        animation: none !important;
        position: static !important;
    }

    .preview-document-body {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Assinaturas: Garantir posicionamento correto */
    .preview-signature-image {
        max-height: 240px !important;
        width: auto !important;
        margin-bottom: -15px !important;
        display: block !important;
    }
    
    .preview-signature-line {
        margin-top: 0 !important;
        margin-bottom: 12px !important;
        width: auto !important;
        display: inline-block !important;
    }

    .preview-signature-stack {
        gap: 60px !important;
        padding-top: 40px !important;
    }

    /* Fotos e Layout */
    .preview-photo-card { 
        break-inside: avoid !important; 
        page-break-inside: avoid !important; 
    }

    /* Remover animações de tudo */
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}
