:root {
  color-scheme: light;
  --bg: #f5f7f5;
  --panel: #ffffff;
  --panel-soft: #f1f6f4;
  --ink: #17201b;
  --muted: #66736b;
  --line: #dce3de;
  --teal: #167c80;
  --coral: #d95d55;
  --gold: #c68722;
  --green: #2f8f59;
  --danger: #b54040;
  --violet: #6a5b9a;
  --shadow: 0 14px 34px rgba(33, 42, 35, 0.06);
  --shadow-strong: 0 28px 80px rgba(20, 27, 22, 0.24);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.app-shell[hidden],
.login-screen[hidden] {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-strong);
  padding: 28px;
}

.login-card h1 {
  margin-bottom: 22px;
}

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

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 0.98rem;
}

.header-actions,
.section-heading,
.field-row,
.card-form,
.payment-actions,
.view-tabs,
.bill-actions,
.timeline-row,
.smart-row,
.ledger-line {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
  padding: 0 12px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 124, 128, 0.5);
}

.header-primary {
  min-height: 42px;
  padding: 0 15px;
}

.icon-button svg,
.primary-action svg,
.secondary-action svg,
.bill-action svg,
.view-tab svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
}

.icon-button.subtle {
  background: var(--panel-soft);
}

.icon-button.dark {
  background: var(--ink);
  color: white;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 1.42rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.metric em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 380px);
  gap: 16px;
  align-items: start;
}

.tool-panel,
.list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.tool-panel {
  padding: 18px;
}

.list-panel {
  min-width: 0;
  padding: 20px;
}

.side-stack {
  position: sticky;
  top: 16px;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.bill-form,
.smart-form {
  display: grid;
  gap: 14px;
}

.editor-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
}

.wide-field {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 92px;
  padding: 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 124, 128, 0.13);
}

input[readonly] {
  background: #f6f8f4;
  color: var(--muted);
}

.field-row {
  gap: 10px;
}

.field-row > label {
  flex: 1;
  min-width: 0;
}

.debt-box {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf5ee;
}

.debt-box[hidden] {
  display: none;
}

.debt-preview,
.income-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.42;
  padding: 11px;
}

.debt-preview strong,
.income-summary strong {
  color: var(--ink);
}

.primary-action,
.secondary-action {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-action {
  border: 0;
  background: #147a7d;
  color: white;
}

.primary-action:hover {
  background: #106d70;
}

.primary-action.compact {
  min-height: 42px;
}

.secondary-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-action:hover {
  border-color: var(--teal);
}

.secondary-action.compact {
  min-height: 34px;
  padding: 0 12px;
}

.list-heading {
  align-items: flex-start;
}

.total-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: #f2eadc;
  color: #6b4712;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.view-tabs {
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.view-tab {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  padding: 0 12px;
}

.view-tab[aria-pressed="true"] {
  border-color: var(--teal);
  background: #e9f5f5;
  color: #0e6266;
}

.utility-tab {
  margin-left: auto;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.person-filters {
  display: flex;
  grid-column: 1 / -1;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.person-filter {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  padding: 0 12px;
  white-space: nowrap;
}

.person-filter[aria-pressed="true"] {
  border-color: var(--filter-color, var(--teal));
  box-shadow: inset 0 -3px 0 var(--filter-color, var(--teal));
}

.swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--swatch-color, var(--teal));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 3px rgba(32, 38, 33, 0.18);
}

.filter-field span {
  color: var(--muted);
  font-size: 0.72rem;
}

.view-host {
  min-height: 260px;
}

.bill-list {
  display: grid;
  gap: 12px;
}

.bill-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--person-color, var(--teal));
  border-radius: 8px;
  background: #fff;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.bill-card[data-clickable="true"] {
  cursor: pointer;
}

.bill-card[data-clickable="true"]:hover {
  border-color: rgba(22, 124, 128, 0.42);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

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

.bill-topline,
.bill-meta,
.bill-tags {
  display: flex;
  align-items: center;
}

.bill-topline {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.bill-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  line-height: 1.25;
}

.status-badge,
.person-badge,
.card-badge,
.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 0.73rem;
  font-weight: 850;
  white-space: nowrap;
}

