/* DESIGN SYSTEM - IMPORT RATEIO */

:root {
    /* Fonts */
    --font-primary: 'Quicksand', system-ui, sans-serif;
    --font-secondary: 'Nunito', system-ui, sans-serif;

    /* Dark Theme Colors - Glass Dourado Original Claude */
    --bg-app: #1a150e; /* Fundo escuro um pouco mais claro (Mocha) */
    --glow-1: rgba(245, 196, 81, 0.24);
    --glow-2: rgba(184, 134, 11, 0.18);
    --glow-3: rgba(255, 255, 255, 0.035);
    
    --bg-card: rgba(255, 255, 255, 0.055);
    --bg-input: rgba(255, 255, 255, 0.10); /* Fundo dos campos ajustado */
    
    --border-color: rgba(245, 196, 81, 0.2);
    --glass-border-strong: rgba(245, 196, 81, 0.34);
    
    --text-primary: #f7ecd8;
    --text-muted: #b8a888;
    --text-faint: #6e6250;

    --primary: #f5c451;
    --primary-hover: #ffd873;
    --primary-glow: rgba(245, 196, 81, 0.16);
    --gradient-brand: linear-gradient(135deg, #ffd873 0%, #b8860b 100%);
    --gradient-text: linear-gradient(135deg, #ffe9a8 0%, #f0b429 100%);
    --on-gradient: #1a1305;

    --secondary: rgba(255, 255, 255, 0.08);
    --secondary-hover: rgba(255, 255, 255, 0.14);
    --secondary-border: rgba(245, 196, 81, 0.22);

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.12);
    --success-border: rgba(52, 211, 153, 0.3);

    --warning: #fb923c;
    --warning-bg: rgba(251, 146, 60, 0.12);
    --warning-border: rgba(251, 146, 60, 0.3);

    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-bg: rgba(248, 113, 113, 0.12);

    --info: #38bdf8;
    --info-bg: rgba(56, 189, 248, 0.1);
    --info-border: rgba(56, 189, 248, 0.3);

    --card-shadow: 0 8px 40px -8px rgba(245, 196, 81, 0.3);
    --input-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.15);

    --border-radius-sm: 12px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --border-radius-full: 9999px;

    --glass-blur: blur(22px) saturate(140%);
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Opções de cores que combinam perfeitamente com o dourado */
body.theme-navy {
    --bg-app: #08111e; /* Azul Escuro Marinho */
}
body.theme-emerald {
    --bg-app: #061c14; /* Verde Esmeralda Escuro */
}
body.theme-wine {
    --bg-app: #1a080a; /* Vinho / Bordô Escuro */
}
body.theme-royal {
    --bg-app: #140b1c; /* Roxo Real Escuro */
}

/* Light Theme Overrides — glass claro sobre fundo marfim com glow dourado suave */
[data-theme="light"] {
    --bg-app: #faf6ec;
    --glow-1: rgba(234, 179, 8, 0.12);
    --glow-2: rgba(146, 101, 10, 0.08);
    --glow-3: rgba(0, 0, 0, 0.015);
    --bg-card: rgba(255, 255, 255, 0.62);
    --bg-input: rgba(255, 255, 255, 0.8);
    --border-color: rgba(180, 130, 20, 0.22);
    --text-primary: #2b2410;
    --text-muted: #6b5d3f;

    --primary: #b8860b;
    --primary-hover: #92650a;
    --primary-glow: rgba(180, 130, 20, 0.12);
    --gradient-brand: linear-gradient(135deg, #eab308 0%, #92650a 100%);
    --on-gradient: #1a1305;

    --secondary: rgba(255, 255, 255, 0.65);
    --secondary-hover: rgba(255, 255, 255, 0.9);
    --secondary-border: rgba(180, 130, 20, 0.28);

    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.1);
    --success-border: rgba(5, 150, 105, 0.25);

    --warning: #ea580c;
    --warning-bg: rgba(234, 88, 12, 0.1);
    --warning-border: rgba(234, 88, 12, 0.25);

    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-bg: rgba(220, 38, 38, 0.08);

    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.08);
    --info-border: rgba(2, 132, 199, 0.25);

    --card-shadow: 0 8px 32px -8px rgba(180, 130, 20, 0.18);
    --input-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.03);
}

