:root {
  --ink: #1c1914;
  --muted: #6b645a;
  --paper: #f3eee4;
  --card: rgba(255, 252, 246, 0.86);
  --line: rgba(40, 32, 20, 0.12);
  --accent: #0f6b5c;
  --accent-2: #c45c26;
  --credit: #0f6b5c;
  --debit: #b33a2b;
  --shadow: 0 12px 40px rgba(40, 28, 12, 0.12);
  --radius: 14px;
  --font: 'Source Sans 3', system-ui, sans-serif;
  --display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: #e8e0d2;
  padding: 1.25rem clamp(1rem, 3vw, 2rem) 2rem;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(15, 107, 92, 0.14), transparent 45%),
    radial-gradient(ellipse at 90% 10%, rgba(196, 92, 38, 0.12), transparent 40%),
    linear-gradient(165deg, #f6f1e7 0%, #e7dfd0 45%, #ddd2c0 100%);
}
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
.back:hover { color: var(--ink); }
.brand h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.sub { color: var(--muted); margin-top: 0.25rem; }
.top-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.save-status {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 5rem;
}
.save-status.err { color: var(--debit); }
.save-status.ok { color: var(--credit); }

[hidden] {
  display: none !important;
}

.auth-gate {
  min-height: calc(100vh - 2.5rem);
  display: grid;
  place-items: center;
  padding: 1rem 0;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.4rem 1.35rem;
  backdrop-filter: blur(10px);
  animation: auth-in 0.35s ease;
}
@keyframes auth-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.auth-card h1 {
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 0.2rem;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 1.1rem 0 1rem;
  padding: 0.25rem;
  background: rgba(28, 25, 20, 0.05);
  border-radius: 999px;
}
.auth-tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
}
.auth-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(40, 28, 12, 0.08);
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.auth-form input {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}
.auth-submit { width: 100%; margin-top: 0.35rem; }
.auth-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}
.auth-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
  line-height: 1.35;
}
.auth-error {
  color: var(--debit);
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.6rem;
}
.auth-switch {
  margin-top: 0.9rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.linkish {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkish:hover { color: var(--ink); }

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: var(--card);
  color: var(--ink);
  transition: transform 0.12s, background 0.12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--debit); border-color: rgba(179, 58, 43, 0.3); }
.file-btn { display: inline-flex; align-items: center; }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value {
  font-family: var(--display);
  font-size: 1.55rem;
  margin-top: 0.2rem;
}
.stat .value.pos { color: var(--credit); }
.stat .value.neg { color: var(--debit); }

.layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.accounts-panel, .ledger-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(8px);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.panel-head h2, .ledger-head h2 {
  font-family: var(--display);
  font-size: 1.25rem;
}
.muted { color: var(--muted); font-size: 0.92rem; }

.account-list { list-style: none; display: grid; gap: 0.45rem; }
.account-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.account-card:hover { border-color: rgba(15, 107, 92, 0.35); }
.account-card.active {
  border-color: var(--accent);
  background: rgba(15, 107, 92, 0.08);
  box-shadow: inset 3px 0 0 var(--accent);
}
.account-card .name { font-weight: 700; }
.account-card .meta { display: flex; justify-content: space-between; margin-top: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.account-card .bal { font-weight: 700; color: var(--ink); }
.account-card .bal.neg { color: var(--debit); }
.account-actions { display: flex; gap: 0.35rem; margin-top: 0.55rem; }
.account-actions .btn { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr; }
}
.filters input, .filters select,
.dlg input, .dlg select, .dlg textarea {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
}

.table-wrap { overflow-x: auto; }
.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.tx-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
.tx-table td {
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid rgba(40, 32, 20, 0.06);
  vertical-align: middle;
}
.tx-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-table .credit { color: var(--credit); font-weight: 600; }
.tx-table .debit { color: var(--debit); font-weight: 600; }
.tx-table .icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.2rem 0.35rem;
}
.tx-table .icon-btn:hover { color: var(--debit); }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  display: none;
}
.empty.show { display: block; }

