/* ============================================
   ImobiSISMAX - Estilos Globais
   Tema Liquid Glass | Dark & Light Mode
   ============================================ */

/* ============================================
   FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

.record-not-found.glass-card {
    max-width: 680px;
    margin: clamp(24px, 8vh, 88px) auto;
    padding: clamp(28px, 6vw, 56px);
    text-align: center;
    background: radial-gradient(ellipse at top, var(--accent-light), transparent 65%), var(--bg-base);
}

.modal-content.negotiation-transfer-content { max-width: 620px; }
.modal-content.negotiation-transfer-content > form { padding: 0; }
.modal-content.negotiation-transfer-content > form > .modal-footer { margin: 0; }
.negotiation-transfer-content .modal-body { display: grid; gap: 18px; padding: 20px 28px; }
.negotiation-transfer-content .transfer-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.negotiation-transfer-content .transfer-origin-box { padding: 12px 14px; border: 1px solid var(--border-glass); border-radius: 12px; background: var(--bg-surface); }
.negotiation-transfer-content .transfer-origin-box span { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.negotiation-transfer-content .transfer-origin { display: block; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.negotiation-transfer-content .input-group { min-width: 0; margin: 0; }
.negotiation-transfer-content .transfer-unlink { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.negotiation-transfer-content .transfer-unlink.is-hidden { display: none; }
@media (max-width: 520px) {
    .negotiation-transfer-content .transfer-fields { grid-template-columns: minmax(0, 1fr); }
    .negotiation-transfer-content .modal-footer { flex-wrap: wrap; }
    .negotiation-transfer-content .modal-body { padding: 18px 20px; }
}

.record-not-found-icon {
    display: grid;
    place-items: center;
    width: 88px;
    height: 88px;
    margin: 0 auto 24px;
    border: 1px solid var(--accent-border);
    border-radius: 28px;
    color: var(--accent-text, var(--accent));
    background: var(--accent-light);
}

.record-not-found .page-title {
    font-size: clamp(24px, 4vw, 32px);
}

.record-not-found p {
    margin: 16px auto 28px;
    max-width: 440px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.record-not-found .btn {
    max-width: 100%;
    white-space: normal;
}

/* ============================================
   CSS CUSTOM PROPERTIES (Variáveis de Tema)
   ============================================ */
:root {
    /* Light Mode (default) */
    --bg-base: #FFFFFF;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-hover: rgba(255, 235, 235, 0.5);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-glass-strong: rgba(255, 255, 255, 0.8);
    --bg-sidebar: rgba(255, 255, 255, 0.5);
    --bg-header: rgba(255, 255, 255, 0.6);
    --bg-input: rgba(255, 255, 255, 0.8);

    --border-glass: rgba(0, 0, 0, 0.08);
    --border-glass-strong: rgba(0, 0, 0, 0.12);
    --border-input: rgba(0, 0, 0, 0.15);

    --text-primary: #000000;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-inverse: #ffffff;

    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-glass-sm: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-glass-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(195, 0, 1, 0.15);

    --blur-glass: 20px;
    --blur-glass-strong: 40px;

    --accent: #C30001;
    --accent-text: var(--accent);
    --accent-hover: #9B0001;
    --accent-light: #FFEBEB;
    --accent-border: #F29E9F;
    --success: #22c55e;
    --success-hover: #16a34a;
    --success-light: rgba(34, 197, 94, 0.1);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.1);

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 64px;
    --app-safe-top: 0px;
    --app-chrome-color: #ffffff;
    --tab-bar-height: 44px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
.dark {
    color-scheme: dark;
    --bg-page: #20242b;
    --bg-base: #2b313a;
    --bg-surface: #343c47;
    --bg-surface-hover: #3f4a59;
    --bg-glass: #3b4552;
    --bg-glass-strong: #465260;
    --bg-sidebar: #272e38;
    --bg-header: #29313b;
    --app-chrome-color: var(--bg-header);
    --bg-input: #3b4552;

    --border-glass: #5a687b;
    --border-glass-strong: #78889e;
    --border-input: #78889e;

    --text-primary: #f5f7fa;
    --text-secondary: #d5dce6;
    --text-muted: #c0cad8;
    --text-inverse: #20242b;

    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glass-sm: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-glass-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(195, 0, 1, 0.2);

    --accent-text: #ffb1b3;
    --primary-text: var(--accent-text);
    --accent-light: #50343e;
    --accent-border: #cf858e;
    --success-light: rgba(34, 197, 94, 0.15);
}

html[data-app-standalone="true"] {
    --app-safe-top: env(safe-area-inset-top, 0px);
    background-color: var(--app-chrome-color);
}
html[data-app-standalone="true"] body { --header-height: calc(64px + var(--app-safe-top)) !important; }
html[data-app-standalone="true"] .glass-header {
    padding-top: var(--app-safe-top);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    background: var(--app-chrome-color);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
html[data-app-standalone="true"] .sidebar-logo { padding-top: var(--app-safe-top); }

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

html {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-page, var(--bg-base));
    color: var(--text-primary);
    min-height: 100vh;
    transition: var(--transition);
    line-height: 1.6;
}

a {
    color: var(--accent-text, var(--accent));
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* ============================================
   GLASS COMPONENTS
   ============================================ */

/* Card Glass */
.glass-card {
    background: var(--bg-surface);
    backdrop-filter: blur(var(--blur-glass));
    -webkit-backdrop-filter: blur(var(--blur-glass));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    transition: var(--transition);
}

.glass-card:hover {
    background: rgb(246, 246, 246);
    box-shadow: var(--shadow-glass-lg);
    border-color: var(--border-glass-strong);
}

.dark .glass-card:hover {
    background: var(--bg-surface-hover);
}

/* Sidebar Glass */
.glass-sidebar {
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--blur-glass-strong));
    -webkit-backdrop-filter: blur(var(--blur-glass-strong));
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    overflow-y: hidden;
    overflow-x: hidden;
    transition: var(--transition);
}

/* Header Glass */
.glass-header {
    background: var(--bg-header);
    backdrop-filter: blur(var(--blur-glass-strong));
    -webkit-backdrop-filter: blur(var(--blur-glass-strong));
    border-bottom: 1px solid var(--border-glass);
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 100;
    transition: var(--transition);
}

/* Tab Bar (Chrome-like tabs) */
.tab-bar {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    height: var(--tab-bar-height);
    background: var(--bg-header);
    backdrop-filter: blur(var(--blur-glass-strong));
    -webkit-backdrop-filter: blur(var(--blur-glass-strong));
    border-bottom: 1px solid var(--border-glass);
    z-index: 99;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    padding: 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 800px) {
    :root, body {
        --tab-bar-height: 0px;
    }

    #tab-bar, .tab-bar {
        display: none !important;
    }
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

