:root {
  color-scheme: light;
  --canvas: #f5f8fa;
  --surface: #ffffff;
  --ink: #15201d;
  --muted: #6a7773;
  --line: #dbe4e1;
  --line-strong: #c5d2ce;
  --positive: #16734a;
  --positive-soft: #e4f3eb;
  --negative: #c65343;
  --negative-soft: #fde9e5;
  --accent: #286a73;
  --accent-soft: #e3f0f1;
  --warning: #a66b16;
  --warning-soft: #fcf1db;
  --shadow: 0 12px 36px rgba(27, 55, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(40, 106, 115, 0.28);
  outline-offset: 2px;
}

.app-shell,
.login-shell {
  width: min(100%, 680px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
}

.app-shell {
  padding: env(safe-area-inset-top) 18px calc(92px + env(safe-area-inset-bottom));
}

.login-shell {
  display: grid;
  align-content: center;
  gap: 30px;
  padding: max(34px, env(safe-area-inset-top)) 28px max(34px, env(safe-area-inset-bottom));
}

.login-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  background: #15382d;
  color: #fff;
  font-size: 24px;
  font-weight: 750;
}

.login-copy h1,
.topbar h1 {
  margin: 0;
  color: var(--ink);
  font-weight: 730;
}

.login-copy h1 {
  font-size: 32px;
  line-height: 1.08;
}

.login-copy p {
  max-width: 330px;
  margin: 11px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 12px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.password-input,
.month-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.password-input {
  height: 50px;
  padding: 0 13px;
}

.month-input {
  width: auto;
  min-height: 38px;
  padding: 0 10px;
}

.primary-button,
.secondary-button,
.quiet-button {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 680;
}

.primary-button {
  border: 1px solid #15382d;
  background: #15382d;
  color: #fff;
}

.primary-button:hover {
  background: #1c4a3b;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
}

.secondary-button:hover,
.quiet-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quiet-button {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.button-row .primary-button {
  flex: 1;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--negative);
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
}

.topbar h1 {
  font-size: 21px;
  line-height: 1;
}

.topbar-meta {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.view {
  padding-top: 26px;
}

.view-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.view-heading h2,
.section-heading h3 {
  margin: 0;
  font-weight: 720;
}

.view-heading h2 {
  font-size: 27px;
  line-height: 1.08;
}

.view-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section {
  margin-top: 30px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-heading h3 {
  font-size: 16px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.hero-balance {
  display: grid;
  gap: 6px;
  padding: 26px 0 25px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.hero-balance strong {
  color: var(--ink);
  font-size: 39px;
  font-weight: 730;
  line-height: 1;
}

.hero-balance small {
  color: var(--muted);
  font-size: 13px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 18px 12px 19px 0;
}

.metric + .metric {
  border-left: 1px solid var(--line);
  padding-left: 15px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.1;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.chart-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  box-shadow: var(--shadow);
}

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 4px;
}

.chart-header strong {
  font-size: 15px;
}

.chart-header span {
  color: var(--muted);
  font-size: 12px;
}

.cashflow-chart {
  display: block;
  width: 100%;
  height: 188px;
}

.chart-legend {
  display: flex;
  gap: 15px;
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  content: "";
}

.chart-legend .inflow::before {
  background: var(--positive);
}

.chart-legend .outflow::before {
  background: var(--negative);
}

.list {
  border-top: 1px solid var(--line);
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.row-main {
  min-width: 0;
}

.row-title {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-value {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 670;
  text-align: right;
}

.pending-mark {
  color: var(--warning);
}

.empty-state {
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
}

.payment-list {
  display: grid;
  gap: 10px;
}

.payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.payment-row:first-child {
  border-top: 1px solid var(--line);
}

.payment-row strong {
  display: block;
  font-size: 14px;
}

.payment-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.payment-amount {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  text-align: right;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 680px);
  min-height: calc(70px + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.tab-button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.tab-button[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.bar-list {
  display: grid;
  gap: 13px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 13px;
}

.bar-label span:last-child {
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 4px;
  background: #e8eeee;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

.service-list,
.account-list {
  border-top: 1px solid var(--line);
}

.service-row,
.account-row {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.service-row-top,
.account-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.service-name,
.account-name {
  font-weight: 680;
}

.service-type,
.account-type {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.status.partial,
.status.needs_attention {
  background: var(--warning-soft);
  color: var(--warning);
}

.status.error {
  background: var(--negative-soft);
  color: var(--negative);
}

.service-detail {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-row-top strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 90px;
  left: 18px;
  z-index: 20;
  width: min(calc(100% - 36px), 644px);
  margin: 0 auto;
  pointer-events: none;
}

.toast:not(:empty) {
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #18221f;
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 13px;
}

.loading {
  display: grid;
  min-height: 45vh;
  place-items: center;
  color: var(--muted);
}

@media (min-width: 681px) {
  body {
    padding: 24px 0;
  }

  .app-shell,
  .login-shell {
    min-height: calc(100vh - 48px);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .tabbar {
    bottom: 24px;
    border: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
  }
}
