:root {
  --navy: #0d1729;
  --navy-2: #152238;
  --ink: #172033;
  --muted: #667085;
  --soft: #f5f7fb;
  --line: #e6e9ef;
  --card: #ffffff;
  --accent: #7357e8;
  --accent-dark: #6044d4;
  --accent-soft: #f0edff;
  --green: #0d9f6e;
  --red: #dc3f52;
  --amber: #c27b0a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .045);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--soft); }
body { margin: 0; color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { flex: 0 0 auto; }
h1, h2, h3, p { margin-top: 0; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 252px; background: var(--navy); color: #cbd3df; padding: 27px 18px 18px; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30; }
.brand { height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 10px; color: white; font-size: 18px; font-weight: 730; letter-spacing: -.35px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: linear-gradient(145deg, #8a71f5, #6848dc); color: white; font-weight: 800; box-shadow: 0 5px 16px rgba(115,87,232,.3); }
.sidebar nav { margin-top: 34px; display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 13px; height: 44px; padding: 0 13px; border-radius: 9px; color: #aab5c6; font-weight: 570; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.active { color: white; background: rgba(123, 98, 232, .2); box-shadow: inset 3px 0 #8d74f2; }
.nav-item.active svg { color: #a994ff; }
.nav-label { margin: 27px 13px 9px; color: #647188; text-transform: uppercase; font-size: 10px; letter-spacing: 1.2px; font-weight: 750; }
.sidebar-user { margin-top: auto; padding: 15px 9px 2px; border-top: 1px solid rgba(255,255,255,.08); display: grid; grid-template-columns: 34px minmax(0,1fr) 30px; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; display: inline-grid; place-items: center; color: white; background: linear-gradient(145deg,#4d67a1,#314569); border-radius: 50%; font-weight: 700; }
.avatar.small { width: 31px; height: 31px; font-size: 12px; }
.avatar.large { width: 72px; height: 72px; font-size: 22px; }
.avatar-photo { object-fit: cover; background: #e7eaf0; }
.sidebar-user strong, .sidebar-user span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sidebar-user strong { color: white; font-size: 12px; }
.sidebar-user span { color: #7f8da3; font-size: 10px; margin-top: 2px; }
.sidebar-user form { margin: 0; }
.sidebar-user .icon-btn { color: #8290a4; }

.main-wrap { min-width: 0; flex: 1; margin-left: 252px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 70px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 34px; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.topbar-spacer { flex: 1; }
.mobile-menu { display: none !important; }
.content { width: 100%; max-width: 1480px; margin: 0 auto; padding: 35px 36px 64px; flex: 1; }
.site-footer { width: 100%; padding: 17px 28px; color: #8892a2; font-size: 10px; }
.site-footer p { max-width: 1480px; margin: 0 auto; text-align: center; line-height: 1.7; }
.site-footer i { margin: 0 8px; color: #c0c6cf; font-style: normal; }
.site-footer a { color: #667085; transition: color .15s; }
.site-footer a:hover { color: var(--accent); }
.site-footer strong { color: #667085; font-weight: 650; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.eyebrow { color: var(--accent); text-transform: uppercase; font-size: 10px; line-height: 1; letter-spacing: 1.45px; font-weight: 800; display: block; margin-bottom: 9px; }
.page-head h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.75px; font-weight: 730; }
.page-head p { color: var(--muted); margin: 8px 0 0; line-height: 1.5; }
.page-actions { display: flex; gap: 10px; }

.btn { min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 650; transition: .15s ease; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(115,87,232,.2); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; border-color: #d8dde6; color: #344054; }
.btn-secondary:hover { border-color: #b9c0cc; background: #fafbfc; }
.btn-danger { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn { border: 0; padding: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer; color: #667085; }
.icon-btn:hover { background: #f0f2f6; color: var(--ink); }
.icon-btn.danger:hover { color: var(--red); background: #fff1f2; }
.text-link { color: var(--accent); font-weight: 650; display: inline-flex; align-items: center; gap: 5px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-head.padded { padding: 21px 22px 0; }
.panel-head h2 { font-size: 15px; line-height: 1.3; margin: 0; letter-spacing: -.18px; }
.panel-head p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.panel-head > a { font-size: 12px; color: var(--accent); font-weight: 650; display: flex; align-items: center; gap: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 15px; margin-bottom: 17px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 19px 20px; box-shadow: var(--shadow); min-width: 0; position: relative; overflow: hidden; }
.stat-card > span { display: block; color: var(--muted); font-size: 11px; font-weight: 580; margin-bottom: 9px; }
.stat-card > strong { display: block; font-size: 24px; line-height: 1.15; letter-spacing: -.7px; margin-bottom: 8px; }
.stat-card > small { font-size: 10px; color: #8490a2; }
.stat-card .positive { color: var(--green); }
.stat-card .negative { color: var(--red); }
.primary-stat { background: linear-gradient(135deg, #7559e9, #6248d3); border-color: transparent; color: white; }
.primary-stat::after { content: ''; position: absolute; width: 140px; height: 140px; right: -55px; top: -70px; border: 25px solid rgba(255,255,255,.07); border-radius: 50%; }
.primary-stat > span, .primary-stat > small, .primary-stat .positive, .primary-stat .negative { color: rgba(255,255,255,.76); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(300px,.85fr); gap: 17px; }
.dashboard-grid > .panel { padding: 22px; }
.recent-panel { grid-column: 1 / -1; }
.bar-chart { height: 235px; display: flex; align-items: stretch; gap: clamp(12px,3vw,34px); padding: 20px 10px 0; border-bottom: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 53px, #edf0f4 54px); }
.bar-col { height: 100%; flex: 1; min-width: 22px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
.bar { width: min(38px,80%); min-height: 5px; height: var(--height); background: linear-gradient(180deg,#8a73ef,#6e50df); border-radius: 7px 7px 2px 2px; transition: height .5s ease; }
.bar-col > span { position: absolute; bottom: -26px; color: #7b8494; font-size: 10px; white-space: nowrap; }
.bar-value { opacity: 0; pointer-events: none; position: absolute; bottom: calc(var(--height) + 8px); padding: 4px 7px; color: white; background: var(--navy); font-size: 9px; border-radius: 5px; white-space: nowrap; z-index: 2; transition: opacity .15s; }
.bar-col:hover .bar-value { opacity: 1; }
.chart-panel { padding-bottom: 46px !important; }
.breakdown { display: grid; gap: 18px; }
.breakdown-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 11px; }
.breakdown-meta > span { display: flex; align-items: center; gap: 8px; }
.breakdown-meta i, .category-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.breakdown-row small { color: #98a0af; font-size: 9px; display: block; margin-top: 5px; }
.progress { height: 5px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; width: min(var(--progress),100%); background: var(--bar); border-radius: inherit; }
.progress.large { height: 8px; }
.progress.over i { background: var(--red) !important; }

.transaction-row { min-height: 60px; display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 8px 3px; border-bottom: 1px solid #edf0f4; }
.transaction-row:last-child { border-bottom: 0; }
.transaction-row:hover .transaction-main strong { color: var(--accent); }
.category-dot { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--dot); background: color-mix(in srgb, var(--dot) 12%, white); }
.transaction-main { min-width: 0; }
.transaction-main strong, .transaction-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-main strong { font-size: 12px; margin-bottom: 4px; }
.transaction-main small { color: var(--muted); font-size: 10px; }
.transaction-amount { font-weight: 700; font-size: 12px; }

.filter-panel { padding: 14px; margin-bottom: 14px; }
.filters { display: flex; align-items: flex-end; gap: 9px; flex-wrap: wrap; }
.filters label { min-width: 130px; }
.filters label > span { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; margin: 0 0 5px 2px; }
.filters .search-field { flex: 1; min-width: 230px; position: relative; }
.search-field svg { position: absolute; left: 12px; bottom: 11px; color: #9aa3b2; }
.search-field input { padding-left: 38px; }
input, select, textarea { width: 100%; border: 1px solid #d9dee7; border-radius: 8px; background: #fff; color: var(--ink); outline: 0; transition: .15s; }
input, select { height: 40px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #8c75ef; box-shadow: 0 0 0 3px rgba(115,87,232,.1); }
input::placeholder, textarea::placeholder { color: #a8b0bd; }

.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 15px; text-align: left; background: #fafbfc; border-bottom: 1px solid var(--line); color: #747f90; font-size: 9px; text-transform: uppercase; letter-spacing: .7px; font-weight: 750; white-space: nowrap; }
td { padding: 12px 15px; border-bottom: 1px solid #edf0f3; font-size: 11px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.align-right, .amount-cell { text-align: right; }
.amount-cell { font-weight: 700; font-size: 12px; }
.merchant-cell { display: flex; align-items: center; gap: 10px; min-width: 175px; }
.merchant-cell > span:last-child { min-width: 0; }
.merchant-cell strong, .merchant-cell small { display: block; }
.merchant-cell small { color: #8993a2; margin-top: 3px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.category-chip { display: inline-flex; align-items: center; gap: 7px; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 99px; font-size: 9px; font-weight: 680; }
.status-cleared { color: #087653; background: #e7f8f1; }
.status-pending { color: #97600a; background: #fff6dd; }
.status-reimbursable { color: #5e45c6; background: #f0edff; }
.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.row-actions form { margin: 0; }
.empty-table { padding: 58px 20px; text-align: center; }
.empty-table h3 { margin: 15px 0 6px; }
.empty-table p { color: var(--muted); margin-bottom: 16px; }
.empty-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin: 0 auto; font-size: 26px; font-weight: 800; }

.expense-layout { display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: 17px; align-items: start; }
.form-panel { padding: 23px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
label { display: block; font-size: 11px; font-weight: 650; color: #475467; }
label input, label select, label textarea, label .input-prefix { margin-top: 7px; }
label small { display: block; color: #98a0af; font-size: 9px; margin-top: 5px; font-weight: 450; }
.span-2 { grid-column: span 2; }
.input-prefix { display: flex; border: 1px solid #d9dee7; border-radius: 8px; overflow: hidden; background: white; }
.input-prefix:focus-within { border-color: #8c75ef; box-shadow: 0 0 0 3px rgba(115,87,232,.1); }
.input-prefix > span { width: 38px; background: #f7f8fa; border-right: 1px solid #e2e5ea; display: grid; place-items: center; color: #667085; font-weight: 600; }
.input-prefix input { margin: 0; border: 0; border-radius: 0; box-shadow: none !important; }
.check-label { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.check-label > input { position: absolute; opacity: 0; pointer-events: none; }
.check-label > span { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid #cfd5df; border-radius: 6px; color: transparent; }
.check-label input:checked + span { background: var(--accent); border-color: var(--accent); color: white; }
.check-label strong, .check-label small { display: block; }
.receipt-panel { position: sticky; top: 87px; }
.upload-zone { height: 172px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #c6cbd5; border-radius: 11px; background: #fafbfc; cursor: pointer; transition: .15s; }
.upload-zone:hover { border-color: var(--accent); background: #fbfaff; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-zone > span { color: var(--accent); margin-bottom: 10px; }
.upload-zone strong { color: var(--ink); }
.upload-zone small { margin-top: 5px; }
.upload-zone.has-file { border-color: var(--green); background: #f1fbf7; }
.receipt-link { display: flex; align-items: center; gap: 7px; color: var(--accent); font-weight: 650; margin-top: 13px; }
.form-actions { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }

.budget-form { margin-bottom: 17px; }
.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 160px; }
.budget-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 15px; }
.budget-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.budget-top { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; }
.budget-top h3 { font-size: 13px; margin: 0 0 3px; }
.budget-top p { font-size: 10px; color: var(--muted); margin: 0; }
.budget-numbers { margin: 24px 0 11px; display: flex; align-items: baseline; justify-content: space-between; }
.budget-numbers strong { font-size: 22px; letter-spacing: -.5px; }
.budget-numbers span { font-size: 10px; color: var(--muted); }
.budget-foot { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 9px; }
.budget-grid > .empty-state { grid-column: 1 / -1; }

.loan-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 15px; }
.loan-grid > .empty-state { grid-column: 1 / -1; }
.loan-card { display: block; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: .16s ease; }
.loan-card:hover { transform: translateY(-2px); border-color: #cfc8f3; box-shadow: 0 10px 28px rgba(16,24,40,.08); }
.loan-card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.loan-type { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 5px 8px; border-radius: 7px; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .45px; }
.loan-type-lent { color: #087653; background: #e7f8f1; }
.loan-type-borrowed { color: #5e45c6; background: #f0edff; }
.loan-card h3 { margin: 0 0 4px; font-size: 15px; }
.loan-card > p { margin: 0 0 5px; color: var(--muted); font-size: 10px; }
.loan-card-amount { display: block; font-size: 25px; letter-spacing: -.7px; margin-bottom: 18px; }
.loan-card-foot { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 9px; margin-top: 8px; }
.negative { color: var(--red) !important; }

.loan-detail-grid { display: grid; grid-template-columns: minmax(280px,.8fr) minmax(400px,1.2fr); gap: 17px; align-items: start; }
.loan-summary { padding: 23px; }
.loan-balance { margin: 25px 0 17px; }
.loan-balance span, .loan-balance small { display: block; color: var(--muted); font-size: 10px; }
.loan-balance strong { display: block; font-size: 32px; letter-spacing: -1px; margin: 7px 0 4px; }
.loan-summary-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 22px 0; }
.loan-summary-grid > div { background: white; padding: 13px; }
.loan-summary-grid span, .loan-summary-grid strong { display: block; }
.loan-summary-grid span { color: var(--muted); font-size: 9px; margin-bottom: 5px; }
.loan-summary-grid strong { font-size: 11px; }
.loan-notes { border-top: 1px solid var(--line); padding-top: 17px; }
.loan-notes > span { color: var(--muted); font-size: 10px; margin-right: 8px; }
.loan-notes p { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 15px 0 0; }
.loan-history { grid-column: 1 / -1; padding: 23px; }
.loan-history-row { min-height: 58px; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 11px; align-items: center; border-bottom: 1px solid var(--line); }
.loan-history-row:last-child { border-bottom: 0; }
.loan-history-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.loan-history-row strong, .loan-history-row small { display: block; }
.loan-history-row strong { font-size: 11px; margin-bottom: 4px; }
.loan-history-row small { color: var(--muted); font-size: 9px; }
.loan-history-row time { color: var(--muted); font-size: 9px; }
.danger-zone { grid-column: 1 / -1; }
.danger-zone > form { margin-top: 16px; }
.writeoff-form { border-top: 1px solid var(--line); padding-top: 16px; }
.text-danger { border: 0; background: transparent; color: var(--red); padding: 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 11px; font-weight: 650; }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; }

.loan-form { max-width: 820px; }
.direction-picker { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; margin-bottom: 20px; }
.direction-picker label { cursor: pointer; }
.direction-picker input { position: absolute; opacity: 0; pointer-events: none; }
.direction-picker label > span { min-height: 94px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 15px; border: 1px solid #d9dee7; border-radius: 11px; transition: .15s; }
.direction-picker label > span svg { color: var(--accent); margin-bottom: 2px; }
.direction-picker label > span strong, .direction-picker label > span small { display: block; }
.direction-picker label > span small { margin: 0; }
.direction-picker input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px rgba(115,87,232,.08); }
.loan-fixed-summary { display: flex; align-items: center; gap: 25px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; margin-bottom: 20px; }
.loan-fixed-summary > div { margin-left: auto; }
.loan-fixed-summary small, .loan-fixed-summary strong { display: block; }
.loan-fixed-summary small { color: var(--muted); font-size: 9px; margin-bottom: 4px; }
.loan-fixed-summary strong { font-size: 12px; }
.inline-optional { display: inline; margin-left: 4px; }
.form-submit { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 18px; }

.report-filter { padding: 15px; margin-bottom: 16px; }
.report-filter .inline-form { max-width: 600px; }
.report-stats .text-stat { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reports-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(310px,.8fr); gap: 17px; }
.reports-grid .panel { padding: 22px; }
.report-chart { overflow-x: auto; gap: 18px; }
.report-chart .bar-col { min-width: 35px; }
.report-categories { display: grid; gap: 16px; }
.report-category { display: grid; grid-template-columns: 34px minmax(100px,1fr) auto; gap: 10px; align-items: center; }
.report-category > div strong { display: block; font-size: 11px; margin-bottom: 7px; }
.report-category > span:last-child { text-align: right; }
.report-category > span:last-child strong, .report-category > span:last-child small { display: block; }
.report-category > span:last-child small { color: var(--muted); margin-top: 3px; }

.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 17px; align-items: start; }
.settings-security { grid-column: 1 / -1; }
.stack-form { display: grid; gap: 16px; }
.stack-form.compact { gap: 15px; }
.stack-form.compact .btn { justify-self: start; }
.security-status { display: flex; align-items: center; gap: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfc; }
.security-status > span { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.security-status > div { flex: 1; }
.security-status strong, .security-status p { display: block; }
.security-status p { color: var(--muted); margin: 4px 0 0; font-size: 11px; }
.security-status.enabled { background: #f1fbf7; border-color: #c7ebdc; }
.security-status.enabled > span { color: var(--green); background: #dff5eb; }
.profile-picture-field { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfc; }
.profile-picture-field > div { display: grid; gap: 5px; }
.profile-picture-field .btn { width: fit-content; margin: 0; }
.profile-picture-field .btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.profile-picture-field small { color: var(--muted); font-size: 9px; }
.remove-photo { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 9px; font-weight: 550; }
.remove-photo input { width: 14px; height: 14px; margin: 0; }
.inline-confirm { display: flex; align-items: flex-end; gap: 10px; margin-top: 15px; max-width: 470px; }
.inline-confirm label { flex: 1; }
.setup-steps { display: grid; gap: 14px; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 11px; }
.step > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: white; font-weight: 700; }
.step strong { display: block; }
.step p { color: var(--muted); margin: 5px 0 12px; font-size: 11px; }
.step form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.step form > strong { grid-column: 1 / -1; }
.secret-code { display: block; width: fit-content; margin: 8px 0 12px; padding: 10px 12px; background: #f3f1fd; border-radius: 7px; color: #513cb4; letter-spacing: 1px; font-weight: 700; }
.qr-setup { display: flex; align-items: center; gap: 22px; margin-top: 13px; }
.qr-setup > img { width: 220px; height: 220px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: white; image-rendering: pixelated; }
.qr-setup small { display: block; color: var(--muted); font-size: 10px; }
.recovery-box { border: 1px solid #f1cc79; border-radius: 11px; background: #fff9e9; padding: 17px; margin-bottom: 14px; }
.recovery-box h3 { font-size: 13px; margin: 0 0 5px; }
.recovery-box p { color: #786130; font-size: 11px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2,1fr); gap: 7px; }
.recovery-codes code { padding: 7px 9px; background: white; border: 1px solid #f1dfa9; border-radius: 6px; }

.admin-stats { grid-template-columns: repeat(3,1fr); }
.admin-actions { display: flex; align-items: center; gap: 6px; }
.admin-actions select { width: auto; height: 34px; font-size: 10px; }
.admin-edit-grid { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 17px; align-items: start; }
.admin-edit-grid .danger-zone { grid-column: auto; }
.admin-check { margin-top: 7px; }
.audit-panel { margin-top: 17px; }
td code { padding: 3px 6px; background: #f2f1f8; color: #5743ad; border-radius: 5px; font-size: 10px; }
.table-sub { display: block; color: var(--muted); margin-top: 3px; }

.flash { min-height: 44px; border-radius: 10px; padding: 10px 12px; margin-bottom: 17px; display: flex; align-items: center; gap: 9px; font-size: 12px; }
.flash span { flex: 1; }
.flash button { border: 0; background: transparent; padding: 3px; cursor: pointer; }
.flash-success { color: #087653; background: #eaf9f3; border: 1px solid #c5ebdc; }
.flash-error { color: #ac293a; background: #fff0f2; border: 1px solid #fecdd3; }
.compact-empty { text-align: center; padding: 25px 12px; color: var(--muted); }
.compact-empty p { margin-bottom: 6px; }
.compact-empty a { color: var(--accent); font-weight: 650; }
.empty-state { text-align: center; padding: 65px 25px; }
.empty-state h1, .empty-state h2 { margin: 18px 0 7px; }
.empty-state p { color: var(--muted); margin-bottom: 19px; }

.auth-page { min-height: 100vh; background: white; display: flex; flex-direction: column; }
.auth-page .site-footer { flex: 0 0 auto; background: white; }
.auth-shell { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(460px,.82fr) minmax(500px,1.18fr); background: white; }
.auth-card { width: min(430px,calc(100% - 50px)); margin: auto; padding: 46px 0; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 750; margin-bottom: 65px; }
.auth-heading { margin-bottom: 27px; }
.auth-heading h1 { margin: 0 0 10px; font-size: 31px; line-height: 1.16; letter-spacing: -1px; }
.auth-heading p { color: var(--muted); line-height: 1.65; margin: 0; }
.auth-heading.center { text-align: center; }
.auth-card .stack-form { gap: 17px; }
.auth-card input { height: 46px; }
.auth-card .btn { min-height: 46px; margin-top: 3px; }
.form-hint { color: var(--muted); font-size: 10px; margin: -8px 0 0; }
.form-error { min-height: 43px; display: flex; align-items: center; gap: 8px; color: #ab293b; background: #fff1f2; border: 1px solid #fecdd3; border-radius: 9px; padding: 9px 11px; margin-bottom: 18px; font-size: 11px; }
.form-error.neutral { color: #5e45c6; background: var(--accent-soft); border-color: #dcd5fb; justify-content: center; }
.hp-field { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.human-check { display: grid; grid-template-columns: minmax(180px,1fr) 120px; gap: 12px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfc; }
.human-check img { display: block; width: 100%; max-width: 240px; height: 70px; border-radius: 9px; }
.human-check > div .text-link { margin-top: 6px; font-size: 9px; }
.auth-switch { text-align: center; color: var(--muted); margin: 24px 0 0; font-size: 11px; }
.auth-switch a { color: var(--accent); font-weight: 700; }
.auth-aside { min-height: calc(100vh - 82px); margin: 14px; border-radius: 20px; padding: clamp(48px,7vw,100px); color: white; background: radial-gradient(circle at 80% 15%,rgba(132,111,238,.32),transparent 35%), radial-gradient(circle at 20% 80%,rgba(51,85,126,.5),transparent 35%), linear-gradient(145deg,#162238,#0c1525 70%); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth-aside::after { content: ''; position: absolute; width: 440px; height: 440px; border: 1px solid rgba(255,255,255,.06); border-radius: 50%; right: -220px; bottom: -230px; box-shadow: 0 0 0 80px rgba(255,255,255,.02),0 0 0 160px rgba(255,255,255,.015); }
.auth-aside > * { position: relative; z-index: 2; }
.feature-pill { display: inline-flex; align-items: center; gap: 7px; width: fit-content; padding: 7px 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); border-radius: 99px; color: #c7baff; font-size: 10px; font-weight: 650; margin-bottom: 30px; }
.auth-aside h2 { font-size: clamp(36px,4vw,58px); line-height: 1.08; letter-spacing: -2px; margin: 0 0 23px; max-width: 710px; }
.auth-aside h2 em { font-style: normal; color: #9883f3; }
.auth-aside > div > p { color: #9ca9bc; font-size: 15px; line-height: 1.7; max-width: 560px; }
.auth-proof { margin-top: 70px; display: flex; gap: 45px; }
.auth-proof strong, .auth-proof span { display: block; }
.auth-proof strong { color: white; margin-bottom: 6px; }
.auth-proof span { color: #78869a; font-size: 10px; }
.auth-aside blockquote { margin: 70px 0 0; font-family: Georgia,serif; font-size: 19px; line-height: 1.5; color: #c8d0dc; }
.auth-aside blockquote span { display: block; font-family: inherit; color: #7e899a; font-size: 11px; margin-top: 8px; }
.auth-card-centered { max-width: 390px; text-align: left; }
.auth-card-centered .auth-brand { justify-content: center; }
.security-orb { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 22px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.code-input { text-align: center; font-size: 20px; letter-spacing: 5px; font-weight: 700; }
.auth-shell > .empty-state { grid-column: 1 / -1; align-self: center; }

.backdrop { display: none; }

@media (max-width: 1120px) {
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .budget-grid { grid-template-columns: repeat(2,1fr); }
  .loan-grid { grid-template-columns: repeat(2,1fr); }
  .auth-shell { grid-template-columns: minmax(420px,.9fr) minmax(420px,1.1fr); }
  .auth-aside { padding: 55px; }
}

@media (max-width: 850px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(9,16,28,.55); }
  .sidebar.open ~ .main-wrap + .backdrop { display: block; }
  .main-wrap { margin-left: 0; }
  .mobile-menu { display: inline-grid !important; }
  .topbar { padding: 0 20px; }
  .content { padding: 28px 20px 50px; }
  .dashboard-grid, .reports-grid { grid-template-columns: 1fr; }
  .recent-panel { grid-column: auto; }
  .expense-layout { grid-template-columns: 1fr; }
  .loan-detail-grid { grid-template-columns: 1fr; }
  .admin-edit-grid { grid-template-columns: 1fr; }
  .receipt-panel { position: static; }
  .auth-shell { display: block; }
  .auth-card { min-height: calc(100vh - 54px); display: flex; flex-direction: column; justify-content: center; }
  .auth-brand { margin-bottom: 48px; }
  .auth-aside { display: none; }
}

@media (max-width: 620px) {
  .page-head { display: block; }
  .page-head h1 { font-size: 24px; }
  .page-actions { margin-top: 17px; }
  .page-actions .btn { flex: 1; }
  .stat-grid, .budget-grid, .loan-grid, .settings-grid { grid-template-columns: 1fr; }
  .settings-security { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters .search-field { grid-column: 1 / -1; min-width: 0; }
  .filters label { min-width: 0; }
  .filters .btn { width: 100%; }
  .bar-chart { gap: 8px; }
  .bar-col > span { font-size: 9px; }
  .auth-card { width: min(390px,calc(100% - 38px)); }
  .auth-heading h1 { font-size: 27px; }
  .security-status { align-items: flex-start; flex-wrap: wrap; }
  .security-status form { width: 100%; }
  .security-status .btn { width: 100%; }
  .inline-confirm, .step form { display: grid; grid-template-columns: 1fr; }
  .recovery-codes { grid-template-columns: 1fr; }
  .qr-setup { align-items: flex-start; flex-direction: column; }
  .human-check { grid-template-columns: 1fr; }
  .site-footer i { margin: 0 4px; }
  .direction-picker { grid-template-columns: 1fr; }
  .loan-fixed-summary { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .loan-fixed-summary > div { margin-left: 0; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