.tab-bar .tab-scroll-btn {
    flex-shrink: 0;
    width: 32px;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass-strong);
    border: none;
    border-left: 1px solid var(--border-glass);
    border-right: 1px solid var(--border-glass);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    z-index: 2;
    transition: background 0.2s, color 0.2s;
}
.tab-bar .tab-scroll-btn:hover {
    color: var(--accent-text, var(--accent));
    background: var(--accent-light);
}
.tab-bar .tab-scroll-btn:active {
    background: var(--accent);
    color: var(--text-inverse);
}
.tab-bar.has-overflow .tab-scroll-btn {
    display: flex;
}

.tab-close-all-btn {
    flex-shrink: 0;
    width: 32px;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass-strong);
    border: none;
    border-left: 1px solid var(--border-glass);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, color 0.2s;
}
.tab-close-all-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}
.tab-close-all-btn:active {
    background: var(--danger);
    color: var(--text-inverse);
}
.tab-bar.has-multiple .tab-close-all-btn {
    display: flex;
}

.tab-list {
    display: flex;
    height: 100%;
    align-items: flex-end;
    gap: 1px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    padding: 0 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tab-list::-webkit-scrollbar {
    display: none;
}

.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 33px;
    padding: 0 12px;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    max-width: none;
    min-width: 60px;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.15s, color 0.15s;
    border: 1px solid transparent;
    border-bottom: none;
    flex-shrink: 0;
    position: relative;
    user-select: none;
}

.tab-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-secondary);
}

.tab-item.active {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-glass);
    font-weight: 600;
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--bg-surface-hover);
}

.tab-item .tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tab-item .tab-icon svg {
    width: 13px;
    height: 13px;
}

.tab-item .tab-title {
    overflow: visible;
    text-overflow: clip;
    flex: 1;
    min-width: 0;
}

.tab-item .tab-close {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    flex-shrink: 0;
    margin-left: 2px;
}

.tab-item:hover .tab-close,
.tab-item.active .tab-close {
    opacity: 0.5;
}

.tab-item .tab-close:hover {
    opacity: 1;
    background: var(--danger-light);
    color: var(--danger);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: calc(var(--header-height) + var(--tab-bar-height) + 24px);
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: 24px;
    min-height: 100vh;
    transition: var(--transition);
}

/* ============================================
   INPUTS GLASS
   ============================================ */
.input-glass {
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 14px;
    width: 100%;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

select.input-glass {
    padding-right: 36px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.dark select.input-glass,
.dark .phone-country-select {
    color-scheme: dark;
}

.dark select.input-glass option,
.dark .phone-country-select option,
.dark select.input-glass optgroup,
.dark .phone-country-select optgroup {
    background: var(--bg-input);
    color: var(--text-primary);
}

.input-glass::placeholder {
    color: var(--text-muted);
}

.input-glass:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-glass-sm);
    background: var(--bg-glass-strong);
}

.dark .input-glass:focus {
    border-color: var(--accent-border);
}

.input-glass:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.property-address-group {
    display: flex;
    align-items: stretch;
    min-width: 0;
}

.property-address-group > :is(.input-glass, .searchable-select-wrapper) {
    flex: 1 1 auto;
    min-width: 0;
}

.property-address-group > .input-glass,
.property-address-group .searchable-select-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.property-address-group > .property-address-action {
    flex: 0 0 48px;
    min-width: 48px;
    padding: 0;
    border: 1px solid var(--border-input);
    border-left: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    background: var(--bg-glass);
    color: var(--text-secondary);
}

.property-address-action svg {
    width: 18px;
    height: 18px;
}

select.property-address-display:disabled {
    background-image: none;
    padding-right: 16px;
    cursor: default;
    opacity: 0.8;
}

.property-address-action [data-property-cep-spinner],
.property-address-action[aria-busy="true"] [data-property-cep-icon] {
    display: none;
}

.property-address-action[aria-busy="true"] [data-property-cep-spinner] {
    display: block;
    width: 17px;
    height: 17px;
}

[data-property-cep-status] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.modal-content.property-cep-dialog {
    position: fixed;
    inset: 0;
    width: min(420px, calc(100% - 24px));
    margin: auto;
    max-height: min(75dvh, 500px);
    background: var(--bg-base);
    color: var(--text-primary);
}

.property-cep-dialog:not([open]) { display: none; }
.property-cep-dialog::backdrop { background: rgba(0, 0, 0, .5); }

.property-cep-dialog .property-cep-options {
    display: grid;
    align-content: start;
    gap: 8px;
    overflow-y: auto;
}

.property-cep-options > .property-cep-choice {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    text-align: start;
    white-space: normal;
    overflow-wrap: anywhere;
    gap: 3px 12px;
    min-height: 46px;
}

.property-cep-choice > small {
    grid-column: 1 / -1;
    color: var(--text-muted);
    line-height: 1.35;
}

@media (max-width: 800px) {
    .modal-content.property-cep-dialog {
        inset: auto 0 0;
        width: 100%;
        max-width: none;
        border-radius: 18px 18px 0 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

.searchable-select-wrapper {
    position: relative;
    width: 280px;
    flex: 0 0 280px;
    z-index: 2;
}

.searchable-select-wrapper.searchable-select-fluid {
    width: 100%;
    flex: 1 1 auto;
}

.searchable-select-card-context {
    position: relative;
    z-index: 35;
    overflow: visible;
}

.searchable-select-wrapper.is-open {
    z-index: 140;
}

.searchable-select-native {
    display: none !important;
}

.searchable-select-combobox {
    position: relative;
}

.searchable-select-input {
    width: 100%;
    padding-right: 42px;
}

.searchable-select-wrapper.is-disabled {
    opacity: 0.5;
}

.searchable-select-wrapper.is-disabled .searchable-select-input,
.searchable-select-wrapper.is-disabled .searchable-select-toggle {
    cursor: not-allowed;
}

.searchable-select-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transform: translateY(-50%);
    transition: background 0.16s ease, color 0.16s ease;
}

.searchable-select-toggle:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-primary);
}

.searchable-select-toggle svg {
    transition: transform 0.16s ease;
}

.searchable-select-wrapper.is-open .searchable-select-toggle svg {
    transform: rotate(180deg);
}

.searchable-select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: none;
    max-height: 260px;
    overflow: auto;
    padding: 8px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
}

.searchable-select-wrapper.is-open .searchable-select-menu {
    display: block;
}

.searchable-select-option {
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

.searchable-select-option + .searchable-select-option {
    margin-top: 4px;
}

.searchable-select-option-multiple { gap: 10px; }
.searchable-select-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
}
.searchable-select-option.is-selected .searchable-select-check {
    border-color: currentColor;
    background: var(--accent-light);
}

