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

:root {
    --bg-canvas: #F9FAFB;
    --bg-surface: #FFFFFF;
    --bg-subtle: #F3F4F6;
    --bg-hover: #ECEEF2;
    --text-main: #111827;
    --text-secondary: #4B5563;
    --text-muted: #6B7280;
    --border-light: #E5E7EB;
    --border-focus: #D1D5DB;
    
    /* Identidade Cloudflare + Apple Precision */
    --cf-orange: #F6821F;
    --cf-orange-soft: rgba(246, 130, 31, 0.1);
    --apple-blue: #0066CC;
    --apple-blue-soft: rgba(0, 102, 204, 0.08);
    --emerald: #059669;
    --emerald-soft: rgba(5, 150, 105, 0.1);
    --amber: #D97706;
    --rose: #E11D48;
    --violet: #7C3AED;

    --radius-xl: 20px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.06), 0 4px 16px -2px rgba(16, 24, 40, 0.04);
    --shadow-elevated: 0 12px 28px -4px rgba(16, 24, 40, 0.08), 0 4px 12px -2px rgba(16, 24, 40, 0.03);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-canvas);
    background-image: radial-gradient(#E5E7EB 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-main);
    line-height: 1.5;
    letter-spacing: -0.011em;
    overflow-x: hidden;
}

/* Top Navigation Estilo Cloudflare Dashboard */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #F6821F 0%, #FBAD41 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 6px rgba(246, 130, 31, 0.25);
}

.brand-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

/* Quick Search Bar (Estilo Ctrl+K Cloudflare) */
.quick-search-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 7px 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: all 0.2s var(--ease-spring);
    min-width: 240px;
}

.quick-search-btn:hover {
    border-color: var(--cf-orange);
    color: var(--text-main);
    box-shadow: 0 0 0 3px var(--cf-orange-soft);
}

.search-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kbd-shortcut {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    padding: 2px 6px;
    color: var(--text-secondary);
}

/* Main Layout */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 36px 24px 80px;
}

/* Breadcrumb & Header Editorial */
.page-header {
    margin-bottom: 28px;
    animation: fadeSlideUp 0.6s var(--ease-out-expo) both;
}

.eyebrow-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--emerald-soft);
    color: var(--emerald);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald);
    animation: pulseDot 2s infinite;
}

.page-title {
    font-size: clamp(1.75rem, 3.5vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-main);
    line-height: 1.15;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 6px;
    max-width: 740px;
}

/* Grid Principal 12 Colunas */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    align-items: start;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 26px;
    box-shadow: var(--shadow-card);
    transition: transform 0.35s var(--ease-spring), box-shadow 0.35s var(--ease-spring), border-color 0.25s ease;
    animation: fadeSlideUp 0.7s var(--ease-out-expo) both;
}

.card:hover {
    box-shadow: var(--shadow-elevated);
}

.col-7 { grid-column: span 7; animation-delay: 0.05s; }
.col-5 { grid-column: span 5; animation-delay: 0.1s; }
.col-4 { grid-column: span 4; animation-delay: 0.15s; }
.col-8 { grid-column: span 8; animation-delay: 0.2s; }
.col-12 { grid-column: span 12; animation-delay: 0.25s; }

/* Segmented Control com Pílula Deslizante Física */
.segmented-wrap {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--bg-subtle);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
    user-select: none;
}

.segmented-glider {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / 3);
    background: var(--bg-surface);
    border-radius: 7px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: transform 0.4s var(--ease-spring);
    z-index: 1;
}

.seg-btn {
    position: relative;
    z-index: 2;
    background: transparent;
    border: none;
    padding: 9px 10px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.seg-btn.active {
    color: var(--text-main);
}

/* Hero Display do Resultado Líquido */
.result-hero {
    background: linear-gradient(180deg, #FFFFFF 0%, #F9FAFB 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 22px;
    position: relative;
    overflow: hidden;
}

.result-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--cf-orange);
}

.result-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.result-label {
    font-size: 0.84rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.effective-badge {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--cf-orange-soft);
    color: var(--cf-orange);
}

.result-number {
    font-size: clamp(2.2rem, 4.5vw, 3.25rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin: 6px 0 4px;
    transition: transform 0.2s var(--ease-spring);
}

.result-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Barra de Distribuição Multicolorida */
.meter-section {
    margin-bottom: 24px;
}

.meter-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.meter-track {
    height: 12px;
    width: 100%;
    background: var(--bg-subtle);
    border-radius: 999px;
    overflow: hidden;
    display: flex;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border-light);
}

.meter-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.55s var(--ease-spring);
}

.fill-net { background: var(--emerald); }
.fill-inss { background: var(--cf-orange); }
.fill-irrf { background: var(--rose); }
.fill-other { background: var(--violet); }

