:root {
  --forest: #1b2924;
  --forest-mid: #2d453e;
  --forest-soft: #4a635b;
  --gold: #eab33b;
  --gold-deep: #c8942a;
  --gold-mist: #f6e6bf;
  --paper: #f6f3ea;
  --paper-2: #efe9db;
  --card: #fffdf8;
  --line: #d8d2c4;
  --muted: #5e6a65;
  --danger: #8f3a2a;
  --ok: #2f6a4a;
  --info: #3d5a52;
  --shadow: 0 8px 24px rgba(27, 41, 36, 0.08);
  --radius: 10px;
  --font-ui: "Source Sans 3", "Segoe UI", sans-serif;
  --font-brand: "Cormorant Garamond", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--forest);
  background:
    radial-gradient(1200px 420px at 0% -10%, rgba(234, 179, 59, 0.12), transparent 50%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 22px;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--gold);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(27, 41, 36, 0.2);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link,
.nav-button {
  font: inherit;
  color: var(--forest-mid);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover,
.nav-button:hover {
  background: var(--gold-mist);
}

.nav-link.is-active {
  color: var(--forest);
  box-shadow: inset 0 -2px 0 var(--gold);
}

.nav-user {
  color: var(--muted);
  font-size: 13px;
  padding: 0 8px;
}

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--gold);
  color: var(--forest);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.content {
  width: min(980px, calc(100% - 32px));
  margin: 18px auto 0;
  flex: 1;
}

.site-footer {
  width: min(980px, calc(100% - 32px));
  margin: 24px auto 16px;
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  gap: 8px;
}

.dot {
  color: var(--gold-deep);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.compact {
  padding: 16px 18px;
}

.modal-card.compact {
  padding: 12px 14px;
}

.card-accent {
  border-color: #e3c77a;
  box-shadow: var(--shadow), inset 3px 0 0 var(--gold);
}

.card-head {
  margin-bottom: 12px;
}

.card-head.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.card-head h1,
.hero-copy h1 {
  margin: 0 0 4px;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
}

.card-head p,
.lead {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.auth-layout,
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.auth-single {
  width: min(420px, 100%);
  margin: 0 auto;
}

.auth-switch {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13.5px;
}

.auth-switch a {
  color: var(--forest);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
}

.auth-switch a:hover {
  color: var(--gold-deep);
}

.welcome-home {
  max-width: 520px;
}


.form {
  display: grid;
  gap: 9px;
}

.input,
.select {
  font: inherit;
  font-size: 14px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--forest);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.field {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--forest-mid);
  min-width: 0;
}

.input:focus,
.select:focus {
  outline: 2px solid rgba(234, 179, 59, 0.45);
  border-color: var(--gold-deep);
}

.btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: fit-content;
}

.btn-primary {
  background: var(--gold);
  color: var(--forest);
  border-color: var(--gold-deep);
}

.btn-primary:hover {
  background: #f0c45a;
}

.btn-secondary,
.btn-tiny,
.btn-ghost-tiny {
  background: #fff;
  color: var(--forest-mid);
  border-color: var(--line);
}

.btn-tiny,
.btn-ghost-tiny {
  padding: 5px 8px;
  font-size: 12.5px;
}

.btn-ghost-tiny {
  background: transparent;
}

.error {
  color: var(--danger);
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.flash {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13.5px;
}

.flash-success {
  border-color: #b7d4c4;
  background: #f1f8f4;
}

.flash-error {
  border-color: #e3c1b8;
  background: #fbf3f1;
}

.flash-warning,
.flash-info {
  border-color: #ead7a4;
  background: #fbf6ea;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.hero-logo {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold-deep);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.meta-list {
  display: grid;
  gap: 8px;
  margin: 0 0 4px;
}

.meta-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}

.meta-list dt {
  color: var(--muted);
  font-size: 13px;
}

.meta-list dd {
  margin: 0;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th,
.table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
}

.table tr.is-pending {
  background: #fbf6ea;
}

.table tr.tx-row-income td {
  background: #eef6f0;
}

.table tr.tx-row-expense td {
  background: #f7efed;
}

.table tr.tx-row-transfer td {
  background: #f1f2f1;
}

.table tr.tx-row-income:hover td {
  background: #e5f0e8;
}

.table tr.tx-row-expense:hover td {
  background: #f2e6e3;
}

.table tr.tx-row-transfer:hover td {
  background: #e9ebea;
}