.searchable-select-option:hover,
.searchable-select-option.is-selected {
    background: rgba(14, 116, 144, 0.1);
    color: #0e7490;
}

.searchable-select-empty {
    padding: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.dark .searchable-select-toggle:hover {
    background: var(--bg-surface-hover);
}

.dark .searchable-select-menu {
    border-color: var(--border-glass-strong);
    background: var(--bg-glass-strong);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.dark .searchable-select-option:hover,
.dark .searchable-select-option.is-selected {
    background: rgba(14, 116, 144, 0.18);
    color: #67e8f9;
}

@media (max-width: 720px) {
    .searchable-select-wrapper {
        width: 100%;
        flex-basis: 100%;
    }
}

.phone-group {
    display: flex;
    gap: 0;
}

.phone-country-wrap {
    position: relative;
    flex: 0 0 104px;
    min-width: 104px;
}

.phone-country {
    width: auto;
    min-width: 95px;
    border-radius: 8px 0 0 8px;
    border-right: none;
    padding-right: 4px;
    font-size: 13px;
}

.phone-country-wrap .phone-country {
    display: block;
    width: 100%;
    min-width: 0;
    height: 100%;
    color: transparent;
    padding-left: 10px;
    padding-right: 28px;
    text-shadow: none;
}

.phone-country-wrap .phone-country option {
    color: #111827;
}

.dark .phone-country-wrap .phone-country option {
    background: var(--bg-input);
    color: var(--text-primary);
}

.phone-country-display {
    position: absolute;
    inset: 0 26px 0 12px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 7px;
    pointer-events: none;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.phone-country-flag {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 16px;
    flex: 0 0 22px;
    overflow: hidden;
    border-radius: 3px;
    background-color: #f3f4f6;
    background-position: center;
    background-size: cover;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.16);
}

.phone-country-flag-br {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 20'%3E%3Cpath fill='%23009b3a' d='M0 0h28v20H0z'/%3E%3Cpath fill='%23ffdf00' d='M14 2l11 8-11 8-11-8z'/%3E%3Ccircle cx='14' cy='10' r='4' fill='%23002776'/%3E%3C/svg%3E");
}

.phone-country-flag-us {
    background: repeating-linear-gradient(to bottom, #b22234 0 1.55px, #fff 1.55px 3.1px);
}

.phone-country-flag-us::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 44%;
    height: 54%;
    background: #3c3b6e;
}

.phone-country-flag-pt {
    background: linear-gradient(to right, #006600 0 40%, #ff0000 40% 100%);
}

.phone-country-flag-ar {
    background: linear-gradient(to bottom, #74acdf 0 33.33%, #fff 33.33% 66.66%, #74acdf 66.66% 100%);
}

.phone-country-flag-py {
    background: linear-gradient(to bottom, #d52b1e 0 33.33%, #fff 33.33% 66.66%, #0038a8 66.66% 100%);
}

.phone-country-flag-uy {
    background: repeating-linear-gradient(to bottom, #fff 0 2.22px, #0038a8 2.22px 4.44px);
}

.phone-country-flag-uy::after,
.phone-country-flag-cl::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 42%;
    height: 50%;
    background: #fff;
}

.phone-country-flag-cl {
    background: linear-gradient(to bottom, #fff 0 50%, #d52b1e 50% 100%);
}

.phone-country-flag-cl::after {
    background: #0039a6;
}

.phone-country-flag-co {
    background: linear-gradient(to bottom, #fcd116 0 50%, #003893 50% 75%, #ce1126 75% 100%);
}

.phone-country-flag-mx {
    background: linear-gradient(to right, #006847 0 33.33%, #fff 33.33% 66.66%, #ce1126 66.66% 100%);
}

.phone-country-flag-es {
    background: linear-gradient(to bottom, #aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75% 100%);
}

.phone-input {
    border-radius: 0 8px 8px 0;
    flex: 1;
}

.phone-country-select {
    width: 80px;
    display: inline-block;
    vertical-align: top;
}

.phone-number-input {
    width: calc(100% - 90px);
    display: inline-block;
}

/* Input Label */
.input-label {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-glass-strong);
    border-radius: 22px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Input Group (label + input + error) */
.input-group {
    margin-bottom: 20px;
}

.modal-content .input-group {
    margin-bottom: 0;
}

.modal-content .grid {
    gap: 12px;
}

.input-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(195, 0, 1, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(195, 0, 1, 0.4);
    transform: translateY(-1px);
}

.page-floating-save {
    position: fixed;
    z-index: 90;
    right: max(24px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 58px;
    height: 58px;
    min-width: 58px;
    padding: 0;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 30px rgba(207, 0, 0, 0.32);
}

.page-floating-save svg {
    width: 23px;
    height: 23px;
}

.page-floating-save:disabled {
    transform: none;
}

@media (max-width: 639px) {
    .page-floating-save {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        width: 54px;
        height: 54px;
        min-width: 54px;
    }
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: #1a1a2e;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--border-glass-strong);
}

.modal-footer .btn-ghost {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
}

.modal-footer .btn-ghost:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.dark .modal-footer .btn-ghost {
    background: var(--bg-glass);
    border: 1px solid var(--border-input);
    color: var(--text-primary);
}

.dark .modal-footer .btn-ghost:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-glass-strong);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

/* ============================================
   STAT CARDS (Dashboard)
   ============================================ */
.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .stat-info h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-card .stat-info .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon-green { background: var(--success-light); color: var(--success); }
.stat-icon-red { background: var(--danger-light); color: var(--danger); }
.stat-icon-blue { background: var(--info-light); color: var(--info); }
.stat-icon-yellow { background: var(--warning-light); color: var(--warning); }

/* ============================================
   TABLE GLASS
   ============================================ */
.table-glass {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-glass thead th {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
}

.table-glass tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-glass);
    font-size: 14px;
    color: var(--text-primary);
    vertical-align: middle;
}

.table-glass tbody tr {
    transition: var(--transition);
}

.table-glass tbody tr:hover {
    background: rgb(238, 238, 238);
}

.dark .table-glass tbody tr:hover {
    background: var(--bg-surface-hover);
}

.table-glass tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.badge-secondary {
    background: rgba(113, 128, 150, 0.14);
    color: var(--text-secondary);
}

.dark .badge-secondary {
    background: rgba(161, 161, 170, 0.18);
    color: #d4d4d8;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-dot-green { background: var(--success); }
.badge-dot-red { background: var(--danger); }
.badge-dot-yellow { background: var(--warning); }
.badge-dot-blue { background: var(--info); }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-glass-lg);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.7s;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-success { background: rgba(34, 197, 94, 0.9); }
.toast-primary { background: rgba(195, 0, 1, 0.9); }
.toast-error { background: rgba(239, 68, 68, 0.9); }
.toast-warning { background: rgba(245, 158, 11, 0.9); color: #1a1a2e; }
.toast-info { background: rgba(59, 130, 246, 0.9); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ============================================
   MODAL
   ============================================ */
/* Lock both shell and document scrollers, including calendars portaled to body. */
html:has(.modal-overlay.active),
html:has(dialog[open]),
body:has(.modal-overlay.active),
body:has(dialog[open]),
body:has(.modal-overlay.active) .main-content,
body:has(dialog[open]) .main-content {
    overflow: hidden !important;
    overscroll-behavior: none;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
    overscroll-behavior: none;
}

.modal-content {
    background: var(--bg-base);
    border: 1px solid var(--border-glass-strong);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: scaleIn 0.2s ease;
}

/* Keep titles and close actions visible in both overlay and native dialogs. */
.modal-header,
dialog > header {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-shrink: 0;
    background: var(--bg-base, #fff) !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

dialog > header {
    top: calc(-1 * var(--dialog-padding, 0px));
    margin: calc(-1 * var(--dialog-padding, 0px)) calc(-1 * var(--dialog-padding, 0px)) 0;
    padding: var(--dialog-padding, 0px);
    border-bottom: 1px solid var(--border-glass);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-base);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-header > div {
    min-width: 0;
}

/* Padrao unico para textos explicativos de todas as modais. */
.modal-header .modal-subtitle,
.modal-header > p,
.modal-header > div > p {
    margin: 4px 0 0 !important;
    color: var(--text-muted) !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
}

.modal-body,
.modal-content > p,
.modal-content > form {
    padding: 20px 28px;
}

.modal-body p,
.modal-content > p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

.modal-header .modal-close,
dialog > header .modal-close,
.modal-close-icon,
button.modal-close-icon,
dialog button.modal-close-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    padding: 0;
    border-radius: 10px;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-glass-strong);
    color: var(--text-muted);
    font-size: 0 !important;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-header .modal-close > *, dialog > header .modal-close > *, .modal-close-icon > * { display: none; }
.modal-header .modal-close::before, dialog > header .modal-close::before, .modal-close-icon::before {
    content: '';
    display: block;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    background: linear-gradient(45deg, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%),
                linear-gradient(-45deg, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%);
    pointer-events: none;
}
.modal-header .modal-close:hover:not(:disabled), dialog > header .modal-close:hover:not(:disabled), .modal-close-icon:hover:not(:disabled) {
    background: var(--danger-light);
    color: var(--danger);
}
.modal-header .modal-close:focus-visible, dialog > header .modal-close:focus-visible, .modal-close-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.modal-initial-focus:focus { outline:none; }
@media (max-width:800px) {
    /* Touch and restored programmatic focus are not keyboard navigation. */
    html[data-ui-input="pointer"] .btn:focus,
    html[data-ui-input="pointer"] .modal-close:focus,
    html[data-ui-input="pointer"] .modal-close-icon:focus { outline:none; }
}
.modal-header .modal-close:disabled, dialog > header .modal-close:disabled, .modal-close-icon:disabled { opacity: .45; cursor: not-allowed; }

.imoveis-view-lightbox[data-image-viewer] {
    overflow: hidden;
    background: #040912;
    padding-top: calc(68px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    touch-action: pan-y pinch-zoom;
}
[data-image-viewer] img[data-image-viewer-photo] {
    flex: none;
    max-width: none;
    max-height: none;
    transform-origin: center;
    transition: transform .18s ease;
    user-select: none;
    -webkit-user-drag: none;
    cursor: grab;
}
[data-image-viewer].is-image-dragging,
[data-image-viewer].is-image-dragging img[data-image-viewer-photo] { cursor: grabbing; }
[data-image-viewer] .modal-close-icon,
[data-image-viewer] .image-viewer-rotate {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(14px + env(safe-area-inset-right, 0px));
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 10px;
    color: #fff;
    background: #1e293b;
    cursor: pointer;
}
[data-image-viewer] .image-viewer-rotate { right: calc(66px + env(safe-area-inset-right, 0px)); }
[data-image-viewer] .image-viewer-rotate svg { width: 20px; height: 20px; pointer-events: none; }
[data-image-viewer] .modal-close-icon:hover,
[data-image-viewer] .image-viewer-rotate:hover { background: #334155; color: #fff; }
[data-image-viewer] .image-viewer-rotate:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
[data-image-viewer] .image-viewer-rotate:disabled { opacity: .55; cursor: wait; }
[data-image-viewer] .image-viewer-rotate.is-hidden { display: none; }
[data-image-viewer] .imoveis-view-lightbox-counter { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
@media (prefers-reduced-motion: reduce) {
    [data-image-viewer] img[data-image-viewer-photo] { transition: none; }
}

.modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 28px 24px;
    border-top: 1px solid var(--border-glass);
    background: var(--bg-base);
}

.modal-footer .btn {
    position: relative;
    flex-shrink: 0;
    box-shadow: none;
    transform: none;
}

.modal-footer .btn:hover {
    transform: none;
    box-shadow: none;
}

/* Footer dentro de form: compensa o padding do form */
.modal-content > form .modal-footer {
    margin: 24px -28px -20px;
    padding: 16px 28px 20px;
}

.clientes-duplicate-content {
    max-width: 760px;
}

.clientes-duplicate-alert {
    padding: 14px 16px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 16px;
    background: rgba(245, 158, 11, 0.08);
    color: #92400e;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
}

.clientes-duplicate-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.clientes-duplicate-card {
    padding: 14px;
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    background: var(--bg-secondary);
}

.clientes-duplicate-card-header,
.clientes-duplicate-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.clientes-duplicate-card-header strong {
    color: var(--text-primary);
    font-size: 15px;
}

.clientes-duplicate-card-header span,
.clientes-duplicate-meta,
.clientes-duplicate-match {
    color: var(--text-muted);
    font-size: 12px;
}

.clientes-duplicate-meta,
.clientes-duplicate-match {
    margin-top: 8px;
}

.clientes-duplicate-match {
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(14, 116, 144, 0.08);
    color: #0e7490;
    font-weight: 700;
}

.clientes-duplicate-brokers {
    display: grid;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.clientes-duplicate-brokers li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: 12px;
}

.clientes-duplicate-brokers span {
    color: var(--text-muted);
    text-align: right;
}

.dark .clientes-duplicate-alert {
    background: rgba(245, 158, 11, 0.14);
    color: #fbbf24;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ============================================
   SIDEBAR MENU
   ============================================ */
.sidebar-logo {
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--header-height);
    min-height: var(--header-height);
    flex: 0 0 var(--header-height);
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-logo img {
    display: block;
    width: 100%;
    max-width: 196px;
    height: auto;
    max-height: 52px;
    min-width: 0;
    object-fit: contain;
}

.sidebar-logo .sidebar-brand-on-dark,
.dark .sidebar-logo .sidebar-brand-on-light {
    display: none;
}

.dark .sidebar-logo .sidebar-brand-on-dark {
    display: block;
}

@media (min-width: 1025px) {
    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-logo img,
    .sidebar-will-collapse .glass-sidebar .sidebar-logo img {
        max-width: 54px;
    }
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
}

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}

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

.sidebar-link.active {
    background: var(--accent-light);
    color: var(--accent-text, var(--accent));
}

.sidebar-link-danger {
    color: var(--danger);
}

.sidebar-link .link-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-tree {
    display: block;
}

.sidebar-tree summary {
    list-style: none;
    cursor: pointer;
}

.sidebar-tree summary::-webkit-details-marker {
    display: none;
}

.sidebar-tree-chevron {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform .2s ease;
}

.sidebar-tree[open] .sidebar-tree-chevron {
    transform: rotate(180deg);
}

.sidebar-submenu {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 3px 0 5px 32px;
    padding-left: 10px;
    border-left: 1px solid var(--border-glass);
}

.sidebar-sublink {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 7px 10px;
    border-radius: 9px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}

.sidebar-sublink:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-sublink.active {
    background: var(--accent-light);
    color: var(--accent-text, var(--accent));
}

.sidebar-subtree {
    display: block;
}

.sidebar-subtree summary {
    list-style: none;
    cursor: pointer;
}

.sidebar-subtree summary::-webkit-details-marker {
    display: none;
}

.sidebar-subtree-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    overflow: hidden;
    padding: 7px 10px;
    border-radius: 9px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}

.sidebar-subtree-summary span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-subtree-summary:hover,
.sidebar-subtree-summary.active {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-subtree-chevron {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform .2s ease;
}

.sidebar-subtree[open] .sidebar-subtree-chevron {
    transform: rotate(180deg);
}

.sidebar-subtree-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 2px 12px;
    padding-left: 8px;
    border-left: 1px solid var(--border-glass);
}

.sidebar-sublink-branch {
    font-size: 12px;
    font-weight: 500;
    padding: 6px 9px;
}

.sidebar-submenu-empty {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
    padding: 7px 10px;
}

.sidebar-bottom {
    position: relative;
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid var(--border-glass);
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--blur-glass-strong));
    -webkit-backdrop-filter: blur(var(--blur-glass-strong));
}

/* Toggle button */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-toggle-btn .toggle-icon-expand {
    display: none;
}

/* ============================================
   SIDEBAR COLLAPSED STATE
   ============================================ */
/* Estado imediato via html class (evita flash) */
.sidebar-will-collapse .glass-sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-will-collapse .glass-header {
    left: var(--sidebar-collapsed-width);
}

.sidebar-will-collapse .tab-bar {
    left: var(--sidebar-collapsed-width);
}

.sidebar-will-collapse .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.sidebar-will-collapse .glass-sidebar .sidebar-logo h1,
.sidebar-will-collapse .glass-sidebar .sidebar-section-title {
    display: none;
}

.sidebar-will-collapse .glass-sidebar .sidebar-logo {
    justify-content: center;
    padding: 0;
}

.sidebar-will-collapse .glass-sidebar .sidebar-link span:not(.link-icon) {
    display: none;
}

.sidebar-will-collapse .glass-sidebar .sidebar-link {
    justify-content: center;
    padding: 10px;
    gap: 0;
}

.sidebar-will-collapse .glass-sidebar .sidebar-toggle-btn .toggle-icon-collapse {
    display: none;
}

.sidebar-will-collapse .glass-sidebar .sidebar-toggle-btn .toggle-icon-expand {
    display: block;
}

/* Estado via JS (após init) */
.glass-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.glass-sidebar.collapsed ~ .glass-header,
.glass-sidebar.collapsed ~ .tab-bar {
    left: var(--sidebar-collapsed-width);
}

/* Fix: header/tab-bar/main são siblings do sidebar no DOM? Não — usamos body class */
body.sidebar-collapsed .glass-header {
    left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .tab-bar {
    left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Sidebar interno quando colapsado */
.glass-sidebar.collapsed:not(.is-peeking) .sidebar-logo h1 {
    display: none;
}

.glass-sidebar.collapsed:not(.is-peeking) .sidebar-logo {
    justify-content: center;
    padding: 0;
}

.glass-sidebar.collapsed:not(.is-peeking) .sidebar-nav {
    padding: 16px 8px;
}

.glass-sidebar.collapsed:not(.is-peeking) .sidebar-section-title {
    display: none;
}

.glass-sidebar.collapsed:not(.is-peeking) .sidebar-link {
    justify-content: center;
    padding: 10px;
    gap: 0;
}

.glass-sidebar.collapsed:not(.is-peeking) .sidebar-link span:not(.link-icon) {
    display: none;
}

.glass-sidebar.collapsed:not(.is-peeking) .sidebar-link .link-icon {
    width: 24px;
    height: 24px;
}

@media (min-width: 1025px) {
    .glass-sidebar.collapsed.is-peeking {
        width: var(--sidebar-width);
        z-index: 110;
        background: var(--bg-base);
        box-shadow: var(--shadow-glass-lg);
    }

    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-tree-chevron,
    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-submenu {
        display: none;
    }
}

@media (min-width: 1025px) and (prefers-reduced-motion: reduce) {
    .glass-sidebar.collapsed { transition: none; }
}

.glass-sidebar.collapsed:not(.is-peeking) .sidebar-bottom {
    padding: 8px;
}

.glass-sidebar.collapsed .sidebar-toggle-btn .toggle-icon-collapse {
    display: none;
}

.glass-sidebar.collapsed .sidebar-toggle-btn .toggle-icon-expand {
    display: block;
}

/* Tooltip no hover quando colapsado */
.glass-sidebar.collapsed .sidebar-link {
    position: relative;
}

.glass-sidebar.collapsed .sidebar-link::after {
    display: none;
}

.sidebar-floating-tooltip {
    position: fixed;
    z-index: 180;
    max-width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--border-glass-strong);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text-primary);
    box-shadow: var(--shadow-glass-lg);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.sidebar-floating-tooltip.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.dark .sidebar-floating-tooltip {
    background: var(--bg-glass-strong);
}

.sidebar-flyout {
    position: fixed;
    z-index: 181;
    width: min(300px, calc(100vw - 88px));
    padding-left: 10px;
}

.sidebar-flyout[hidden] { display: none; }

.sidebar-flyout-panel {
    display: flex;
    flex-direction: column;
    max-height: min(480px, calc(100dvh - 16px));
    overflow: hidden;
    border: 1px solid var(--border-glass-strong);
    border-radius: 12px;
    background: var(--bg-base);
    color: var(--text-primary);
    box-shadow: var(--shadow-glass-lg);
}

.sidebar-flyout-panel > p {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-glass);
    font-size: 13px;
    font-weight: 650;
}

.sidebar-flyout .sidebar-submenu {
    margin: 0;
    padding: 6px;
    border-left: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar-flyout .sidebar-sublink:focus-visible,
.sidebar-flyout .sidebar-subtree-summary:focus-visible {
    outline-offset: -2px;
}

/* ============================================
   HEADER
   ============================================ */
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-currency-balance {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 112px;
    height: 42px;
    padding: 5px 12px 5px 6px;
    border: 1px solid rgba(202, 138, 4, 0.2);
    border-radius: 13px;
    background:
        linear-gradient(135deg, rgba(254, 252, 232, 0.94), rgba(255, 255, 255, 0.78));
    box-shadow: 0 7px 20px rgba(113, 63, 18, 0.08);
    color: var(--text-primary);
    text-decoration: none;
}

.header-currency-logo {
    width: 31px;
    height: 31px;
    flex: 0 0 31px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(113, 63, 18, 0.2);
}

.header-currency-content {
    display: grid;
    gap: 1px;
    min-width: 0;
    line-height: 1;
}

.header-currency-name {
    overflow: hidden;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.header-currency-value {
    color: #854d0e;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.dark .header-currency-balance {
    border-color: rgba(250, 204, 21, 0.2);
    background: linear-gradient(135deg, rgba(66, 50, 13, 0.62), rgba(255, 255, 255, 0.04));
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.18);
}

.dark .header-currency-value {
    color: #fde68a;
}

.header-search {
    position: relative;
}

.header-search input {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 8px 16px 8px 40px;
    color: var(--text-primary);
    font-size: 14px;
    width: 280px;
    outline: none;
    transition: var(--transition);
}

.header-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    width: 320px;
}

.header-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-surface-hover);
    color: var(--accent-text, var(--accent));
}

/* Both icons arrive in the HTML; the prepaint theme class selects the right one. */
.theme-toggle [data-theme-icon="dark"],
.dark .theme-toggle [data-theme-icon="light"] { display: none; }
.dark .theme-toggle [data-theme-icon="dark"] { display: block; }

.phone-whatsapp-link {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    margin-left: auto;
    padding: 0;
    color: var(--success);
    border: 1px solid var(--success);
    background: var(--success-light);
}

.phone-whatsapp-link > svg {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
}

.phone-whatsapp-link:hover {
    color: var(--success);
    background: var(--success-light);
    border-color: var(--success);
}

.phone-whatsapp-link:focus-visible {
    outline: 2px solid var(--success);
    outline-offset: 3px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    overflow: hidden;
    padding: 0;
}

.user-avatar:hover {
    box-shadow: var(--shadow-glow);
}

.user-avatar-has-media {
    background: transparent;
}

.user-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.header-user-name {
    color: var(--text-primary);
}

.impersonation-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(420px, 42vw);
    padding: 6px 8px 6px 12px;
    border: 1px solid rgba(245, 158, 11, 0.32);
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 12px;
    line-height: 1;
    box-shadow: 0 10px 24px rgba(245, 158, 11, 0.12);
}

.impersonation-pill strong {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #7c2d12;
}

.impersonation-pill-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.impersonation-pill-action {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: #c2410c;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.16s ease, transform 0.16s ease;
}

.impersonation-pill-action:hover {
    background: #9a3412;
    transform: translateY(-1px);
}

.user-dropdown-button {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
}

.dark .impersonation-pill {
    border-color: rgba(251, 191, 36, 0.3);
    background: #422006;
    color: #fed7aa;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.dark .impersonation-pill strong {
    color: #ffedd5;
}

.dark .impersonation-pill-action {
    background: #ea580c;
}

.dark .impersonation-pill-action:hover {
    background: #f97316;
}

.user-dropdown {
    position: fixed;
    min-width: 200px;
    padding: 8px 0;
    z-index: 99999;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    background: var(--bg-base);
    border: 1px solid var(--border-glass-strong);
}

.user-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-glass);
}

.user-dropdown-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-dropdown-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.user-dropdown-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
}

.user-dropdown-link:hover {
    background: var(--bg-surface-hover);
}

.user-dropdown-divider {
    border-top: 1px solid var(--border-glass);
    margin: 4px 0;
}

.user-dropdown-link-danger {
    color: var(--danger);
}

/* ============================================
   HAMBURGER (Mobile)
   ============================================ */
.hamburger {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    justify-content: center;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.pagination a {
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
}

.pagination a:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 200px;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.list-loading.is-hidden { display: none; }

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-glass);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   SCROLLBAR CUSTOMIZADA
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-glass-strong);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

@supports (-moz-appearance: none) {
    html, .sidebar-nav {
        scrollbar-width: thin;
        scrollbar-color: var(--border-glass-strong) transparent;
    }

    .sidebar-nav:hover {
        scrollbar-color: var(--text-muted) transparent;
    }
}

/* ============================================
   PAGE TITLE
   ============================================ */
.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: -16px;
    margin-bottom: 24px;
}

/* Supporting copy inside cards and sections; modal subtitles have their own rule. */
.card-description,
.modal-body .card-description {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
}

/* ============================================
   PAGE TABS
   ============================================ */
.page-tabs-card {
    overflow: hidden;
}

.page-tabs-nav {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent-text, var(--accent));
    border-bottom-color: var(--accent);
}

/* ============================================
   FORM HELPERS
   ============================================ */
.is-hidden {
    display: none;
}

.input-uppercase {
    text-transform: uppercase;
}

.social-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.social-label svg {
    flex-shrink: 0;
}

.section-heading-sm {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.section-heading-spaced {
    margin-bottom: 12px;
}

.section-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.loading-text {
    color: var(--text-muted);
    font-size: 13px;
}

.caption-text {
    font-size: 12px;
    color: var(--text-muted);
}

.helper-text {
    color: var(--text-muted);
    font-size: 11px;
}

.table-empty-message {
    color: var(--text-muted);
    padding: 32px 0;
}

.empty-state-illustration {
    opacity: 0.2;
}

.empty-state-title {
    color: var(--text-primary);
}

.empty-state-subtitle {
    color: var(--text-secondary);
}

.empty-state-description {
    color: var(--text-muted);
    max-width: 420px;
}

.counter-text {
    font-size: 12px;
    color: var(--text-muted);
}

.custom-list-settings { grid-column: 1 / -1; min-width: 0; }
.custom-list-settings:hover { background: var(--bg-surface); }
.custom-list-settings h3 { margin: 0 0 8px; font-weight: 700; }
.custom-list-settings .option-card { border-color: var(--border-glass); background: var(--bg-glass); }
.custom-list-settings .option-card-body small { display: block; margin-top: 4px; color: var(--text-muted); line-height: 1.5; }
.custom-list-settings fieldset { padding: 0; margin: 0; min-width: 0; border: 0; }
.custom-list-settings-switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; margin-bottom: 16px; }
.custom-list-settings-switches .option-card { min-width: 0; height: 100%; }
.custom-list-settings-panel { min-width: 0; border: 1px solid var(--border-glass-strong); border-radius: 16px; background: var(--bg-glass); box-shadow: var(--shadow-glass-sm); }
.custom-list-settings-panel.is-hidden { display: none; }
.custom-list-settings-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px; cursor: pointer; list-style: none; }
.custom-list-settings-summary::-webkit-details-marker { display: none; }
.custom-list-settings-summary > strong { min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.custom-list-settings-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; border-radius: 16px; }
.custom-list-settings-disclosure-actions { flex: 0 0 auto; }
.custom-list-settings-disclosure-actions svg { width: 16px; height: 16px; }
.custom-list-settings-collapse { display: none; }
.custom-list-settings-panel[open] > .custom-list-settings-summary { border-bottom: 1px solid var(--border-glass); }
.custom-list-settings-panel[open] .custom-list-settings-expand { display: none; }
.custom-list-settings-panel[open] .custom-list-settings-collapse { display: inline; }
.custom-list-settings-panel[open] .custom-list-settings-disclosure-actions svg { transform: rotate(180deg); }
.custom-list-settings-panel:not([open]) > .custom-list-settings-fields { display: none; }
.custom-list-settings-panel > .custom-list-settings-fields { padding: 16px; }
.custom-list-settings-fields { display: grid; gap: 18px; }
.custom-list-settings-fields.is-hidden { display: none; }
.custom-list-settings-fields .option-card { min-width: 0; }
.custom-list-settings-group { padding: 16px; border: 1px solid var(--border-glass); border-radius: 14px; background: var(--bg-glass); min-width: 0; }
.custom-list-settings-group h4, .custom-list-settings-preview h4 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.custom-list-settings-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.custom-list-settings-options .option-card { height: 100%; }
.custom-list-settings-preview { min-width: 0; padding-top: 8px; }
.custom-list-settings-preview [data-custom-list-preview] { margin-top: 16px; pointer-events: none; }
.custom-list-settings-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }

.modal-content-xs {
    max-width: 420px;
}

.modal-content-sm {
    max-width: 450px;
}

.modal-content-md {
    max-width: 500px;
}

.modal-content-lg {
    max-width: 760px;
}

.btn-ghost-danger {
    color: var(--danger);
}

.btn-ghost-warning {
    color: var(--warning);
}

.section-title-icon {
    vertical-align: -3px;
    margin-right: 6px;
}

.btn-icon-leading {
    vertical-align: -2px;
    margin-right: 4px;
}

/* ============================================
   SORTABLE PHONE ROWS
   ============================================ */
.telefone-row {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    position: relative;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--bg-glass-strong);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.telefone-row.dragging {
    opacity: 0.55;
}

.telefone-row.drop-before,
.telefone-row.drop-after {
    background: var(--bg-hover);
}

.telefone-row .telefone-drag-handle {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: grab;
    border-radius: 8px;
}

.telefone-row .telefone-drag-handle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.telefone-row .telefone-drag-handle:active {
    cursor: grabbing;
}

.phone-sortable-group { align-items: stretch; min-width: 0; }
.phone-touch-sortable .telefone-drag-handle { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.telefone-row .phone-input-group .phone-sortable-group > .telefone-drag-handle {
    align-self: stretch;
    flex: 0 0 36px;
    width: 36px;
    height: auto;
    min-height: 0;
    border: 1px solid var(--border-glass);
    border-radius: 8px 0 0 8px;
    background: var(--bg-glass);
    box-shadow: none;
}
.phone-sortable-group .phone-country { border-left: 0; border-radius: 0; }
.telefone-row .phone-sortable-group > .telefone-drag-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; z-index: 3; }
@media (max-width: 480px) {
    .phone-sortable-group .phone-country-wrap { flex-basis: 64px; min-width: 64px; }
    .phone-sortable-group .phone-country-display { left: 8px; right: 18px; gap: 0; }
    .phone-sortable-group .phone-country-flag { display: none; }
    .phone-sortable-group .phone-input { padding-left: 8px; padding-right: 8px; }
}

