/* Global Reset & Design Tokens */
:root {
    --bg-main: #060913;
    --bg-card: rgba(13, 20, 38, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(59, 130, 246, 0.15);
    
    --text-main: #E2E8F0;
    --text-muted: #94A3B8;
    --text-dark: #64748B;
    
    --color-primary: #3B82F6;
    --color-primary-hover: #2563EB;
    --color-success: #10B981;
    --color-success-hover: #059669;
    --color-gold: #F59E0B;
    --color-gold-hover: #D97706;
    --color-red: #EF4444;
    --color-red-hover: #DC2626;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
    
    --font-heading: 'Outfit', 'Sarabun', sans-serif;
    --font-body: 'Inter', 'Sarabun', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 50% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(245, 158, 11, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
    font-weight: 600;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* App Container Layout */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
}

/* Main Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    z-index: 10;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.header-brand h1 {
    font-size: 20px;
    line-height: 1.2;
    background: linear-gradient(to right, #ffffff, #94A3B8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub-brand {
    font-size: 11px;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: block;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.tab-btn svg {
    opacity: 0.7;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: #ffffff;
    background: var(--color-primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.tab-btn.active svg {
    opacity: 1;
}

/* Header Status */
.header-status {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 30px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
}

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

.sync-indicator.online .indicator-dot {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}

.sync-indicator.offline .indicator-dot {
    background-color: var(--text-dark);
}

.sync-indicator.error .indicator-dot {
    background-color: var(--color-red);
    box-shadow: 0 0 8px var(--color-red);
}

/* Content Area */
.main-content {
    flex-grow: 1;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-pane.active {
    display: block;
}

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

/* Summary Grid Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--text-dark);
}

.total-networth::before {
    background: linear-gradient(to bottom, var(--color-primary), #60A5FA);
}

.total-profit-loss::before {
    background: linear-gradient(to bottom, var(--color-success), #34D399);
}

.cash-balances::before {
    background: linear-gradient(to bottom, #818CF8, #A78BFA);
}

.dividend-summary::before {
    background: linear-gradient(to bottom, var(--color-gold), #FBBF24);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    margin: 8px 0;
    letter-spacing: -0.01em;
}

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

.cash-row {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
    font-size: 13px;
}

.cash-row strong {
    font-family: var(--font-heading);
    color: #ffffff;
}

/* Market Prices Bar */
.market-prices-bar {
    margin-bottom: 24px;
    padding: 16px 24px;
}

.market-prices-bar h3 {
    font-size: 13px;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.prices-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.price-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

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

.price-val {
    font-family: var(--font-heading);
    font-weight: 600;
    color: #ffffff;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.chart-container h3 {
    font-size: 16px;
    margin-bottom: 20px;
    font-weight: 600;
    color: #ffffff;
}

.chart-content {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 24px;
}

.canvas-wrapper {
    position: relative;
    max-width: 240px;
    max-height: 240px;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

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

.legend-label {
    flex-grow: 1;
}

.legend-value {
    font-family: var(--font-heading);
    font-weight: 600;
    color: #ffffff;
}

/* Data Tables */
.asset-breakdown-card h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.data-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Forms */
.transaction-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.form-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.form-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 500;
    padding: 8px 16px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.form-tab-btn:hover {
    color: var(--text-main);
}

.form-tab-btn.active {
    color: var(--color-primary);
}

.form-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary);
}

.sub-form {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.sub-form.active {
    display: flex;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

input, select, textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 14px;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
    background: rgba(0, 0, 0, 0.4);
}

/* Buttons */
.btn {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

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

.btn-success:hover {
    background: var(--color-success-hover);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

.btn-gold:hover {
    background: var(--color-gold-hover);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

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

.btn-red:hover {
    background: var(--color-red-hover);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--text-dark);
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: var(--text-muted);
    color: #ffffff;
}

.btn-block {
    width: 100%;
}

.btn-icon-only {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

/* Badges */
.badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: var(--color-primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

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

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

.badge-gold {
    background: rgba(245, 158, 11, 0.2);
    color: var(--color-gold);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Instructions card list */
.instructions-card h3 {
    margin-bottom: 12px;
}

.instructions-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.tips-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    list-style: none;
    font-size: 13px;
    color: var(--text-muted);
}

.tips-list li {
    position: relative;
    padding-left: 20px;
}

.tips-list li::before {
    content: '✦';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--color-primary);
}

.tips-list code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-family: monospace;
    color: var(--color-success);
}

/* Passcode Gate Screen */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.95);
    backdrop-filter: blur(20px);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.overlay.active {
    display: flex;
}

.gate-card {
    max-width: 420px;
    width: 100%;
    text-align: center;
    background: rgba(13, 20, 38, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(59, 130, 246, 0.1);
}

.logo-container {
    margin-bottom: 24px;
}

.logo-container .logo-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.logo-container h2 {
    font-size: 24px;
    color: #ffffff;
    margin-bottom: 8px;
}

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

.gate-card .input-group {
    margin-bottom: 20px;
}

.gate-card input {
    width: 100%;
    text-align: center;
    font-size: 20px;
    letter-spacing: 0.25em;
    padding: 12px;
}

.gate-footer {
    margin-top: 24px;
    color: var(--text-dark);
}

.gate-footer span {
    color: var(--color-primary);
    font-weight: 600;
}

/* Settings and Sync Page */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.settings-grid h3 {
    margin-bottom: 8px;
}

.settings-grid .desc {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.backup-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

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

/* Helpers */
.text-center { text-align: center; }
.text-green { color: var(--color-success); }
.text-gold { color: var(--color-gold); }
.text-red-important { color: var(--color-red) !important; }
.font-xs { font-size: 11px; }
.font-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
.flex-col { flex-direction: column; }
.w-48 { width: 192px; }

/* Filter Container Styling */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.filters-container {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filters-container select {
    font-size: 13px;
    padding: 8px 12px;
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-family: var(--font-heading);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1000;
    animation: slideIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.toast.show {
    display: block;
}

.toast.success {
    border-color: var(--color-success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.toast.error {
    border-color: var(--color-red);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

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

/* Divtracker Styles */
.yield-settings-card h3 {
    margin-bottom: 4px;
}

.yield-settings-card p {
    font-size: 13px;
    margin-bottom: 20px;
}

.small-table td {
    padding: 10px 16px;
}

.small-table input[type="number"] {
    width: 90px;
    padding: 6px 10px;
    font-size: 12px;
}

.small-table input[type="text"] {
    width: 80px;
    padding: 6px 10px;
    font-size: 12px;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .transaction-grid {
        grid-template-columns: 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }
    
    .main-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
        padding: 16px;
    }
    
    .nav-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding: 4px;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tabs::-webkit-scrollbar {
        display: none; /* Hide scrollbars for a clean look */
    }
    
    .tab-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .header-status {
        justify-content: space-between;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .chart-content {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .chart-legend {
        max-height: 150px;
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .history-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .filters-container select, .filters-container button {
        width: 100%;
    }
}

/* Custom Asset Settings & Styling Additions */
.settings-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.market-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.market-bar-header h3 {
    margin-bottom: 0 !important;
}

.edit-price-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-edit-price {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.6;
    padding: 2px;
    transition: opacity 0.2s ease;
}

.btn-edit-price:hover {
    opacity: 1;
}

.small-table select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: #ffffff;
    padding: 6px;
    border-radius: 4px;
    font-size: 12px;
    width: 130px;
}

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

