:root {
  --ink: #2b2440;
  --muted: #675f79;
  --paper: #fffdf8;
  --pink: #ffd8e8;
  --rose: #f26d9a;
  --mint: #bff4df;
  --aqua: #bfefff;
  --sun: #ffe58f;
  --violet: #cfc4ff;
  --green: #23885b;
  --green-soft: #dff8ec;
  --orange-soft: #ffe3bd;
  --red-soft: #ffe0e0;
  --line: rgba(43, 36, 64, 0.14);
  --shadow: 0 18px 45px rgba(63, 50, 86, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 8% 7%, rgba(255, 229, 143, 0.76) 0 7rem, transparent 7.1rem),
    radial-gradient(circle at 92% 9%, rgba(191, 239, 255, 0.8) 0 8rem, transparent 8.1rem),
    linear-gradient(135deg, #fff6fb 0%, #f4fffb 46%, #fffaf0 100%);
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 180px;
  height: 120px;
  color: rgba(43, 36, 64, 0.035);
  font-size: 135px;
  line-height: 1;
  pointer-events: none;
}

body::before {
  content: "🐈";
  top: 380px;
  left: -62px;
  transform: rotate(-12deg);
}

body::after {
  content: "🐾";
  right: -8px;
  bottom: 26px;
  transform: rotate(14deg);
}

.app-shell::before,
.app-shell::after {
  position: fixed;
  z-index: -1;
  color: rgba(242, 109, 154, 0.045);
  font-size: 112px;
  line-height: 1;
  pointer-events: none;
}

.app-shell::before {
  content: "🐱";
  top: 48px;
  right: 1vw;
  transform: rotate(9deg);
}

.app-shell::after {
  content: "🐾";
  left: 3vw;
  bottom: 150px;
  transform: rotate(-18deg);
}

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

button,
input,
select,
textarea {
  border-radius: 8px;
}

.app-shell {
  width: min(1840px, calc(100% - 64px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
  gap: 20px;
  align-items: center;
}

.hero-copy {
  padding: 8px 0;
}

.kicker {
  width: max-content;
  margin: 0 0 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--sun);
  color: #5a4300;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 6vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.subtitle {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.45;
}

.account-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.account-bar span {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-weight: 800;
}

.hero-art {
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.hero-art img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.party-note {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 16px;
  margin: 22px 0 16px;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 30px rgba(63, 50, 86, 0.12);
}

.party-note h2,
.party-note h3 {
  margin: 0 0 10px;
}

.party-note p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

.gift-directions {
  padding: 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 216, 232, 0.7), rgba(191, 244, 223, 0.72));
}

.gift-directions ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.32;
}