/* Reset & Global */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background:
        radial-gradient(ellipse 900px 650px at 8% -8%, var(--glow-1), transparent 60%),
        radial-gradient(ellipse 800px 750px at 108% 15%, var(--glow-2), transparent 60%),
        radial-gradient(ellipse 700px 550px at 45% 115%, var(--glow-3), transparent 60%),
        var(--bg-app);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-secondary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: var(--transition-smooth);
    min-height: 100vh;
}

h1, h2, h3, .card-title, .modal-header h3, .auth-header h2, .nav-logo span, .brand-name {
    font-family: var(--font-primary);
}

/* App Layout */
.app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    padding: 1rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--gradient-brand);
    color: var(--on-gradient);
    border-radius: var(--border-radius-md);
    box-shadow: 0 6px 18px -4px rgba(180, 130, 20, 0.5);
}

.logo-area h1 {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

.logo-area .subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-family: var(--font-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--gradient-brand);
    color: var(--on-gradient);
    border-color: transparent;
    box-shadow: 0 8px 22px -6px rgba(180, 130, 20, 0.55);
}

.btn-primary:hover {
    box-shadow: 0 12px 28px -6px rgba(180, 130, 20, 0.7);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

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

.btn-warning {
    background-color: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning);
    box-shadow: 0 4px 14px 0 var(--warning-bg);
}

.btn-warning:hover {
    background-color: var(--warning);
    color: #ffffff;
}

.btn-danger {
    background-color: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: #ffffff;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--border-radius-sm);
}

.btn-block {
    width: 100%;
}

.theme-toggle button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.theme-toggle button:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background-color: var(--secondary);
}

/* Main Layout Grid */
.app-main {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .app-main {
        /* minmax(0, 1fr) instead of 1fr — a bare 1fr track has an implicit
           min-width:auto, so it grows to fit non-shrinking content (e.g. the
           radio-tile-group below) instead of respecting the viewport width. */
        grid-template-columns: minmax(0, 1fr);
    }
}

.app-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.app-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    transition: var(--transition-smooth);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.card-title svg {
    width: 28px;
    height: 28px;
    padding: 6px;
    box-sizing: border-box;
    background: var(--gradient-brand);
    color: var(--on-gradient);
    border-radius: 10px;
    flex-shrink: 0;
}

.card-header-with-badge, .card-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

/* Home / Painel Inicial — quick-launch cards */
.home-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .home-quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 580px) {
    .home-quick-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.home-quick-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.home-quick-card:hover {
    border-color: var(--glass-border-strong);
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -8px rgba(180, 130, 20, 0.35);
}

.home-quick-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--gradient-brand);
    color: var(--on-gradient);
    border-radius: var(--border-radius-md);
    box-shadow: 0 6px 18px -4px rgba(180, 130, 20, 0.5);
    flex-shrink: 0;
}

.home-quick-text h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.home-quick-text p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.card-header-with-badge .card-title, .card-header-actions .card-title {
    margin-bottom: 0;
}

.badge {
    background-color: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(245, 196, 81, 0.2);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius-full);
}

/* Form Controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--input-shadow);
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Helper Text */
.helper-text {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Grid Utilities */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .grid-2, .grid-3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Input Prefix Decorator */
.input-prefix-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}

.input-prefix-container .form-control {
    padding-left: 2.75rem;
}

/* Custom Weight Input Layout */
.weight-input-container {
    display: grid;
    grid-template-columns: 1fr 70px;
    gap: 0.5rem;
}

