/* SpendLens Portal — Brand Styles
   Brand: Purple (#6B2FA0) + Cyan (#3DD6D0) from SpendLens logo
   Font: Inter (clean, modern, highly legible) */

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

:root {
    --brand: #6B2FA0;
    --brand-light: #F3EAFB;
    --brand-lighter: #F9F5FD;
    --brand-dark: #5A2387;
    --brand-darker: #3E1660;
    --accent: #3DD6D0;
    --accent-light: #E6FAF9;
    --accent-dark: #2BB5B0;
    --green: #22C55E;
    --green-light: #DCFCE7;
    --amber: #F59E0B;
    --amber-light: #FEF3C7;
    --red: #EF4444;
    --red-light: #FEE2E2;
    --bg: #F8F9FC;
    --card-bg: #FFFFFF;
    --text: #1E1E2D;
    --text-secondary: #64748B;
    --text-light: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 2px rgba(107,47,160,0.04);
    --shadow-md: 0 4px 12px rgba(107,47,160,0.06);
    --shadow-lg: 0 8px 30px rgba(107,47,160,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--brand-darker) 0%, var(--brand) 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(107,47,160,0.1);
}

.sidebar-brand {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-sub {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-top: 0.5rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.nav-links {
    list-style: none;
    padding: 0.75rem 0;
    flex: 1;
}

.nav-links li { margin: 2px 0; }

.nav-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-links a:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.06);
}

.nav-links a.active {
    color: white;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--accent);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.logout-link {
    color: rgba(255,255,255,0.4);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.15s;
}

.logout-link:hover { color: rgba(255,255,255,0.8); }

/* ===== MAIN CONTENT ===== */
.content {
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    flex: 1;
    max-width: 1300px;
}

.content-full {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--brand-darker) 0%, var(--brand) 40%, #8B5CC8 100%);
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
    font-weight: 400;
}

/* ===== PERIOD SELECTOR / FILTER BAR ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.period-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.period-selector label,
.filter-bar label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.period-selector select,
.filter-bar select {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748B' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.period-selector select:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(107,47,160,0.08);
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.filter-pill:hover { border-color: var(--brand); color: var(--brand); }
.filter-pill.active {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}

/* ===== CARDS ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

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

.card-accent {
    border-top: 3px solid var(--accent);
}

.card-purple {
    border-top: 3px solid var(--brand);
}

.card-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.card-value.positive { color: var(--green); }
.card-value.negative { color: var(--red); }

.card-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

.card-icon.income { background: var(--green-light); }
.card-icon.spending { background: var(--red-light); }
.card-icon.net { background: var(--brand-light); }
.card-icon.periods { background: var(--accent-light); }

/* Stat card with icon */
.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.stat-card .card-icon { margin-bottom: 0; flex-shrink: 0; }

/* ===== CHARTS ===== */
.chart-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.chart-container h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.chart-wrap {
    position: relative;
    height: 320px;
}

.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ===== TABLES ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.data-table tbody tr {
    transition: background 0.1s;
}

.data-table tbody tr:hover {
    background: var(--brand-lighter);
}

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

.amount-positive { color: var(--green); font-weight: 600; }
.amount-negative { color: var(--red); font-weight: 600; }

/* Needs/Wants badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-need {
    background: var(--brand-light);
    color: var(--brand);
}

.badge-want {
    background: var(--amber-light);
    color: #92400E;
}

.badge-group {
    background: var(--accent-light);
    color: var(--accent-dark);
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    font-weight: 600;
}

/* Category group headers */
.group-header {
    background: var(--bg);
    font-weight: 600;
    color: var(--text);
}

.group-header td {
    padding: 0.6rem 1rem;
    border-bottom: 2px solid var(--border);
    font-size: 0.8rem;
}

