:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #1b1f24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f6f7f9;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: #206a5d;
  color: #fff;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  border: 1px solid #cfd6dd;
  background: #fff;
  color: #1b1f24;
}

button.danger {
  background: #b42318;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 6px;
  background: #206a5d;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
}

.icon-button-secondary {
  border: 1px solid #cfd6dd;
  background: #fff;
  color: #607080;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  padding: 0 18px;
  background: #206a5d;
  color: #fff;
  font-weight: 600;
}

.secondary-link {
  border: 1px solid #cfd6dd;
  background: #fff;
  color: #1b1f24;
}

.page-login {
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(100%, 420px);
  padding: 24px;
}

.auth-panel,
.panel {
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgb(27 31 36 / 6%);
}

.auth-panel {
  padding: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #607080;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.form {
  display: grid;
  gap: 16px;
}

.form label {
  display: grid;
  gap: 6px;
  color: #34404b;
  font-weight: 600;
}

.form input,
.form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd6dd;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.form input:disabled,
.form select:disabled {
  cursor: not-allowed;
  color: #607080;
  opacity: 1;
}

.alert {
  border: 1px solid #e7b7b7;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff4f4;
  color: #8a1f1f;
}

.alert-info {
  border-color: #b8d2ea;
  background: #eef6ff;
  color: #24537a;
}

.rate-required-alert {
  margin: -8px 0 10px;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: 64px;
  border-bottom: 1px solid #d9e0e7;
  padding: 0 24px;
  gap: 18px;
  background: #fff;
}

