:root {
    --bg-body: #0a0a0c;
    --bg-panel: #16181b;
    --bg-card: #1c1d22;
    --border-color: #2b2f36;
    --text-primary: #eaecef;
    --text-secondary: #848e9c;
    --color-primary: #fcd535;
    --color-primary-hover: #e0be2f;
    --color-success: #0ecb81;
    --color-danger: #f6465d;
    --border-radius: 16px;
    /* Increased for Apple look */
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* Apple Native Font Stack */
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    /* App feel */
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 0 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 25px;
    -webkit-app-region: drag;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease;
    padding-left: 20px;
}

.logo:hover {
    transform: scale(1.02);
}

.logo-icon {
    font-size: 24px;
}

.logo-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1;
}

/* Hamburger Menu Styles */
.hamburger-container {
    position: relative;
    margin-left: 10px;
}

.hamburger-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-primary);
}

.hamburger-bar {
    width: 18px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-container.active .hamburger-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-container.active .hamburger-bar:nth-child(2) { opacity: 0; }
.hamburger-container.active .hamburger-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.hamburger-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 220px;
    background: rgba(28, 29, 34, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    display: none;
    flex-direction: column;
    gap: 5px;
    z-index: 10000;
    transform-origin: top right;
    animation: dropdownOpen 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dropdownOpen {
    from { opacity: 0; transform: scale(0.9) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.hamburger-container.active .hamburger-dropdown {
    display: flex;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    transform: translateX(5px);
}

.dropdown-item span:first-child {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.lang-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    flex-direction: row !important;
    align-items: center;
    gap: 16px;
    -webkit-app-region: no-drag;
}

.profile-info-compact {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 5px;
}

.dropdown-item-btn {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-secondary);
    width: 100%;
    text-align: left;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-item-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    transform: translateX(5px);
}

.dropdown-item-btn span {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.view-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: 15px;
    background: var(--border-color);
    padding: 3px;
    border-radius: 8px;
}

.view-toggle .view-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-right: 5px;
    padding-left: 5px;
}

.view-toggle .lang-btn {
    border: none;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 0.95rem;
}

.profile-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    font-size: 0.9rem;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Summary Cards Row */
.summary-cards {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-shrink: 0;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: var(--shadow-subtle);
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-title {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.card-title-row .card-title {
    margin-bottom: 0;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Core Grid: Table (1fr), Chart (280px) */
.core-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    flex: 1;
    overflow: hidden;
    padding-bottom: 20px;
}

/* Panels */
.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

/* Form Styles */
.form-panel {
    overflow-y: auto;
}

.form-panel::-webkit-scrollbar {
    display: none;
}

.form-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-row-grid .form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.helper-text {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 6px;
    opacity: 0.8;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.primary-btn {
    background-color: var(--color-primary);
    color: #0b0e11;
}

.primary-btn:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
}

.secondary-btn {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px dashed var(--border-color);
}
.secondary-btn:hover {
    background-color: rgba(255,255,255,0.05);
    border-color: var(--color-primary);
}

/* OCR Modal Styles */
.ocr-drag-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255,255,255,0.02);
    position: relative;
    overflow: hidden;
}
.ocr-drag-zone:hover, .ocr-drag-zone.dragover {
    border-color: var(--color-primary);
    background: rgba(252, 213, 53, 0.05);
}
.ocr-drag-zone img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    object-fit: contain;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Live indicators & Market Prices */
.live-indicator {
    background-color: rgba(14, 203, 129, 0.15);
    color: var(--color-success);
    font-size: 0.65rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.live-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    background-color: var(--color-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.7;
    }
}

.market-prices {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.market-prices h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 600;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-color);
}

.price-row:last-of-type {
    border-bottom: none;
}

.price-info {
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.crypto-icon-mini {
    width: 20px;
    height: 20px;
    display: inline-flex;
}

.price-info-col {
    display: flex;
    flex-direction: column;
}

.acc-balance {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.sparkline-container {
    width: 60px;
    height: 25px;
}

/* next update section */
.next-update-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.api-attribution a {
    color: var(--color-primary);
    text-decoration: none;
    opacity: 0.8;
}

.api-attribution a:hover {
    text-decoration: underline;
    opacity: 1;
}

.update-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(180deg);
}

.next-update {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 15px;
}

/* Table Area */
.table-scroll-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.table-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.deposits-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.deposits-table th,
.deposits-table td {
    padding: 14px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.deposits-table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    position: sticky;
    top: 0;
    background-color: var(--bg-panel);
    z-index: 10;
}

.sortable {
    cursor: pointer;
    user-select: none;
}

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

.sort-icon {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 4px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--text-secondary);
    opacity: 0.4;
}

.sortable[data-dir="asc"] .sort-icon {
    border-top: none;
    border-bottom: 4px solid var(--color-primary);
    opacity: 1;
}

.sortable[data-dir="desc"] .sort-icon {
    border-top: 4px solid var(--color-primary);
    opacity: 1;
}

.asset-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.delete-btn {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid rgba(246, 70, 93, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: rgba(246, 70, 93, 0.1);
    border-color: var(--color-danger);
}

.empty-state {
    text-align: center;
    padding: 50px 0;
    color: var(--text-secondary);
}

/* Chart */
.chart-container {
    flex: 1;
    position: relative;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Typography Colors */
.text-success {
    color: var(--color-success);
}

.text-danger {
    color: var(--color-danger);
}

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

.font-weight-bold {
    font-weight: 600;
}

.badge {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: 10px;
    vertical-align: middle;
    font-weight: 600;
}

.badge.positive {
    background-color: rgba(14, 203, 129, 0.15);
    color: var(--color-success);
}

.badge.negative {
    background-color: rgba(246, 70, 93, 0.15);
    color: var(--color-danger);
}

.badge.neutral {
    background-color: var(--border-color);
    color: var(--text-secondary);
}

/* Modais */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 20000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ── Alert Cards ──────────────────────────────────────────── */
.alert-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-input, rgba(255,255,255,0.05));
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    gap: 12px;
    transition: border-color 0.2s;
}
.alert-card:hover { border-color: var(--color-primary); }

.alert-card-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}
.alert-card-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.alert-card-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.alert-card-detail strong {
    color: var(--color-primary);
    margin: 0 3px;
}
.alert-card-last {
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.alert-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.alert-toggle-btn,
.alert-delete-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
}
.alert-toggle-btn:hover { background: rgba(252,213,53,0.12); border-color: var(--color-primary); }
.alert-toggle-btn.paused { opacity: 0.5; }
.alert-delete-btn:hover  { background: rgba(246,70,93,0.12);  border-color: #f6465d; }


.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 30px;
    width: 450px;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.welcome-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.modal-body {
    margin: 20px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-body ul {
    padding-left: 20px;
}

.modal-body li {
    margin-bottom: 10px;
}

strong {
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.big-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.history-link {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.history-link:hover {
    color: var(--color-primary);
}

.right-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.right-panel::-webkit-scrollbar {
    display: none;
}


/* Fullscreen P&L Card */
.pl-card-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 10000 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.pl-card-fullscreen .card-title-row {
    margin-bottom: 30px;
}

.pl-card-fullscreen .card-value {
    font-size: 8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pl-card-fullscreen .card-title {
    font-size: 2rem;
}

.pl-card-fullscreen #view-history-link {
    font-size: 1.5rem;
    margin-top: 50px;
}

.pl-card-fullscreen .live-indicator {
    font-size: 1rem;
    padding: 8px 16px;
}

.pl-card-fullscreen #total-pl-pct {
    font-size: 2.5rem;
    padding: 10px 20px;
    margin-left: 0;
}

.pl-card-fullscreen #fullscreen-pl-btn {
    position: absolute;
    top: 30px;
    right: 40px;
    font-size: 3rem !important;
    color: var(--text-primary) !important;
    opacity: 0.7;
    transition: all 0.2s;
}

.pl-card-fullscreen #fullscreen-pl-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Animation for updating numbers */
@keyframes flash-update {
    0% { 
        color: var(--color-primary); 
        text-shadow: 0 0 10px rgba(252, 213, 53, 0.5);
    }
    50% { 
        color: var(--color-primary); 
        text-shadow: 0 0 10px rgba(252, 213, 53, 0.5);
        transform: scale(1.02);
    }
    100% { 
        color: inherit; 
        text-shadow: none;
        transform: scale(1);
    }
}

.value-updated {
    animation: flash-update 1s ease-out;
    display: inline-block;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN SCREEN — Autenticação OTP
   ══════════════════════════════════════════════════════════════ */

/* Remove o overflow:hidden do body para a tela de login funcionar */
body {
    overflow: auto;
}

.login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.4s ease, transform 0.4s ease;
    /* Fundo com padrão sutil */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(252, 213, 53, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(14, 203, 129, 0.03) 0%, transparent 50%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 48px 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.03);
    animation: slideUpIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUpIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Shake quando o código está errado */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15%  { transform: translateX(-8px); }
    30%  { transform: translateX(8px); }
    45%  { transform: translateX(-6px); }
    60%  { transform: translateX(6px); }
    75%  { transform: translateX(-4px); }
    90%  { transform: translateX(4px); }
}
.login-card.shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ── Logo ──────────────────────────────────────────────────── */
.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo-icon {
    font-size: 2.8rem;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 16px rgba(252, 213, 53, 0.3));
}

.login-title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ── Steps ─────────────────────────────────────────────────── */
.login-step {
    display: none;
    flex-direction: column;
    gap: 0;
    animation: fadeStep 0.3s ease both;
}
.login-step.active {
    display: flex;
}

@keyframes fadeStep {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.login-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ── Campo de e-mail ───────────────────────────────────────── */
.login-input-group {
    position: relative;
    margin-bottom: 16px;
}

.login-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    pointer-events: none;
}

.login-input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: var(--bg-body);
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.12);
}
.login-input::placeholder { color: var(--text-secondary); }