/* ===== TRAFFIC LIGHTS ===== */
.traffic-light {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.traffic-green { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.traffic-amber { background: var(--amber); box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.traffic-red { background: var(--red); box-shadow: 0 0 6px rgba(239,68,68,0.4); }

/* ===== PROGRESS BARS ===== */
.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--border-light);
    border-radius: 100px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.5s ease;
}

.progress-fill.green { background: linear-gradient(90deg, #22C55E, #4ADE80); }
.progress-fill.amber { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.progress-fill.red { background: linear-gradient(90deg, #EF4444, #F87171); }
.progress-fill.brand { background: linear-gradient(90deg, var(--brand), #8B5CC8); }
.progress-fill.accent { background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }

/* ===== INSIGHT CARDS ===== */
.insight-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
}

.insight-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.insight-card.high { border-left: 4px solid var(--red); }
.insight-card.medium { border-left: 4px solid var(--amber); }
.insight-card.low { border-left: 4px solid var(--green); }

.insight-title {
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
}

.insight-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.insight-saving {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--green);
}

/* ===== LOGIN PAGE ===== */
.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(255,255,255,0.1);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--brand) 0%, #8B5CC8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.login-brand .tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
}

.login-secure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 1.5rem;
}

.login-secure svg {
    width: 14px;
    height: 14px;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.15s;
    background: var(--bg);
}

.form-group input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(107,47,160,0.1);
    background: white;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, #8B5CC8 100%);
    color: white;
    width: 100%;
    box-shadow: 0 4px 12px rgba(107,47,160,0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(107,47,160,0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.error-msg {
    background: var(--red-light);
    color: var(--red);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

/* ===== SECTIONS ===== */
.section {
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Needs vs Wants summary */
.needs-wants-bar {
    display: flex;
    height: 8px;
    border-radius: 100px;
    overflow: hidden;
    background: var(--border-light);
    margin: 0.75rem 0;
}

.needs-fill {
    background: linear-gradient(90deg, var(--brand), #8B5CC8);
    transition: width 0.5s;
}

.wants-fill {
    background: linear-gradient(90deg, var(--amber), #FBBF24);
    transition: width 0.5s;
}

.needs-wants-legend {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.3rem;
}

.legend-dot.needs { background: var(--brand); }
.legend-dot.wants { background: var(--amber); }

/* ===== TOOLTIPS ===== */
[data-tooltip] {
    position: relative;
    cursor: default;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
    animation: tooltipFade 0.15s ease;
}

[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text);
    z-index: 50;
    pointer-events: none;
    animation: tooltipFade 0.15s ease;
}

@keyframes tooltipFade {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== WELCOME GREETING ===== */
.greeting {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 0.25rem;
}

.greeting strong {
    color: var(--text);
    font-weight: 600;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { margin-left: 0; padding: 1rem; }
    .card-grid { grid-template-columns: 1fr 1fr; }
    .card-grid-3, .card-grid-4 { grid-template-columns: 1fr 1fr; }
    .chart-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .card-grid, .card-grid-3, .card-grid-4 { grid-template-columns: 1fr; }
}

/* ===== UTILITIES ===== */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--text-secondary); }
.fw-600 { font-weight: 600; }

/* ===== TRANSACTION DRILL-DOWN ===== */
.drilldown-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.15s;
}

.drilldown-link:hover {
    color: var(--brand);
}

.drilldown-link svg {
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    transform: translateX(-4px);
}

.drilldown-link:hover svg {
    opacity: 1;
    transform: translateX(0);
}

.breadcrumb-link {
    color: var(--brand);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.txn-description {
    font-weight: 500;
    color: var(--text);
    font-size: 0.875rem;
}

.txn-memo {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

/* Sortable table headers */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

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

.sortable .sort-icon::after {
    content: '';
    display: inline-block;
    margin-left: 4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid var(--text-light);
    vertical-align: middle;
}

.sortable.sort-asc .sort-icon::after {
    border-bottom-color: var(--brand);
}

.sortable.sort-desc .sort-icon::after {
    border-bottom: none;
    border-top: 4px solid var(--brand);
}

/* ===== DEBT CARDS ===== */
.debt-card {
    border-left: 4px solid var(--red);
}

.debt-progress {
    height: 8px;
    background: var(--border-light);
    border-radius: 100px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.debt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22C55E, #4ADE80);
    border-radius: 100px;
    transition: width 0.5s;
}

/* ===== SIDEBAR NAV ICONS ===== */
.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
}

.sidebar-footer .logout-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-footer svg {
    width: 16px;
    height: 16px;
}

/* ===== CARD ICONS (SVG) ===== */
.card-icon svg {
    width: 22px;
    height: 22px;
}

/* Insight written analysis */
.insight-analysis {
    background: var(--brand-lighter);
    border: 1px solid var(--brand-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    line-height: 1.7;
    font-size: 0.9rem;
    color: var(--text);
}

.insight-analysis strong {
    color: var(--brand);
}

.insight-analysis .highlight {
    background: rgba(107,47,160,0.08);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-weight: 600;
}