.table-journal {
  table-layout: fixed;
  font-size: 12.5px;
}

.table-journal th,
.table-journal td {
  padding: 4px 6px;
  vertical-align: middle;
  font-size: 12.5px;
}

.table-journal th {
  font-size: 11.5px;
}

.table-journal .col-date {
  width: 5.8rem;
  white-space: nowrap;
}

.table-journal .col-account {
  width: 16%;
}

.table-journal .col-category {
  width: 14%;
}

.table-journal .col-comment {
  width: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-journal .col-amount {
  width: 9.5rem;
  text-align: right;
  white-space: nowrap;
}

.table-journal th.col-amount {
  text-align: right;
}

.table-journal .col-actions {
  width: 5.25rem;
  min-width: 5.25rem;
  padding-right: 8px;
  overflow: visible;
  text-align: right;
}

.table-journal .col-actions .icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.table-journal .col-actions .icon-btn svg {
  width: 12px;
  height: 12px;
}

.tx-date-day {
  display: block;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.tx-date-time {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.journal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: end;
  margin: 0 0 12px;
  padding: 10px 0 12px;
  border-bottom: 1px dashed var(--line);
}

.journal-filters .field {
  margin: 0;
  gap: 2px;
  font-size: 12px;
}

.journal-filters .input,
.journal-filters .multi-select-trigger {
  font-size: 12.5px;
  padding: 5px 8px;
  min-height: 32px;
}

.journal-filter-date {
  width: 8.5rem;
}

.journal-filter-search {
  flex: 1 1 12rem;
  min-width: 10rem;
}

.journal-filter-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.multi-select {
  position: relative;
  min-width: 10rem;
  max-width: 14rem;
}

.multi-select-trigger {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.multi-select-trigger svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

.multi-select-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 16rem;
  max-height: 240px;
  overflow: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(27, 41, 36, 0.14);
}

.multi-select-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1.25;
}

.multi-select-option:hover {
  background: #f6f2e8;
}

.multi-select-option input {
  margin-top: 2px;
  flex-shrink: 0;
}

.multi-select-empty {
  margin: 4px 6px;
  font-size: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.pagination-status {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 820px) {
  .journal-filter-actions {
    margin-left: 0;
    width: 100%;
  }
}

.role-form,
.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
}

.chip,
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--gold-mist);
  color: var(--forest);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

.link-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.accounts-page {
  display: grid;
  gap: 14px;
}

.disclosure {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.disclosure.is-collapsed[hidden] {
  display: none;
}

.form-inline-grid {
  grid-template-columns: 1.4fr 1fr auto;
  align-items: end;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.col-actions .inline-form {
  display: inline-flex;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--forest-mid);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--gold-mist);
  border-color: #e3c77a;
}

.icon-btn-danger:hover {
  background: #fbf3f1;
  border-color: #e3c1b8;
  color: var(--danger);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 7px;
  background: #f3efe4;
  border: 1px solid var(--line);
  font-size: 13px;
}

.currency-symbol {
  font-weight: 700;
  color: var(--gold-deep);
  min-width: 1.4em;
  text-align: center;
}

.page-corner-link {
  justify-self: end;
  font-size: 12.5px;
}

.page-corner-link a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
}

.page-corner-link a:hover {
  color: var(--forest);
  border-bottom-color: var(--gold-deep);
}

.modal-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(380px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(90vh, 640px);
  margin: auto;
  overflow: hidden;
}

.modal-dialog::backdrop {
  background: rgba(27, 41, 36, 0.35);
}

.modal-card {
  margin: 0;
  width: 100%;
  max-width: 100%;
  max-height: min(90vh, 640px);
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(27, 41, 36, 0.18);
  padding: 12px 14px;
  font-size: 13px;
}

.modal-card.form {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
}

.modal-card-compact .modal-head {
  margin-bottom: 4px;
}

.modal-card-compact .modal-head h1,
.modal-card .card-head h1 {
  font-size: 1.05rem;
  margin: 0;
}

.modal-card .card-head p {
  font-size: 12px;
  margin-top: 2px;
}

.modal-card .field {
  gap: 2px;
  font-size: 12px;
}

.modal-card .input,
.modal-card .select {
  font-size: 13px;
  padding: 5px 8px;
}

.modal-card .btn {
  font-size: 12.5px;
  padding: 6px 10px;
}

