:root {
  --bg: #07111f;
  --bg-soft: #0b1728;
  --panel: rgba(255,255,255,.96);
  --panel-solid: #fff;
  --ink: #142033;
  --muted: #708096;
  --line: #e7ebf1;
  --primary: #6c5ce7;
  --primary-2: #8b7cf6;
  --cyan: #19b9d1;
  --green: #1eb980;
  --red: #ed5c70;
  --amber: #f3a83b;
  --purple: #9c6ade;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(15, 28, 48, .10);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: #f3f6fa; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.desktop-only { display: inline-flex; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 248px; color: #dce5f3; background: radial-gradient(circle at 10% 0%, #172e4b 0, #0a1728 45%, #07111f 100%); padding: 28px 20px 22px; display: flex; flex-direction: column; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg, #8e7dff, #5b49d9); color: white; font-size: 22px; font-weight: 900; box-shadow: 0 10px 24px rgba(108,92,231,.35); }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 16px; letter-spacing: .03em; }
.brand small { color: #91a4bd; margin-top: 5px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.side-nav { margin-top: 36px; display: flex; flex-direction: column; gap: 7px; }
.side-nav a { display: flex; gap: 13px; align-items: center; color: #9fb0c6; padding: 12px 14px; border-radius: 13px; font-size: 14px; font-weight: 650; transition: .2s ease; }
.side-nav a span { width: 22px; text-align: center; font-size: 18px; color: #8196b0; }
.side-nav a:hover { color: white; background: rgba(255,255,255,.06); }
.side-nav a.active { color: white; background: linear-gradient(105deg, rgba(108,92,231,.34), rgba(108,92,231,.10)); box-shadow: inset 3px 0 0 #8c7cff; }
.side-nav a.active span { color: #b7adff; }
.nav-label { margin: 22px 14px 3px; color: #61758e; font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.055); padding: 12px; border: 1px solid rgba(255,255,255,.06); border-radius: 16px; }
.avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg,#25b9cf,#6c5ce7); font-weight: 800; }
.avatar.large { width: 54px; height: 54px; font-size: 21px; }
.user-meta { min-width: 0; display: flex; flex-direction: column; flex: 1; }
.user-meta strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.user-meta small { color: #8295ad; margin-top: 3px; }
.sidebar-user > a { color: #9fb0c6; padding: 6px; }

.main-content { margin-left: 248px; min-height: 100vh; padding: 30px 34px 60px; }
.topbar { min-height: 64px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.eyebrow { display: block; color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .14em; font-weight: 850; margin-bottom: 6px; }
.topbar h1 { margin: 0; font-size: clamp(23px, 3vw, 31px); line-height: 1.05; letter-spacing: -.035em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: white; color: #64748b; font-size: 20px; }
.card { background: var(--panel); border: 1px solid rgba(220,226,235,.92); border-radius: var(--radius); box-shadow: var(--shadow); }
.button { border: 0; border-radius: 12px; min-height: 40px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 760; font-size: 13px; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: linear-gradient(120deg, var(--primary), #806ff1); box-shadow: 0 9px 22px rgba(108,92,231,.25); }
.button-soft { color: #5546c9; background: #eeebff; }
.button-ghost { color: #536277; background: transparent; border: 1px solid var(--line); }
.button-danger { color: #c83e53; background: #fff0f3; }
.button-large { min-height: 50px; border-radius: 14px; }
.alert { padding: 13px 16px; margin: 0 0 20px; border-radius: 13px; font-size: 13px; font-weight: 650; }
.alert-success { background: #e9fbf4; color: #157451; border: 1px solid #bcebd9; }
.alert-danger { background: #fff0f2; color: #ad3345; border: 1px solid #f5c6ce; }
.alert-warning { background: #fff8e8; color: #8e6419; border: 1px solid #f1dfad; }

/* Login */
.auth-body { background: var(--bg); color: white; }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: 1.25fr .75fr; overflow: hidden; }
.auth-visual { min-height: 100vh; position: relative; display: flex; align-items: center; padding: 8vw; background: radial-gradient(circle at 20% 25%, #183653 0, #0b1b30 35%, #07111f 70%); overflow: hidden; }
.auth-visual::after { content: ""; position: absolute; inset: 0; opacity: .16; background-image: linear-gradient(rgba(255,255,255,.05) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.05) 1px,transparent 1px); background-size: 50px 50px; mask-image: linear-gradient(to right, black, transparent 88%); }
.auth-orb { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .55; }
.orb-one { width: 340px; height: 340px; right: -130px; top: 7%; background: radial-gradient(circle at 35% 30%, #9b8cff, #5a36bf 55%, transparent 70%); }
.orb-two { width: 240px; height: 240px; left: -90px; bottom: -70px; background: radial-gradient(circle at 35% 30%, #31d6d1, #126894 58%, transparent 70%); }
.auth-copy { position: relative; z-index: 1; max-width: 670px; }
.pill { display: inline-block; padding: 7px 11px; border: 1px solid rgba(164,181,204,.25); background: rgba(255,255,255,.06); border-radius: 999px; color: #abc0d7; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.auth-copy h1 { font-size: clamp(40px, 5vw, 73px); line-height: .98; letter-spacing: -.055em; margin: 27px 0 22px; }
.auth-copy h1 em { color: #a99cff; font-style: normal; }
.auth-copy p { max-width: 540px; color: #9eb1c8; font-size: 17px; line-height: 1.7; }
.auth-highlights { display: flex; flex-wrap: wrap; gap: 20px; color: #c2d0df; font-size: 13px; margin-top: 40px; }
.auth-panel { display: grid; place-items: center; background: #f5f7fa; padding: 40px; color: var(--ink); }
.login-card { width: min(410px, 100%); }
.login-brand { color: var(--ink); margin-bottom: 48px; }
.login-heading h2 { margin: 0 0 8px; font-size: 31px; letter-spacing: -.04em; }
.login-heading p { color: var(--muted); margin: 0 0 30px; line-height: 1.55; }
.login-card label { display: block; margin: 0 0 18px; font-size: 12px; color: #4d5a6c; font-weight: 750; }
.login-card input { display: block; width: 100%; height: 52px; margin-top: 8px; border: 1px solid #dce2ea; border-radius: 13px; background: white; padding: 0 15px; outline: none; }
.login-card input:focus { border-color: #8a79ef; box-shadow: 0 0 0 4px rgba(108,92,231,.10); }
.login-card .button { width: 100%; margin-top: 6px; }
.security-note { text-align: center; color: #8a96a6; font-size: 11px; margin-top: 24px; }
.auth-alert { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100; }

/* Forms */
.expense-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 22px; align-items: start; }
.entry-card { padding: 25px; }
.receipt-drop { border: 1.5px dashed #cfd6e3; border-radius: 18px; padding: 20px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; background: linear-gradient(120deg,#f8f7ff,#f5fbfd); margin-bottom: 26px; }
.scan-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; background: #e8e4ff; color: var(--primary); font-size: 28px; }
.receipt-drop h3 { margin: 0 0 4px; font-size: 16px; }
.receipt-drop p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.file-button input { display: none; }
.receipt-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }
.receipt-selected { grid-column: 1 / -1; padding: 10px 12px; border-radius: 11px; background: #eef3ff; color: #4d5e82; font-size: 12px; overflow-wrap: anywhere; }
.button-disabled { opacity: .55; pointer-events: none; }
.parse-progress,.parse-result { display: flex; align-items: center; gap: 13px; padding: 14px 16px; border-radius: 14px; margin: -12px 0 25px; }
.parse-progress { background: #eef3ff; color: #4d5e82; }
.parse-result { background: #e9fbf4; color: #157451; }
.parse-progress > div,.parse-result > div { display: flex; flex-direction: column; gap: 3px; }
.parse-progress small,.parse-result small { opacity: .78; }
.parse-progress-content { flex: 1; min-width: 0; }
.parse-progress-heading { display: flex !important; flex-direction: row !important; justify-content: space-between; align-items: center; gap: 12px; }
.parse-progress-heading small { font-weight: 850; opacity: 1; }
.progress-track { width: 100%; height: 8px; margin: 7px 0 4px; border-radius: 999px; background: #dce4f5; overflow: hidden; }
.progress-track span { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--primary),#4e9cff); transition: width .28s ease; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #cbd5e9; border-top-color: var(--primary); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.attached-receipt { display: flex; justify-content: space-between; align-items: center; background: #f4f7fb; border: 1px solid var(--line); padding: 15px; border-radius: 15px; margin-bottom: 23px; }
.attached-receipt > div { display: grid; grid-template-columns: auto 1fr; column-gap: 11px; }
.attachment-icon { grid-row: 1/3; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: #e6e9ff; color: var(--primary); }
.attached-receipt small { color: var(--muted); margin-top: 3px; }
.section-heading,.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading { margin-bottom: 19px; }
.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading h2,.card-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.section-heading p,.card-heading a { margin: 0; color: var(--muted); font-size: 12px; }
.step { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: #eeeaff; color: var(--primary); font-size: 10px; font-weight: 900; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; color: #445064; font-size: 12px; font-weight: 740; }
.field input,.field select,.field textarea,.filter-form input,.filter-form select { width: 100%; border: 1px solid #dce2ea; border-radius: 12px; background: #fbfcfe; color: var(--ink); outline: none; padding: 0 13px; transition: .18s ease; }
.field input,.field select,.filter-form input,.filter-form select { height: 46px; }
.field textarea { resize: vertical; padding-top: 12px; }
.field input:focus,.field select:focus,.field textarea:focus,.filter-form input:focus,.filter-form select:focus { border-color: #9182ef; box-shadow: 0 0 0 4px rgba(108,92,231,.09); background: white; }
.field small { color: var(--muted); font-weight: 500; line-height: 1.4; }
.span-2 { grid-column: span 2; }
.money-input { display: grid; grid-template-columns: auto 1fr; align-items: center; border: 1px solid #dce2ea; border-radius: 12px; background: #fbfcfe; overflow: hidden; }
.money-input span { height: 44px; display: grid; place-items: center; padding: 0 12px; color: #5a48cd; background: #efedff; font-size: 12px; }
.money-input input { border: 0; border-radius: 0; background: transparent; }
.money-input:focus-within { border-color: #9182ef; box-shadow: 0 0 0 4px rgba(108,92,231,.09); }
.input-with-action { display: grid; grid-template-columns: 1fr 42px; }
.input-with-action input { border-radius: 12px 0 0 12px; }
.input-with-action button { border: 1px solid #dce2ea; border-left: 0; border-radius: 0 12px 12px 0; background: #eef2f8; color: #596a81; }
.advanced-panel { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.advanced-panel summary { cursor: pointer; color: #5c6780; font-size: 12px; font-weight: 750; }
.advanced-grid { margin-top: 15px; }
.save-panel { position: sticky; top: 25px; padding: 25px; text-align: center; }
.save-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 4px auto 17px; border-radius: 19px; background: linear-gradient(145deg,#e6fbf3,#d7f8ec); color: var(--green); font-size: 25px; }
.save-panel h3 { margin: 0 0 10px; font-size: 20px; }
.save-panel p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.save-summary { display: flex; justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 0; margin: 18px 0; font-size: 12px; }
.save-panel .button { width: 100%; margin-bottom: 9px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.form-card { padding: 25px; }
.form-intro { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 9px 0 22px; }
.stack-form { display: flex; flex-direction: column; gap: 15px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.narrow-card { width: min(650px,100%); margin: auto; }

/* Dashboard */
.filter-bar { padding: 12px 14px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.filter-form { display: flex; align-items: center; gap: 9px; }
.filter-form.wrap { flex-wrap: wrap; width: 100%; }
.filter-form input,.filter-form select { width: auto; min-width: 140px; background: white; }
.search-input { flex: 1; min-width: 220px !important; }
.segmented { display: flex; padding: 4px; border-radius: 11px; background: #edf1f6; }
.segmented button { border: 0; border-radius: 8px; padding: 8px 13px; color: #718096; background: transparent; font-size: 11px; font-weight: 760; }
.segmented button.active { color: #4f42c1; background: white; box-shadow: 0 3px 10px rgba(45,55,72,.09); }
.period-caption { color: var(--muted); font-size: 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; padding: 20px; min-height: 133px; display: flex; flex-direction: column; }
.metric-card::before { content:""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.accent-red::before { background: var(--red); }.accent-green::before { background: var(--green); }.accent-blue::before { background: var(--cyan); }.accent-purple::before { background: var(--purple); }
.metric-card::after { content:""; position:absolute; width:70px; height:70px; border-radius:50%; right:-24px; top:-25px; background: currentColor; opacity:.045; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 720; }
.metric-card strong { margin-top: 14px; font-size: clamp(19px,2vw,26px); letter-spacing: -.04em; }
.metric-card small { margin-top: auto; color: #8995a5; font-size: 10px; }
.dashboard-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 18px; margin-bottom: 18px; }
.chart-card,.category-list-card,.recent-card,.table-card,.list-card { padding: 21px; }
.card-heading { margin-bottom: 18px; }
.card-heading a { color: #6555d7; font-weight: 750; }
.chart-wrap { height: 280px; position: relative; }
.chart-wrap.donut { height: 280px; }
.empty-chart { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.lower-grid { grid-template-columns: 1fr 1.3fr; }
.category-list,.transaction-list { display: flex; flex-direction: column; }
.category-row,.transaction-row { min-height: 62px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 11px; border-top: 1px solid #edf0f4; }
.category-row:first-child,.transaction-row:first-child { border-top: 0; }
.category-avatar,.transaction-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #5e4fd1; background: #efedff; font-weight: 820; }
.category-row > div:nth-child(2),.transaction-row > div:nth-child(2) { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.category-row strong,.transaction-row strong { font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.category-row small,.transaction-row small { color: var(--muted); font-size: 10px; }
.category-row > span,.transaction-row > span { font-size: 12px; font-weight: 800; }
.amount-out { color: #b54456; }.amount-in { color: #16815b; display: flex; align-items: center; gap: 7px; }
.income-icon { color: var(--green); background: #e6f9f1; }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); font-size: 12px; }
.empty-state.compact { padding: 30px 10px; }

/* Tables and lists */
.transactions-filter { align-items: stretch; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: #8491a2; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; border-bottom: 1px solid #edf0f4; font-size: 12px; vertical-align: middle; }
tbody tr { cursor: pointer; transition: .15s; }
tbody tr:hover { background: #fafbfe; }
td strong,td small { display: block; } td small { color: var(--muted); margin-top: 4px; }
.category-badge,.role-badge { display: inline-flex; padding: 5px 8px; border-radius: 8px; color: #5c50bd; background: #f0eeff; font-size: 10px; font-weight: 750; }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .05em; }
.status-confirmed { color: #157451; background: #e5f8f0; }.status-draft { color: #946616; background: #fff3d6; }
.split-layout { display: grid; grid-template-columns: minmax(330px,.75fr) minmax(0,1.25fr); gap: 20px; align-items: start; }
.list-card { min-height: 400px; }
.tiny-delete { border: 0; width: 25px; height: 25px; border-radius: 8px; color: #b34b5b; background: #fff0f2; }
.commitment-list { display: flex; flex-direction: column; gap: 10px; }
.commitment-item { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 15px; }
.commitment-item.disabled { opacity: .55; }
.due-badge { width: 50px; height: 54px; display: grid; place-items: center; border-radius: 13px; background: #efedff; color: #5949cb; }
.due-badge small { font-size: 7px; font-weight: 900; letter-spacing: .12em; }.due-badge strong { font-size: 20px; line-height: .8; }
.commitment-info { display: flex; flex-direction: column; gap: 4px; }
.commitment-info strong { font-size: 13px; }.commitment-info span { color: #5f6c7f; font-size: 11px; }.commitment-info small { color: var(--muted); font-size: 10px; }
.commitment-actions { display: flex; align-items: center; gap: 6px; }
.status-toggle { border: 0; border-radius: 9px; background: #eef1f6; color: #5c687a; padding: 7px 9px; font-size: 10px; font-weight: 750; }

/* Settings/admin */
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.profile-card,.settings-card { padding: 24px; }
.profile-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.profile-hero h2 { margin: 0 0 4px; }.profile-hero p { margin: 0; color: var(--muted); font-size: 12px; }
.settings-row { display: flex; justify-content: space-between; gap: 15px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 12px; }
.settings-row span { color: var(--muted); }
.connection-dot { width: 11px; height: 11px; border-radius: 50%; background: #c8d0dc; box-shadow: 0 0 0 5px #f0f2f6; }.connection-dot.connected { background: var(--green); box-shadow: 0 0 0 5px #e3f7ef; }
.settings-card p,.settings-card li { color: var(--muted); font-size: 12px; line-height: 1.65; }
.settings-card code { color: #5747c7; background: #efedff; padding: 2px 5px; border-radius: 5px; }
.link-code { display: inline-flex; padding: 13px 18px; margin: 2px 0 15px; border: 1px dashed #9688ef; border-radius: 13px; background: #f4f2ff; color: #5141c0; font-size: 20px; font-weight: 900; letter-spacing: .14em; }
.member-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.member-card { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; border: 1px solid var(--line); padding: 16px; border-radius: 16px; transition: .16s; }
.member-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(26,39,61,.09); }
.member-info h3 { margin: 0 0 3px; font-size: 14px; }.member-info p { margin: 0 0 8px; color: var(--muted); font-size: 11px; }.member-info > div { display: flex; gap: 6px; }
.member-stat { text-align: right; }.member-stat strong { display: block; font-size: 22px; }.member-stat small { color: var(--muted); font-size: 9px; }

.bottom-nav { display: none; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .expense-layout { grid-template-columns: 1fr; }
  .save-panel { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; text-align: left; }
  .save-panel .save-icon,.save-panel h3,.save-panel p,.save-panel .save-summary,.danger-zone { grid-column: span 2; }
  .save-panel .save-icon { margin-left: 0; }
}

@media (max-width: 820px) {
  body { background: #f4f6fa; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: max(20px,env(safe-area-inset-top)) 15px calc(95px + var(--safe-bottom)); }
  .topbar { margin-bottom: 18px; min-height: 48px; }
  .topbar-actions .icon-button { display: none; }
  .desktop-only { display: none; }
  .bottom-nav { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: calc(70px + var(--safe-bottom)); padding: 7px 14px var(--safe-bottom); background: rgba(255,255,255,.94); backdrop-filter: blur(18px); border-top: 1px solid #e3e7ed; display: grid; grid-template-columns: repeat(5,1fr); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #8591a2; }
  .bottom-nav a span { font-size: 20px; line-height: 1; }.bottom-nav a small { font-size: 9px; font-weight: 720; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .add-button span { width: 43px; height: 43px; margin-top: -26px; display: grid; place-items: center; border-radius: 15px; color: white; background: linear-gradient(145deg,var(--primary),#8a79ef); box-shadow: 0 9px 22px rgba(108,92,231,.35); font-size: 27px; }
  .bottom-nav .add-button small { margin-top: 2px; }
  .dashboard-grid,.lower-grid,.split-layout,.settings-grid { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-form { flex-wrap: wrap; }.filter-form > * { flex: 1; }.segmented { flex-basis: 100%; }.segmented button { flex: 1; }
  .period-caption { display: none; }
  .member-grid { grid-template-columns: 1fr; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; padding: max(45px,env(safe-area-inset-top)) 24px calc(35px + env(safe-area-inset-bottom)); }
  .login-brand { margin-bottom: 58px; }
}

@media (max-width: 560px) {
  .main-content { padding-left: 12px; padding-right: 12px; }
  .topbar h1 { font-size: 24px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 121px; padding: 15px; }.metric-card strong { font-size: 18px; }
  .entry-card,.form-card,.list-card,.chart-card,.category-list-card,.recent-card,.table-card,.profile-card,.settings-card { padding: 17px; border-radius: 17px; }
  .receipt-drop { grid-template-columns: auto 1fr; padding: 15px; }.receipt-actions { grid-column: span 2; display: grid; grid-template-columns: 1fr; width: 100%; }.receipt-actions .file-button { width: 100%; }.receipt-selected { grid-column: span 2; }
  .form-grid { grid-template-columns: 1fr; }.span-2 { grid-column: span 1; }
  .save-panel { grid-template-columns: 1fr; }.save-panel .save-icon,.save-panel h3,.save-panel p,.save-panel .save-summary,.danger-zone { grid-column: span 1; }
  .save-panel .save-icon { margin: auto; }.save-panel { text-align: center; }
  .chart-wrap,.chart-wrap.donut { height: 240px; }
  .filter-form input,.filter-form select { width: 100%; min-width: 0; }
  .transactions-filter .filter-form > * { flex-basis: 100%; }
  .commitment-item { grid-template-columns: auto 1fr; }.commitment-actions { grid-column: span 2; justify-content: flex-end; }
  .member-card { grid-template-columns: auto 1fr; }.member-stat { display: none; }
  th:nth-child(2),td:nth-child(2),th:nth-child(5),td:nth-child(5),th:nth-child(6),td:nth-child(6) { display: none; }
}
.transaction-row > a { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.transaction-row > a strong { font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.transaction-row > a small { color: var(--muted); font-size: 10px; }
.commitment-info a:hover strong { color: var(--primary); }
.extraction-review { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #f8fafc; }
.extraction-review summary { cursor: pointer; color: #536176; font-size: 12px; font-weight: 800; }
.extraction-review h4 { margin: 16px 0 7px; font-size: 11px; color: #526075; text-transform: uppercase; letter-spacing: .08em; }
.extraction-review pre { max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; padding: 13px; border-radius: 11px; background: #0b1728; color: #d9e6f5; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Receipt-first automatic entry */
.receipt-first-intro { margin: 2px 0 20px; }
.receipt-first-intro h2 { margin: 8px 0 7px; font-size: clamp(22px,3vw,30px); letter-spacing: -.035em; }
.receipt-first-intro p { max-width: 720px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.receipt-first-badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; color: #5a49c6; background: #efedff; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.auto-review { margin: 0 0 24px; border: 1px solid #dce6df; border-radius: 19px; overflow: hidden; background: linear-gradient(145deg,#fbfffd,#f7fbff); box-shadow: 0 16px 34px rgba(28,71,52,.07); }
.auto-review-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 15px 17px; border-bottom: 1px solid #e8efeb; }
.auto-review-head > div { display: flex; gap: 10px; align-items: center; }
.auto-review-head > div > div { display: flex; flex-direction: column; gap: 2px; }
.auto-review-head strong { font-size: 13px; }
.auto-review-head small { color: var(--muted); font-size: 10px; }
.success-dot { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: white; background: #1b9568; font-weight: 900; }
.review-provider { display: inline-flex; padding: 6px 8px; border-radius: 8px; color: #526277; background: #edf2f7; font-size: 9px; font-weight: 850; }
.auto-total { padding: 21px 18px 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; }
.auto-total > span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.auto-total > strong { color: #172338; font-size: clamp(28px,5vw,42px); line-height: 1; letter-spacing: -.045em; }
.auto-total > strong small { color: #6b778a; font-size: 12px; letter-spacing: .02em; }
.auto-review-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; background: #e7ece9; border-top: 1px solid #e7ece9; border-bottom: 1px solid #e7ece9; }
.auto-review-grid > div { min-width: 0; padding: 13px 16px; display: flex; flex-direction: column; gap: 5px; background: rgba(255,255,255,.92); }
.auto-review-grid span { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.auto-review-grid strong { color: #2a374a; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.auto-review-actions { padding: 13px 16px; display: flex; justify-content: flex-end; }
.manual-entry-trigger { margin: 2px 0 18px; display: flex; justify-content: center; gap: 7px; color: var(--muted); font-size: 11px; }
.text-button { border: 0; padding: 0; color: var(--primary); background: transparent; font: inherit; font-weight: 850; text-decoration: underline; text-underline-offset: 3px; }
.detail-fields-collapsed { display: none; }
#expense-submit:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; filter: grayscale(.2); }

@media (max-width: 560px) {
  .receipt-first-intro { text-align: center; }
  .receipt-first-intro p { font-size: 11px; }
  .auto-review-head { align-items: flex-start; }
  .auto-total { align-items: flex-start; flex-direction: column; gap: 8px; }
  .auto-review-grid { grid-template-columns: 1fr; }
  .auto-review-grid .span-2 { grid-column: span 1; }
  .auto-review-actions .button { width: 100%; }
}

/* v1.3 transaction visibility and installment scheduling */
.table-subtitle { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 650; }
.transaction-row td { vertical-align: middle; }
.transaction-row td:first-child,.transaction-row td:nth-child(3),.transaction-row td:last-child { min-width: 130px; }
.transaction-row td > strong,.transaction-row td > small { display: block; }
.transaction-row td > small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.empty-state a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.field > small { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; line-height: 1.45; font-weight: 550; }
.schedule-section { padding: 17px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg,#fbfcff,#f7f9fd); }
.schedule-heading h3 { margin: 0 0 13px; font-size: 15px; letter-spacing: -.015em; }
.choice-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
.choice-card { position: relative; min-width: 0; cursor: pointer; }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card span { min-height: 84px; display: flex; flex-direction: column; gap: 5px; padding: 13px; border: 1px solid #dfe5ee; border-radius: 13px; background: white; transition: .16s ease; }
.choice-card strong { color: #2c3a4e; font-size: 11px; }
.choice-card small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.choice-card input:checked + span { border-color: #8777ec; background: #f2efff; box-shadow: 0 0 0 3px rgba(108,92,231,.09); }
.choice-card input:checked + span strong { color: #5746ca; }
.custom-month-field,.duration-inputs { margin-top: 13px; }
.duration-inputs { display: grid; grid-template-columns: 1fr; }
.schedule-preview { margin-top: 13px; padding: 13px 14px; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; align-items: center; border-radius: 13px; color: #40526c; background: #eaf5f4; border: 1px solid #d4e9e6; }
.schedule-preview span { grid-row: span 2; align-self: center; padding: 6px 8px; border-radius: 8px; color: #167258; background: #d7eee8; font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.schedule-preview strong { font-size: 11px; }
.schedule-preview small { color: #698078; font-size: 9px; }
.commitment-period { color: #5546c9 !important; font-weight: 700; }

@media (max-width: 700px) {
  .choice-grid { grid-template-columns: 1fr; }
  .choice-card span { min-height: 0; }
  .schedule-section { padding: 14px; }
  .schedule-preview { grid-template-columns: 1fr; }
  .schedule-preview span { grid-row: auto; width: max-content; }
}