/* ── Botão principal ───────────────────────────────────────── */
.login-btn {
    width: 100%;
    padding: 15px;
    background: var(--color-primary);
    color: #0b0e11;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    margin-top: 4px;
    box-shadow: 0 4px 20px rgba(252, 213, 53, 0.25);
}
.login-btn:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(252, 213, 53, 0.35);
}
.login-btn:active  { transform: translateY(0); }
.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── OTP Digit Inputs ──────────────────────────────────────── */
.otp-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin: 8px 0 20px;
}

.otp-digit {
    width: 52px;
    height: 60px;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    background: var(--bg-body);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    caret-color: var(--color-primary);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.otp-digit:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.15);
    transform: scale(1.05);
}
.otp-digit:not(:placeholder-shown) {
    border-color: rgba(252, 213, 53, 0.5);
    color: var(--color-primary);
}

.otp-sep {
    color: var(--border-color);
    font-size: 1.4rem;
    font-weight: 300;
    margin: 0 2px;
    user-select: none;
}

/* ── "Lembrar" checkbox ────────────────────────────────────── */
.login-remember-row {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.login-remember-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.login-remember-label input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ── Ações secundárias ─────────────────────────────────────── */
.login-secondary-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
}

.login-link-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
}
.login-link-btn:hover      { color: var(--color-primary); }
.login-link-btn:disabled   { opacity: 0.4; cursor: default; }

