@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

/* ==================== DESIGN SYSTEM (UI-UX PRO MAX) ==================== */
:root {
    /* Financial Dark Palette */
    --bg-deep: #020617;
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-card: #0E1223;
    --bg-muted: #1A1E2F;
    --bg-hover: #253349;

    /* Text */
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;

    /* Accent */
    --accent: #22C55E;
    --accent-hover: #16A34A;
    --red: #EF4444;
    --red-hover: #DC2626;
    --yellow: #EAB308;
    --blue: #3B82F6;
    --blue-hover: #2563EB;

    /* Border */
    --border: #334155;
    --border-light: #1E293B;

    /* Radius */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    /* Typography */
    --font-body: 'Fira Sans', sans-serif;
    --font-mono: 'Fira Code', monospace;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;

    /* Header */
    --header-height: 56px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ==================== LAYOUT ==================== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.logo i {
    color: var(--accent);
    font-size: 1.5rem;
}

.logo-sub {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Nav */
.nav-menu {
    list-style: none;
    padding: 0.75rem 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

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

.nav-link.active {
    background: var(--bg-muted);
    color: var(--accent);
}

.nav-link.active i {
    color: var(--accent);
}

.nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-light);
}

.user-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 1rem;
    flex-shrink: 0;
}

.user-meta {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-xs);
    transition: all 0.15s;
}

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

/* ==================== MAIN CONTENT ==================== */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Header */
.topbar {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.market-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(34,197,94,0.1);
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
}

.market-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s infinite;
}

.clock {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

/* Overlay */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 90;
}

/* ==================== CONTENT AREA ==================== */
.content {
    padding: 1rem 1.25rem 2rem;
    flex: 1;
}

/* ==================== KPI CARDS ==================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: border-color 0.2s;
}

.kpi-card:hover {
    border-color: var(--border);
}

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

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

.kpi-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.kpi-icon.green {
    background: rgba(34,197,94,0.1);
    color: var(--accent);
}

.kpi-icon.blue {
    background: rgba(59,130,246,0.1);
    color: var(--blue);
}

.kpi-icon.yellow {
    background: rgba(234,179,8,0.1);
    color: var(--yellow);
}

.kpi-icon.red {
    background: rgba(239,68,68,0.1);
    color: var(--red);
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.kpi-change {
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kpi-change.up {
    color: var(--accent);
}

.kpi-change.down {
    color: var(--red);
}

/* ==================== PANELS ==================== */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

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

.panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title i {
    color: var(--accent);
    font-size: 0.8rem;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
}

.panel-body {
    padding: 1rem;
}

/* ==================== CHART CONTAINER ==================== */
.chart-wrap {
    position: relative;
    height: 280px;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ==================== STOCK LIST ==================== */
.stock-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stock-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s;
    cursor: pointer;
}

.stock-item:hover {
    border-color: var(--border);
}

.stock-left {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.stock-ticker {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
}

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

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

.stock-price {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
}

.stock-change {
    font-size: 0.75rem;
    font-weight: 500;
}

.stock-change.up { color: var(--accent); }
.stock-change.down { color: var(--red); }

/* ==================== TABLE ==================== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

thead th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

tbody tr:hover {
    background: var(--bg-muted);
}

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

.mono {
    font-family: var(--font-mono);
}

/* ==================== FORM ==================== */
.form-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

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

.form-input, .form-select {
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    transition: border-color 0.2s;
}

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

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xs);
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-body);
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-muted);
    color: var(--text-secondary);
}

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

.btn-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.4rem;
    background: none;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
}

.btn-icon:hover {
    border-color: var(--border);
    color: var(--text-primary);
}

/* ==================== STATUS BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.badge.green {
    background: rgba(34,197,94,0.12);
    color: var(--accent);
}

.badge.red {
    background: rgba(239,68,68,0.12);
    color: var(--red);
}

.badge.yellow {
    background: rgba(234,179,8,0.12);
    color: var(--yellow);
}

.badge.blue {
    background: rgba(59,130,246,0.12);
    color: var(--blue);
}

/* ==================== ALERT LIST ==================== */
.alert-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border);
}

.alert-item.triggered {
    border-left-color: var(--accent);
    background: rgba(34,197,94,0.05);
}

.alert-item.warning {
    border-left-color: var(--yellow);
    background: rgba(234,179,8,0.05);
}

.alert-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.alert-icon.green {
    background: rgba(34,197,94,0.15);
    color: var(--accent);
}

.alert-icon.yellow {
    background: rgba(234,179,8,0.15);
    color: var(--yellow);
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-size: 0.8125rem;
    font-weight: 500;
}

.alert-time {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* ==================== DASHBOARD GRID ==================== */
.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
}

/* ==================== PORTFOLIO ==================== */
.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.8125rem;
}

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

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

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

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

/* ==================== RESPONSIVE: TABLET (768px) ==================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .overlay.show {
        display: block;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-grid {
        grid-template-columns: 1fr;
    }

    .stock-grid {
        grid-template-columns: 1fr;
    }

    .portfolio-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: column;
    }
}

/* ==================== RESPONSIVE: MOBILE (480px) ==================== */
@media (max-width: 480px) {
    .content {
        padding: 0.75rem;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .kpi-card {
        padding: 0.75rem;
    }

    .kpi-value {
        font-size: 1.15rem;
    }

    .kpi-icon {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .panel-body {
        padding: 0.75rem;
    }

    .chart-wrap {
        height: 200px;
    }

    .portfolio-summary {
        grid-template-columns: 1fr;
    }

    .market-badge {
        display: none;
    }

    .topbar-title {
        font-size: 0.9rem;
    }

    table {
        font-size: 0.75rem;
    }

    thead th, tbody td {
        padding: 0.5rem 0.5rem;
    }
}

/* ==================== RESPONSIVE: SMALL PHONE (360px) ==================== */
@media (max-width: 360px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .stock-grid {
        gap: 0.5rem;
    }
}
/* ==================== MODAL ==================== */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}
