:root {
  color-scheme: light;
  --ink: #122f2a;
  --muted: #4d635c;
  --brand: #08654e;
  --brand-dark: #074e3f;
  --line: #dce8e2;
  --wash: #f5f9f7;
  --surface: #fff;
  --radius: 1.15rem;
  font-family: "Nirmala UI", "Noto Sans Bengali", "Bangla Sangam MN", "Vrinda", system-ui, sans-serif;
  line-height: 1.6;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 6rem; }
body { margin: 0; color: var(--ink); background: var(--wash); }
a { color: var(--brand-dark); text-underline-offset: .18em; }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.3; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.75rem); letter-spacing: -.035em; }
h2 { font-size: 1.35rem; }
small { font-size: .8rem; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { display: block; }

:focus-visible { outline: 3px solid #a54811; outline-offset: 3px; }
.skip-link { position: fixed; z-index: 10; left: 1rem; top: 1rem; padding: .6rem 1rem; transform: translateY(-180%); background: #fff; border-radius: .55rem; }
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.micro { font-size: .88rem; }
.eyebrow { color: var(--brand-dark); font-size: .83rem; font-weight: 700; margin-bottom: .28rem; }
.amount { font-family: "Nirmala UI", "Noto Sans Bengali", system-ui, sans-serif; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

.brand { display: inline-flex; align-items: center; gap: .65rem; min-width: 0; color: inherit; text-decoration: none; }
.brand-icon { display: grid; place-items: center; flex: 0 0 2.65rem; height: 2.65rem; color: #fff; background: var(--brand); border-radius: .82rem; }
.brand-text { display: block; font-size: 1.14rem; font-weight: 800; white-space: nowrap; line-height: 1.24; }
.brand-text small { display: block; margin-top: .14rem; color: var(--muted); font-weight: 500; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.55rem; padding: .48rem .83rem; border: 1px solid transparent; border-radius: .65rem; line-height: 1.28; font-weight: 700; text-align: center; text-decoration: none; }
.button:hover { text-decoration: none; }
.primary { color: #fff; background: var(--brand); }
.primary:hover { background: var(--brand-dark); }
.secondary { color: var(--brand-dark); border-color: #acc9ba; background: #f7fbf8; }
.secondary:hover, .quiet:hover { background: #e3f3eb; }
.quiet { background: #fff; border-color: var(--line); color: var(--brand-dark); white-space: nowrap; }
.danger { background: #fff6f3; border-color: #e5b9af; color: #842e22; }
.danger:hover { background: #fee8e1; }
.button.small { min-height: 2.15rem; padding: .32rem .6rem; font-size: .84rem; }
.button.full { width: 100%; }
.alert { margin: 0 0 1.1rem; padding: .75rem 1rem; border: 1px solid; border-radius: .7rem; overflow-wrap: anywhere; }
.alert-error { background: #fff0eb; border-color: #eab5a8; color: #7f2d22; }
.alert-success { background: #e9f8ed; border-color: #b0d9bd; color: #1b5836; }

.form-stack { display: grid; gap: .8rem; }
.form-stack.tiny { gap: .55rem; }
.form-stack label { display: block; font-size: .91rem; font-weight: 650; min-width: 0; }
.form-stack input:not([type=checkbox]), .form-stack select, .form-stack textarea {
  display: block; width: 100%; min-width: 0; margin-top: .26rem; padding: .47rem .62rem;
  color: var(--ink); background: #fff; border: 1px solid #b7c9c0; border-radius: .55rem;
}
.form-stack input:not([type=checkbox]), .form-stack select { min-height: 2.6rem; }
.form-stack input[type=file] { font-size: .83rem; }
.form-stack input::file-selector-button { margin-right: .42rem; border: 0; padding: .17rem .36rem; border-radius: .25rem; color: var(--brand-dark); background: #e8f4ed; cursor: pointer; }
.form-stack textarea { resize: vertical; }
.form-stack input::placeholder { color: #61746b; opacity: 1; }
.form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.optional { margin-left: .23rem; color: var(--muted); font-size: .72rem; font-weight: 500; }
.field-help { display: block; margin-top: .18rem; color: var(--muted); font-size: .77rem; font-weight: 400; }
.form-stack .checkbox-label { display: flex; align-items: flex-start; gap: .45rem; font-weight: 500; }
.checkbox-label input { width: 1rem; height: 1rem; flex: 0 0 1rem; margin: .26rem 0 0; accent-color: var(--brand); }

.login-page { display: grid; min-height: 100vh; min-height: 100dvh; align-items: center; padding: clamp(.9rem, 3vw, 2.5rem); background: #edf5ef; }
.login-layout { display: grid; grid-template-columns: 1.13fr 1fr; max-width: 59rem; width: 100%; margin: auto; border: 1px solid #d0e2d7; border-radius: 1.65rem; overflow: hidden; background: #fff; box-shadow: 0 1rem 3.5rem #17493319; }
.login-intro { position: relative; display: grid; align-content: space-between; min-height: 31rem; padding: clamp(1.4rem, 4vw, 2.7rem); overflow: hidden; isolation: isolate; background: #0b4338; color: #fff; }
.login-intro .brand-icon { background: #c4e9d5; color: #084235; }
.login-intro .brand-text small, .login-intro .eyebrow, .login-message p { color: #d1ecdc; }
.login-message { position: relative; z-index: 1; padding-bottom: 2rem; }
.login-message h1 { font-size: clamp(2rem, 4.3vw, 3.25rem); line-height: 1.36; }
.login-message p { max-width: 22rem; margin-top: .7rem; }
.login-decoration { position: absolute; z-index: -1; inset: auto -1rem -3rem auto; width: 14rem; height: 13rem; display: flex; align-items: flex-end; gap: .6rem; transform: rotate(-19deg); pointer-events: none; }
.login-decoration span { width: 1.1rem; border-radius: 1rem 1rem 0 0; background: #69aa92; opacity: .29; height: 35%; }
.login-decoration span:nth-child(2) { height: 49%; }.login-decoration span:nth-child(3) { height: 43%; }.login-decoration span:nth-child(4) { height: 61%; }.login-decoration span:nth-child(5) { height: 56%; }.login-decoration span:nth-child(6) { height: 75%; }.login-decoration span:nth-child(7) { height: 88%; }
.login-box { padding: clamp(1.4rem, 4.5vw, 3rem); align-self: center; }
.login-box h2 { margin-bottom: .25rem; font-size: 2rem; }
.login-box .muted { margin-bottom: 1.35rem; }
.login-box .form-stack { gap: 1rem; }
.login-box .button { margin-top: .3rem; }
.login-help { color: var(--muted); font-size: .85rem; margin-top: 1.25rem; }

.topbar { position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line); background: #fff; }
.topbar-inner { max-width: 86rem; min-height: 4.55rem; margin: auto; padding: .66rem clamp(.85rem, 3vw, 2rem); display: flex; align-items: center; justify-content: space-between; gap: .8rem 1.5rem; }
.nav-links { display: flex; gap: clamp(.85rem, 2vw, 1.65rem); align-items: center; }
.nav-links a { color: var(--muted); text-decoration: none; font-weight: 650; white-space: nowrap; }
.nav-links a:hover { color: var(--brand-dark); text-decoration: underline; }
.identity { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.identity-text { text-align: right; line-height: 1.25; min-width: 0; }
.identity-text strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem; }
.identity-text small { color: var(--muted); }
.dashboard { max-width: 86rem; margin: auto; padding: clamp(1.15rem, 3vw, 2.45rem) clamp(.85rem, 3vw, 2rem) 0; }
.overview { display: flex; justify-content: space-between; align-items: end; gap: 1rem; padding: .15rem 0 1.15rem; }
.overview p { margin-top: .22rem; }
.overview-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.summary-grid, .workspace-grid, .settings-grid { display: grid; gap: 1rem; }
.summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.workspace-grid { grid-template-columns: minmax(0, 1.7fr) minmax(19.75rem, 1fr); align-items: start; }
.panel { padding: clamp(.85rem, 2.1vw, 1.4rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; box-shadow: 0 .15rem .5rem #143a2a06; }
.summary-panel { background: linear-gradient(120deg, #f8fcf9, #fff 70%); }
.panel-title, .panel-head { display: flex; align-items: center; gap: .65rem; }
.panel-title { margin-bottom: .28rem; }
.panel-head { justify-content: space-between; margin-bottom: .95rem; }
.section-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .66rem; background: #def1e7; color: #075942; font-size: 1.13rem; font-weight: 750; }
.section-mark.warm { background: #f9edd7; color: #774a11; }
.summary-list { margin: .65rem 0 0; }
.summary-list > div { display: flex; align-items: center; justify-content: space-between; gap: .65rem; padding: .46rem 0; border-top: 1px solid var(--line); }
.summary-list dt { overflow-wrap: anywhere; }
.summary-list dt small { display: block; color: var(--muted); }
.summary-list dd { margin: 0; }
.project-totals { margin-bottom: 1rem; }
.project-totals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .75rem; margin-top: .8rem; }
.project-total { min-width: 0; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .75rem; background: #fbfdfa; }
.project-total h3 { margin: 0; overflow-wrap: anywhere; }
.project-total dl { margin: .45rem 0 0; }
.project-total dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .35rem 0; }
.project-total dd { margin: 0; white-space: nowrap; }
.project-net { border-top: 1px solid var(--line); color: var(--brand-dark); font-weight: 750; }
.project-net.negative { color: #a32c31; }
.empty { border: 1px dashed #bfd4c8; border-radius: .75rem; padding: 1rem; color: var(--muted); background: #f8fcf9; overflow-wrap: anywhere; }
.empty.compact { padding: .62rem .75rem; margin-top: .65rem; font-size: .9rem; }
.ledger-empty { min-height: 8.5rem; display: grid; place-content: center; text-align: center; gap: .18rem; }
.ledger-empty strong { color: var(--ink); }
.count-label { color: var(--muted); font-size: .81rem; text-align: right; }

.table-scroll { overflow-x: auto; }
.ledger-table { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: .9rem; }
.ledger-table th, .ledger-table td { border-bottom: 1px solid var(--line); padding: .6rem .5rem; text-align: left; vertical-align: top; }
.ledger-table th { color: #28584b; background: #eef6f1; font-size: .8rem; white-space: nowrap; }
.ledger-table th:first-child { border-radius: .46rem 0 0 .46rem; }
.ledger-table th:last-child { border-radius: 0 .46rem .46rem 0; }
.ledger-table td:nth-child(2) { overflow-wrap: anywhere; max-width: 12rem; }
.ledger-table td small { display: block; color: var(--muted); }
.badge { display: inline-block; max-width: 100%; padding: .14rem .44rem; border-radius: .32rem; background: #edf3f0; color: #3e5d53; font-size: .73rem; font-weight: 700; white-space: nowrap; }
.badge.pending, .badge.awaiting_payment { color: #694610; background: #fff0cb; }
.badge.posted, .badge.approved { color: #1b5738; background: #e1f4e7; }
.badge.rejected { color: #862a22; background: #fae8e2; }
.badge.reversed { color: #53426e; background: #eee9f6; }
.entry-details { min-width: 4.15rem; }
.entry-details[open] { min-width: min(14rem, 50vw); }
.entry-details summary, .reverse-form summary { color: var(--brand-dark); font-weight: 650; cursor: pointer; }
.entry-meta { display: grid; gap: .27rem; margin: .42rem 0; overflow-wrap: anywhere; }
.entry-meta strong { font-size: .82rem; }
.entry-note { white-space: pre-wrap; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.reverse-form { margin-top: .5rem; }
.reverse-form .form-stack { margin-top: .4rem; }
.pagination { display: flex; gap: .55rem; margin-top: .8rem; }

.settings, .history, .security { margin-top: 1rem; }
.password-form { max-width: 23rem; }
.settings-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; gap: .75rem; }
.settings-card { min-width: 0; padding: .6rem .72rem; border: 1px solid var(--line); border-radius: .75rem; }
.settings-card > summary { color: var(--brand-dark); font-weight: 750; cursor: pointer; }
.settings-card > summary span { display: inline-block; margin-left: .24rem; font-size: .77rem; color: var(--muted); font-weight: 500; }
.settings-card > form, .settings-card > p { margin-top: .66rem; }
.setup-list, .audit-list { padding: 0; list-style: none; margin: 0; }
.setup-list { margin-top: .5rem; }
.setup-list li, .audit-list li { display: flex; align-items: start; justify-content: space-between; gap: .5rem; padding: .48rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.setup-list li { font-size: .82rem; }
.setup-list small, .audit-list small { display: block; color: var(--muted); }
.setup-list > li > small { text-align: right; }
.audit-list li span { color: var(--muted); font-size: .81rem; text-align: right; }
.page-footer { padding: 1.25rem 0; text-align: center; color: var(--muted); font-size: .8rem; }

@media (max-width: 62rem) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 45rem) {
  html { scroll-padding-top: 1rem; }
  .topbar { position: static; }
  .topbar-inner { flex-wrap: wrap; }
  .nav-links { order: 3; flex: 0 0 100%; gap: .85rem; border-top: 1px solid var(--line); padding-top: .55rem; font-size: .9rem; flex-wrap: wrap; }
  .overview { align-items: start; flex-direction: column; }
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: unset; gap: 1.35rem; }
  .login-message { padding-bottom: .2rem; }
  .login-message h1 br { display: none; }
  .login-decoration { transform: scale(.8) rotate(-19deg); transform-origin: bottom right; }
  .identity-text strong { max-width: 7rem; }
}

@media (max-width: 28rem) {
  .summary-grid, .settings-grid { grid-template-columns: 1fr; }
  .identity-text { display: none; }
  .ledger-table { min-width: 30rem; }
}