.gift-directions li {
  margin: 0 0 4px;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.metric {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 6px 18px rgba(63, 50, 86, 0.1);
}

.metric strong {
  display: block;
  color: var(--rose);
  font-size: clamp(1.55rem, 2.4vw, 2rem);
  line-height: 1;
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.1;
}

.sources {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.sources a {
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(63, 50, 86, 0.1);
}

.sources img {
  display: block;
  width: 100%;
  height: 86px;
  object-fit: cover;
}

.sources span {
  display: block;
  padding: 8px 10px 10px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(340px, 1.05fr);
  gap: 8px;
  margin: 12px 0 18px;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 28px rgba(63, 50, 86, 0.1);
  backdrop-filter: blur(12px);
}

.toolbar-primary,
.toolbar-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.toolbar-primary {
  display: grid;
  grid-template-columns: minmax(240px, 1fr);
  gap: 6px;
}

.toolbar-secondary {
  justify-content: flex-end;
  align-items: center;
}

.toolbar .field span,
.toolbar .search span {
  display: none;
}

body.is-guest .admin-only {
  display: none !important;
}

.field span,
.search span {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.search input {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 2px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.field textarea {
  resize: vertical;
}

.small-field {
  width: 132px;
}

.budget-field {
  width: 108px;
}

.segments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  min-height: 34px;
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment {
  min-height: 26px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.segment.is-active {
  color: #194b39;
  background: var(--mint);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

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

.action-button,
.primary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}

.action-button,
.primary-button,
.danger-button {
  min-height: 34px;
  padding: 6px 9px;
}

.primary-button {
  border-color: transparent;
  background: var(--mint);
  color: #194b39;
}

.danger-button {
  border-color: transparent;
  background: var(--red-soft);
  color: #8f2828;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
}

.section {
  margin-top: 24px;
}

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

h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  letter-spacing: 0;
}

.pill {
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--violet);
  color: #40317c;
  font-weight: 800;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: linear-gradient(90deg, var(--pink), var(--mint), var(--sun));
  color: #3b3155;
  font-size: 0.84rem;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: rgba(191, 239, 255, 0.18);
}

tbody tr:hover {
  background: rgba(255, 229, 143, 0.26);
}

tbody tr.is-ordered {
  background: rgba(191, 244, 223, 0.5);
}

tbody tr.is-reserved {
  background: rgba(255, 216, 232, 0.38);
}

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 96px;
}

.number {
  width: 24px;
  flex: 0 0 24px;
  font-weight: 800;
}

.thumb {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 6px 16px rgba(63, 50, 86, 0.12);
}

.thumb-fallback {
  display: grid;
  place-items: center;
  color: #5d4bb2;
  font-weight: 900;
  background: linear-gradient(135deg, var(--pink), var(--aqua));
}

.market,
.article,
.money {
  font-weight: 800;
  white-space: nowrap;
}

.market {
  color: var(--muted);
}

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

.reserve-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 150px;
}

.reserved-name,
.reserve-line {
  color: #8f2858;
  font-weight: 900;
}

.status,
.priority {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-weight: 800;
  white-space: nowrap;
}

.status {
  background: var(--green-soft);
  color: #135b3e;
}

.status.expensive,
.status.postpone {
  background: var(--orange-soft);
  color: #8a5000;
}

.priority.high {
  background: var(--pink);
  color: #9f2354;
}

.priority.normal {
  background: var(--aqua);
  color: #235b7b;
}

.priority.later {
  background: #e7e1ff;
  color: #55429c;
}

a.open-link {
  color: #6645c7;
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 9px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.compact-button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.reserved-button {
  border-color: transparent;
  background: var(--pink);
  color: #8f2858;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 14px;
}

.wish-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 30px rgba(63, 50, 86, 0.12);
}

.wish-card.is-ordered {
  background: rgba(223, 248, 236, 0.92);
}

.wish-card.is-reserved {
  border-color: rgba(242, 109, 154, 0.42);
}

.wish-card img,
.wish-card .thumb-fallback {
  width: 100%;
  height: 190px;
  border: 0;
  border-radius: 0;
  object-fit: cover;
}

.card-body {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
}

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

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty {
  padding: 28px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

dialog {
  width: min(820px, calc(100% - 24px));
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(43, 36, 64, 0.38);
}

.dialog-form {
  display: grid;
  gap: 16px;
}

.dialog-head,
.dialog-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

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

.compact-dialog-actions {
  grid-template-columns: 1fr auto;
}

.auth-form {
  max-width: 520px;
  margin: 0 auto;
}

.dialog-note {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

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

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

.inline-switch {
  align-self: end;
}

body.child-mode .parent-only {
  display: none;
}

body.child-mode table {
  min-width: 900px;
}

body.child-mode th:nth-child(4),
body.child-mode td:nth-child(4),
body.child-mode th:nth-child(7),
body.child-mode td:nth-child(7),
body.child-mode th:nth-child(10),
body.child-mode td:nth-child(10),
body.child-mode th:nth-child(11),
body.child-mode td:nth-child(11) {
  display: none;
}

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

  .toolbar-primary {
    grid-template-columns: minmax(220px, 320px) 1fr;
  }

  .toolbar-secondary {
    justify-content: flex-start;
  }
}

@media (min-width: 1101px) {
  .toolbar-primary {
    grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 10px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kicker {
    margin-bottom: 6px;
    padding: 4px 9px;
    font-size: 0.88rem;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .subtitle {
    margin-top: 8px;
    font-size: 0.98rem;
    line-height: 1.32;
  }

  .account-bar {
    margin-top: 8px;
  }

  .hero-art img {
    max-height: 170px;
    object-fit: cover;
    object-position: center 36%;
  }

  .party-note {
    margin: 12px 0;
    padding: 12px;
  }

  .party-note p {
    font-size: 0.95rem;
    line-height: 1.35;
  }

  .gift-directions {
    padding: 10px 12px;
  }

  .party-note,
  .sources,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .dashboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
  }

  .metric {
    min-height: 48px;
    padding: 8px 10px;
  }

  .metric strong {
    font-size: 1.42rem;
  }

  .metric span {
    font-size: 0.78rem;
  }

  .toolbar {
    position: static;
    margin: 12px 0 16px;
    padding: 8px;
  }

  .segment {
    flex: 1 1 120px;
  }

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

@media (max-width: 640px) {
  .hero-art {
    display: none;
  }

  .toolbar-primary {
    grid-template-columns: 1fr;
  }

  .toolbar-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .dashboard {
    gap: 6px;
  }

  .metric {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-height: 44px;
    padding: 6px;
    text-align: center;
  }

  .small-field,
  .budget-field {
    width: 100%;
  }

  .action-button,
  .primary-button,
  .danger-button {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .toolbar,
  .sources,
  dialog,
  .row-actions {
    display: none;
  }

  .app-shell {
    width: 100%;
  }

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

  .hero-art {
    max-height: 180px;
  }

  .table-wrap,
  .metric,
  .wish-card {
    box-shadow: none;
  }
}
