:root {
  color-scheme: dark;
  --ink: #08120f;
  --surface: #0d1915;
  --surface-light: #12221c;
  --text: #f4f0e7;
  --muted: #93a198;
  --line: rgba(225, 235, 228, 0.13);
  --sage: #b8e8c7;
  --teal: #75c7ba;
  --amber: #e9b875;
  --sun: #f2d49b;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  background: radial-gradient(circle at 50% -15%, rgba(143, 209, 166, 0.09), transparent 34%), var(--ink);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--ink);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.shell {
  width: min(calc(100% - 40px), var(--max));
  margin-inline: auto;
}

.topbar {
  display: flex;
  min-height: 106px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  font-size: 1.34rem;
  font-weight: 560;
  letter-spacing: 0.22em;
  text-decoration: none;
}
.eclipse {
  position: relative;
  display: inline-grid;
  width: 1.25em;
  height: 1.25em;
  margin-right: 0.16em;
  place-items: center;
}
.sun, .moon { position: absolute; display: block; border-radius: 50%; }
.sun {
  inset: 4%;
  background: var(--sun);
  box-shadow: 0 0 12px rgba(242, 212, 155, 0.2), 0 0 32px rgba(242, 212, 155, 0.09);
}
.moon { width: 82%; height: 82%; background: var(--ink); }
.connection {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.connection span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 14px rgba(117, 199, 186, 0.5);
}
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.logout-button {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.logout-button:hover, .logout-button:focus-visible { color: var(--sage); border-color: var(--sage); }

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  min-height: 100dvh;
  padding: 24px;
  place-items: center;
  background: radial-gradient(circle at 50% 20%, rgba(143, 209, 166, 0.11), transparent 35%), rgba(8, 18, 15, 0.98);
}
.is-locked .shell { visibility: hidden; }
.access-card {
  width: min(100%, 430px);
  padding: 48px;
  border: 1px solid var(--line);
  background: rgba(13, 25, 21, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
}
.access-wordmark {
  margin-bottom: 34px;
  font-size: 2rem;
}
.wordmark:focus-visible {
  outline: 2px solid var(--sun);
  outline-offset: 6px;
}
.access-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 7vw, 4.2rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.96;
}
.access-card > p:not(.eyebrow):not(.access-error) { margin: 20px 0 34px; color: var(--muted); }
.access-card label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.access-card input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: var(--ink);
  color: var(--text);
}
.access-card input:focus { border-color: var(--sage); }
.access-card button {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border: 0;
  background: var(--text);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}
.access-card button:hover, .access-card button:focus-visible { background: var(--sage); }
.access-error { min-height: 20px; margin: 14px 0 0; color: #efb49f; font-size: 0.78rem; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 70px;
  align-items: center;
  padding: 48px 0;
}
.eyebrow {
  margin: 0 0 20px;
  color: var(--sage);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.hero .eyebrow { margin: 0; }
.month-control {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: stretch;
  border: 1px solid var(--line);
  background: rgba(13, 25, 21, 0.72);
}
.month-control button {
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.month-control button:hover, .month-control button:focus-visible { background: var(--surface-light); color: var(--sage); }
.month-control label {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 16px 10px;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.month-control label span {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.month-control input {
  width: 155px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  color-scheme: dark;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.summary-card {
  min-height: 235px;
  padding: 26px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(13, 25, 21, 0.72);
}
.card-top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.summary-card strong {
  display: block;
  margin-top: 72px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 5vw, 4.7rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 1;
}
.summary-card p { margin: 12px 0 0; color: var(--muted); font-size: 0.8rem; }
.robin { box-shadow: inset 0 3px 0 var(--teal); }
.lena { box-shadow: inset 0 3px 0 var(--amber); }
.total-card { background: var(--text); color: var(--ink); }
.total-card .card-top, .total-card p { color: #5f6b64; }

.settlement {
  display: flex;
  min-height: 235px;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: 46px 48px;
  border-bottom: 1px solid var(--line);
}
.settlement h2 {
  max-width: 700px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 1;
}
.settlement > strong {
  color: var(--sage);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 7vw, 6rem);
  font-weight: 400;
  letter-spacing: -0.06em;
  white-space: nowrap;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: 14px;
  padding: 14px 0 100px;
}
.panel {
  min-height: 430px;
  border: 1px solid var(--line);
  background: rgba(13, 25, 21, 0.68);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.section-head h2, .section-head span {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.category-list { padding: 10px 22px 24px; }
.category-row { padding: 18px 0; border-bottom: 1px solid var(--line); }
.category-meta { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 10px; }
.category-meta span:last-child { color: var(--sage); }
.category-bar { height: 3px; background: rgba(225, 235, 228, 0.08); }
.category-bar span { display: block; height: 100%; background: var(--teal); }
.empty-copy { margin: 36px 0; color: var(--muted); }

.expense-list { min-width: 0; }
.expense-row {
  display: grid;
  grid-template-columns: 88px 10px minmax(120px, 0.8fr) minmax(140px, 1.4fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 78px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--line);
}
.person-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.person-dot.lena-dot { background: var(--amber); }
.expense-date, .expense-description { color: var(--muted); font-size: 0.78rem; }
.expense-category { font-weight: 600; }
.expense-amount { font-size: 1.03rem; white-space: nowrap; }
.empty-state {
  display: grid;
  min-height: 330px;
  place-content: center;
  justify-items: center;
  text-align: center;
}
.empty-ring {
  width: 58px;
  height: 58px;
  border: 7px solid rgba(242, 212, 155, 0.22);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(242, 212, 155, 0.08);
}
.empty-state p { margin: 24px 0 6px; font-family: Georgia, "Times New Roman", serif; font-size: 1.7rem; }
.empty-state small { color: var(--muted); }

footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  align-items: center;
  min-height: 112px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
footer span:nth-child(2) { text-align: center; }
footer span:last-child { text-align: right; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 26px; padding: 42px 0; }
  .month-control { max-width: 360px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 190px; }
  .summary-card strong { margin-top: 48px; }
  .settlement { align-items: flex-start; flex-direction: column; padding: 54px 24px; }
  .details-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .shell { width: min(calc(100% - 28px), var(--max)); }
  .topbar { min-height: 88px; }
  .connection { font-size: 0; gap: 0; }
  .connection span { width: 9px; height: 9px; }
  .topbar-actions { gap: 12px; }
  .access-card { padding: 34px 26px; }
  .month-control { grid-template-columns: 44px 1fr 44px; }
  .summary-card { padding: 22px; }
  .settlement { min-height: 260px; }
  .expense-row {
    grid-template-columns: 8px 1fr auto;
    gap: 12px;
    padding: 18px;
  }
  .expense-date { grid-column: 2; }
  .expense-description { grid-column: 2 / -1; }
  .expense-amount { grid-column: 3; grid-row: 1; }
  footer { grid-template-columns: 1fr; gap: 10px; padding: 28px 0; }
  footer span:nth-child(2), footer span:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