.weight-unit-select {
    padding: 0.75rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.weight-unit-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Toggle Switch Component */
.label-with-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.label-with-toggle label {
    margin-bottom: 0;
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    gap: 0.35rem;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: relative;
    width: 32px;
    height: 18px;
    background-color: var(--border-color);
    border-radius: var(--border-radius-full);
    transition: var(--transition-smooth);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.toggle-switch input:checked + .slider {
    background-color: var(--primary);
}

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

.toggle-text {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Radio Tiles Component */
.radio-tile-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.radio-tile {
    position: relative;
    cursor: pointer;
}

.radio-tile input {
    position: absolute;
    opacity: 0;
}

.tile-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
}

.tile-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tile-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.2;
}

.radio-tile input:checked + .tile-content {
    border-color: var(--primary);
    background-color: var(--primary-glow);
    box-shadow: 0 0 0 2px var(--primary);
}

/* Segmented Toggle (Simplificado/Completo, etc.) */
.tax-mode-toggle {
    display: flex;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 3px;
    gap: 3px;
}

.radio-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.48rem 0;
    font-family: var(--font-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: 9px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.radio-label input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-label:has(input:checked) {
    background: var(--gradient-brand);
    color: var(--on-gradient);
}

/* Product Form Row Setup */
.product-form {
    display: grid;
    grid-template-columns: 2.2fr 0.8fr 1.2fr 1.5fr 1.5fr auto;
    gap: 1rem;
    align-items: end;
}

@media (max-width: 900px) {
    .product-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .name-field {
        grid-column: span 2;
    }
    .add-button-group {
        grid-column: span 2;
    }
}

/* Effective Rate Display */
.effective-rate-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding: 0.8rem 0.9rem;
    background: linear-gradient(120deg, rgba(234, 179, 8, 0.14), rgba(146, 101, 10, 0.08));
    border: 1px solid var(--secondary-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
}

.effective-rate-display span {
    font-weight: 700;
    color: var(--text-muted);
}

.effective-rate-display strong {
    font-family: var(--font-secondary);
    font-size: 1.05rem;
    font-weight: 800;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Taxation badges in tables */
.badge-taxable {
    background-color: rgba(245, 196, 81, 0.1);
    color: var(--primary);
    border: 1px solid rgba(245, 196, 81, 0.3);
}

.badge-exempt-books {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-exempt-meds {
    background-color: rgba(6, 182, 212, 0.1);
    color: var(--info);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Tables Styling */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

th, td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-input);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

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

tbody tr {
    transition: var(--transition-smooth);
}

tbody tr:hover {
    background-color: rgba(245, 196, 81, 0.03);
}

tfoot tr {
    background-color: var(--bg-input);
    font-weight: 700;
    color: var(--text-primary);
}

tfoot th, tfoot td {
    border-top: 2px solid var(--border-color);
    padding: 1rem;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.empty-state {
    padding: 3rem 1rem !important;
    color: var(--text-muted);
}

.empty-icon {
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-weight: 600;
    font-size: 1rem;
}

.empty-state .small {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    font-weight: 400;
}

/* Actions Column Buttons */
.btn-icon-danger {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-danger:hover {
    background-color: var(--danger-bg);
}

.btn-icon-edit {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-edit:hover {
    background-color: var(--primary-glow);
}

/* Results KPI Dashboard */
.results-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .results-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 580px) {
    .results-kpi-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.kpi-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: auto;
    height: 4px;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0.35rem 0;
    line-height: 1.2;
}

.kpi-sub {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* KPI Accent Colors */
.info-card::before { background-color: var(--info); }
.secondary-card::before { background-color: var(--secondary-border); }
.warning-card::before { background-color: var(--warning); }
.primary-card::before { background: var(--gradient-brand); }
.success-card::before { background-color: var(--success); }

.info-card .kpi-value { color: var(--info); }
.warning-card .kpi-value { color: var(--warning); }
.primary-card .kpi-value { color: var(--primary); }

/* Results Table Details */
.highlight-col {
    background-color: rgba(245, 196, 81, 0.04);
    font-weight: 700;
    color: var(--primary);
}

.table-results th.highlight-col {
    background-color: rgba(245, 196, 81, 0.1);
}

.multiplier-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: var(--border-radius-sm);
}

.multiplier-badge.low {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.multiplier-badge.mid {
    background-color: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

.multiplier-badge.high {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Charts Card Custom Setup */
.grid-2-desktop {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (max-width: 900px) {
    .grid-2-desktop {
        grid-template-columns: minmax(0, 1fr);
    }
}

.donut-chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    min-height: 220px;
}

@media (max-width: 500px) {
    .donut-chart-container {
        flex-direction: column;
        gap: 1rem;
    }
}

.custom-donut-chart {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.custom-donut-chart svg {
    transform: rotate(-90deg);
}

.donut-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-center-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    display: block;
}

.donut-center-lbl {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
}

.legend-label-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

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

.legend-value {
    color: var(--text-primary);
}

/* Horizontal Cost Distribution Stacked Bars */
.bars-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 0.5rem 0;
}

.bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 700;
}

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

.bar-value {
    color: var(--primary);
}

.bar-value .original {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: line-through;
    margin-right: 0.35rem;
}

.stacked-progress-bar {
    height: 14px;
    border-radius: var(--border-radius-full);
    background-color: var(--bg-input);
    display: flex;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

.progress-segment {
    height: 100%;
    transition: var(--transition-smooth);
    position: relative;
}

.progress-segment:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #0f172a;
    color: #ffffff;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* Color codes for items */
.color-product { background-color: #6366f1; } /* Blue/Indigo */
.color-freight { background-color: #a855f7; } /* Purple */
.color-insurance { background-color: #ec4899; } /* Pink */
.color-fees { background-color: #14b8a6; } /* Teal */
.color-taxes { background-color: #f59e0b; } /* Amber */

/* Footer */
.app-footer-info {
    margin-top: 2rem;
    padding: 1.5rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.disclaimer {
    max-width: 800px;
    margin: 0 auto;
    opacity: 0.7;
    line-height: 1.4;
}

/* Utilitários Hidden */
.hidden {
    display: none !important;
}

/* Responsive Table Wrapper Fix */
@media (max-width: 768px) {
    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* Print Styling */
@media print {
    body {
        background-color: white !important;
        color: black !important;
        font-size: 10pt;
    }
    .app-container {
        padding: 0;
        max-width: 100%;
    }
    .app-header, 
    .app-sidebar, 
    .product-entry-card, 
    .header-actions,
    .btn,
    .theme-toggle,
    .empty-state-row,
    th:last-child, 
    td:last-child {
        display: none !important;
    }
    .app-main {
        display: block;
    }
    .app-content {
        width: 100% !important;
    }
    .card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin-bottom: 2rem;
    }
    .results-kpi-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.5rem !important;
        border-bottom: 2px solid #ccc;
        padding-bottom: 1rem;
    }
    .kpi-card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
    .kpi-card::before {
        display: none;
    }
    .kpi-value {
        font-size: 1.2rem !important;
        color: black !important;
    }
    .highlight-col {
        background-color: transparent !important;
        color: black !important;
        font-weight: bold;
    }
    .multiplier-badge {
        border: none !important;
        background: transparent !important;
        color: black !important;
        font-weight: bold !important;
    }
    table {
        border-collapse: collapse;
        width: 100% !important;
    }
    th, td {
        border-bottom: 1px solid #ddd !important;
        color: black !important;
    }
    th {
        background-color: #f5f5f5 !important;
    }
    .grid-2-desktop {
        grid-template-columns: 1fr !important;
    }
    .chart-card {
        page-break-inside: avoid;
    }
}

/* ==========================================
   AUTHENTICATION SCREEN STYLES
   ========================================== */

.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 900px 700px at 12% 15%, rgba(245, 196, 81, 0.14), transparent 60%),
        radial-gradient(ellipse 700px 600px at 90% 85%, rgba(184, 134, 11, 0.1), transparent 60%),
        rgb(9, 7, 4);
    z-index: 9999;
    padding: 1.5rem;
    overflow-y: auto;
    transition: var(--transition-smooth);
}

.auth-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.25rem 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
}

[data-theme="light"] .auth-screen {
    background:
        radial-gradient(ellipse 900px 700px at 12% 15%, rgba(234, 179, 8, 0.14), transparent 60%),
        radial-gradient(ellipse 700px 600px at 90% 85%, rgba(146, 101, 10, 0.1), transparent 60%),
        rgb(250, 246, 236);
}

[data-theme="light"] .auth-card {
    background: rgba(255, 255, 255, 0.68);
    box-shadow: 0 15px 35px rgba(180, 130, 20, 0.12);
    border-color: var(--border-color);
}

/* ==========================================
   LOGIN SCREEN — split art panel
   Intentionally always light, regardless of the user's dark/light
   preference for the rest of the app (the login screen is the same
   for every visitor before they're authenticated).
   ========================================== */
#auth-container.auth-screen {
    --bg-app: #faf6ec;
    --bg-input: rgba(255, 255, 255, 0.8);
    --border-color: rgba(180, 130, 20, 0.22);
    --text-primary: #2b2410;
    --text-muted: #6b5d3f;
    --primary: #b8860b;
    --primary-hover: #92650a;
    --primary-glow: rgba(180, 130, 20, 0.12);
    --gradient-brand: linear-gradient(135deg, #eab308 0%, #92650a 100%);
    --secondary: rgba(255, 255, 255, 0.65);
    --secondary-hover: rgba(255, 255, 255, 0.9);
    --secondary-border: rgba(180, 130, 20, 0.28);

    background:
        radial-gradient(ellipse 900px 700px at 12% 15%, rgba(234, 179, 8, 0.14), transparent 60%),
        radial-gradient(ellipse 700px 600px at 90% 85%, rgba(146, 101, 10, 0.1), transparent 60%),
        rgb(250, 246, 236);
    align-items: stretch;
    padding: 0;
}

#auth-container .auth-card {
    background: rgba(255, 255, 255, 0.68);
    box-shadow: 0 15px 35px rgba(180, 130, 20, 0.12);
}

#auth-container .auth-split {
    display: flex;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    align-items: stretch;
}

#auth-container .auth-art-half {
    flex: 0 0 46%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-height: 100vh;
}

#auth-container .auth-art-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
}

#auth-container .auth-logo-wrap {
    position: relative;
    z-index: 1;
    width: 66%;
    max-width: 320px;
}

#auth-container .auth-logo-wrap canvas {
    width: 100%;
    display: block;
    filter: drop-shadow(0 18px 40px rgba(43, 36, 16, 0.28));
}

#auth-container .auth-art-copy {
    position: absolute;
    left: 2rem;
    right: 2rem;
    bottom: 2.25rem;
    z-index: 1;
}

#auth-container .auth-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #92650a;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

#auth-container .auth-art-copy h4 {
    font-family: var(--font-primary);
    color: #2b2410;
    font-size: 1.15rem;
    line-height: 1.4;
    margin: 0;
    font-weight: 700;
}

#auth-container .auth-form-half {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}

@media (max-width: 820px) {
    #auth-container .auth-split {
        flex-direction: column;
    }
    #auth-container .auth-art-half {
        flex: 0 0 auto;
        min-height: 0;
        padding: 2.5rem 1.5rem 2rem;
    }
    #auth-container .auth-logo-wrap {
        width: 44%;
        max-width: 200px;
    }
    #auth-container .auth-art-copy {
        position: static;
        margin-top: 1.25rem;
        text-align: center;
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

