* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #0f1117; --surface: #1a1d27; --surface-hover: #22262f;
    --border: rgba(255,255,255,0.06); --border-strong: rgba(255,255,255,0.1);
    --text: #e8eaed; --text-sec: #9aa0a6; --text-dim: #5f6368;
    --accent: #4d8df7; --green: #34a853; --red: #ea4335;
    --orange: #f9ab00; --purple: #a142f4; --radius: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--text); min-height: 100vh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

#app { max-width: 520px; margin: 0 auto; padding: 16px; padding-bottom: 40px; }

.header { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.header h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.header p { font-size: 12px; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.8px; }

/* Cards */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card-title {
    font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-dim); margin-bottom: 14px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Stat grid */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.stat { text-align: left; padding: 8px; background: rgba(255,255,255,0.02); border-radius: 6px; }
.stat-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.orange { color: var(--orange); }
.stat-value.accent { color: var(--accent); }
.stat-value.purple { color: var(--purple); }
.stat-label { font-size: 10px; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Chart */
.chart-wrap { position: relative; height: 220px; margin-top: 8px; }
canvas { width: 100% !important; }

/* Month picker */
.month-picker {
    display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.month-picker::-webkit-scrollbar { display: none; }
.month-btn {
    flex-shrink: 0; padding: 6px 14px; border-radius: 4px; border: 1px solid var(--border);
    background: transparent; color: var(--text-sec); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; letter-spacing: 0.3px;
}
.month-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.month-btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.month-btn:active { transform: scale(0.97); }

/* Sale rows */
.sale-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.sale-row:last-child { border-bottom: none; }
.sale-name { font-size: 13px; font-weight: 500; }
.sale-date { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.sale-price { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.sale-profit { font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.sale-profit.pos { color: var(--green); }
.sale-profit.neg { color: var(--red); }

/* Customer rows */
.cust-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.cust-row:last-child { border-bottom: none; }
.cust-name { font-size: 13px; font-weight: 500; }
.cust-count { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.cust-rev { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Expense bars */
.exp-bar-wrap { margin-bottom: 10px; }
.exp-bar-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.exp-bar-label span:first-child { color: var(--text-sec); font-weight: 400; }
.exp-bar-label span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.exp-bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.04); }
.exp-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.exp-bar-fill.cos { background: var(--orange); }
.exp-bar-fill.oe { background: var(--purple); }

/* Nav tabs */
.nav {
    display: flex; gap: 0; background: var(--surface); border-radius: 6px;
    padding: 2px; margin-bottom: 20px; border: 1px solid var(--border);
}
.nav-btn {
    flex: 1; padding: 8px 0; border: none; border-radius: 4px; background: none;
    color: var(--text-dim); font-size: 12px; font-weight: 500; cursor: pointer;
    transition: all 0.15s; letter-spacing: 0.3px;
}
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn:hover:not(.active) { color: var(--text-sec); }
.nav-btn:active { opacity: 0.7; }

/* Ledger grid */
.ledger-grid { display: flex; flex-direction: column; gap: 12px; }

/* Loader */
.loader { text-align: center; padding: 40px; color: var(--text-dim); font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase; }

/* Fade in */
.fade-in { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Desktop */
@media (min-width: 768px) {
    #app { max-width: 880px; padding: 32px 40px; }
    .header h1 { font-size: 24px; }
    .header { margin-bottom: 28px; }
    .card { padding: 20px; margin-bottom: 14px; }
    .stat-value { font-size: 22px; }
    .stat-label { font-size: 11px; }
    .chart-wrap { height: 260px; }
    .nav-btn { padding: 10px 0; font-size: 13px; }
    .sale-name, .cust-name { font-size: 14px; }
    .sale-price, .cust-rev { font-size: 14px; }
    .month-btn { padding: 8px 16px; font-size: 13px; }
    .ledger-grid { flex-direction: row; }
    .ledger-grid .card { flex: 1; min-width: 0; }
}

@media (min-width: 1024px) {
    #app { max-width: 1060px; }
    .card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
    .card-grid .card { margin-bottom: 0; }
    .card-grid .card.full { grid-column: 1 / -1; }
    .stat-grid { grid-template-columns: 1fr 1fr 1fr; }
    .chart-wrap { height: 300px; }
}
