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

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* LOGIN */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 360px; box-shadow: var(--shadow-md); text-align: center; }
.login-logo { margin-bottom: 16px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-card .subtitle { color: var(--muted); margin-bottom: 28px; }

/* FORMS */
.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.field input, .field select { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border-color .15s; background: var(--surface); color: var(--text); }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s, box-shadow .15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: white; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-full { width: 100%; justify-content: center; padding: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 10; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; font-weight: 500; transition: background .12s, color .12s; border: none; background: none; width: 100%; text-align: left; font-size: 13px; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: #eff6ff; color: var(--primary); }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.main { margin-left: 220px; flex: 1; padding: 28px 32px; max-width: calc(100vw - 220px); }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 700; }

/* TRANSACTIONS */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.filters .field { margin-bottom: 0; }
.filters .field input, .filters .field select { width: auto; }
.search-input { min-width: 220px; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 11px 14px; }
.amount-pos { color: var(--success); font-weight: 600; }
.amount-neg { color: var(--danger); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.badge-pending { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.merchant-logo { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; background: var(--bg); }

/* PAGINATION */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 16px; }
.pagination span { font-size: 13px; color: var(--muted); }

/* ACCOUNTS */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.account-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.account-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.account-institution { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.account-name { font-size: 15px; font-weight: 600; margin: 2px 0; }
.account-mask { font-size: 12px; color: var(--muted); }
.account-balance { font-size: 22px; font-weight: 700; margin-top: 8px; }
.account-available { font-size: 12px; color: var(--muted); margin-top: 2px; }
.account-type-tag { font-size: 11px; background: var(--bg); border: 1px solid var(--border); padding: 2px 8px; border-radius: 20px; color: var(--muted); }

/* ANALYTICS */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.chart-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
canvas { max-height: 280px; }
.category-list { margin-top: 8px; }
.category-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.category-row:last-child { border-bottom: none; }
.category-bar-wrap { width: 80px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.category-bar { height: 100%; background: var(--primary); border-radius: 3px; }

/* EMPTY STATE */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { opacity: .3; margin-bottom: 12px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); }

/* TOAST */
#toast { position: fixed; bottom: 24px; right: 24px; background: #1e293b; color: white; padding: 12px 18px; border-radius: 10px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; z-index: 100; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }

/* LINK MODAL */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: white; border-radius: 14px; padding: 28px; width: 100%; max-width: 400px; }
.modal h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal p { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; max-width: 100vw; }
  .analytics-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
}