.auth-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    text-align: center;
    border-bottom: 2px solid transparent;
    transition: var(--transition-smooth);
}

.auth-tab:hover {
    color: var(--text-primary);
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

.auth-alert.error {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-alert.success {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

/* User Profile Badge Header */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.75rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--primary-glow);
    color: var(--primary);
}

#user-display-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
}

.btn-logout:hover {
    color: var(--danger);
    background-color: var(--danger-bg);
}

@media print {
    .auth-screen {
        display: none !important;
    }
}

/* ==========================================
   TRIAL & PAYWALL STYLES
   ========================================== */

/* Trial Banner */
.trial-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(90deg, rgba(245, 196, 81, 0.16) 0%, rgba(184, 134, 11, 0.12) 100%);
    border-bottom: 1px solid var(--border-color);
    animation: slideDown 0.4s ease;
    gap: 1rem;
}

[data-theme="light"] .trial-banner {
    background: linear-gradient(90deg, rgba(234, 179, 8, 0.1) 0%, rgba(146, 101, 10, 0.08) 100%);
    border-bottom-color: var(--border-color);
}

.trial-banner-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.trial-banner-content svg {
    color: var(--primary);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

/* Paywall Cards Specifics */
.paywall-card {
    text-align: center;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.paywall-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--primary-glow);
    color: var(--primary);
    margin-bottom: 1.5rem;
    animation: pulseGlow 2s infinite;
}

