:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #656b73;
  --line: #d9dfdf;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f2f6f5;
  --brand: #2d776f;
  --brand-strong: #18544f;
  --blue: #315b87;
  --red: #b65c50;
  --gold: #bc8b2f;
  --green: #467a42;
  --shadow: 0 18px 45px rgba(24, 33, 38, 0.14);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.login {
  min-height: 100svh;
  display: grid;
  background: var(--paper);
}

.login-art {
  min-height: 34svh;
  background:
    linear-gradient(180deg, rgba(251, 250, 247, 0.1), rgba(251, 250, 247, 0.88)),
    url("assets/family-planner-hero.png") center / cover;
}

.login-panel {
  width: min(520px, calc(100% - 40px));
  margin: -54px auto 24px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 11vw, 3.7rem);
  line-height: 0.95;
}

.login-panel h1 {
  font-size: clamp(2rem, 9vw, 3.6rem);
}

.lede {
  margin: 14px 0 20px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.55;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.profile-card,
.event-card,
.expense-row,
.child-total {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.profile-card {
  min-height: 76px;
  padding: 14px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
}

.profile-card:hover,
.profile-card:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
}

.avatar.adult {
  background: var(--brand);
}

.avatar.child {
  background: var(--blue);
}

.name {
  display: block;
  font-weight: 850;
}

.role {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-shell {
  min-height: 100svh;
  padding-bottom: 132px;
}

.sidebar {
  min-height: auto;
  padding: 12px 14px;
  background: #173f3d;
  color: #fff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #f8d979;
  color: #173f3d;
  font-size: 1.35rem;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 1.15rem;
}

.brand span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
}


.nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #173f3d;
  box-shadow: 0 -10px 28px rgba(16, 28, 31, 0.18);
}

.nav button,
.logout {
  min-height: 54px;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: #fff;
  background: transparent;
  text-align: left;
}

.nav button.active,
.nav button:hover,
.logout:hover {
  background: rgba(255, 255, 255, 0.14);
}

.nav button.active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.9rem;
  font-weight: 950;
}

.nav button.active .nav-icon {
  background: #f8d979;
  color: #173f3d;
}

