:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #778197;
  --line: #e8edf5;
  --primary: #5b6cf9;
  --primary-dark: #4655e8;
  --primary-soft: #eef0ff;
  --green: #169b72;
  --green-soft: #e8f8f1;
  --orange: #d97706;
  --orange-soft: #fff3df;
  --sidebar: #151b31;
  --sidebar-muted: #a5aec5;
  --shadow: 0 12px 34px rgba(24, 37, 72, .055);
  --radius: 18px;
  --purple: #5965ec;
  --purple-soft: #eef0ff;
  --blue: #2784df;
  --blue-soft: #e9f4ff;
  --danger: #e23d3d;
  --danger-soft: #fdebeb;
}

* { box-sizing: border-box; }

body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* Shell / sidebar */
.app { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
aside { background: var(--sidebar); color: white; padding: 27px 16px; display: flex; flex-direction: column; gap: 34px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 12px; font-weight: 750; font-size: 20px; letter-spacing: -.5px; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg,#7c8aff,#5364f4); box-shadow: 0 7px 20px #5364f455; flex: none; }
.brand-mark svg { width: 21px; height: 21px; }
.nav-label { color: #737f9f; text-transform: uppercase; letter-spacing: 1.4px; font-size: 10px; font-weight: 800; padding: 0 13px; margin-bottom: 9px; }
nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 13px; padding: 12px 13px; color: var(--sidebar-muted); border-radius: 12px; text-decoration: none; font-size: 13px; font-weight: 550; transition: .2s; border: 0; background: transparent; width: 100%; text-align: left; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover, .nav-item.active { color: white; background: #2a3354; }
.nav-item.active { box-shadow: inset 3px 0 #7c8aff; }
.nav-item.is-soon { opacity: .55; cursor: default; }
.nav-item.is-soon:hover { color: var(--sidebar-muted); background: transparent; }
.soon-badge { margin-left: auto; background: var(--primary-soft); color: var(--primary); text-transform: uppercase; letter-spacing: .4px; font-size: 9px; font-weight: 800; padding: 3px 7px; border-radius: 6px; flex: none; }
.sidebar-bottom { margin-top: auto; }
.upgrade { border: 1px solid #343d5b; background: linear-gradient(145deg,#242d4c,#1b223a); border-radius: 15px; padding: 17px; }
.upgrade-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #394574; margin-bottom: 13px; color: #cbd1ff; }
.upgrade strong { display: block; font-size: 13px; margin-bottom: 6px; }
.upgrade p { color: #a6afc8; font-size: 11px; line-height: 1.55; margin: 0 0 13px; }
.upgrade button { width: 100%; background: #7482ff; color: white; border: 0; border-radius: 9px; padding: 9px; font-size: 12px; font-weight: 700; }
.upgrade button:disabled { opacity: .6; cursor: default; }

main { min-width: 0; }

/* Header */
header { height: 82px; background: rgba(255,255,255,.82); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 42px; gap: 20px; }
.crumb { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.header-title { font-size: 15px; font-weight: 750; }
.header-right { display: flex; align-items: center; gap: 18px; }
.period { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 9px 12px; color: #4b5569; font-size: 12px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: white; color: #626e84; display: grid; place-items: center; position: relative; }
.icon-button svg { width: 17px; height: 17px; }
.icon-button:disabled { opacity: .55; cursor: default; }
.dot { width: 6px; height: 6px; background: #f97372; border: 1px solid white; border-radius: 50%; position: absolute; top: 8px; right: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; background: #e9eaff; color: #4c58dc; font-size: 12px; font-weight: 800; border: 0; }
.avatar-menu { position: relative; }
.avatar-dropdown { position: absolute; right: 0; top: calc(100% + 10px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 180px; padding: 8px; display: none; z-index: 20; }
.avatar-dropdown.open { display: block; }
.avatar-dropdown a, .avatar-dropdown button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; border: 0; background: transparent; color: var(--ink); font-size: 12px; font-weight: 600; text-decoration: none; text-align: left; }
.avatar-dropdown a:hover, .avatar-dropdown button:hover { background: var(--bg); }
.avatar-dropdown .dropdown-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* Content */
.content { max-width: 1500px; padding: 32px 42px 44px; margin: 0 auto; }
.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
h1 { font-size: clamp(24px, 2.4vw, 30px); letter-spacing: -1px; margin: 0 0 7px; }
.subtitle { color: var(--muted); font-size: 13px; margin: 0; }
.primary-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 11px; padding: 12px 16px; color: white; background: var(--primary); font-weight: 700; font-size: 12px; box-shadow: 0 6px 14px #5b6cf933; transition: .2s; white-space: nowrap; text-decoration: none; }
.primary-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.primary-btn:disabled { opacity: .6; cursor: default; transform: none; }
.primary-btn svg { width: 15px; height: 15px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 17px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat { padding: 20px 21px; min-width: 0; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 20px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-icon { width: 39px; height: 39px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.stat-icon svg { width: 19px; height: 19px; }
.purple { color: var(--purple); background: var(--purple-soft); } .green { color: var(--green); background: var(--green-soft); }
.orange { color: var(--orange); background: var(--orange-soft); } .blue { color: var(--blue); background: var(--blue-soft); }
.stat-value { font-size: clamp(22px,2vw,29px); font-weight: 780; letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-foot { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.trend { color: var(--green); background: var(--green-soft); border-radius: 6px; padding: 4px 6px; font-weight: 750; }
.trend.down { color: var(--danger); background: var(--danger-soft); }
.stat.is-soon .stat-value { color: var(--muted); }

/* Grid / panels / chart */
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(280px,1fr); gap: 20px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 21px 22px 0; }
.panel-title { font-size: 14px; font-weight: 750; margin: 0; }
.panel-subtitle { color: var(--muted); font-size: 11px; margin-top: 5px; }
.select { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: white; color: #68748a; font-size: 11px; }
.chart-area { padding: 18px 20px 13px; }
.chart-legend { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 10px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--primary); }
.legend-dot.pale { background: #cfd5ff; }
.chart { width: 100%; height: 190px; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: #9aa3b4; font-family: inherit; }
.chart-empty { padding: 40px 10px; text-align: center; color: var(--muted); font-size: 12px; }

/* Category breakdown */
.budget-list { padding: 22px; display: grid; gap: 21px; }
.budget-row { display: grid; gap: 9px; }
.budget-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.budget-name { display: flex; align-items: center; gap: 9px; font-weight: 650; }
.category-icon { width: 31px; height: 31px; border-radius: 10px; display: grid; place-items: center; font-size: 14px; background: var(--green-soft); color: var(--green); }
.category-icon::before { content: '•'; }
.budget-amount { color: #58647a; font-size: 11px; white-space: nowrap; }
.progress { height: 7px; border-radius: 20px; background: #eff2f7; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* Category icon map (presentation only, no schema change) */
.category-icon.cat-FOOD { background: var(--green-soft); color: var(--green); } .category-icon.cat-FOOD::before { content: '🛒'; }
.category-icon.cat-TRANSPORT { background: var(--purple-soft); color: var(--purple); } .category-icon.cat-TRANSPORT::before { content: '🚗'; }
.category-icon.cat-ENTERTAINMENT { background: var(--orange-soft); color: var(--orange); } .category-icon.cat-ENTERTAINMENT::before { content: '🎬'; }
.category-icon.cat-UTILITIES { background: var(--blue-soft); color: var(--blue); } .category-icon.cat-UTILITIES::before { content: '💡'; }
.category-icon.cat-HEALTHCARE { background: var(--blue-soft); color: var(--blue); } .category-icon.cat-HEALTHCARE::before { content: '♡'; }
.category-icon.cat-SHOPPING { background: var(--purple-soft); color: var(--purple); } .category-icon.cat-SHOPPING::before { content: '🛍'; }
.category-icon.cat-EDUCATION { background: var(--orange-soft); color: var(--orange); } .category-icon.cat-EDUCATION::before { content: '📚'; }
.category-icon.cat-TRAVEL { background: var(--blue-soft); color: var(--blue); } .category-icon.cat-TRAVEL::before { content: '✈️'; }
.category-icon.cat-HOUSING { background: var(--orange-soft); color: var(--orange); } .category-icon.cat-HOUSING::before { content: '🏠'; }
.category-icon.cat-OTHER { background: var(--green-soft); color: var(--green); } .category-icon.cat-OTHER::before { content: '•'; }

/* Transactions table */
.transactions { overflow: hidden; }
.transactions .panel-head { padding-bottom: 18px; }
.text-link { border: 0; background: transparent; color: var(--primary); font-size: 11px; font-weight: 750; cursor: pointer; text-decoration: none; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; white-space: nowrap; }
th { background: #fafbfe; color: #929caf; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; font-weight: 750; padding: 12px 22px; }
td { padding: 15px 22px; border-top: 1px solid #f0f2f7; font-size: 12px; }
tbody tr:hover { background: #fafbff; }
.merchant { display: flex; align-items: center; gap: 11px; }
.merchant-note { color: var(--muted); font-size: 10px; margin-top: 4px; }
.merchant-name { font-weight: 700; }
.tag { border-radius: 7px; padding: 5px 8px; display: inline-block; color: #667187; background: #f0f2f7; font-size: 10px; }
.amount { text-align: right; font-weight: 750; }
.status { color: var(--green); background: var(--green-soft); border-radius: 7px; padding: 5px 8px; font-size: 10px; }

footer { color: #a0a8b7; font-size: 10px; padding: 25px 42px; text-align: center; }
.mobile-menu { display: none; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: #11182b88; display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal-backdrop.open { display: flex; }
.modal { width: min(100%,430px); background: white; border-radius: 20px; padding: 25px; box-shadow: 0 25px 70px #10172a44; }
.modal h2 { margin: 0 0 7px; font-size: 20px; }
.modal p { color: var(--muted); font-size: 12px; margin: 0 0 22px; }
.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field label { font-size: 11px; font-weight: 700; color: #58647a; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: white; }
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #5b6cf91c; }
.field-error { color: var(--danger); font-size: 11px; margin-top: -2px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-hint { color: var(--muted); font-size: 11px; margin-top: -2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink); }
.radio-group { display: flex; gap: 9px; flex-wrap: wrap; }
.radio-group input { position: absolute; opacity: 0; pointer-events: none; }
.radio-group label { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 10px 15px; font-size: 12px; font-weight: 700; color: #58647a; cursor: pointer; transition: .2s; }
.radio-group input:checked + label { background: var(--primary); border-color: var(--primary); color: white; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.secondary-btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: white; border-radius: 10px; padding: 11px 14px; color: #58647a; font-size: 12px; font-weight: 700; text-decoration: none; }

/* Alerts */
.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-radius: 14px; padding: 14px 16px; font-size: 12px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--green-soft); color: var(--green); border-color: #c9ecdc; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f6cfcf; }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); border-color: #d9deff; }
.alert-dismiss { border: 0; background: transparent; color: inherit; font-size: 14px; line-height: 1; opacity: .6; cursor: pointer; }
.alert-dismiss:hover { opacity: 1; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 24px; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line); background: white; color: #58647a; font-size: 12px; font-weight: 700; text-decoration: none; }
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: white; }
.pagination .disabled { opacity: .45; pointer-events: none; }

/* Empty states */
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state p { font-size: 13px; margin: 0 0 18px; }

/* Auth shell */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); padding: 30px 16px; gap: 20px; }
.auth-shell-top { width: min(100%, 420px); display: flex; align-items: center; justify-content: space-between; }
.auth-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; }
.auth-card.wide { width: min(100%, 520px); }
.auth-card h1 { font-size: 20px; margin: 0 0 6px; }
.auth-card .subtitle { margin-bottom: 24px; }
.auth-lang-switch { display: flex; gap: 6px; }
.auth-lang-switch a { padding: 6px 10px; border-radius: 8px; font-size: 11px; font-weight: 700; text-decoration: none; color: var(--muted); border: 1px solid var(--line); background: white; }
.auth-lang-switch a.active { background: var(--primary); border-color: var(--primary); color: white; }
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }
.auth-foot a { color: var(--primary); font-weight: 700; text-decoration: none; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 215px minmax(0,1fr); }
  header { padding: 0 27px; } .content { padding: 28px 27px 35px; }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0,1.2fr) minmax(260px,1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { display: block; }
  aside { display: none; }
  .app.nav-open aside { display: flex; position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; overflow-y: auto; }
  header { height: 70px; padding: 0 18px; }
  .mobile-menu { display: grid; }
  .crumb, .period { display: none; }
  .header-right { gap: 9px; }
  .content { padding: 25px 16px 30px; }
  .welcome { align-items: flex-start; flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats { gap: 11px; }
  .stat { padding: 16px; }
  .stat-top { margin-bottom: 15px; }
  .stat-icon { width: 33px; height: 33px; }
  .stat-value { font-size: 23px; }
  footer { padding: 22px 15px; }
}
@media (max-width: 430px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }
  .stat-foot { font-size: 10px; flex-wrap: wrap; }
  .avatar { width: 34px; height: 34px; }
  .header-title { font-size: 14px; }
  .panel-head { padding-left: 16px; padding-right: 16px; }
  th, td { padding-left: 15px; padding-right: 15px; }
}
