:root {
  --rose-900: #4a1732;
  --rose-800: #7d234f;
  --rose-700: #a92f67;
  --rose-600: #c83f7c;
  --rose-100: #ffe8f1;
  --rose-50: #fff5f9;
  --teal-700: #117a72;
  --teal-100: #dff7f3;
  --plum-100: #f3e5f1;
  --paper: #ffffff;
  --line: #ecd5df;
  --ink: #332530;
  --muted: #755f6d;
  --shadow: 0 18px 45px rgba(126, 35, 79, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 184, 210, 0.28), transparent 34rem),
    linear-gradient(135deg, #fff8fb 0%, #f8fbff 48%, #fff3f7 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

.month-control {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 0.72rem 0.82rem;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--rose-600);
  box-shadow: 0 0 0 3px rgba(200, 63, 124, 0.14);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid #f0dce4;
  padding: 0.78rem 0.75rem;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--rose-800);
  font-size: 0.74rem;
  text-transform: uppercase;
}

td {
  color: var(--ink);
  font-size: 0.9rem;
}

.is-hidden {
  display: none !important;
}

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

.login-panel {
  width: min(100%, 390px);
  border: 1px solid rgba(236, 213, 223, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.brand-mark {
  display: grid;
  width: 3.2rem;
  height: 3.2rem;
  margin-bottom: 1rem;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rose-700), #dd6f9c);
  color: white;
  font-size: 1.55rem;
  font-weight: 900;
}

.login-panel label + label {
  margin-top: 0.8rem;
}

.login-panel h1,
.topbar h1,
.panel-heading h2 {
  margin: 0;
  color: var(--rose-900);
  letter-spacing: 0;
}

.login-panel h1 {
  margin-bottom: 1.35rem;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
}

.form-message {
  min-height: 1.2rem;
  margin: 0.85rem 0 0;
  color: #9a1f3f;
  font-size: 0.9rem;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 1.1rem;
}

main,
.summary-grid,
.workspace-grid,
.details-grid,
.records-section {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 0.25rem 0.4rem;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.heart-mark {
  position: relative;
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  transform: rotate(-45deg);
  border-radius: 8px 8px 4px 8px;
  background: linear-gradient(135deg, #d33d7b, #f38ab2);
  box-shadow: 0 12px 24px rgba(169, 47, 103, 0.2);
}

.heart-mark::before,
.heart-mark::after {
  position: absolute;
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 50%;
  background: inherit;
  content: "";
}

.heart-mark::before {
  top: -1.25rem;
  left: 0;
}

.heart-mark::after {
  top: 0;
  left: 1.25rem;
}

.eyebrow {
  margin: 0 0 0.18rem;
  color: var(--teal-700);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.month-control {
  min-width: 16rem;
}

.month-stepper {
  display: grid;
  grid-template-columns: 2.75rem minmax(10rem, 1fr) 2.75rem;
  gap: 0.4rem;
}

.icon-button {
  display: grid;
  min-height: 2.75rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--rose-800);
  font-size: 1.35rem;
  font-weight: 900;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 2.75rem;
  border-radius: 8px;
  padding: 0.72rem 1rem;
  font-weight: 850;
}

.primary-button {
  width: 100%;
  margin-top: 1rem;
  background: linear-gradient(135deg, var(--rose-700), var(--rose-600));
  color: #fff;
  box-shadow: 0 10px 22px rgba(169, 47, 103, 0.24);
}

.secondary-button {
  width: fit-content;
  background: var(--teal-700);
  color: #fff;
}

.compact-button {
  width: auto;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--rose-800);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.summary-card {
  min-height: 8.8rem;
  border: 1px solid rgba(236, 213, 223, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.summary-card strong {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.summary-card b {
  display: block;
  margin-top: 0.55rem;
  color: var(--rose-900);
  font-size: clamp(1.26rem, 2vw, 1.75rem);
  line-height: 1.12;
  word-break: break-word;
}

.summary-card span {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.due-breakdown {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.due-row {
  display: grid;
  grid-template-columns: minmax(3.5rem, 1fr) auto;
  gap: 0.18rem 0.45rem;
  border-top: 1px solid rgba(236, 213, 223, 0.76);
  padding-top: 0.45rem;
}

.due-row strong,
.due-row b {
  margin: 0;
  color: var(--rose-900);
  font-size: 0.82rem;
  line-height: 1.25;
}

.due-row small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.due-row span {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.2;
}

.account-breakdown {
  display: grid;
  gap: 0.32rem;
  margin-top: 0.7rem;
}

.account-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid rgba(236, 213, 223, 0.68);
  padding-top: 0.36rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.account-row b {
  color: var(--ink);
  font-size: 0.78rem;
  white-space: nowrap;
}

.account-row.positive b {
  color: var(--teal-700);
}

.account-row.negative b {
  color: #9a1f3f;
}

.account-row.total {
  color: var(--rose-900);
  font-weight: 900;
}

.account-row.total b {
  color: var(--rose-800);
}

.mini-action {
  min-height: 2.25rem;
  margin-top: 0.85rem;
  border-radius: 8px;
  background: var(--rose-800);
  color: white;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 850;
}

.summary-card.accent {
  border-color: rgba(17, 122, 114, 0.24);
  background: linear-gradient(135deg, rgba(223, 247, 243, 0.78), rgba(255, 255, 255, 0.92));
}

.summary-card.warning {
  border-color: rgba(201, 80, 120, 0.34);
  background: linear-gradient(135deg, rgba(255, 232, 241, 0.88), rgba(255, 255, 255, 0.94));
}

.month-status {
  margin: -0.2rem 0 0.9rem;
  border: 1px solid rgba(17, 122, 114, 0.22);
  border-radius: 8px;
  background: rgba(223, 247, 243, 0.78);
  color: var(--teal-700);
  padding: 0.8rem 1rem;
  font-weight: 850;
}

.workspace-grid,
.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.records-section {
  display: grid;
  gap: 0.9rem;
}

.tool-panel,
.table-panel {
  min-width: 0;
  border: 1px solid rgba(236, 213, 223, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.panel-heading h2 {
  font-size: 1.02rem;
}

.panel-heading span {
  color: var(--teal-700);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: right;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

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

.person-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.person-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 245, 249, 0.92), rgba(255, 255, 255, 0.96));
  padding: 0.9rem;
}

.person-panel h3 {
  margin: 0 0 0.7rem;
  color: var(--rose-900);
  font-size: 1rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid #f1dfe7;
  padding: 0.55rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-row:first-of-type {
  border-top: 0;
}

.metric-row b {
  color: var(--ink);
  text-align: right;
}

.metric-row.total {
  color: var(--rose-900);
  font-weight: 900;
}

.metric-row.total b {
  color: var(--rose-800);
  font-size: 1.05rem;
}

.metric-row.loan,
.metric-row.loan-total {
  color: #9a1f3f;
  font-weight: 850;
}

.metric-row.loan-total b {
  color: #9a1f3f;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.delete-button {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 8px;
  background: var(--rose-100);
  color: var(--rose-800);
  font-size: 1.1rem;
  font-weight: 900;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  background: var(--plum-100);
  color: var(--rose-800);
  padding: 0.18rem 0.52rem;
  font-size: 0.78rem;
  font-weight: 850;
}

.archive-list {
  display: grid;
  gap: 0.55rem;
}

.archive-chip {
  display: flex;
  min-height: 3rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 245, 249, 0.86);
  color: var(--rose-900);
  padding: 0.65rem 0.75rem;
  text-align: left;
}

.archive-chip.active {
  border-color: rgba(17, 122, 114, 0.34);
  background: var(--teal-100);
}

.archive-chip b {
  white-space: nowrap;
}

.empty-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(28rem, calc(100vw - 2rem));
  border-radius: 8px;
  background: var(--rose-900);
  color: white;
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  font-weight: 800;
  z-index: 20;
}

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

@media (max-width: 820px) {
  .app-shell {
    padding: 0.8rem;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .title-block {
    align-items: center;
  }

  .heart-mark {
    width: 2.15rem;
    height: 2.15rem;
  }

  .heart-mark::before,
  .heart-mark::after {
    width: 2.15rem;
    height: 2.15rem;
  }

  .heart-mark::before {
    top: -1rem;
  }

  .heart-mark::after {
    left: 1rem;
  }

  .summary-grid,
  .workspace-grid,
  .details-grid,
  .person-breakdown {
    grid-template-columns: 1fr;
  }

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

  .secondary-button,
  .ghost-button,
  .month-control {
    width: 100%;
  }

  .month-stepper {
    grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem;
  }

  .compact-button {
    width: 100%;
  }
}