.status-badge {
  background: #eef3ef;
  color: var(--muted);
}

.status-badge.paid {
  background: rgba(47, 143, 89, 0.13);
  color: #236b43;
}

.status-badge.overdue {
  background: rgba(181, 64, 64, 0.12);
  color: var(--danger);
}

.status-badge.unpaid {
  background: rgba(198, 135, 34, 0.14);
  color: #7a5317;
}

.status-badge.skipped {
  background: rgba(106, 91, 154, 0.13);
  color: var(--violet);
}

.bill-meta {
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.87rem;
}

.bill-meta strong {
  color: var(--ink);
}

.bill-tags {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.person-badge {
  background: color-mix(in srgb, var(--person-color, var(--teal)) 16%, white);
  color: var(--ink);
}

.card-badge {
  background: #edf6f7;
  color: #215c60;
}

.type-badge {
  background: #f4eee4;
  color: #6b4712;
}

.bill-notes {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.bill-actions {
  gap: 7px;
  align-self: start;
}

.bill-action {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.bill-action:hover {
  border-color: var(--teal);
}

.bill-action.pay {
  color: var(--green);
}

.bill-action.late {
  color: var(--gold);
}

.bill-action.delete {
  color: var(--danger);
}

.bill-action.mistake {
  color: var(--violet);
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  border: 1px dashed #bbc7bd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.empty-state strong {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 1.05rem;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
}

.day-cell {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  min-width: 0;
}

.day-cell.outside {
  background: #f3f5f0;
}

.day-number {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
}

.day-cell.today .day-number {
  background: var(--teal);
  color: white;
}

.day-items {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.day-item {
  display: grid;
  gap: 1px;
  border: 0;
  border-left: 3px solid var(--person-color, var(--teal));
  border-radius: 6px;
  background: #f8faf6;
  color: var(--ink);
  padding: 5px 6px;
  text-align: left;
  min-width: 0;
}

.day-item strong,
.day-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-item strong {
  font-size: 0.68rem;
  line-height: 1.15;
}

.day-item span {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.15;
}

.day-more {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 850;
  padding: 2px 0;
  text-align: left;
}

.list-panel.calendar-expanded {
  position: fixed;
  inset: 16px;
  z-index: 18;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: auto;
  box-shadow: var(--shadow-strong);
}

.list-panel.calendar-expanded .month-grid {
  height: 100%;
  min-height: 720px;
}

.list-panel.calendar-expanded .day-cell {
  min-height: 160px;
}

.list-panel.calendar-expanded .day-item strong {
  font-size: 0.74rem;
}

.list-panel.calendar-expanded .day-item span {
  font-size: 0.68rem;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-row {
  gap: 12px;
  align-items: stretch;
}

.timeline-date {
  display: grid;
  width: 78px;
  min-height: 72px;
  place-items: center;
  border-radius: 8px;
  background: #eef5f1;
  color: var(--ink);
  font-weight: 850;
  text-align: center;
}

.timeline-date span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.timeline-row .bill-card {
  flex: 1;
}

.smart-results,
.month-ledger {
  display: grid;
  gap: 10px;
}

.calendar-status,
.sync-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

.calendar-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 12px;
  padding: 11px;
}

.calendar-status.connected {
  border-color: rgba(47, 143, 89, 0.35);
  background: rgba(47, 143, 89, 0.08);
  color: #236b43;
}

.calendar-actions {
  display: grid;
  gap: 8px;
}

.setup-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1px dashed rgba(22, 124, 128, 0.45);
  border-radius: 8px;
  background: #f5fbfb;
  color: #0e6266;
  font-size: 0.88rem;
  font-weight: 850;
  margin-top: 8px;
  text-decoration: none;
}

.setup-link[hidden] {
  display: none;
}

.setup-link svg {
  width: 16px;
  height: 16px;
}

.sync-note {
  margin: 12px 0 0;
}

.smart-card,
.ledger-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.smart-card h3,
.ledger-card h3 {
  margin: 0 0 10px;
}

.smart-list {
  display: grid;
  gap: 8px;
}

.smart-row,
.ledger-line {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.smart-row strong,
.ledger-line strong {
  color: var(--ink);
}

.settings-block + .settings-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.people-settings {
  display: grid;
  gap: 10px;
}

.person-editor {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.person-editor input[type="color"] {
  width: 44px;
  height: 42px;
  min-height: unset;
  padding: 3px;
}

.card-form {
  gap: 8px;
}

.card-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.card-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px 0 11px;
  background: #fff;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 750;
}

.card-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-remove {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f4eeee;
  color: var(--danger);
}

.chip-remove svg {
  width: 14px;
  height: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(32, 38, 33, 0.38);
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.payment-modal {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-strong);
  padding: 18px;
}

.bill-editor-modal {
  width: min(780px, 100%);
}

.modal-tools {
  display: flex;
  gap: 8px;
}

.payment-context {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.payment-context strong {
  display: block;
  margin-bottom: 6px;
}

.payment-context span {
  color: var(--muted);
  font-size: 0.88rem;
}

.payment-actions {
  gap: 10px;
}

.payment-actions > button {
  flex: 1;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  display: flex;
  width: min(460px, calc(100% - 32px));
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-strong);
  padding: 13px;
}

.toast[hidden] {
  display: none;
}

.toast > div {
  flex: 1;
  min-width: 0;
}

.toast strong,
.toast span {
  display: block;
}

.toast span {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 3px;
}

.toast-close {
  width: 34px;
  height: 34px;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-stack {
    grid-template-columns: 1fr;
  }

  .month-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .weekday {
    display: none;
  }

  .day-cell.outside {
    display: none;
  }
}

@media (max-width: 760px) {
  .filters {
    grid-template-columns: 1fr;
  }

  .editor-form {
    grid-template-columns: 1fr;
  }

  .timeline-row {
    display: grid;
  }

  .timeline-date {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1540px);
    padding-top: 14px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .header-primary {
    width: 100%;
  }

  .user-pill {
    width: 100%;
    justify-content: center;
  }

  .field-row,
  .bill-card,
  .bill-actions,
  .payment-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .field-row,
  .bill-actions {
    display: grid;
  }

  .bill-card {
    grid-template-columns: 1fr;
  }

  .bill-actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .bill-action {
    width: 100%;
  }

  .month-grid {
    grid-template-columns: 1fr;
  }
}

/* Professional interface pass */
body {
  background:
    linear-gradient(rgba(20, 29, 24, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 29, 24, 0.025) 1px, transparent 1px),
    #f5f7f5;
  background-size: 28px 28px;
}

.app-shell {
  width: min(1580px, calc(100% - 32px));
  padding-top: 18px;
}

.app-header {
  position: sticky;
  top: 10px;
  z-index: 12;
  border: 1px solid rgba(220, 227, 222, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 48px rgba(33, 42, 35, 0.08);
  backdrop-filter: blur(14px);
  margin-bottom: 14px;
  padding: 14px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(22, 124, 128, 0.22);
  border-radius: 8px;
  background: #eef7f7;
  color: var(--teal);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-lockup h1 {
  font-size: clamp(1.55rem, 2vw, 2.15rem);
  letter-spacing: 0;
}

.header-actions {
  padding-left: 12px;
}

.user-pill,
.icon-button,
.primary-action,
.secondary-action,
.view-tab,
.person-filter {
  box-shadow: 0 1px 0 rgba(20, 27, 22, 0.04);
}

.summary-grid {
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 104px;
  padding: 17px 18px;
  box-shadow: 0 10px 28px rgba(33, 42, 35, 0.045);
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--teal);
}

.metric:nth-child(2)::before {
  background: var(--green);
}

.metric:nth-child(3)::before {
  background: var(--gold);
}

.metric:nth-child(4)::before {
  background: var(--violet);
}

.metric:nth-child(5)::before {
  background: var(--coral);
}

.metric span {
  color: #59655d;
  font-size: 0.74rem;
}

.metric strong {
  margin-top: 10px;
  font-size: clamp(1.35rem, 1.6vw, 1.75rem);
}

.workspace {
  grid-template-columns: minmax(0, 1fr) minmax(330px, 390px);
  gap: 18px;
}

.list-panel,
.tool-panel {
  box-shadow: 0 10px 30px rgba(33, 42, 35, 0.045);
}

.list-panel {
  overflow: hidden;
  padding: 0;
}

.list-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #fff;
  margin: 0;
  padding: 18px 20px;
}

.command-surface {
  position: sticky;
  top: 98px;
  z-index: 8;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.94);
  backdrop-filter: blur(12px);
  padding: 14px 20px 16px;
}

.view-tabs {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  gap: 2px;
  margin-bottom: 12px;
  padding: 3px;
}

.view-tab {
  border: 0;
  min-height: 36px;
  background: transparent;
}

.view-tab[aria-pressed="true"] {
  background: #e9f5f5;
  box-shadow: inset 0 0 0 1px rgba(22, 124, 128, 0.16);
}

.utility-tab {
  margin-left: 6px;
  border-left: 1px solid var(--line);
}

.filters {
  grid-template-columns: minmax(145px, 0.75fr) minmax(145px, 0.75fr) minmax(220px, 1.4fr);
  border: 0;
  background: transparent;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.person-filters {
  padding-bottom: 2px;
}

.filter-field span {
  font-weight: 850;
}

.view-host {
  padding: 18px 20px 20px;
}

.bill-list {
  gap: 10px;
}

.bill-card {
  grid-template-columns: minmax(0, 1fr) minmax(148px, auto);
  align-items: stretch;
  border-left-width: 5px;
  padding: 15px;
}

.bill-actions {
  display: grid;
  grid-template-columns: repeat(2, 38px);
  align-content: start;
  justify-content: end;
  gap: 8px;
}

.bill-action {
  width: 38px;
  height: 38px;
  background: #fbfcfb;
}

.bill-meta {
  gap: 8px 14px;
}

.bill-tags {
  gap: 6px;
}

.status-badge,
.person-badge,
.card-badge,
.type-badge {
  min-height: 25px;
}

.side-stack {
  gap: 14px;
}

.tool-panel {
  padding: 16px;
}

.tool-panel .section-heading {
  border-bottom: 1px solid var(--line);
  margin: -2px 0 14px;
  padding-bottom: 12px;
}

.smart-card,
.ledger-card,
.calendar-status,
.payment-context,
.debt-preview,
.income-summary {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.smart-row,
.ledger-line {
  align-items: flex-start;
}

.smart-row span,
.ledger-line span {
  min-width: 0;
}

.smart-row strong,
.ledger-line strong {
  text-align: right;
}

.calendar-actions {
  grid-template-columns: 1fr 1fr;
}

.month-grid {
  gap: 7px;
}

.day-cell {
  min-height: 156px;
  padding: 9px;
}

.day-item {
  transition:
    background 140ms ease,
    transform 140ms ease;
}

.day-item:hover {
  background: #eef5f1;
  transform: translateY(-1px);
}

.timeline {
  gap: 12px;
}

.timeline-date {
  border: 1px solid var(--line);
}

.modal-backdrop {
  background: rgba(20, 27, 22, 0.46);
  backdrop-filter: blur(8px);
}

.payment-modal {
  border-color: rgba(220, 227, 222, 0.95);
  padding: 0;
}

.payment-modal > .section-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  margin: 0;
  padding: 18px;
  backdrop-filter: blur(10px);
}

.payment-modal .bill-form {
  padding: 18px;
}

.toast {
  align-items: flex-start;
  border-color: rgba(220, 227, 222, 0.95);
  box-shadow: 0 24px 68px rgba(20, 27, 22, 0.22);
}

@media (max-width: 1280px) {
  .command-surface {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-header {
    position: static;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tab {
    flex: 1;
    justify-content: center;
  }

  .calendar-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 18px, 1580px);
  }

  .list-heading,
  .command-surface,
  .view-host {
    padding-left: 14px;
    padding-right: 14px;
  }

  .bill-actions {
    grid-template-columns: repeat(5, 1fr);
  }
}
