:root {
  --ink: #173d3a;
  --muted: #708b87;
  --teal: #0e6b63;
  --teal-deep: #09554e;
  --mint: #dff2ea;
  --mint-soft: #eef8f3;
  --line: #d8e7e1;
  --panel: rgba(255, 255, 255, 0.92);
  --danger: #c76858;
  --gold: #ba812f;
  font-family: "DM Sans", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: #eaf4ef;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #eaf4ef; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; background: radial-gradient(circle at 100% 0, #d8efe6 0, transparent 35%), #eaf4ef; }
.app-frame { width: min(100%, 1180px); min-height: 100vh; margin: 0 auto; padding: 24px 24px 100px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 15px; background: var(--teal); color: #e6fff5; font-size: 24px; box-shadow: 0 10px 20px rgba(14, 107, 99, .18); }
.eyebrow { margin: 0 0 4px; color: var(--teal); font-size: 12px; font-weight: 700; letter-spacing: .12em; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(23px, 3vw, 32px); letter-spacing: -.03em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .avatar { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); color: var(--teal-deep); }
.avatar { display: grid; place-items: center; background: var(--teal); color: #fff; border: 0; font-weight: 800; }

.page { display: grid; gap: 18px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 26px; border-radius: 26px; background: linear-gradient(135deg, #126e65, #2a877a); color: #fff; box-shadow: 0 18px 30px rgba(14, 107, 99, .2); }
.hero .eyebrow { color: #aee4d1; }
.hero h2 { font-size: clamp(23px, 4vw, 34px); max-width: 560px; margin-top: 5px; }
.hero-copy { max-width: 620px; }
.hero-note { margin-top: 10px; color: #d8f5e9; font-size: 13px; line-height: 1.6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn { border: 0; border-radius: 12px; padding: 11px 15px; font-weight: 700; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 7px 14px rgba(14, 107, 99, .2); }
.btn-light { background: #fff; color: var(--teal-deep); }
.btn-ghost { background: transparent; color: var(--teal); border: 1px solid var(--line); }
.btn-danger { background: #fff0ec; color: var(--danger); }
.btn-small { padding: 8px 11px; font-size: 12px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-head p { color: var(--muted); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { min-height: 122px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 8px 22px rgba(25, 70, 62, .05); }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--mint); color: var(--teal); font-size: 17px; }
.stat-card small { display: block; margin-top: 14px; color: var(--muted); }
.stat-card strong { display: block; margin-top: 2px; font-size: 27px; letter-spacing: -.04em; }
.stat-card strong span { font-size: 13px; font-weight: 500; color: var(--muted); }

.content-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: 0 8px 22px rgba(25, 70, 62, .05); }
.profile-card { padding: 0 20px 20px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); overflow: hidden; }
.profile-cover { height: 110px; margin: 0 -20px; background: linear-gradient(135deg, #126e65, #b7e5d2); }
.profile-main { display: flex; align-items: flex-end; gap: 18px; margin-top: -42px; }
.profile-avatar { position: relative; width: 92px; height: 92px; display: grid; place-items: center; border: 5px solid #fff; border-radius: 50%; background: var(--mint); color: var(--teal); overflow: visible; font-size: 38px; font-weight: 800; }
.profile-avatar-image { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-avatar-fallback { display: grid; place-items: center; width: 100%; height: 100%; }
.avatar-upload { position: absolute; right: -22px; bottom: -10px; padding: 5px 8px; border-radius: 999px; background: #fff; color: var(--teal); font-size: 10px; font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,.12); white-space: nowrap; }
.avatar-upload input { display: none; }
.profile-title { padding-bottom: 6px; }
.profile-title p:last-child { margin-top: 5px; color: var(--muted); font-size: 13px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.panel + .panel { margin-top: 16px; }
.record-list { display: grid; gap: 10px; margin-top: 16px; }
.record-card { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px; border: 1px solid #e2eee8; border-radius: 15px; background: #fbfdfc; }
.batch-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--mint-soft); color: var(--muted); font-size: 12px; }
.batch-check { display: grid; place-items: center; }
.batch-check input { width: 18px; height: 18px; accent-color: var(--teal); }
.batch-card { grid-template-columns: 24px 48px minmax(0, 1fr) auto; }
.record-main { min-width: 0; }
.record-badge { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--mint); color: var(--teal); font-size: 20px; }
.record-card h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.record-side { text-align: right; }
.record-side strong { display: block; font-size: 15px; }
.pill { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; background: var(--mint-soft); color: var(--teal); font-size: 11px; font-weight: 700; }
.pill.warn { background: #fff3de; color: var(--gold); }
.pill.danger { background: #ffede9; color: var(--danger); }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.quick-card { display: grid; gap: 7px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #fbfdfc; text-align: left; color: var(--ink); }
.quick-card:hover { border-color: #9dcec0; background: #f4fbf7; }
.quick-card span { color: var(--muted); font-size: 12px; }
.quick-card strong { font-size: 14px; }
.quick-mark { color: var(--teal); font-size: 19px; }

.bottom-nav { position: fixed; z-index: 10; right: 50%; bottom: 18px; display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); width: min(calc(100% - 32px), 560px); transform: translateX(50%); padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.95); box-shadow: 0 14px 38px rgba(30, 79, 68, .18); backdrop-filter: blur(14px); }
.nav-item { display: grid; gap: 3px; justify-items: center; border: 0; border-radius: 12px; padding: 8px 4px; color: var(--muted); background: transparent; font-size: 11px; }
.nav-item span:first-child { font-size: 18px; }
.nav-item.active { background: var(--mint); color: var(--teal); font-weight: 800; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.ledger-filter-toolbar { align-items: flex-end; padding: 12px; border-radius: 14px; background: var(--mint-soft); }
.filter-field { display: grid; gap: 5px; min-width: 170px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-field input, .filter-field select { min-height: 40px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.filter-field select { min-width: min(420px, 60vw); }
.search { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfc; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.select { padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfc; color: var(--ink); }
.ledger-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.ledger-total { padding: 16px; border-radius: 16px; background: var(--mint-soft); }
.ledger-total.income { background: #e7f6ef; }
.ledger-total.expense { background: #fff4e4; }
.ledger-total small { color: var(--muted); }
.ledger-total strong { display: block; margin-top: 7px; font-size: 22px; }
.ledger-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid #edf2ef; }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row .record-badge { width: 42px; height: 42px; font-size: 18px; }
.amount.income { color: var(--teal); }
.amount.expense { color: var(--danger); }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(18, 45, 42, .48); backdrop-filter: blur(5px); }
.modal { width: min(100%, 720px); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; border-radius: 22px; background: #fff; box-shadow: 0 22px 55px rgba(10, 45, 39, .28); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.close { width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--mint-soft); color: var(--teal); font-size: 19px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: #fbfdfc; color: var(--ink); }
.field textarea { min-height: 85px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14, 107, 99, .1); }
.mode-switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 5px; border-radius: 13px; background: var(--mint-soft); margin-bottom: 16px; }
.mode-switch button { border: 0; border-radius: 9px; padding: 10px; color: var(--muted); background: transparent; font-weight: 700; }
.mode-switch button.active { background: #fff; color: var(--teal); box-shadow: 0 3px 8px rgba(20, 70, 60, .08); }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.summary-card { display: grid; gap: 12px; padding: 16px; border-radius: 16px; background: var(--mint-soft); }
.summary-item { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.summary-item strong { color: var(--ink); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.detail-id { margin-top: 5px; color: var(--muted); font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.detail-kpi { padding: 13px; border-radius: 13px; background: var(--mint-soft); }
.detail-kpi small { color: var(--muted); }
.detail-kpi strong { display: block; margin-top: 5px; font-size: 17px; }
.chart { position: relative; height: 170px; margin-top: 15px; padding: 10px 0 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 41px, #edf3ef 42px); }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-labels { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 11px; }
.history { display: grid; gap: 10px; margin-top: 14px; }
.history-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf2ef; }
.history-item:last-child { border-bottom: 0; }
.history-item small { color: var(--muted); }
.empty { padding: 25px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 92px; transform: translate(-50%, 12px); padding: 10px 14px; border-radius: 11px; color: #fff; background: #153f3b; opacity: 0; pointer-events: none; transition: all .2s ease; font-size: 13px; box-shadow: 0 8px 20px rgba(10, 50, 43, .25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .app-frame { padding: 17px 14px 100px; }
  .topbar { margin-bottom: 15px; }
  .hero { align-items: flex-start; flex-direction: column; padding: 20px; }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { min-height: 108px; padding: 14px; }
  .ledger-summary { grid-template-columns: 1fr; }
  .form-grid, .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid .detail-kpi:last-child { grid-column: 1 / -1; }
  .modal { padding: 18px; }
  .filter-field, .filter-field select { width: 100%; min-width: 0; }
  .record-card { grid-template-columns: 42px minmax(0, 1fr); }
  .record-side { grid-column: 2; text-align: left; }
}