.meter-legend {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.legend-box {
    background: var(--bg-canvas);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.legend-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

/* Tabela de Demonstrativo (Holerite Clean) */
.breakdown-table {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.bd-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    background: var(--bg-surface);
    transition: background 0.15s ease;
}

.bd-row:hover {
    background: var(--bg-canvas);
}

.bd-row:last-child {
    border-bottom: none;
}

.bd-row.bd-total {
    background: var(--bg-subtle);
    font-weight: 700;
}

.bd-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.bd-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.bd-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Painel de Controlos Interativos */
.panel-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.field-block {
    margin-bottom: 18px;
}

.field-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-prefix {
    position: absolute;
    left: 14px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}

.cf-input {
    width: 100%;
    padding: 11px 14px 11px 42px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-canvas);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.2s ease;
    font-variant-numeric: tabular-nums;
}

.cf-input.no-prefix {
    padding-left: 14px;
}

.cf-input:focus {
    background: var(--bg-surface);
    border-color: var(--cf-orange);
    box-shadow: 0 0 0 3px var(--cf-orange-soft);
}

/* Botões de Incremento Rápido (Chips) */
.quick-chips {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.chip-btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.76rem;
    font-weight: 600;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chip-btn:hover {
    background: var(--bg-surface);
    border-color: var(--cf-orange);
    color: var(--cf-orange);
    transform: translateY(-1px);
}

/* Range Slider Customizado */
.cf-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    outline: none;
    margin-top: 12px;
}

.cf-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--cf-orange);
    border: 3px solid #FFFFFF;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: grab;
    transition: transform 0.15s ease;
}

.cf-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Stepper para Dependentes */
.stepper-box {
    display: flex;
    align-items: center;
    background: var(--bg-canvas);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.step-btn {
    width: 42px;
    height: 40px;
    border: none;
    background: var(--bg-subtle);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.step-btn:hover {
    background: var(--border-light);
    color: var(--text-main);
}

.step-input {
    flex: 1;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
}

/* Switch Toggle */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid var(--border-light);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-track {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border-focus);
    transition: 0.3s var(--ease-spring);
    border-radius: 999px;
}

.switch-track:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: 0.3s var(--ease-spring);
    border-radius: 50%;
}

input:checked + .switch-track {
    background-color: var(--cf-orange);
}

input:checked + .switch-track:before {
    transform: translateX(20px);
}

/* Botões de Ação Primário e Secundário */
.actions-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.btn-primary {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid #E06D0A;
    background: linear-gradient(180deg, #F6821F 0%, #E5710E 100%);
    color: #FFFFFF;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 1px 2px rgba(246, 130, 31, 0.3);
    transition: all 0.2s var(--ease-spring);
}

.btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s var(--ease-spring);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--border-focus);
}

/* KPI Mini Cards (Métricas de Valor) */
.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.kpi-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
}

.kpi-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Acordeão de FAQ e Memória de Cálculo */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

details.faq-item {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-canvas);
    padding: 14px 18px;
    transition: all 0.2s ease;
}

details.faq-item[open] {
    background: var(--bg-surface);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-xs);
}

details.faq-item summary {
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

details.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-body {
    margin-top: 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
    border-top: 1px solid var(--border-light);
    padding-top: 10px;
}

/* Pílulas de Salários Vizinhos (Malha de 1.852 Páginas) */
.neighbors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.neighbor-card {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-canvas);
    text-decoration: none;
    transition: all 0.2s var(--ease-spring);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.neighbor-card:hover {
    background: var(--bg-surface);
    border-color: var(--cf-orange);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xs);
}

.nb-gross {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-muted);
}

.nb-net {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

/* Command Palette Modal (Ctrl+K) */
.cmd-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(4px);
    z-index: 900;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.cmd-backdrop.open {
    display: flex;
}

.cmd-modal {
    width: 100%;
    max-width: 540px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.18);
    overflow: hidden;
    animation: modalPop 0.25s var(--ease-spring);
}

.cmd-input-wrap {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    gap: 10px;
}

.cmd-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 0.98rem;
    font-family: inherit;
    color: var(--text-main);
}

.cmd-results {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
}

.cmd-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.88rem;
}

.cmd-item:hover {
    background: var(--bg-subtle);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-main);
    color: #FFFFFF;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: var(--shadow-elevated);
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.35s var(--ease-spring);
    z-index: 999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Responsividade Mobile & Tablet */
@media (max-width: 960px) {
    .col-7, .col-5, .col-4, .col-8 {
        grid-column: span 12;
    }
    .container {
        padding: 20px 16px 60px;
    }
}

@media (max-width: 600px) {
    .meter-legend {
        grid-template-columns: repeat(2, 1fr);
    }
    .quick-search-btn span.search-placeholder {
        display: none;
    }
    .quick-search-btn {
        min-width: auto;
    }
    .actions-group {
        grid-template-columns: 1fr;
    }
}
