.secondary-page {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 1.1rem;
  align-content: start;
  container-type: inline-size;
}

.secondary-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .85rem 1.3rem;
  margin: 0 0 .25rem;
}

.secondary-heading h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 760;
  letter-spacing: -.06em;
  line-height: 1.1;
}

.secondary-heading p {
  margin: .45rem 0 0;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.5;
}

.secondary-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.05rem;
  background: var(--surface);
}

.secondary-card-heading {
  min-height: 3.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .8rem 1.2rem;
  border-bottom: 1px solid var(--line);
}

.secondary-card-heading h2 {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 740;
  letter-spacing: -.02em;
}

.secondary-button {
  min-height: 2.65rem;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .45rem .82rem;
  border: 1px solid transparent;
  border-radius: .62rem;
  font-family: inherit;
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.secondary-button svg { flex-shrink: 0; }

.secondary-button--primary {
  color: white;
  background: var(--brand);
}

.secondary-button--primary:hover { background: #056444; }

.secondary-button--outline {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.secondary-button--outline:hover { background: var(--bg); }

.secondary-button--warning { color: #973b44; }
:root[data-theme="dark"] .secondary-button--warning { color: #f3a4ac; }

.secondary-button:focus-visible,
.report-preset:focus-visible,
.secondary-table-scroll:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.secondary-count {
  display: inline-grid;
  min-width: 1.8rem;
  min-height: 1.6rem;
  align-items: center;
  padding: .1rem .4rem;
  border-radius: .45rem;
  color: var(--brand);
  background: var(--mint);
  font-size: .8rem;
  font-weight: 700;
  text-align: center;
}

.secondary-empty {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .65rem;
  min-height: 6rem;
  padding: 1.1rem;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}

.secondary-empty p { margin: 0; }

.report-controls { padding: .9rem 1rem; }

.report-presets {
  display: flex;
  width: max-content;
  max-width: 100%;
  gap: .18rem;
  margin-bottom: .9rem;
  padding: .22rem;
  border-radius: .65rem;
  background: var(--bg);
}

.report-preset {
  min-height: 2.3rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  padding: .24rem .7rem;
  color: var(--muted);
  background: none;
  font-family: inherit;
  font-size: .83rem;
  font-weight: 650;
  cursor: pointer;
}

.report-preset:hover { color: var(--text); }

.report-preset.is-active {
  border-color: var(--line);
  color: var(--brand);
  background: var(--surface);
  box-shadow: 0 1px 2px #193d2e0a;
}

.report-filters {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(2, minmax(7.5rem, 1fr)) repeat(2, minmax(8rem, 1.15fr)) auto;
  gap: .75rem;
}

.report-filters label,
.schedule-select,
.secondary-dialog-fields > label {
  display: grid;
  gap: .35rem;
  min-width: 0;
  color: var(--text);
  font-size: .83rem;
  font-weight: 690;
}

.report-filters input,
.report-filters select,
.schedule-select select,
.secondary-dialog-fields input:not([type="radio"]),
.secondary-dialog-fields select,
.secondary-dialog-fields textarea {
  min-width: 0;
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  padding: .45rem .55rem;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 450;
}

.report-filters :is(input, select):focus,
.schedule-select select:focus,
.secondary-dialog-fields :is(input, select, textarea):focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.report-filters input[type="date"],
.secondary-dialog-fields input[type="date"],
.secondary-dialog-fields input[type="time"] { color-scheme: light; }

.report-summary,
.finance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-summary { gap: .7rem; }
.report-summary--personal { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.report-stat {
  min-width: 0;
  min-height: 8.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: .93rem 1rem;
  color: var(--text);
}

.report-summary > .report-stat {
  border: 1px solid var(--line);
  border-radius: .92rem;
  background: var(--surface);
}

.report-summary > .report-stat:first-child {
  border-color: #cdeadc;
  background: var(--mint);
}

.report-stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .45rem;
  margin-bottom: .38rem;
  font-size: .86rem;
  font-weight: 690;
  line-height: 1.3;
}

.report-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: .5rem;
  color: var(--brand);
  background: var(--mint);
}

.report-summary > .report-stat:first-child .report-stat-icon { background: var(--surface); }

.report-stat strong {
  display: block;
  color: var(--text);
  font-size: clamp(1.18rem, 2.7vw, 1.85rem);
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.045em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.report-stat small {
  display: block;
  margin-top: .36rem;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}

.report-breakdowns { display: grid; gap: .9rem; }

@container (min-width: 72rem) {
  .report-breakdowns { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
}

.secondary-table-scroll { overflow-x: auto; }

.secondary-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.secondary-table thead { background: var(--bg); }

.secondary-table :is(th, td) {
  min-height: 2.8rem;
  padding: .78rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.secondary-table thead th {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.secondary-table th:first-child { text-align: left; }
.secondary-table tbody th { font-weight: 690; }
.secondary-table tbody tr:last-child > * { border-bottom: 0; }

.secondary-table-count {
  color: var(--muted);
  font-size: .78rem;
}

.finance-grid > .report-stat { border-bottom: 1px solid var(--line); }
.finance-grid > .report-stat:not(:nth-child(3n)) { border-right: 1px solid var(--line); }

.report-footnote {
  margin: 0;
  padding: .85rem 1.05rem;
  color: var(--muted);
  background: var(--bg);
  font-size: .8rem;
  line-height: 1.5;
}

.expense-list,
.team-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.expense-row,
.team-row,
.team-invitation-row {
  display: flex;
  align-items: center;
  gap: .68rem;
  min-height: 3.5rem;
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.expense-row:last-child,
.team-row:last-child,
.team-invitation-row:last-child { border-bottom: 0; }

.expense-row {
  justify-content: space-between;
  font-size: .87rem;
}

.expense-row > strong { white-space: nowrap; }

.expense-label,
.team-person {
  display: grid;
  gap: .26rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.expense-label small,
.team-person > small {
  color: var(--muted);
  font-size: .78rem;
}

.team-avatar {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.45rem;
  height: 2.45rem;
  border-radius: .76rem;
  color: var(--brand);
  background: var(--mint);
  font-size: .82rem;
  font-weight: 760;
}

.team-avatar--admin {
  color: #276858;
  background: #e1f2ec;
}

.team-avatar--assistant {
  color: #794785;
  background: #f4e8f7;
}

.team-avatar--master { border-radius: 50%; }

.team-person { flex: 1; }
.team-person strong { font-size: .94rem; }

.team-you {
  display: inline-flex;
  margin-inline-start: .25rem;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 550;
}

.team-role {
  display: inline-block;
  max-width: 100%;
  padding: .27rem .48rem;
  border-radius: .4rem;
  color: var(--muted);
  background: var(--bg);
  font-size: .77rem;
  font-weight: 690;
  line-height: 1.2;
}

.team-role--admin {
  color: #276858;
  background: #e1f2ec;
}

.team-role--assistant {
  color: #794785;
  background: #f4e8f7;
}

.team-row-actions,
.team-invitation-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.team-row-actions .secondary-button,
.team-invitation-actions .secondary-button {
  min-height: 2.45rem;
}

.team-invitation-actions { flex-wrap: wrap; }

.invitation-status {
  display: inline-block;
  padding: .32rem .52rem;
  border-radius: .45rem;
  color: var(--brand);
  background: var(--mint);
  font-size: .77rem;
  font-weight: 700;
  line-height: 1.3;
}

.invitation-status--expired { color: var(--muted); background: var(--bg); }

.schedule-controls,
.schedule-week {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem;
}

.schedule-controls { padding: .85rem 1rem; }

.schedule-week {
  justify-content: flex-start;
  font-size: .93rem;
}

.schedule-week strong { padding-inline: .25rem; }

.schedule-week-arrow {
  min-width: 2.6rem;
  padding: 0 .35rem;
  font-size: 1.4rem;
}

.schedule-today { margin-inline-start: .2rem; }

.schedule-select {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.schedule-days { display: grid; gap: .7rem; }

.schedule-day.is-today { border-color: #9cd7bb; }

.schedule-day-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.schedule-day.is-today .schedule-day-heading { background: var(--mint); }

.schedule-day-heading h2 {
  margin: 0 0 .15rem;
  font-size: .98rem;
  text-transform: capitalize;
}

.schedule-day-heading span {
  color: var(--muted);
  font-size: .8rem;
}

.schedule-entries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11.5rem), 1fr));
}

.schedule-entry {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
  min-height: 3.8rem;
  padding: .65rem 1rem;
}

.schedule-entry .team-avatar {
  width: 2rem;
  height: 2rem;
  font-size: .72rem;
}

.schedule-entry-detail {
  min-width: 0;
  display: grid;
  gap: .28rem;
  overflow-wrap: anywhere;
}

.schedule-entry-detail strong { font-size: .84rem; }

.schedule-entry-detail small {
  color: var(--muted);
  font-size: .77rem;
}

.schedule-you { margin-inline-start: .2rem; font-weight: 550; }

.schedule-status {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.35;
}

.schedule-status.is-available {
  color: var(--brand);
  font-weight: 660;
}

.schedule-status.is-off {
  color: #985046;
  font-weight: 660;
}

.account-card { max-width: 42rem; }

.account-identity {
  display: flex;
  align-items: center;
  gap: .88rem;
  padding: 1.15rem;
  border-bottom: 1px solid var(--line);
}

.account-identity .team-avatar {
  width: 3.2rem;
  height: 3.2rem;
  font-size: 1.02rem;
}

.account-identity h2 {
  margin: 0 0 .31rem;
  font-size: 1.2rem;
  letter-spacing: -.025em;
}

.account-details { margin: 0; padding: 0 1.15rem; }

.account-details > div {
  display: grid;
  grid-template-columns: minmax(4.5rem, 23%) 1fr;
  gap: .5rem .8rem;
  padding: .85rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .87rem;
  line-height: 1.45;
}

.account-details dt { color: var(--muted); }
.account-details dd { margin: 0; overflow-wrap: anywhere; }
.account-actions { display: flex; flex-wrap: wrap; gap: .55rem; padding: 1rem 1.15rem; }

.account-push {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .9rem 1.15rem 1.05rem;
}

.account-push p { flex: 1 1 15rem; }

.backup-details > div { grid-template-columns: minmax(9.5rem, 32%) minmax(0, 1fr); }

.backup-details :is(dt, dd),
[data-account-backup] :is([data-backup-message], [data-backup-run]) {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

@container (max-width: 28rem) {
  .backup-details > div { grid-template-columns: minmax(0, 1fr); row-gap: .25rem; }
}

.account-theme {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  padding: .9rem 1.15rem 1.05rem;
}

.theme-option { position: relative; min-width: 0; cursor: pointer; }

.theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.theme-option > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: .4rem .5rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--surface);
  color: var(--text);
  font-size: .86rem;
  font-weight: 690;
}

.theme-option > span:hover { background: var(--bg); }
.theme-option input:checked + span { border-color: var(--brand); color: var(--brand); background: var(--mint); }
.theme-option input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.theme-swatch {
  flex: 0 0 auto;
  width: 1.14rem;
  height: .86rem;
  border: 1px solid var(--swatch-border);
  border-radius: .2rem;
  background: linear-gradient(90deg, var(--swatch-sidebar) 30%, var(--swatch-panel) 30%);
}

.theme-swatch-light { --swatch-border: #7f9e8e; --swatch-sidebar: #295844; --swatch-panel: #f4f7f5; }
.theme-swatch-dark { --swatch-border: #759487; --swatch-sidebar: #101813; --swatch-panel: #35483f; }

.secondary-dialog-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

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

.secondary-dialog-fields textarea {
  min-height: 4.7rem;
  resize: vertical;
}

.secondary-form-help {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}

.password-visibility {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 2.5rem;
  width: fit-content;
  margin-top: .35rem;
  color: var(--muted);
  font-size: .84rem;
  cursor: pointer;
}

.password-visibility input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--brand); }
.password-visibility input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.invitation-fields { gap: .7rem; }

.invitation-fields input[readonly] {
  padding-inline: .75rem;
  background: var(--bg);
}

.invitation-fields input[name="invitation-code"] {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .91rem;
}

.invitation-copy { justify-self: start; }

.team-confirm {
  display: grid;
  gap: .55rem;
  color: var(--muted);
  font-size: .93rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.team-confirm strong { color: var(--text); }
.team-dialog-danger { color: #fff; background: #9e363e; }
.team-dialog-danger:hover { background: #862c33; }

@media (max-width: 480px) {
  .invitation-copy { justify-self: stretch; width: 100%; }
}

.schedule-kind {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.schedule-kind legend {
  margin: 0 0 .4rem;
  padding: 0;
  color: var(--text);
  font-size: .83rem;
  font-weight: 690;
}

.schedule-kind > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
}

.schedule-kind label {
  position: relative;
  display: block;
  cursor: pointer;
}

.schedule-kind input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.schedule-kind label span {
  display: grid;
  place-items: center;
  min-height: 2.65rem;
  padding: .5rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  color: var(--text);
  background: var(--surface);
  font-size: .83rem;
  font-weight: 650;
  text-align: center;
}

.schedule-kind input:checked + span {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--mint);
}

.schedule-kind input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.schedule-dialog:has(input[name="kind"][value="from"]:checked) .schedule-end,
.schedule-dialog:has(input[name="kind"][value="off"]:checked) :is(.schedule-start, .schedule-end),
.schedule-dialog:has(input[name="kind"][value="note"]:checked) :is(.schedule-start, .schedule-end) { display: none; }

@container (max-width: 53rem) {
  .report-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-filters > button { justify-self: start; }
}

@container (max-width: 34rem) {
  .secondary-card-heading { padding-inline: .84rem; }

  .report-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
  }

  .report-summary > .report-stat:first-child { grid-column: 1 / -1; }
  .report-summary--personal > .report-stat:first-child { grid-column: auto; }

  .report-stat {
    min-height: 6.75rem;
    padding: .7rem .72rem;
  }

  .report-stat-icon {
    width: 1.7rem;
    height: 1.7rem;
  }

  .report-stat-icon svg { width: 1rem; }

  .finance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-grid > .report-stat:not(:nth-child(3n)) { border-right: 0; }
  .finance-grid > .report-stat:nth-child(odd) { border-right: 1px solid var(--line); }

  .secondary-table :is(th, td) {
    padding-inline: .65rem;
    font-size: .8rem;
  }

  .secondary-table-count {
    display: block;
    font-size: .7rem;
  }

  .expense-row,
  .team-row,
  .team-invitation-row { padding-inline: .8rem; }

  .team-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: .55rem;
    row-gap: .42rem;
  }

  .team-row .team-role { justify-self: start; grid-column: 2; }
  .team-row-actions {
    grid-column: 3;
    grid-row: 1 / span 2;
    max-width: 5.7rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .team-row-actions .secondary-button:has(svg) span { display: none; }
  .team-row-actions .secondary-button:has(svg) { width: 2.6rem; min-height: 2.6rem; padding: .25rem; }
  .team-person strong { font-size: .9rem; }

  .team-invitation-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: .6rem;
  }

  .team-invitation-actions { grid-column: 1 / -1; }
  .team-invitation-actions .secondary-button { min-height: 2.6rem; }

  .schedule-controls { padding-inline: .68rem; }
  .schedule-week { gap: .35rem; }
  .schedule-week strong { font-size: .84rem; }
  .schedule-week-arrow { min-width: 2.5rem; }
  .schedule-today { margin: 0; }
  .schedule-select { width: 100%; }
  .schedule-entry { padding-inline: .75rem; }
}

@media (max-width: 385px) {
  .secondary-dialog-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: .62rem;
  }

  .report-preset { padding-inline: .5rem; }
}
