:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #1f6feb;
    --primary-dark: #185abc;
    --success: #0f8f5f;
    --danger: #d92d20;
    --warning: #b7791f;
    --shadow: 0 20px 60px rgba(15, 23, 42, .08);
    --radius: 22px;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: radial-gradient(circle at top left, #e8f1ff 0, transparent 32rem), var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 268px;
    background: #0f172a;
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { color: white; display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; }
.brand:hover { text-decoration: none; }
.brand-mark, .auth-logo {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #1f6feb, #6e56cf);
    color: white;
    font-weight: 900;
    letter-spacing: -.05em;
}
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
    color: #cbd5e1;
    padding: 12px 14px;
    border-radius: 14px;
    font-weight: 650;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.1); color: white; text-decoration: none; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.sidebar-footer a { color: #93c5fd; }
.user-pill { background: rgba(255,255,255,.1); padding: 10px 12px; border-radius: 14px; color: white; }
.main { flex: 1; padding: 32px; max-width: 1400px; margin: 0 auto; width: 100%; }
.main-centered { display: grid; place-items: center; max-width: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.04em; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.top-search input { width: min(380px, 36vw); }
.auth-card, .panel, .hero-card, .stat-card {
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(226,232,240,.9);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}
.auth-card { width: min(460px, calc(100vw - 32px)); padding: 34px; }
.wide-card { width: min(820px, calc(100vw - 32px)); }
.auth-card h1 { margin: 18px 0 8px; font-size: 30px; letter-spacing: -.04em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
form { margin: 0; }
label { display: flex; flex-direction: column; gap: 7px; font-weight: 700; font-size: 14px; margin-bottom: 14px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: white;
    color: var(--text);
    padding: 13px 14px;
    border-radius: 14px;
    font: inherit;
    outline: none;
    transition: border .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus { border-color: rgba(31,111,235,.7); box-shadow: 0 0 0 4px rgba(31,111,235,.11); }
.btn, button.btn, .icon-btn {
    border: 1px solid var(--line);
    background: white;
    color: var(--text);
    padding: 11px 15px;
    border-radius: 14px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-weight: 800;
}
.btn:hover, .icon-btn:hover { text-decoration: none; border-color: #cbd5e1; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.full { width: 100%; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.alert { border-radius: 16px; padding: 14px 16px; margin: 0 0 18px; font-weight: 700; }
.alert-error { background: #fef3f2; color: #b42318; border: 1px solid #fecdc9; }
.alert-success { background: #ecfdf3; color: #067647; border: 1px solid #abefc6; }
.alert-warn { background: #fffaeb; color: #b54708; border: 1px solid #fedf89; }
.hero-card { padding: 28px; display: grid; grid-template-columns: 1fr minmax(280px, 520px); gap: 24px; align-items: center; margin-bottom: 24px; }
.hero-card h2 { margin: 8px 0; font-size: clamp(26px, 4vw, 42px); letter-spacing: -.05em; line-height: 1.03; }
.hero-card p { color: var(--muted); margin: 0; font-size: 17px; }
.quick-add { display: flex; flex-direction: column; gap: 12px; }
.quick-add textarea { min-height: 124px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0 0 24px; }
.stat-card { padding: 22px; }
.stat-card span { display: block; color: var(--muted); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat-card strong { font-size: clamp(24px, 4vw, 34px); letter-spacing: -.04em; }
.stat-card.positive strong, .positive-text { color: var(--success); }
.stat-card.negative strong, .negative-text { color: var(--danger); }
.dashboard-grid, .content-grid { display: grid; gap: 18px; }
.dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.two-columns { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
.panel { padding: 22px; }
.panel h3 { margin: 0 0 16px; font-size: 22px; letter-spacing: -.03em; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel-header h3 { margin: 0; }
.list-item {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 18px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 10px;
}
.list-item strong { display: block; margin-bottom: 4px; }
.list-item span, .list-item p { display: block; color: var(--muted); margin: 0; font-size: 14px; }
.with-actions { align-items: flex-start; }
.with-actions > div:first-child { flex: 1; min-width: 0; }
.icon-btn { padding: 9px 11px; font-size: 13px; white-space: nowrap; }
.icon-btn.danger { color: var(--danger); }
.done { opacity: .58; }
.done strong { text-decoration: line-through; }
.empty-state { border: 1px dashed #cbd5e1; border-radius: 18px; padding: 18px; color: var(--muted); background: #f8fafc; }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }
.empty-state p { margin: 0; }
.stack-form { display: flex; flex-direction: column; }
.form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.form-section-title { margin: 18px 0 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 900; }
.tabs { display: flex; background: #f1f5f9; border-radius: 12px; padding: 4px; gap: 4px; }
.tabs a { padding: 8px 10px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 800; }
.tabs a.active { background: white; color: var(--text); box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.month-filter { display: flex; gap: 8px; align-items: center; }
.month-filter input { min-width: 160px; }
.category-row { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 12px 0; }
.category-row small { color: var(--muted); margin-left: 6px; }
.amount { font-weight: 900; white-space: nowrap; }
.checkbox-line { flex-direction: row; align-items: center; gap: 10px; }
.checkbox-line input { width: auto; }
.password-input-row { display: flex; gap: 8px; }
.password-input-row .btn { white-space: nowrap; }
.secret-box { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: center; word-break: break-all; }
.secret-box code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.accent-panel { background: linear-gradient(135deg, #eff6ff, #faf5ff); }
.big-search { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 18px; }
.results-list { display: grid; gap: 10px; }
.result-item { display: block; border: 1px solid var(--line); border-radius: 18px; background: white; padding: 16px; color: var(--text); }
.result-item:hover { text-decoration: none; border-color: #bfdbfe; }
.result-item span { display: inline-block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 900; color: var(--primary); margin-bottom: 4px; }
.result-item strong { display: block; }
.result-item small { color: var(--muted); display: block; margin: 3px 0 6px; }
.result-item p { color: var(--muted); margin: 0; }
.diagnostic-list { display: grid; gap: 10px; margin-top: 18px; }
.diagnostic-row { display: flex; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 16px; padding: 14px; align-items: center; }
.diagnostic-row span { display: block; color: var(--muted); margin-top: 3px; font-size: 14px; }
.diagnostic-row.ok b { color: var(--success); }
.diagnostic-row.bad b { color: var(--danger); }
.diagnostic-row.warn b { color: var(--warning); }
.codebox { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; min-height: 230px; }
@media (max-width: 1000px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: auto; height: auto; border-radius: 0 0 24px 24px; }
    .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar-footer { margin-top: 0; }
    .hero-card, .two-columns, .dashboard-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { flex-direction: column; align-items: stretch; }
    .top-search input { width: 100%; }
}
@media (max-width: 640px) {
    .main { padding: 18px; }
    .sidebar { padding: 18px; }
    .nav { grid-template-columns: 1fr; }
    .stats-grid, .form-row { grid-template-columns: 1fr; }
    .panel-header, .list-item, .big-search { flex-direction: column; align-items: stretch; display: flex; }
    .month-filter, .password-input-row { flex-direction: column; }
    .auth-card { padding: 24px; }
}