.brand {
  font-weight: 800;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.welcome {
  margin: 0;
  color: #607080;
  font-weight: 600;
}

.topnav-end {
  margin-left: auto;
}

.topbar-spacer {
  flex: 1;
  min-width: 24px;
}

.tab {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  padding: 0 12px;
  color: #607080;
  font-weight: 600;
}

.tab.active {
  background: #eef3f1;
  color: #1b1f24;
}

.container {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 32px 24px;
}

.container-wide {
  width: min(100%, 1480px);
}

.container-center {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
}

.hero {
  margin-bottom: 24px;
}

.hero-tight {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.hero h1 {
  margin-bottom: 8px;
}

.hero-alert {
  margin: 0;
}

.panel {
  padding: 24px;
}

.panel-narrow {
  width: min(100%, 540px);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
}

.panel-header-stack {
  align-items: start;
}

.panel-copy {
  margin: 8px 0 0;
  max-width: 760px;
  color: #607080;
}

.sectionbar {
  border-bottom: 1px solid #d9e0e7;
  background: #fff;
}

.sectionbar-inner {
  width: min(100%, 1480px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
}

.subnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtab {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  color: #607080;
  font-weight: 600;
}

.subtab.active {
  background: #eef3f1;
  color: #1b1f24;
}

.page-alert {
  margin-bottom: 20px;
}

.dashboard-panel {
  padding-top: 20px;
}

.dashboard-header {
  width: 100%;
}

.dashboard-header > div {
  width: 100%;
}

.dashboard-header .panel-copy {
  max-width: none;
  white-space: nowrap;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: inherit;
  font-weight: 700;
}

.sort-arrow {
  color: #607080;
  font-size: 0.85rem;
  line-height: 1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
}

.balance-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #fff;
}

.balance-table thead th {
  padding: 12px;
  background: #f3f6f8;
  color: #1b1f24;
  font-size: 0.9rem;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid #d9e0e7;
}

.balance-table thead th.numeric {
  text-align: center;
}

.balance-table td {
  border-top: 1px solid #edf1f5;
  padding: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.balance-table tbody tr:nth-child(odd) {
  background: #fbfcfd;
}

.balance-table tbody tr:hover {
  background: #f7faf9;
}

.numeric {
  text-align: right;
}

.balance-table tbody td.numeric {
  text-align: right;
}

.actions-cell {
  text-align: center;
  white-space: nowrap;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #d9e0e7;
  border-radius: 6px;
  background: #fff;
  color: #607080;
}

.icon-link + .icon-link {
  margin-left: 6px;
}

.cell-accent.asset-detail {
  background: #f7f9fb;
  color: #34404b;
}

.cell-accent.total-assets {
  background: #e8f7ee;
  color: #14532d;
}

.cell-accent.debt {
  background: #fff1f2;
  color: #9f1239;
}

.emphasis {
  font-weight: 700;
}

.balance {
  background: #edf4ff;
  color: #1e3a8a;
  font-weight: 800;
}

.progress {
  min-width: 112px;
  background: #fff;
  font-weight: 700;
}

.progress.positive {
  color: #166534;
}

.progress.negative {
  color: #9f1239;
}

.progress.empty-progress {
  color: #8a96a3;
}

.progress-track {
  position: relative;
  display: block;
  min-width: 88px;
  min-height: 28px;
  overflow: hidden;
  border: 1px solid #d9e0e7;
  border-radius: 6px;
  background: #f8fafb;
}

.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress-width, 0%);
  background: #dff3e7;
}

.progress.negative .progress-bar {
  background: #fde2e5;
}

.progress-value {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 28px;
  padding: 0 8px;
}

.progress-missing {
  display: block;
  min-width: 88px;
  min-height: 28px;
  padding: 5px 8px;
  color: #8a96a3;
  text-align: center;
}

.composer-panel {
  width: 100%;
}

.builder-row {
  display: flex;
  align-items: end;
  gap: 14px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.builder-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.builder-toolbar-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.builder-toolbar-label {
  color: #607080;
  font-weight: 600;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.based-on-select {
  min-width: 280px;
  max-width: 420px;
}

.modal {
  width: min(100% - 32px, 460px);
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  padding: 0;
  background: #fff;
  box-shadow: 0 24px 70px rgb(27 31 36 / 20%);
}

.modal::backdrop {
  background: rgb(27 31 36 / 35%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #e5ebf0;
}

.modal-header h3 {
  margin: 0;
}

.modal-form {
  padding: 20px;
}

.modal .based-on-select {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.field-date {
  width: 180px;
}

.field-year {
  width: 110px;
}

.field-quarter {
  width: 90px;
}

.field-rate {
  width: 90px;
}

.builder-section + .builder-section {
  margin-top: 28px;
}

.builder-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.builder-section-header h3 {
  margin: 0;
}

.summary-pill {
  border: 1px solid #d9e0e7;
  border-radius: 999px;
  padding: 8px 14px;
  background: #f8fafb;
  color: #607080;
  font-weight: 600;
}

.summary-pill strong {
  color: #1b1f24;
}

.builder-grid {
  display: grid;
  gap: 16px;
}

.builder-grid-assets {
  grid-template-columns: 1fr;
}

.builder-grid-liabilities {
  grid-template-columns: 1fr;
}

.entry-card {
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.entry-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5ebf0;
  background: #fff;
}

.entry-card-header h4 {
  margin: 0;
  font-size: 1rem;
}

.icon-action,
.row-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 6px;
  background: #206a5d;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
}

.row-remove {
  background: #eef2f5;
  color: #607080;
}

.entry-card-table {
  overflow-x: auto;
  background: #fff;
}

.entry-card table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.entry-card th,
.entry-card td {
  padding: 10px 12px;
  border-top: 1px solid #edf1f5;
  white-space: nowrap;
  text-align: left;
}

.entry-card th {
  background: #f7f9fb;
  color: #607080;
  font-size: 0.84rem;
}

.entry-card td input {
  min-height: 36px;
}

.concept-input {
  min-width: 220px;
}

.money-input {
  width: 132px;
  min-width: 132px;
  max-width: 132px;
  text-align: right;
}

.money-input.calculated-input,
.money-input.calculated-input:disabled {
  border-color: #c8d0d8;
  background: #eef2f5;
  color: #46515c;
}

.entry-card td:nth-child(2),
.entry-card td:nth-child(3),
.entry-card td:nth-child(4),
.entry-card th:nth-child(2),
.entry-card th:nth-child(3),
.entry-card th:nth-child(4) {
  text-align: right;
  width: 144px;
}

.entry-card td:last-child,
.entry-card th:last-child {
  width: 60px;
  text-align: center;
}

.entry-card td:nth-child(4) {
  padding-right: 18px;
}

.percent-badge {
  display: inline-flex;
  min-width: 64px;
  justify-content: flex-end;
  color: #607080;
  font-weight: 700;
}

.entry-card-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid #e5ebf0;
  background: #f8fafb;
  color: #607080;
  font-weight: 600;
}

.entry-card-total strong {
  color: #1b1f24;
  text-align: right;
}

.balance-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.summary-box {
  display: grid;
  gap: 8px;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.summary-box span {
  color: #607080;
  font-weight: 600;
}

.summary-box strong {
  font-size: 1.2rem;
}

.summary-box-balance {
  background: #eff6ff;
  border-color: #c8d9f0;
}

.builder-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.builder-actions-left,
.builder-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.period-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.period-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #e5e9ee;
  border-radius: 6px;
  padding: 12px;
}

.empty {
  margin: 0;
  color: #607080;
}

.center-copy {
  text-align: center;
}

.center-copy h1 {
  margin: 0;
}

.alert-success {
  border-color: #b4dfc2;
  background: #edf9f1;
  color: #166534;
}

@media (max-width: 640px) {
  .panel-header,
  .period-list li {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 10px;
    padding: 12px 16px;
    flex-wrap: nowrap;
  }

  .topnav,
  .topnav-end {
    margin-left: 0;
    flex-wrap: nowrap;
  }

  .brand,
  .welcome {
    display: none;
  }

  .topbar-spacer {
    margin-left: auto;
    min-width: 0;
  }

  .hero-tight,
  .builder-section-header,
  .builder-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .sectionbar-inner {
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
  }

  .subnav {
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
  }

  .subtab,
  .sectionbar-inner > .button-link {
    min-width: 0;
    white-space: nowrap;
  }

  .sectionbar-inner > .button-link {
    flex: 0 0 auto;
    padding: 0 14px;
  }

  .dashboard-header .panel-copy {
    white-space: normal;
  }

  .builder-grid-assets,
  .builder-grid-liabilities,
  .balance-summary {
    grid-template-columns: 1fr;
  }

  .builder-actions,
  .builder-actions-left,
  .builder-actions-right {
    align-items: stretch;
    flex-direction: column;
  }
}