.telefone-row .input-group {
    margin-bottom: 0;
}

.telefone-row .phone-input-group {
    width: 280px;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 280px;
}

.telefone-row .telefone-label-input {
    flex: 1 1 180px;
    min-width: 0;
}

.telefone-primary-control {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.telefone-flags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    min-width: 0;
}

.telefone-flags .telefone-primary-control { min-height: 36px; }

.telefone-row .btn-remove-tel {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--danger);
    cursor: pointer;
    border-radius: 6px;
}

.telefone-row .btn-remove-tel:hover {
    background: rgba(239, 68, 68, 0.1);
}

.text-nowrap {
    white-space: nowrap;
}

.text-prewrap {
    white-space: pre-wrap;
}

.text-muted-inline {
    color: var(--text-muted);
}

.text-muted-sm {
    color: var(--text-muted);
    font-size: 13px;
}

.text-muted-xs {
    color: var(--text-muted);
    font-size: 11px;
}

.text-muted-2xs {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.9rem;
}

.text-xs {
    font-size: 0.8rem;
}

.badge-xs {
    font-size: 10px;
}

.action-buttons-inline {
    display: flex;
    gap: 6px;
}

.muted-dash {
    color: var(--text-muted);
}

.inline-code-pill {
    display: inline-block;
    background: var(--bg-surface-hover);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.loading-state-centered {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px 0;
}

.error-state-centered {
    text-align: center;
    padding: 80px 0;
    color: var(--text-muted);
}

.option-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.option-card-start {
    align-items: flex-start;
}

.option-card-disabled {
    opacity: 0.5;
}

.option-card-dimmed {
    opacity: 0.8;
}

.option-card-toggle {
    margin-top: 2px;
}

.option-card-body {
    font-size: 13px;
    color: var(--text-primary);
}

.option-card-meta {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 11px;
}

.permission-grid-root {
    align-items: start;
}

.permission-card {
    align-self: start;
    background: var(--bg-glass-strong);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    overflow: visible;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.permission-card[open] {
    border-color: rgba(214, 0, 0, 0.18);
    box-shadow: var(--shadow-glass-sm);
}

.permission-card-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 15px 16px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.permission-card-summary::-webkit-details-marker {
    display: none;
}

.permission-card-summary:hover {
    background: rgba(148, 163, 184, 0.08);
}

.permission-card-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.permission-card-summary-meta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.permission-card-bulk-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

.permission-card-bulk-toggle .toggle-sm, .toggle.toggle-sm {
    width: 34px;
    height: 20px;
    flex: 0 0 34px;
}

.permission-card-bulk-toggle .toggle-sm .toggle-slider:before, .toggle.toggle-sm .toggle-slider:before {
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
}

.permission-card-bulk-toggle .toggle-sm input:checked + .toggle-slider:before, .toggle.toggle-sm input:checked + .toggle-slider:before {
    transform: translateX(14px);
}

.permission-card-bulk-toggle:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

.permission-card-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform 0.18s ease, color 0.18s ease;
}

.permission-card[open] .permission-card-chevron {
    transform: rotate(180deg);
    color: var(--accent-text, var(--accent));
}

.permission-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px 16px;
    border-top: 1px solid var(--border-glass);
}