.modal-actions {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.modal-stack[hidden] {
  display: none !important;
}

.kind-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 2px;
  background: #f3efe4;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kind-option {
  display: block;
  cursor: pointer;
  margin: 0;
}

.kind-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kind-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--forest-mid);
}

.kind-option input:checked + span {
  background: #fff;
  color: var(--forest);
  box-shadow: 0 1px 0 var(--gold);
}

.transfer-amounts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  align-items: end;
}

.transfer-arrow {
  padding-bottom: 8px;
  color: var(--gold-deep);
  font-weight: 700;
}

.tree-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: calc(var(--depth, 0) * 1.25rem);
  font-weight: 500;
}

.tree-toolbar {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-sm {
  font-size: 12px;
  padding: 5px 9px;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--forest-mid);
  cursor: pointer;
  flex-shrink: 0;
}

.tree-toggle:hover {
  background: #efe9d8;
  color: var(--forest);
}

.tree-toggle svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.tree-toggle[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

.tree-toggle-spacer {
  display: inline-block;
  width: 1.35rem;
  flex-shrink: 0;
}

.tree-row.is-collapsed-parent .tree-name {
  font-weight: 600;
}

.tree-guide {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-right: 2px;
  flex-shrink: 0;
}

.money-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.is-positive {
  color: var(--ok);
}

.is-negative {
  color: var(--danger);
}

.cashflow-filter {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.accounts-checkboxes {
  grid-column: 1 / -1;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 10px;
  margin-top: 6px;
}

.check-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13.5px;
}

.cashflow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.form-tx {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-tx .field-span {
  grid-column: 1 / -1;
}

.subhead {
  margin: 0 0 10px;
  font-size: 1rem;
  font-family: var(--font-brand);
}

.subtabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.subtab {
  text-decoration: none;
  color: var(--forest-mid);
  font-size: 13.5px;
  padding: 6px 10px;
  border-radius: 7px;
}

.subtab:hover {
  background: var(--gold-mist);
}

.subtab.is-active {
  color: var(--forest);
  box-shadow: inset 0 -2px 0 var(--gold);
  font-weight: 600;
}

.nested-subtabs {
  margin: -4px 0 14px;
  padding-left: 2px;
}

.nested-subtabs .subtab {
  font-size: 13px;
  padding: 6px 10px;
}

.col-poster-id {
  width: 5.5rem;
  white-space: nowrap;
}

.poster-map-form .select {
  width: 100%;
  max-width: 28rem;
  font-size: 12.5px;
  padding: 5px 8px;
}

.tag-poster {
  margin-left: 6px;
  font-size: 10.5px;
  padding: 1px 6px;
  background: #dceee6;
  color: var(--forest);
  border: 1px solid #b7d4c6;
  vertical-align: middle;
}

.account-row-poster td {
  background: #e7f5ee;
}

.account-row-poster:hover td {
  background: #d9efe4;
}

.form-category {
  grid-template-columns: 1.2fr 1.2fr 1fr auto;
}

textarea.input {
  resize: vertical;
  min-height: 56px;
}

.journal-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.contour-transfer-hint {
  margin: 0 0 8px;
  font-size: 12.5px;
}

.field-hint.is-danger {
  color: var(--danger);
}

.assets-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.capital-filter {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
}

.capital-rates {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f7f3ea;
}

.field-hint {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.capital-summary-grid,
.capital-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.capital-total {
  margin: 4px 0 0;
  font-size: 1.55rem;
  font-weight: 700;
  font-family: "Cormorant Garamond", serif;
}

.capital-chart-wrap {
  max-width: 360px;
  margin: 8px auto 16px;
}

.assets-type-form {
  grid-template-columns: 1fr auto;
}

.assets-summary {
  margin-top: 4px;
}

.assets-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-dialog-wide {
  width: min(440px, calc(100vw - 24px));
}

.asset-row-done td {
  color: var(--muted);
}

@media (max-width: 760px) {
  .topbar,
  .auth-layout,
  .grid-2,
  .hero-card,
  .card-head.row {
    flex-direction: column;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .form-inline-grid,
  .form-tx,
  .form-category,
  .cashflow-filter,
  .capital-filter,
  .capital-rates,
  .capital-summary-grid,
  .capital-charts-grid,
  .assets-type-form,
  .assets-modal-grid {
    grid-template-columns: 1fr;
  }

  .hero-logo {
    width: 72px;
    height: 72px;
  }
}