.logout {
  width: auto;
  min-height: 38px;
  margin-top: 0;
  margin-left: auto;
  padding: 8px 10px;
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.main {
  min-width: 0;
  padding: 18px 14px 22px;
}

.topbar {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px;
}

.button,
.icon-button {
  min-height: 46px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.button {
  padding: 0 15px;
}

.button.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.danger {
  background: var(--red);
}

.icon-button {
  width: 42px;
  font-size: 1.1rem;
}

.month-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.month-strip h2 {
  min-width: 0;
  flex: 1;
  font-size: 1.45rem;
  text-align: center;
}

.calendar-layout {
  display: grid;
  gap: 18px;
  align-items: start;
}

.calendar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.weekday-row,
.day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday {
  padding: 10px 3px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.day {
  min-height: 78px;
  padding: 5px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
}

.day:nth-child(7n) {
  border-right: 0;
}

.day.muted {
  background: #f8f8f5;
  color: #9aa0a6;
}

.day.today {
  box-shadow: inset 0 0 0 2px var(--brand);
}

.day-number {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  min-height: 24px;
  font-weight: 850;
  font-size: 0.9rem;
}

.event-pill {
  width: 100%;
  margin-top: 6px;
  padding: 5px 4px;
  overflow: hidden;
  border-radius: 6px;
  color: #172124;
  background: #e6efee;
  font-size: 0.68rem;
  font-weight: 750;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-pill.private {
  background: #f3e2df;
}

.event-pill.clan {
  background: #f6e9c8;
}

.side-panel,
.adult-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.side-panel h2,
.adult-panel h2 {
  margin-bottom: 14px;
  font-size: 1.15rem;
}

.event-list,
.expense-list,
.totals-grid {
  display: grid;
  gap: 10px;
}

.event-card {
  padding: 12px;
}

.event-card strong,
.expense-row strong,
.child-total strong {
  display: block;
}

.meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.tag.shared {
  background: #dcebe8;
  color: var(--brand-strong);
}

.tag.private {
  background: #f4dedb;
  color: #873e35;
}

.tag.danger-tag {
  background: #f4dedb;
  color: #873e35;
}

.tag.clan,
.tag.reserved {
  background: #f6e9c8;
  color: #6d4b12;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fff;
}

.adult-grid {
  display: grid;
  gap: 18px;
  align-items: start;
}

.admin-console {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(45, 119, 111, 0.28);
  border-radius: var(--radius);
  background: #eef7f5;
}

.admin-console h2 {
  margin: 0 0 14px;
  font-size: 1.35rem;
}

.admin-grid {
  display: grid;
  gap: 14px;
}

.admin-panel {
  border-color: rgba(45, 119, 111, 0.32);
}

.family-forest {
  display: grid;
  gap: 14px;
}

.family-tree {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.tree-head {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.tree-head strong {
  font-size: 1rem;
}

.tree-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.tree-branch {
  display: grid;
  gap: 10px;
}

.tree-branch.adults {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.tree-branch.children {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.tree-line {
  width: 2px;
  height: 18px;
  margin: 8px auto;
  background: var(--line);
}

.tree-person {
  min-width: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tree-person.adult {
  background: #eef7f5;
}

.tree-person.child {
  background: #f7f8fb;
}

.tree-person strong,
.tree-person span {
  display: block;
}

.tree-person span:not(.avatar) {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.tree-person .tag-row {
  grid-column: 1 / -1;
}

.home-hero {
  margin-bottom: 18px;
  padding: 22px;
  display: grid;
  gap: 18px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(45, 119, 111, 0.94), rgba(49, 91, 135, 0.88)),
    url("assets/family-planner-hero.png") center / cover;
  color: #fff;
  box-shadow: var(--shadow);
}

.home-hero .eyebrow,
.home-hero p {
  color: rgba(255, 255, 255, 0.84);
}

.home-hero h1 {
  font-size: clamp(2.2rem, 10vw, 4.4rem);
}

.home-hero p {
  margin: 10px 0 0;
  font-size: 1.04rem;
}

.home-date {
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
}

.home-date span {
  display: block;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.88rem;
  font-weight: 850;
  text-transform: uppercase;
}

.home-date strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

.home-grid {
  display: grid;
  gap: 14px;
}

.section-head {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.section-head h2 {
  margin: 0;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.wish-list.compact .wish-card img {
  max-height: 150px;
}

.family-switcher {
  margin: 0 0 16px;
  display: grid;
  gap: 6px;
}

.family-switcher span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.family-switcher select {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

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

.inline-form {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.inline-form input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.expense-row {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
}

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

.wish-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.wish-card img {
  width: 100%;
  max-height: 220px;
  display: block;
  object-fit: cover;
  background: var(--surface-2);
}

.wish-body {
  padding: 12px;
}

.wish-body strong {
  display: block;
}

.wish-body p {
  margin: 8px 0 0;
  color: var(--ink);
  line-height: 1.45;
}

.amount {
  color: var(--brand-strong);
  font-size: 1.1rem;
  font-weight: 950;
  white-space: nowrap;
}

.totals-grid {
  grid-template-columns: 1fr;
  margin-bottom: 18px;
}

.child-total {
  padding: 16px;
}

.child-total .amount {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 34, 0.46);
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.modal-head h2 {
  font-size: 1.45rem;
}

.close {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.3rem;
}

.pin-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}


@media (min-width: 760px) {
  .login {
    grid-template-columns: minmax(320px, 0.86fr) 1.14fr;
  }

  .login-art {
    min-height: 100vh;
    background:
      linear-gradient(90deg, rgba(251, 250, 247, 0.9), rgba(251, 250, 247, 0.12)),
      url("assets/family-planner-hero.png") center / cover;
  }

  .login-panel {
    align-self: center;
    margin: 0 auto;
    padding: 34px;
  }

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

  .app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    padding-bottom: 0;
  }

  .sidebar {
    min-height: 100vh;
    padding: 24px;
  }

  .brand {
    margin-bottom: 26px;
  }

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

  .nav {
    position: static;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0;
    box-shadow: none;
    background: transparent;
  }

  .nav button,
  .logout {
    min-height: 44px;
    padding: 10px 12px;
    display: flex;
    justify-content: flex-start;
  }

  .logout {
    width: 100%;
    margin-top: 28px;
    margin-left: 0;
  }

  .main {
    padding: 28px;
  }

  .topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
  }

  .toolbar {
    justify-content: flex-end;
  }

  .month-strip h2 {
    min-width: 220px;
    flex: 0 0 auto;
  }

  .calendar-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .day {
    min-height: 124px;
    padding: 8px;
  }

  .event-pill {
    padding: 6px 7px;
    font-size: 0.78rem;
  }

  .adult-grid {
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  }

  .admin-grid {
    grid-template-columns: minmax(260px, 340px) minmax(260px, 340px) minmax(0, 1fr);
  }

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

  .expense-row {
    grid-template-columns: 1fr auto;
  }

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

  .home-hero {
    grid-template-columns: minmax(0, 1fr) 240px;
    align-items: end;
    padding: 34px;
  }

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

  .wish-card {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .wish-card img {
    height: 100%;
    max-height: none;
  }
}

@media (max-width: 1060px) and (min-width: 760px) {
  .calendar-layout,
  .adult-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: -1;
  }
}