.permission-card-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
}

.permission-card-option.is-dependent-disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.permission-card-option.is-dependent-permission {
    margin-left: 18px;
    padding-left: 12px;
    border-left: 2px solid var(--border-glass-strong);
}

.permission-card-option-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.permission-card-option-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.25;
}

.permission-grid-shared-help .permission-card-toggle { display: inline-flex; margin: 0; }
.permission-grid-shared-help .permission-card-option-body { min-width: 0; }
.permission-grid-shared-help .permission-card-option-label > label { margin: 0; cursor: pointer; overflow-wrap: anywhere; }

@media (max-width: 720px) {
    .permission-card-summary {
        flex-wrap: wrap;
    }

    .permission-card-title {
        flex-basis: calc(100% - 74px);
    }

}

.permission-help {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 1px solid var(--border-glass-strong);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.permission-help:hover,
.permission-help:focus {
    background: var(--accent-light);
    color: var(--accent-text, var(--accent));
    outline: none;
}

.permission-help::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 90;
    width: max-content;
    max-width: 260px;
    transform: translateX(-50%) translateY(4px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: #111827;
    color: #ffffff;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    white-space: normal;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.dark .permission-help::after {
    border-color: rgba(0, 0, 0, 0.08);
    background: #f8fafc;
    color: #111827;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
}

.permission-help:hover::after,
.permission-help:focus::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.permission-card-option-meta {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
}

.permission-card-option-meta.is-inherited {
    background: var(--success-light);
    color: var(--success);
}

.permission-card-option-meta.is-extra {
    background: var(--info-light);
    color: var(--info);
}

.permission-card-option-meta.is-blocked {
    background: var(--danger-light);
    color: var(--danger);
}

.permission-card-option-meta.is-empty {
    background: var(--bg-surface-hover);
    color: var(--text-muted);
}

.perfil-permissions-impact-alert {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    width: fit-content;
    max-width: 100%;
    border: 1px solid var(--warning-border, rgba(245, 158, 11, 0.24));
    border-radius: 14px;
    background: var(--warning-light);
    color: var(--warning);
    padding: 10px 13px;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.35;
}

.perfil-permissions-impact-alert svg {
    flex: 0 0 auto;
}

.permission-bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.info-grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.info-item-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.info-item-value {
    font-size: 0.9rem;
}

.section-top-divider {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.section-heading-sm {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.panel-surface {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.85rem;
    overflow-x: auto;
}

.panel-table {
    width: 100%;
    border-collapse: collapse;
}

.panel-table-key {
    padding: 4px 8px;
    font-weight: 500;
    white-space: nowrap;
    vertical-align: top;
}

.panel-table-value {
    padding: 4px 8px;
}

.modal-content-xl {
    max-width: 700px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
/* O Safari/iOS amplia automaticamente campos com fonte menor que 16px. */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
    select,
    textarea,
    [contenteditable="true"],
    .select2-search__field {
        font-size: 16px !important;
    }
}

@media (max-width: 1024px) {
    html.sidebar-mobile-open { overflow: hidden !important; overscroll-behavior: none; }
    body.sidebar-mobile-open { position: fixed !important; top: var(--sidebar-lock-top, 0px) !important; left: 0 !important; right: 0 !important; width: 100% !important; overflow: hidden !important; overscroll-behavior: none; }
    .glass-sidebar {
        height: 100dvh;
        overscroll-behavior: none;
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        background: #ffffff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .sidebar-bottom {
        background: #ffffff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .dark .glass-sidebar,
    .dark .sidebar-bottom {
        background: var(--bg-sidebar);
    }

    .glass-sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-glass-lg);
    }
    .glass-sidebar .sidebar-nav { overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
    .sidebar-backdrop { touch-action: none; overscroll-behavior: none; }

    /* No mobile, ignora estado colapsado */
    .glass-sidebar.collapsed {
        width: var(--sidebar-width) !important;
    }

    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-logo h1,
    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-section-title,
    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-link span:not(.link-icon) {
        display: initial;
    }

    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-link {
        justify-content: flex-start;
        padding: 10px 12px;
        gap: 12px;
    }

    .glass-sidebar.collapsed:not(.is-peeking) .sidebar-logo {
        justify-content: flex-start;
        padding: 0 24px;
    }

    .glass-sidebar.collapsed .sidebar-link::after {
        display: none;
    }

    .sidebar-toggle-btn {
        display: none;
    }

    .glass-header,
    .sidebar-will-collapse .glass-header,
    .glass-sidebar.collapsed ~ .glass-header,
    body.sidebar-collapsed .glass-header {
        left: 0;
    }

    .tab-bar,
    .sidebar-will-collapse .tab-bar,
    .glass-sidebar.collapsed ~ .tab-bar,
    body.sidebar-collapsed .tab-bar {
        left: 0;
    }

    .main-content,
    .sidebar-will-collapse .main-content,
    body.sidebar-collapsed .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .glass-sidebar { z-index: 110; }
    .sidebar-backdrop.active { z-index: 105; }

    .header-search input {
        width: 200px;
    }

    .header-search input:focus {
        width: 240px;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding-left: 16px;
        padding-right: 16px;
    }

    .header-search {
        display: none;
    }

    .header-inner {
        padding: 0 12px;
    }

    .header-right {
        gap: 8px;
    }

    .header-currency-balance {
        min-width: 0;
        padding-right: 9px;
    }

    .header-currency-name {
        display: none;
    }

    .page-title {
        font-size: 24px;
    }
}

/* ============================================
   BACKDROP MOBILE OVERLAY
   ============================================ */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
}

.sidebar-backdrop.active {
    display: block;
}