.dlg {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(420px, calc(100vw - 2rem));
  box-shadow: 0 24px 60px rgba(20, 14, 8, 0.28);
  background: #fffcf6;
}
.dlg::backdrop { background: rgba(28, 22, 14, 0.45); backdrop-filter: blur(3px); }
.dlg form { padding: 1.25rem; display: grid; gap: 0.7rem; }
.dlg h3 {
  font-family: var(--display);
  font-size: 1.35rem;
  margin-bottom: 0.2rem;
}
.dlg label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.dlg label input, .dlg label select, .dlg label textarea { font-weight: 500; color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.forecast-panel {
  margin-top: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(8px);
}
.forecast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.horizon-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.horizon-label select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  background: #fff;
}
.forecast-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.forecast-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(64px, 1fr);
  gap: 0.55rem;
  align-items: end;
  min-height: 160px;
  padding: 0.75rem 0.25rem 0.4rem;
  margin-bottom: 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.35);
  overflow-x: auto;
}
.fbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  min-height: 140px;
}
.fbar .bar {
  width: 100%;
  max-width: 42px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #1a8f7a, #0f6b5c);
  min-height: 4px;
  transition: height 0.2s;
}
.fbar .bar.neg {
  background: linear-gradient(180deg, #d96a55, #b33a2b);
}
.fbar .m {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}
.fbar .v {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.forecast-subhead {
  font-size: 1.02rem;
  margin: 1.15rem 0 0.3rem;
}
.forecast-hint {
  margin: 0 0 0.65rem;
}
.col-done {
  width: 3.4rem;
  text-align: center;
}
.tx-table td.col-done {
  text-align: center;
}
.due-done td:not(.col-done) {
  text-decoration: line-through;
  opacity: 0.72;
}
.due-done {
  background: rgba(15, 107, 92, 0.06);
}
.done-check {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: #0f6b5c;
  cursor: pointer;
}
.check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.check input { width: auto; }
.muted-row { opacity: 0.55; }

.dlg-assign {
  width: min(640px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
}
.assign-wrap h3 { margin-bottom: 0.35rem; }
.assign-wrap > .muted { margin-bottom: 1rem; }
.assign-section {
  margin-bottom: 1.1rem;
  padding: 0.85rem 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.35);
}
.assign-section h4 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
}
.assign-new-user {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.assign-new-user input[type="text"],
.assign-new-user input:not([type="checkbox"]) {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  background: #fff;
  min-width: 0;
}
.check.inline {
  flex-direction: row !important;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
  font-size: 0.88rem;
}
.assign-users {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.assign-users li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.86rem;
  font-weight: 600;
}
.assign-users .tag-admin {
  color: var(--accent);
  font-size: 0.75rem;
}
.assign-users .del-user {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.1rem;
}
.assign-users .del-user:hover { color: var(--debit); }
#assign-body select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: #fff;
  min-width: 8rem;
}
@media (max-width: 640px) {
  .assign-new-user {
    grid-template-columns: 1fr;
  }
}

.dlg-options {
  width: min(440px, 100%);
}
.dlg-options fieldset.opts-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.9rem 1rem;
  margin: 0 0 0.85rem;
  background: rgba(255,255,255,0.35);
}
.dlg-options legend {
  font-weight: 700;
  padding: 0 0.35rem;
  font-size: 0.92rem;
}
.opts-user { margin: 0 0 0.85rem; }
.opts-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.btn.danger {
  color: var(--debit);
  border-color: rgba(179, 58, 43, 0.35);
}
.btn.danger:hover {
  background: rgba(179, 58, 43, 0.08);
}
.opts-ok {
  color: var(--credit) !important;
  font-weight: 600;
}

.foot {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
:root {
  --ink: #1c1914;
  --muted: #6b645a;
  --paper: #f3eee4;
  --card: rgba(255, 252, 246, 0.86);
  --line: rgba(40, 32, 20, 0.12);
  --accent: #0f6b5c;
  --accent-2: #c45c26;
  --credit: #0f6b5c;
  --debit: #b33a2b;
  --shadow: 0 12px 40px rgba(40, 28, 12, 0.12);
  --radius: 14px;
  --font: 'Source Sans 3', system-ui, sans-serif;
  --display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: #e8e0d2;
  padding: 1.25rem clamp(1rem, 3vw, 2rem) 2rem;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(15, 107, 92, 0.14), transparent 45%),
    radial-gradient(ellipse at 90% 10%, rgba(196, 92, 38, 0.12), transparent 40%),
    linear-gradient(165deg, #f6f1e7 0%, #e7dfd0 45%, #ddd2c0 100%);
}
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
.back:hover { color: var(--ink); }
.brand h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.sub { color: var(--muted); margin-top: 0.25rem; }
.top-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.save-status {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 5rem;
}
.save-status.err { color: var(--debit); }
.save-status.ok { color: var(--credit); }

[hidden] {
  display: none !important;
}

.auth-gate {
  min-height: calc(100vh - 2.5rem);
  display: grid;
  place-items: center;
  padding: 1rem 0;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.4rem 1.35rem;
  backdrop-filter: blur(10px);
  animation: auth-in 0.35s ease;
}
@keyframes auth-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.auth-card h1 {
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 0.2rem;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 1.1rem 0 1rem;
  padding: 0.25rem;
  background: rgba(28, 25, 20, 0.05);
  border-radius: 999px;
}
.auth-tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
}
.auth-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(40, 28, 12, 0.08);
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.auth-form input {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}
.auth-submit { width: 100%; margin-top: 0.35rem; }
.auth-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}
.auth-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
  line-height: 1.35;
}
.auth-error {
  color: var(--debit);
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.6rem;
}
.auth-switch {
  margin-top: 0.9rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.linkish {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkish:hover { color: var(--ink); }

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: var(--card);
  color: var(--ink);
  transition: transform 0.12s, background 0.12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--debit); border-color: rgba(179, 58, 43, 0.3); }
.file-btn { display: inline-flex; align-items: center; }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value {
  font-family: var(--display);
  font-size: 1.55rem;
  margin-top: 0.2rem;
}
.stat .value.pos { color: var(--credit); }
.stat .value.neg { color: var(--debit); }

.layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.accounts-panel, .ledger-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(8px);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.panel-head h2, .ledger-head h2 {
  font-family: var(--display);
  font-size: 1.25rem;
}
.muted { color: var(--muted); font-size: 0.92rem; }

.account-list { list-style: none; display: grid; gap: 0.45rem; }
.account-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.account-card:hover { border-color: rgba(15, 107, 92, 0.35); }
.account-card.active {
  border-color: var(--accent);
  background: rgba(15, 107, 92, 0.08);
  box-shadow: inset 3px 0 0 var(--accent);
}
.account-card .name { font-weight: 700; }
.account-card .meta { display: flex; justify-content: space-between; margin-top: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.account-card .bal { font-weight: 700; color: var(--ink); }
.account-card .bal.neg { color: var(--debit); }
.account-actions { display: flex; gap: 0.35rem; margin-top: 0.55rem; }
.account-actions .btn { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr; }
}
.filters input, .filters select,
.dlg input, .dlg select, .dlg textarea {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
}

.table-wrap { overflow-x: auto; }
.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.tx-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
.tx-table td {
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid rgba(40, 32, 20, 0.06);
  vertical-align: middle;
}
.tx-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-table .credit { color: var(--credit); font-weight: 600; }
.tx-table .debit { color: var(--debit); font-weight: 600; }
.tx-table .icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.2rem 0.35rem;
}
.tx-table .icon-btn:hover { color: var(--debit); }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  display: none;
}
.empty.show { display: block; }

.dlg {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(420px, calc(100vw - 2rem));
  box-shadow: 0 24px 60px rgba(20, 14, 8, 0.28);
  background: #fffcf6;
}
.dlg::backdrop { background: rgba(28, 22, 14, 0.45); backdrop-filter: blur(3px); }
.dlg form { padding: 1.25rem; display: grid; gap: 0.7rem; }
.dlg h3 {
  font-family: var(--display);
  font-size: 1.35rem;
  margin-bottom: 0.2rem;
}
.dlg label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.dlg label input, .dlg label select, .dlg label textarea { font-weight: 500; color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.forecast-panel {
  margin-top: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(8px);
}
.forecast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.horizon-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.horizon-label select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  background: #fff;
}
.forecast-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.forecast-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(64px, 1fr);
  gap: 0.55rem;
  align-items: end;
  min-height: 160px;
  padding: 0.75rem 0.25rem 0.4rem;
  margin-bottom: 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.35);
  overflow-x: auto;
}
.fbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  min-height: 140px;
}
.fbar .bar {
  width: 100%;
  max-width: 42px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #1a8f7a, #0f6b5c);
  min-height: 4px;
  transition: height 0.2s;
}
.fbar .bar.neg {
  background: linear-gradient(180deg, #d96a55, #b33a2b);
}
.fbar .m {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}
.fbar .v {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.forecast-subhead {
  font-size: 1.02rem;
  margin: 1.15rem 0 0.3rem;
}
.forecast-hint {
  margin: 0 0 0.65rem;
}
.col-done {
  width: 3.4rem;
  text-align: center;
}
.tx-table td.col-done {
  text-align: center;
}
.due-done td:not(.col-done) {
  text-decoration: line-through;
  opacity: 0.72;
}
.due-done {
  background: rgba(15, 107, 92, 0.06);
}
.done-check {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: #0f6b5c;
  cursor: pointer;
}
.check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.check input { width: auto; }
.muted-row { opacity: 0.55; }

.dlg-assign {
  width: min(640px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
}
.assign-wrap h3 { margin-bottom: 0.35rem; }
.assign-wrap > .muted { margin-bottom: 1rem; }
.assign-section {
  margin-bottom: 1.1rem;
  padding: 0.85rem 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.35);
}
.assign-section h4 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
}
.assign-new-user {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.assign-new-user input[type="text"],
.assign-new-user input:not([type="checkbox"]) {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  background: #fff;
  min-width: 0;
}
.check.inline {
  flex-direction: row !important;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
  font-size: 0.88rem;
}
.assign-users {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.assign-users li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.86rem;
  font-weight: 600;
}
.assign-users .tag-admin {
  color: var(--accent);
  font-size: 0.75rem;
}
.assign-users .del-user {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.1rem;
}
.assign-users .del-user:hover { color: var(--debit); }
#assign-body select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: #fff;
  min-width: 8rem;
}
@media (max-width: 640px) {
  .assign-new-user {
    grid-template-columns: 1fr;
  }
}

.dlg-options {
  width: min(440px, 100%);
}
.dlg-options fieldset.opts-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.9rem 1rem;
  margin: 0 0 0.85rem;
  background: rgba(255,255,255,0.35);
}
.dlg-options legend {
  font-weight: 700;
  padding: 0 0.35rem;
  font-size: 0.92rem;
}
.opts-user { margin: 0 0 0.85rem; }
.opts-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.btn.danger {
  color: var(--debit);
  border-color: rgba(179, 58, 43, 0.35);
}
.btn.danger:hover {
  background: rgba(179, 58, 43, 0.08);
}
.opts-ok {
  color: var(--credit) !important;
  font-weight: 600;
}

.foot {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
