:root {
  color-scheme: light;
  --navy: #0f2747;
  --blue: #1d4ed8;
  --sky: #eaf2ff;
  --line: #d8e0ea;
  --muted: #576981;
  --text: #172033;
  --bg: #f5f7fb;
  --white: #fff;
  --green: #15803d;
  --red: #b91c1c;
  --shadow: 0 9px 28px rgb(15 39 71 / 7%);
  font: 14px/1.5 Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
}
a { color: var(--blue); }
h1, h2, h3, p { margin: 0; }
.login-wrap {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: 24px; background: linear-gradient(135deg, var(--sky), var(--bg) 55%, var(--sky));
}
.login-card { width: min(440px,100%); padding: 30px; border: 1px solid var(--line); background: white; border-radius: 20px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img, .topbar-name img { flex: none; border-radius: 11px; }
.brand h1, .brand strong { font-size: 19px; line-height: 1.2; }
.brand p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.login-card h2 { margin: 25px 0 14px; font-size: 25px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 12px; text-align: center; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.btn {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); background: white; font-weight: 700; text-decoration: none; text-align: center;
}
.btn:hover:not(:disabled) { background: var(--sky); }
.btn.primary { color: white; background: var(--blue); border-color: var(--blue); }
.btn.primary:hover:not(:disabled) { background: #153fb8; }
.btn.light { color: var(--blue); background: var(--sky); border-color: transparent; }
.btn.link { color: var(--blue); background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.icon-button { width: 42px; padding: 0; font-size: 23px; line-height: 1; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0,1fr); }
.app-main { min-width: 0; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 21px 13px 15px; overflow: auto; background: var(--navy); color: white;
}
.sidebar-brand { margin: 0 5px 22px; }
.sidebar-brand p { color: #c2d1e5; font-size: 10px; }
.nav-section { display: block; padding: 19px 12px 6px; color: #adc1de; font-weight: 700; font-size: 11px; }
.nav-btn {
  display: flex; align-items: center; gap: 11px; width: 100%; margin: 3px 0;
  padding: 10px 12px; border: 0; border-radius: 9px; text-align: left;
  color: #dbe7f5; background: transparent; font-weight: 700;
}
.nav-btn[aria-current="page"], .nav-btn:hover { color: white; background: rgb(255 255 255 / 13%); }
.nav-icon { width: 23px; text-align: center; font-size: 20px; line-height: 24px; }
.sidebar-bottom { margin-top: auto; padding: 16px 5px 0; }
.sidebar-bottom > span { display: block; margin: 0 0 9px 4px; color: #e3edfa; font-size: 12px; overflow-wrap: anywhere; }
.topbar {
  position: sticky; top: 0; z-index: 5; min-height: 66px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 11px 26px; background: white; border-bottom: 1px solid var(--line);
}
.topbar-name { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--navy); font-size: 17px; }
.topbar-name img { display: none; }
#pop-picker { min-width: 0; max-width: min(340px, 54%); }
#pop-picker label { display: flex; align-items: center; gap: 9px; }
#pop-picker select { width: clamp(130px,26vw,255px); }
main { max-width: 1240px; min-width: 0; margin: 0 auto; padding: 26px; }
main:focus { outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 19px; }
.page-head h2 { font-size: clamp(23px,3.2vw,30px); line-height: 1.18; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }
.card { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 17px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.stack { display: grid; gap: 14px; }
.card.narrow { max-width: 720px; }
.summary-grid, .ledger-summary { display: grid; gap: 13px; grid-template-columns: repeat(3,minmax(0,1fr)); }
.metric { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 6px; font-size: clamp(16px,2vw,25px); line-height: 1.22; overflow-wrap: anywhere; }
.metric.balance {
  min-height: 106px; border-color: transparent; color: white;
  background: linear-gradient(145deg, var(--blue), #173e9d); box-shadow: 0 12px 25px rgb(22 65 169 / 18%);
}
.metric.balance span { color: #e4edff; }
.balance-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.balance-toggle { display: none; }
.in { color: var(--green); }
.out { color: var(--red); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 9px; }
.section-head h3 { font-size: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 11px; }
.quick-actions .btn { justify-content: start; padding: 10px; }
.quick-icon, .activity-icon {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 12px;
  color: var(--blue); background: var(--sky); font-size: 20px; font-weight: 800;
}
.quick-icon.in, .activity-icon.in { color: var(--green); background: #dcfce7; }
.quick-icon.out, .activity-icon.out { color: var(--red); background: #fee2e2; }
.empty { display: grid; gap: 10px; align-items: center; justify-items: start; color: var(--muted); background: white; border: 1px dashed var(--line); border-radius: 13px; padding: 20px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: white; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 13px; vertical-align: middle; border-bottom: 1px solid #e8eef6; }
thead { background: #f3f7fd; color: var(--muted); font-size: 12px; }
tr:last-child td { border-bottom: 0; }
td strong { display: block; }
td small { display: block; color: var(--muted); }
.numeric { text-align: right; white-space: nowrap; }
.activity-list { display: grid; gap: 8px; }
.activity {
  display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; padding: 12px;
  color: var(--text); background: white; border: 1px solid var(--line); border-radius: 14px; text-align: left;
}
.activity:hover { border-color: #a6baec; }
.activity-copy { min-width: 0; flex: 1; }
.activity-copy strong, .activity-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-copy small, .activity-amount small { color: var(--muted); }
.activity-amount { min-width: 0; text-align: right; font-weight: 700; font-size: 13px; }
.activity-amount small { display: block; font-size: 10px; font-weight: 400; }
.desktop-table, .mobile-list { margin-top: 10px; }
.mobile-list, .mobile-nav { display: none; }
.form-flow { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
label, .field-label { display: grid; gap: 5px; font-weight: 700; color: var(--text); }
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  min-width: 0; width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 10px; color: var(--text); background: white; font-weight: 400;
}
textarea { display: block; resize: vertical; }
fieldset { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
legend { padding: 0 5px; font-weight: 700; }
.check { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); }
.segment { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segment label { position: relative; cursor: pointer; }
.segment input { position: absolute; opacity: 0; }
.segment span { padding: 10px; text-align: center; border: 1px solid var(--line); border-radius: 10px; }
.segment input:checked + span { border-color: #5681f0; background: var(--sky); color: var(--blue); }
.segment input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.hint, .muted { color: var(--muted); }
.error-text { color: var(--red); font-weight: 700; }
.proof-section { display: grid; gap: 8px; justify-items: start; }
.previews, .proofs { display: grid; grid-template-columns: repeat(auto-fill,minmax(112px,1fr)); width: 100%; gap: 9px; }
.preview, .proofs a { position: relative; display: block; min-width: 0; border-radius: 10px; background: #edf2fa; }
.preview img, .proofs img { width: 100%; height: 108px; display: block; object-fit: cover; border-radius: 10px; }
.preview button { position: absolute; top: 4px; right: 4px; min-width: 34px; min-height: 34px; padding: 0; }
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 9px; align-items: end; }
.ledger-summary { margin: 12px 0; }
.ledger-summary .metric { padding: 10px; }
.ledger-summary .metric strong { font-size: clamp(13px,2vw,21px); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-top: 10px; color: var(--muted); }
.status { display: inline-block; border-radius: 50px; padding: 3px 8px; font-size: 11px; color: var(--muted); background: #eef2f7; }
.status.active { color: var(--green); background: #dcfce7; }
.pop-checks { display: grid; gap: 8px; max-height: 240px; overflow: auto; }
.cluster-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--navy); }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.detail-grid > div { padding: 9px; border-radius: 9px; background: var(--bg); overflow-wrap: anywhere; }
.detail-grid small, .detail-grid strong { display: block; }
.detail-grid small { color: var(--muted); }
.detail-history { border-bottom: 1px solid var(--line); padding: 8px 0; }
dialog { width: min(620px,calc(100% - 24px)); max-height: min(88vh,820px); border: 1px solid var(--line); border-radius: 17px; padding: 0; background: white; color: var(--text); box-shadow: 0 15px 50px rgb(15 39 71 / 25%); }
dialog::backdrop { background: rgb(15 27 48 / 48%); }
.dialog-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: white; }
.dialog-bar h2 { font-size: 19px; }
#dialog-body { padding: 16px; }
.toast { position: fixed; bottom: 18px; right: 18px; max-width: min(440px,calc(100% - 36px)); z-index: 10; padding: 12px 16px; border-radius: 11px; color: white; background: var(--navy); box-shadow: var(--shadow); }
.toast.error { background: #9c1c1c; }
.profile-title { color: var(--navy); font-size: 19px; }

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { position: relative; min-height: 64px; padding: 10px 14px; padding-top: max(10px,env(safe-area-inset-top)); color: white; background: var(--navy); border: 0; }
  .topbar-name { color: white; font-size: 15px; }
  .topbar-name img { display: block; }
  #pop-picker label { color: white; }
  #pop-picker label > span { display: none; }
  #pop-picker select { width: clamp(118px,43vw,205px); padding: 5px 6px; font-size: 16px; }
  main { padding: 15px 13px calc(100px + env(safe-area-inset-bottom)); }
  main.dashboard { padding-top: 0; }
  .dashboard-intro { margin: 0 -13px; padding: 10px 14px 21px; border-radius: 0 0 25px 25px; background: var(--navy); color: white; }
  .dashboard-intro .page-head { margin-bottom: 12px; }
  .dashboard-intro .page-head p { color: #d4e1f3; }
  .dashboard-intro .page-head > .btn { display: none; }
  .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .summary-grid .metric.balance { grid-column: span 2; min-height: 91px; }
  .summary-grid .metric { padding: 12px; }
  .summary-grid .metric.balance strong { margin-top: 2px; font-size: clamp(22px,6vw,31px); }
  .balance-toggle { display: inline-flex; min-height: 36px; padding: 4px 9px; border-color: transparent; color: white; background: rgb(255 255 255 / 14%); font-size: 12px; }
  .balance-toggle:hover:not(:disabled) { color: var(--navy); }
  .quick-actions .btn { flex-direction: column; justify-content: start; border: 0; background: transparent; font-size: 12px; padding: 6px 0; }
  .quick-icon { width: 49px; height: 49px; border-radius: 15px; }
  .section-head { margin-top: 16px; }
  .desktop-table { display: none; }
  .mobile-list { display: grid; }
  .mobile-nav {
    position: fixed; inset: auto 0 0; z-index: 7; display: grid; grid-template-columns: repeat(4,minmax(0,1fr));
    min-height: 65px; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: white; box-shadow: 0 -6px 20px rgb(15 39 71 / 10%);
  }
  .mobile-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 3px 0; border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 11px;
  }
  .mobile-nav button[aria-current="page"] { color: var(--blue); }
  .mobile-nav .nav-icon { font-size: 21px; }
  .mobile-nav .fab .nav-icon {
    min-width: 34px; min-height: 34px; display: grid; place-items: center; border-radius: 50%;
    color: white; background: var(--blue); box-shadow: 0 4px 12px rgb(29 78 216 / 24%);
  }
  .mobile-nav .fab { color: var(--blue); }
  .filters { grid-template-columns: 1fr 1fr; }
  .form-grid { gap: 9px; }
  input:not([type="checkbox"]):not([type="radio"]), textarea, select { font-size: 16px; }
  .card { padding: 13px; }
  .table-wrap th, .table-wrap td { padding: 8px; }
  .toast { bottom: calc(77px + env(safe-area-inset-bottom)); }
  dialog { margin: auto auto max(8px,env(safe-area-inset-bottom)); max-height: 88dvh; }
}
@media (max-width: 370px) {
  .login-wrap { padding: 13px; }
  .login-card { padding: 17px; }
  .form-grid { grid-template-columns: 1fr; }
}
.balance-mobile { display: none !important; }
@media (max-width: 820px) {
  .balance-desktop { display: none !important; }
  .metric .balance-mobile { display: block !important; }
}