.pricing-card-details {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    width: 100%;
    padding: 1.5rem;
    margin-bottom: 1.75rem;
    position: relative;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pricing-badge {
    position: absolute;
    top: -10px;
    right: 1.5rem;
    background: var(--gradient-brand);
    color: var(--on-gradient);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.plan-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
    margin: 0.25rem 0;
}

.plan-price .currency {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.plan-price .amount {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.plan-price .period {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feature-check {
    color: var(--success);
    flex-shrink: 0;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(4, 8, 15, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 440px;
    padding: 2rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    position: relative;
}

[data-theme="light"] .modal-card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: 0 15px 35px rgba(180, 130, 20, 0.14);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

/* Payment Tabs & Panels */
.payment-tabs {
    display: flex;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    gap: 0.25rem;
}

.payment-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
}

.payment-tab.active {
    background: var(--gradient-brand);
    color: var(--on-gradient);
}

.payment-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.payment-instruction {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.pix-qr-container {
    display: flex;
    justify-content: center;
    margin: 0.5rem 0;
}

.mock-qr-code {
    width: 160px;
    height: 160px;
    background-color: white;
    padding: 0.75rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Generates a fake premium QR code pattern */
.qr-pattern {
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(black 30%, transparent 31%),
        radial-gradient(black 30%, transparent 31%),
        linear-gradient(45deg, transparent 46%, black 46%, black 54%, transparent 54%),
        linear-gradient(-45deg, transparent 46%, black 46%, black 54%, transparent 54%);
    background-size: 20px 20px, 12px 12px, 8px 8px, 8px 8px;
    background-position: 0 0, 4px 4px, 0 0, 0 0;
    opacity: 0.85;
}

/* Payment Processing Loading overlay inside modal */
.payment-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
}

[data-theme="light"] .payment-loading {
    background-color: white;
}

.payment-loading p {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3.5px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

/* Animations */
@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

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

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(245, 196, 81, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(245, 196, 81, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 196, 81, 0); }
}

/* Dollar Ticker Bar Styles */
.dollar-ticker-bar {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 0.65rem 2rem;
    transition: var(--transition-smooth);
}

.ticker-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.ticker-left, .ticker-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ticker-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ticker-value {
    font-family: var(--font-secondary);
    font-size: 1.1rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ticker-change {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.ticker-change.up {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ticker-change.down {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.ticker-trend-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ticker-sparkline {
    width: 120px;
    height: 30px;
    display: flex;
    align-items: center;
}

@media (max-width: 768px) {
    .dollar-ticker-bar {
        padding: 0.5rem 1.25rem;
    }
    .ticker-right {
        display: none; /* Oculta a tendência gráfica em telas pequenas */
    }
    .ticker-container {
        justify-content: center;
        gap: 0.5rem;
    }
}

/* Navigation Sidebar Layout */
.nav-sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 2rem);
    position: sticky;
    top: 1rem;
    padding: 1.5rem 1rem;
    z-index: 100;
    transition: var(--transition-smooth);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.nav-logo .logo-icon {
    background: var(--gradient-brand);
    color: var(--on-gradient);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px -4px rgba(180, 130, 20, 0.5);
}

.nav-logo span {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Hamburger toggle: only shown on mobile (see media query below) */
.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    background: var(--secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-nav-toggle .icon-close {
    display: none;
}
.mobile-nav-toggle.active .icon-burger {
    display: none;
}
.mobile-nav-toggle.active .icon-close {
    display: block;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    overflow-y: auto;
}

.nav-eyebrow {
    font-family: var(--font-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.7;
    padding: 0.7rem 0.85rem 0.35rem;
}

.nav-eyebrow:first-child {
    padding-top: 0;
}

.nav-item {
    width: 100%;
    background: none;
    border: none;
    padding: 0.75rem 0.85rem;
    border-radius: var(--border-radius-md);
    color: var(--text-muted);
    font-family: var(--font-secondary);
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
    position: relative;
}

.nav-item svg {
    color: var(--text-muted);
    opacity: 0.75;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.nav-item:hover {
    background-color: var(--secondary);
    color: var(--text-primary);
}

.nav-item:hover svg {
    opacity: 1;
}

.nav-item.active {
    background: var(--gradient-brand);
    color: #1a1305;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 6px 20px -6px rgba(180, 130, 20, 0.55);
    font-weight: 700;
}

.nav-item.active svg {
    color: #1a1305;
    opacity: 1;
}

/* Nav Dropdowns */
.nav-dropdown-group {
    display: flex;
    flex-direction: column;
}

.nav-item .chevron {
    margin-left: auto;
    color: var(--text-muted);
    opacity: 0.6;
    transition: transform 0.25s ease;
}

.nav-dropdown-group.open .chevron {
    transform: rotate(180deg);
}

.nav-dropdown-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-left: 1.75rem;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

.nav-dropdown-items.hidden {
    display: none !important;
}

.nav-subitem {
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    font-family: var(--font-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.nav-subitem:hover {
    color: var(--text-primary);
    background-color: var(--secondary);
}

.nav-subitem.active {
    color: var(--primary);
    font-weight: 700;
    background-color: var(--primary-glow);
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    min-width: 0;
    overflow-y: auto;
    height: calc(100vh - 2rem);
}

/* View Panel System */
.view-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

.view-panel.hidden {
    display: none !important;
}

/* Documents Styling (A4 printable area) */
.document-preview-a4 {
    background: white;
    color: #0f172a;
    width: 100%;
    min-height: 297mm;
    padding: 2.5rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin: 0 auto;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

[data-theme="dark"] .document-preview-a4 {
    background: white;
    color: #0f172a;
}

.table-doc {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table-doc th, .table-doc td {
    border: 1px solid #e2e8f0;
    padding: 0.6rem 0.8rem;
    font-size: 0.75rem;
}

.table-doc th {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
}

/* Print CSS Stylesheet */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .nav-sidebar, 
    .app-header, 
    .dollar-ticker-bar, 
    .trial-banner, 
    .app-footer-info,
    .config-card,
    .results-card > *:not(#print-area-proforma):not(#print-area-commercial):not(#print-area-packing) {
        display: none !important;
    }

    .main-content {
        padding: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .document-preview-a4 {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        position: absolute;
        left: 0;
        top: 0;
        visibility: visible !important;
    }

    .document-preview-a4 * {
        visibility: visible !important;
    }

    .photo-cell-uploader {
        border: none !important;
        background: transparent !important;
    }

    .photo-cell-uploader svg {
        display: none !important;
    }
}

/* Responsiveness for nav sidebar */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .nav-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1rem;
    }
    .nav-logo {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }
    .mobile-nav-toggle {
        display: flex;
    }
    /* Collapsed by default on mobile — tapping the hamburger reveals it as a
       full-width dropdown list instead of dumping every nav item above the
       page content. Bigger rows (min 48px tall) are easier to tap than the
       old wrapped pill row. */
    .nav-menu {
        display: none;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.25rem;
        width: 100%;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
        max-height: 70vh;
        overflow-y: auto;
    }
    .nav-menu.nav-menu-open {
        display: flex;
    }
    .nav-item {
        width: 100%;
        min-height: 48px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    .nav-subitem {
        min-height: 44px;
        padding: 0.7rem 0.85rem;
    }
    .main-content {
        max-width: 100%;
        padding: 1rem;
        height: auto;
    }
    /* Both dropdown groups (Documentações/Cadastros) render permanently expanded —
       keep the items in normal flow instead of position:absolute, otherwise two
       open groups land on the same coordinates and cover each other's links. */
    .nav-dropdown-group {
        flex: 1 1 100%;
        width: 100%;
    }
    .nav-dropdown-items {
        background-color: var(--bg-card);
        border: 1px solid var(--border-color);
        padding: 0.5rem;
        border-radius: var(--border-radius-md);
    }

    /* .header-actions holds 5+ buttons/badges in a single nowrap flex row —
       fine on desktop, but it overflows the viewport well past its own box
       on phones/tablets since nothing here was allowed to wrap. */
    .app-header {
        flex-wrap: wrap;
        row-gap: 0.75rem;
    }
    .header-actions {
        flex-wrap: wrap;
        width: 100%;
    }
}

/* Brand logo micro-animations */
.nav-logo img, .logo-area img {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.nav-logo:hover img, .logo-area:hover img {
    transform: scale(1.08) rotate(-3deg);
}
.auth-header img {
    animation: floatLogo 4s ease-in-out infinite;
}
@keyframes floatLogo {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Currency Pair Block */
.currency-pair-block {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background-color: var(--bg-input);
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.currency-pair-block:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.currency-pair-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.85rem 0.55rem;
    min-width: 0;
}

.currency-pair-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    white-space: nowrap;
}

.currency-pair-control {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    padding: 0;
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
}

.currency-pair-control:focus {
    outline: none;
    box-shadow: none;
}

.currency-pair-control option {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.currency-pair-divider {
    width: 1px;
    background-color: var(--border-color);
    flex-shrink: 0;
    margin: 0.5rem 0;
}

/* =============================================
   VIABILIDADE MODULE (Previsibilidade de Custo)
   ============================================= */

.viab-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.viab-kpi-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.viab-kpi-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viab-kpi-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Form grid used by the Simplificada / Formal calculators */
.viab-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
}

.viab-span-2 {
    grid-column: span 2;
}

/* Responsive */
@media (max-width: 1100px) {
    .viab-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .viab-kpi-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .viab-form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .viab-span-2 {
        grid-column: span 1;
    }
}

/* .results-tab-bar has no wrap, and 3 long labels (Importação Simplificada /
   Importação Formal / Comparação de Mercado) overflow narrow screens. */
@media (max-width: 640px) {
    .results-tab-bar {
        flex-wrap: wrap;
    }
    .results-tab-btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.8rem;
    }
}

/* RESULTS TABS AND NCM PREVIEW FOR FORMAL IMPORT */
.results-tab-bar {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
}

.results-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-smooth);
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

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

.results-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content-panel.hidden {
    display: none !important;
}

.ncm-preview {
    padding: 0.75rem 1rem;
    background-color: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-color);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ncm-preview.success {
    border-color: rgba(16, 185, 129, 0.4);
    background-color: rgba(16, 185, 129, 0.04);
}

.ncm-preview.warning {
    border-color: rgba(245, 158, 11, 0.4);
    background-color: rgba(245, 158, 11, 0.04);
}

.ncm-preview.error {
    border-color: rgba(239, 68, 68, 0.4);
    background-color: rgba(239, 68, 68, 0.04);
}

.ncm-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-weight: 700;
    border-radius: 4px;
    font-size: 0.7rem;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
}