/* ── Mensagem de erro ──────────────────────────────────────── */
.login-error {
    background: rgba(246, 70, 93, 0.1);
    border: 1px solid rgba(246, 70, 93, 0.3);
    color: var(--color-danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 14px;
}

/* ── Rodapé ────────────────────────────────────────────────── */
.login-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 28px;
    opacity: 0.6;
}

/* Hover no perfil (botão de logout) */
.user-profile:hover #profile-name-display {
    color: var(--color-danger);
}
.user-profile:hover .profile-avatar {
    background-color: rgba(246, 70, 93, 0.15);
    color: var(--color-danger);
}

/* Navigation */
.app-nav {
    display: flex;
    gap: 15px;
    margin-right: auto;
    margin-left: 40px;
}

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--color-primary);
    background: rgba(252, 213, 53, 0.1);
}

/* App Sections Visibility */
.app-section {
    display: none;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    overflow-y: auto;
    padding-bottom: 40px;
}

.app-section.active {
    display: flex;
}

/* Daily Reports Styling */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.report-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-subtle);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.report-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.report-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.pattern-badge {
    font-size: 0.7rem;
    background: rgba(14, 203, 129, 0.15);
    color: var(--color-success);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
}

.suggestion-text {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.report-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.report-footer strong {
    color: var(--color-primary);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet (Rewrite v2)
   Foco: Safari iPhone, scroll fluido, touch targets
   ══════════════════════════════════════════════════════════════ */

/* ── Breakpoint: Tablets & Phones (≤768px) ────────────────── */
@media screen and (max-width: 768px) {

    /* ─── CRITICAL: Remove overflow locks ─────────────────── */
    html, body {
        overflow: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .app-container {
        height: auto !important;
        min-height: auto;
        max-width: 100%;
        padding: 0 14px;
        overflow: visible !important;
    }

    .dashboard {
        overflow: visible !important;
        height: auto !important;
        flex: none;
    }

    .app-section {
        overflow: visible !important;
        height: auto !important;
        flex: none;
        padding-bottom: 40px;
    }

    .app-section.active {
        display: flex;
    }

    /* ─── Header / Topbar ─────────────────────────────────── */
    .topbar {
        padding: 14px 0 10px;
        margin-bottom: 14px;
        gap: 8px;
        flex-wrap: nowrap;
        position: sticky;
        top: 0;
        z-index: 1000;
        background: var(--bg-body);
    }

    .logo {
        padding-left: 2px;
        gap: 8px;
        flex-shrink: 0;
    }

    .logo-icon {
        font-size: 18px;
    }

    .logo-text h1 {
        font-size: 1.05rem;
    }

    .logo-text small {
        display: none !important;
    }

    .header-actions {
        gap: 8px;
        flex-shrink: 0;
    }

    .view-toggle {
        margin-right: 0;
        padding: 2px;
        gap: 3px;
    }

    .view-toggle .view-label {
        display: none;
    }

    .view-toggle .lang-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
        min-height: 30px;
    }

    .user-profile {
        gap: 0;
    }

    #profile-name-display {
        display: none;
    }

    .profile-info-compact {
        display: none;
    }

    .profile-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .hamburger-container {
        margin-left: 4px;
    }

    .hamburger-btn {
        width: 34px;
        height: 34px;
    }

    .hamburger-dropdown {
        width: 220px;
        right: 0;
        top: calc(100% + 10px);
    }

    /* ─── Summary Cards ───────────────────────────────────── */
    .summary-cards {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 14px;
    }

    .card {
        padding: 16px;
        border-radius: 12px;
    }

    .card-value {
        font-size: 1.5rem;
    }

    .card-title {
        font-size: 0.82rem;
        margin-bottom: 4px;
    }

    .card-title-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .highlight-card .card-value {
        font-size: 1.6rem;
    }

    .live-indicator {
        font-size: 0.6rem;
        padding: 3px 6px;
    }

    /* ─── Core Grid ───────────────────────────────────────── */
    .core-grid {
        display: flex !important;
        flex-direction: column;
        gap: 14px;
        overflow: visible !important;
        height: auto !important;
        padding-bottom: 40px;
    }

    /* ─── Panels ──────────────────────────────────────────── */
    .panel {
        padding: 14px;
        border-radius: 12px;
        overflow: visible !important;
        height: auto !important;
        flex: none;
    }

    .panel-header {
        margin-bottom: 14px;
    }

    .panel-header h2 {
        font-size: 1rem;
    }

    /* ─── Table Panel ─────────────────────────────────────── */
    .table-panel {
        order: 1;
    }

    .table-panel .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .table-panel .header-actions-group {
        width: 100%;
        display: flex !important;
        gap: 8px !important;
    }

    .table-panel .header-actions-group .btn {
        flex: 1;
        text-align: center;
        padding: 12px 8px !important;
        font-size: 0.8rem !important;
        min-height: 44px;
    }

    /* Table: horizontal scroll on finger swipe */
    .table-scroll-container {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        max-height: none !important;
        flex: none;
        margin: 0 -14px;
        padding: 0 14px;
    }

    .deposits-table {
        font-size: 0.8rem;
        min-width: 620px;
    }

    .deposits-table th,
    .deposits-table td {
        padding: 12px 8px;
        white-space: nowrap;
    }

    .deposits-table th {
        position: static;
    }

    .delete-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
        min-height: 36px;
    }

    /* ─── Right Panel (Charts + Prices) ───────────────────── */
    .right-panel {
        overflow: visible !important;
        order: 2;
        height: auto !important;
    }

    .chart-container {
        min-height: 180px;
        height: 180px !important;
        flex: none !important;
    }

    .market-prices {
        margin-top: 16px;
        padding-top: 16px;
    }

    .market-prices h3 {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }

    .price-row {
        padding: 12px 0;
    }

    .price-info {
        font-size: 0.9rem;
    }

    .acc-balance {
        font-size: 0.72rem;
    }

    .sparkline-container {
        width: 55px;
        height: 22px;
    }

    .next-update-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-top: 12px;
        font-size: 0.72rem;
    }

    /* ─── Reports ─────────────────────────────────────────── */
    .reports-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .report-card {
        padding: 16px;
    }

    #reports-section .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    #reports-section .panel-header > div:last-child {
        width: 100%;
        text-align: left;
    }

    #reports-section .panel-header h2 {
        font-size: 1.2rem !important;
    }

    #reports-section .panel-header p {
        font-size: 0.82rem !important;
    }

    #generate-report-btn {
        width: 100%;
    }

    .suggestion-text {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    /* ─── Modais — Bottom Sheet Style ─────────────────────── */
    .modal-overlay {
        align-items: flex-end;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        padding: 24px 18px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        flex-direction: column;
        gap: 10px;
        padding-top: 16px;
    }

    .modal-footer .btn {
        width: 100% !important;
        padding: 14px !important;
        min-height: 48px;
    }

    /* Form adjustments */
    .form-row-grid {
        grid-template-columns: 1fr;
    }

    .form-group input,
    .form-group select {
        min-height: 48px;
        font-size: 1rem;
    }

    .form-actions {
        flex-direction: column !important;
    }

    .form-actions .btn {
        width: 100% !important;
        min-height: 48px;
    }

    /* ─── Fullscreen P&L (Mobile) ─────────────────────────── */
    .pl-card-fullscreen .card-value {
        font-size: 3rem;
    }

    .pl-card-fullscreen .card-title {
        font-size: 1.1rem;
    }

    .pl-card-fullscreen #total-pl-pct {
        font-size: 1.3rem;
        padding: 6px 12px;
    }

    .pl-card-fullscreen #fullscreen-pl-btn {
        top: 15px;
        right: 15px;
        font-size: 2rem !important;
    }

    .pl-card-fullscreen #view-history-link {
        font-size: 1rem;
        margin-top: 20px;
    }

    /* ─── Login Screen ────────────────────────────────────── */
    .login-screen {
        padding: 16px;
    }

    .login-card {
        margin: 0;
        padding: 32px 24px 28px;
        border-radius: 20px;
        max-width: 100%;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .login-logo-icon {
        font-size: 2.2rem;
    }

    .login-logo {
        margin-bottom: 28px;
    }

    .otp-inputs {
        gap: 6px;
    }

    .otp-digit {
        width: 42px;
        height: 52px;
        font-size: 1.3rem;
    }

    .otp-sep {
        font-size: 1rem;
        margin: 0 1px;
    }

    .login-btn {
        padding: 15px;
        font-size: 1rem;
        min-height: 50px;
    }

    .login-input {
        min-height: 50px;
        font-size: 1rem;
    }

    .login-secondary-actions {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .login-link-btn {
        padding: 8px 0;
        font-size: 0.85rem;
    }

    /* ─── Empty State ─────────────────────────────────────── */
    .empty-state {
        padding: 40px 0 !important;
    }
}

/* ── Breakpoint: Small Phones ≤ 430px (iPhone 14 Pro) ─────── */
@media screen and (max-width: 430px) {

    .app-container {
        padding: 0 10px;
    }

    .topbar {
        padding: 12px 0 8px;
        margin-bottom: 10px;
    }

    .logo-icon {
        font-size: 16px;
    }

    .logo-text h1 {
        font-size: 0.95rem;
    }

    .header-actions {
        gap: 5px;
    }

    .view-toggle {
        border-radius: 6px;
    }

    .view-toggle .lang-btn {
        padding: 5px 8px;
        font-size: 0.72rem;
    }

    .profile-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }

    .hamburger-btn {
        width: 30px;
        height: 30px;
    }

    .hamburger-bar {
        width: 14px;
    }

    /* Summary cards compact */
    .card {
        padding: 14px;
    }

    .card-value {
        font-size: 1.35rem;
    }

    .card-title {
        font-size: 0.78rem;
    }

    /* Core grid */
    .core-grid {
        gap: 12px;
    }

    /* Panel */
    .panel {
        padding: 12px;
    }

    .panel-header h2 {
        font-size: 0.92rem;
    }

    /* Table */
    .deposits-table {
        font-size: 0.75rem;
        min-width: 560px;
    }

    .deposits-table th,
    .deposits-table td {
        padding: 10px 6px;
    }

    .table-panel .header-actions-group .btn {
        font-size: 0.75rem !important;
        padding: 10px 6px !important;
    }

    /* Chart */
    .chart-container {
        min-height: 160px;
        height: 160px !important;
    }

    /* Prices */
    .price-info {
        font-size: 0.82rem;
    }

    .acc-balance {
        font-size: 0.65rem;
    }

    .sparkline-container {
        width: 48px;
        height: 20px;
    }

    /* Modal */
    .modal-content {
        padding: 20px 14px;
        max-height: 92vh;
    }

    /* Login */
    .login-card {
        padding: 28px 18px 24px;
    }

    .login-title {
        font-size: 1.3rem;
    }

    .otp-digit {
        width: 38px;
        height: 46px;
        font-size: 1.15rem;
        border-radius: 8px;
    }

    .otp-inputs {
        gap: 4px;
    }

    .otp-sep {
        margin: 0;
        font-size: 0.9rem;
    }

    /* Report cards */
    .report-card {
        padding: 14px;
    }

    .suggestion-text {
        font-size: 0.88rem;
    }

    .report-footer {
        font-size: 0.78rem;
    }

    /* Reports section header */
    #reports-section .panel-header h2 {
        font-size: 1.1rem !important;
    }
}

/* ── Safe area for notch/dynamic island iPhones ───────────── */
@supports (padding: env(safe-area-inset-top)) {
    @media screen and (max-width: 768px) {
        .topbar {
            padding-top: calc(12px + env(safe-area-inset-top));
        }

        .app-container {
            padding-left: calc(10px + env(safe-area-inset-left));
            padding-right: calc(10px + env(safe-area-inset-right));
        }

        .modal-content {
            padding-bottom: calc(24px + env(safe-area-inset-bottom));
        }

        .login-screen {
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}
