/* ==========================================================================
   Tally settings · layout and components
   Uses tokens from tokens.css only. No raw colours, no off-scale sizes.
   Mobile first; one breakpoint where the side navigation fits (48em).
   ========================================================================== */

/* ---- Base ------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-16);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, dl, dd, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
legend { padding: 0; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-width);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sprite { display: none; }

.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  flex: none;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-2);
  z-index: var(--layer-toast);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---- App header ------------------------------------------------------- */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  color: var(--color-text);
  text-decoration: none;
  font-weight: var(--weight-strong);
  font-size: var(--text-20);
  letter-spacing: var(--tracking-tight);
}
.brand__mark {
  width: var(--space-6);
  height: var(--space-6);
  color: var(--color-accent);
}

.app-header__workspace {
  display: none;
  padding-left: var(--space-3);
  border-left: var(--border-width) solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--text-14);
}


/* ---- Links ------------------------------------------------------------ */
.link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--control-height);
  color: var(--color-accent-strong-text);
  text-decoration: none; /* standalone links (e.g. back): the arrow and position say "link" */
  text-underline-offset: var(--underline-offset);
  text-decoration-thickness: var(--border-width);
}
.link:hover,
.link:focus-visible { text-decoration-line: underline; }

/* Links inside a sentence stay underlined, so they don't rely on colour alone. */
.hint .link, p .link { min-height: 0; display: inline; text-decoration-line: underline; }
.hint .link:hover, p .link:hover { text-decoration-thickness: var(--focus-width); }

/* ---- Layout ----------------------------------------------------------- */
.layout {
  max-width: calc(var(--nav-width) + var(--content-max) + var(--space-16) * 2);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-16);
}

.page-title {
  font-size: var(--text-24);
  line-height: var(--leading-tight);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-tight);
}

/* Back link: part of the page, not the global header. Top-left, on its own
   row above both columns (so the two titles stay aligned), because "back"
   points left. */
.back-link {
  font-size: var(--text-14);
  margin-left: calc(var(--space-1) * -1); /* the arrow icon has empty space on its left; this lines its stroke up with the title */
}

.layout__main { min-width: 0; }
.layout__main:focus { outline: none; }

/* ---- Settings navigation --------------------------------------------- */
/* Phone: a horizontal row that scrolls on its own; the page never does. */
.settings-nav {
  display: flex;
  gap: var(--space-1);
  margin: var(--space-4) calc(var(--space-4) * -1) var(--space-6);
  padding: 0 var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: var(--border-width) solid var(--color-border);
}
.settings-nav::-webkit-scrollbar { display: none; }

.settings-nav__group { display: none; }

.settings-nav__list { display: contents; }

.settings-nav__link {
  display: flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  white-space: nowrap;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-14);
  border-bottom: var(--focus-width) solid transparent;
  transition: color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}
.settings-nav__link:hover { color: var(--color-text); }
.settings-nav__link:focus-visible { outline-offset: calc(var(--focus-width) * -1); }
.settings-nav__link[aria-current="page"] {
  color: var(--color-text);
  font-weight: var(--weight-strong);
  border-bottom-color: var(--color-accent);
}

/* ---- Views ------------------------------------------------------------ */
.view {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.view__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.view__title {
  font-size: var(--text-20);
  line-height: var(--leading-tight);
  font-weight: var(--weight-strong);
}
.view__title:focus { outline: none; }
.view__lead {
  max-width: var(--measure);
  color: var(--color-text-muted);
}

/* ---- Panel (the one surface container) ------------------------------ */
.panel {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.panel__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
}
/* List cards: the header and each row carry their own padding, equal top and bottom. */
.panel__body--flush { padding: 0; gap: 0; }
.panel__body--divided { border-top: var(--border-width) solid var(--color-border); }
.panel__body--row {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
}

.panel__title {
  font-size: var(--text-16);
  line-height: var(--leading-tight);
  font-weight: var(--weight-strong);
}
.panel__title--inset { padding: var(--space-4); }
.panel__body:not(.panel__body--flush) > .panel__title + * { margin-top: calc(var(--space-3) - var(--space-6)); }

.panel__footer {
  display: flex;
  align-items: flex-start; /* a longer message grows downward; the button stays put */
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--color-bg);
}

.count {
  color: var(--color-text-muted);
  font-weight: var(--weight-regular);
}

/* ---- Text helpers ---------------------------------------------------- */
.hint {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--text-14);
  font-weight: var(--weight-regular);
}

.form-status {
  flex: 1;
  min-width: 0;
  min-height: var(--control-height); /* one line sits level with the button */
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
  font-size: var(--text-14);
}
.form-status--saved { color: var(--color-success); }
.form-status--error { color: var(--color-danger); }

.empty {
  padding: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-14);
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  color: var(--color-text);
  font-size: var(--text-14);
}
.notice .icon { margin-top: var(--space-1); color: var(--color-text-muted); }
.notice--warning { background: var(--color-warning-subtle); }
.notice--warning .icon { color: var(--color-warning); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-accent-subtle);
  color: var(--color-accent-strong-text);
  font-size: var(--text-12);
  font-weight: var(--weight-strong);
  line-height: var(--leading-body);
  vertical-align: middle;
}
.badge:empty { display: none; }

/* ---- Button (one component, modifier variants) ---------------------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-14);
  font-weight: var(--weight-strong);
  line-height: var(--leading-tight);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.button:active:not(:disabled) { transform: translateY(var(--border-width)); }
.button:disabled { cursor: not-allowed; opacity: var(--opacity-disabled); }
.button[aria-busy="true"] {
  display: inline-grid;
  place-items: center;
  cursor: progress;
  opacity: 1;
}
.button[aria-busy="true"] > * { grid-area: 1 / 1; }
.button__label { visibility: hidden; display: inline-flex; align-items: center; gap: var(--space-2); }
.button__busy { display: inline-flex; align-items: center; gap: var(--space-2); }

.spinner {
  width: var(--icon-size);
  height: var(--icon-size);
  border: var(--spinner-stroke) solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin var(--duration-spin) linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.button--primary {
  background: var(--color-accent);
  color: var(--color-accent-text);
}
.button--primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.button--secondary {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.button--secondary:hover:not(:disabled) { background: var(--color-surface-hover); }

.button--ghost {
  background: transparent;
  color: var(--color-text);
  padding: 0 var(--space-3);
}
.button--ghost:hover:not(:disabled) { background: var(--color-surface-hover); }

.button--danger { color: var(--color-danger); }
.button--danger:hover:not(:disabled) { background: var(--color-danger-subtle); }

.button--icon-text { gap: var(--space-1); color: var(--color-accent-strong-text); }

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  flex: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.icon-button:hover { background: var(--color-surface-hover); color: var(--color-text); }

/* ---- Form fields ----------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: var(--field-max);
}

.field__label {
  font-size: var(--text-14);
  font-weight: var(--weight-strong);
}

.input,
.select {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-16); /* 16px stops iOS from zooming on focus */
  transition: border-color var(--duration-fast) var(--ease);
}
.input::placeholder { color: var(--color-text-muted); }
.input:hover,
.select:hover { border-color: var(--color-text-muted); }
.input:focus-visible,
.select:focus-visible { outline-offset: 0; border-color: var(--color-focus); }
.input[aria-invalid="true"] { border-color: var(--color-danger); }

.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - var(--space-4)) 50%, calc(100% - var(--space-3)) 50%;
  background-size: var(--space-1) var(--space-1);
  background-repeat: no-repeat;
  cursor: pointer;
}
.select--compact { width: auto; font-size: var(--text-14); }

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  color: var(--color-danger);
  font-size: var(--text-14);
}
.field-error[hidden] { display: none; }

.check,
.radio {
  width: var(--check-size);
  height: var(--check-size);
  margin: 0;
  flex: none;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  cursor: pointer;
}
.choice .check,
.choice .radio { margin-top: var(--space-1); }
.choice__text { display: flex; flex-direction: column; }
.choice--inline { padding: 0; align-items: center; }
.choice--inline .check { margin-top: 0; }
.choice__label { font-size: var(--text-16); }

/* Accordion: expands in place. It must look expandable (a row with a
   chevron), never like a link, which promises navigation or a dialog. */
.accordion {
  /* A soft fill, not an input-style border, so it isn't mistaken for a dropdown. */
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  interpolate-size: allow-keywords; /* lets the open/close height animate where supported */
}
.accordion__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-14);
  cursor: pointer;
  list-style: none;
}
.accordion__trigger::-webkit-details-marker { display: none; }
.accordion__trigger:hover { background: var(--color-surface-hover); }
.accordion__chevron {
  color: var(--color-text-muted);
  transition: transform var(--duration-base) var(--ease);
}
.accordion[open] .accordion__trigger { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.accordion[open] .accordion__chevron { transform: rotate(180deg); }
.accordion::details-content {
  height: 0;
  overflow: clip;
  transition: height var(--duration-base) var(--ease), content-visibility var(--duration-base) allow-discrete;
}
.accordion[open]::details-content { height: auto; }
.accordion__panel {
  padding: var(--space-3) var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
}

.role-help {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-14);
}
.role-help dt { font-weight: var(--weight-strong); }
.role-help dd { color: var(--color-text-muted); }

/* ---- Avatar ---------------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  flex: none;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--color-surface-hover);
  border: var(--border-width) solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--text-12);
  font-weight: var(--weight-strong);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: var(--avatar-lg); height: var(--avatar-lg); font-size: var(--text-24); }
.avatar--pending { border-style: dashed; border-color: var(--color-border-strong); background: transparent; }

.avatar-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}
.avatar-field__controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

/* ---- Notification matrix -------------------------------------------- */
.matrix {
  width: 100%;
  border-collapse: collapse;
}
.matrix th,
.matrix td {
  padding: var(--space-3) 0;
  border-top: var(--border-width) solid var(--color-border);
  text-align: left;
  vertical-align: top;
  font-weight: var(--weight-regular);
}
.matrix thead th {
  border-top: 0;
  padding-top: 0;
  color: var(--color-text-muted);
  font-size: var(--text-14);
  font-weight: var(--weight-strong);
}
.matrix__event { padding-right: var(--space-3); }
.matrix__name { display: block; }
.matrix__channel {
  width: var(--space-16);
  text-align: center;
}
.matrix .matrix__channel { text-align: center; }
.matrix td.matrix__channel { vertical-align: top; padding-top: var(--space-3); }
.matrix__na { color: var(--color-text-muted); }

/* ---- Team ------------------------------------------------------------ */
.invite-grid {
  display: grid;
  gap: var(--space-4);
}
.invite-grid .field { max-width: none; }

.member-list { display: flex; flex-direction: column; }

.member {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
}
.member__who { min-width: 0; }
.member__name {
  font-weight: var(--weight-strong);
  overflow-wrap: anywhere;
}
.member__email {
  color: var(--color-text-muted);
  font-size: var(--text-14);
  overflow-wrap: anywhere;
}
.member__actions {
  grid-column: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.member__role {
  color: var(--color-text-muted);
  font-size: var(--text-14);
}
.member__role:empty { display: none; }

/* ---- Billing --------------------------------------------------------- */
/* At a glance: plan on the left, next payment on the right (stacked on phones). */
.plan-overview {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4) var(--space-8);
}
.plan-summary { display: flex; flex-direction: column; gap: var(--space-1); }
.plan-summary__label {
  color: var(--color-text-muted);
  font-size: var(--text-14);
  font-weight: var(--weight-regular);
}
.plan-summary__value {
  font-size: var(--text-24);
  line-height: var(--leading-tight);
  font-weight: var(--weight-strong);
  font-variant-numeric: tabular-nums;
}

/* Seats used: a native <meter>, so the warning colours come from the value. */
.seats { gap: var(--space-2); }
.seats__row { display: flex; justify-content: space-between; gap: var(--space-4); font-size: var(--text-14); }
.seats__label { font-weight: var(--weight-strong); }
.seats__count { font-variant-numeric: tabular-nums; }
.meter {
  appearance: none;
  display: block;
  width: 100%;
  height: var(--space-2);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-border);
}
.meter::-webkit-meter-bar { height: var(--space-2); border: 0; border-radius: var(--radius-full); background: var(--color-border); }
.meter::-webkit-meter-optimum-value { border-radius: var(--radius-full); background: var(--color-accent); }
.meter::-webkit-meter-suboptimum-value { border-radius: var(--radius-full); background: var(--color-warning); }
.meter::-webkit-meter-even-less-good-value { border-radius: var(--radius-full); background: var(--color-danger); }
.meter::-moz-meter-bar { border-radius: var(--radius-full); background: var(--color-accent); }
.meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--color-warning); }
.meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--color-danger); }

/* Compare plans: one column on narrow screens, three side by side when there's room. */
.plans { display: flex; flex-direction: column; gap: var(--space-3); container-type: inline-size; }
.plans__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.plans__title { font-size: var(--text-16); font-weight: var(--weight-strong); }

/* Segmented control: a radio group that looks like one control.
   The selected option changes colour and background only, never weight,
   so its width (and everything next to it) never shifts. */
.segmented {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}
.segmented__option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: calc(var(--control-height) - var(--space-2));
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--text-14);
  font-weight: var(--weight-strong);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.segmented__option:hover { color: var(--color-text); }
.segmented__option:has(:checked) {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 0 0 var(--border-width) var(--color-border);
}
.segmented__option:has(:focus-visible) { outline: var(--focus-width) solid var(--color-focus); outline-offset: var(--focus-width); }
.plan-grid { display: grid; gap: var(--space-4); }
@container (min-width: 600px) {
  .plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.plan-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.plan-card--current {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 var(--border-width) var(--color-accent);
}
.plan-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.plan-card__name { font-size: var(--text-16); font-weight: var(--weight-strong); }
.plan-card__amount {
  font-size: var(--text-24);
  line-height: var(--leading-tight);
  font-weight: var(--weight-strong);
  font-variant-numeric: tabular-nums;
}
.plan-card__unit { display: block; color: var(--color-text-muted); font-size: var(--text-14); } /* own line, so every card lines up */
.plan-card__total { font-size: var(--text-14); font-weight: var(--weight-strong); }
.plan-card__features { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-14); }
.plan-card__action { margin-top: auto; padding-top: var(--space-2); } /* actions line up at the bottom of every card */
.plan-card__action .button { width: 100%; }

.feature-list { display: flex; flex-direction: column; gap: var(--space-1); }
.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.feature-list .icon { margin-top: var(--space-1); color: var(--color-success); }

.payment { font-weight: var(--weight-strong); margin-top: var(--space-1); }

.table-wrap { position: relative; overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-14);
}
.table th,
.table td {
  padding: var(--space-2) var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}
.table th {
  color: var(--color-text-muted);
  font-weight: var(--weight-strong);
}
.table td { height: calc(var(--control-height) + var(--space-2)); }
.table .table__num { text-align: right; font-variant-numeric: tabular-nums; }
.table__action { text-align: right; width: 1%; }
.table td.table__action { padding-right: var(--space-2); }

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.status--paid { color: var(--color-success); }
.status--due { color: var(--color-warning); }

/* Phones: drop the invoice number column (it's still in each Download button's name). */
@media (max-width: 29.99em) {
  .table__optional { display: none; }
  .table th,
  .table td { padding-left: var(--space-2); padding-right: var(--space-2); }
  .table th:first-child,
  .table td:first-child { padding-left: var(--space-4); }
  .table td.table__action { padding-left: 0; padding-right: var(--space-1); }
}

/* Summary list in confirmation dialogs */
.summary-list {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: var(--space-2);
}
.summary-list dt { color: var(--color-text-muted); }
.summary-list dd { padding-left: var(--space-4); text-align: right; font-variant-numeric: tabular-nums; }
.summary-list .summary-list__total {
  padding-top: var(--space-2);
  border-top: var(--border-width) solid var(--color-border);
  color: var(--color-text);
  font-weight: var(--weight-strong);
}

/* ---- Dialog ---------------------------------------------------------- */
.dialog {
  width: calc(100% - var(--space-8));
  max-width: var(--dialog-max);
  padding: 0;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-raised);
}
.dialog::backdrop { background: var(--color-overlay); }

.dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) 0 var(--space-6);
}
.dialog__title {
  font-size: var(--text-20);
  line-height: var(--leading-tight);
  font-weight: var(--weight-strong);
}
.dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6) var(--space-6);
}
.dialog__body .field { max-width: none; }
.dialog__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-top: var(--border-width) solid var(--color-border);
  background: var(--color-bg);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ---- Toast ----------------------------------------------------------- */
.toast-region {
  position: fixed;
  left: var(--space-4);
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: var(--layer-toast);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  max-width: var(--toast-max);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-inverse-surface);
  color: var(--color-inverse-text);
  box-shadow: var(--shadow-raised);
  font-size: var(--text-14);
  pointer-events: auto;
  animation: toast-in var(--duration-base) var(--ease);
}
.toast__message { flex: 1; min-width: 0; padding: var(--space-2) 0; overflow-wrap: anywhere; }
.toast .button--ghost { color: var(--color-inverse-accent); }
.toast .button--ghost:hover:not(:disabled) { background: var(--color-inverse-hover); }
.toast .icon-button { color: var(--color-inverse-text); }
.toast .icon-button:hover { background: transparent; opacity: var(--opacity-muted); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(var(--space-2)); }
  to { opacity: 1; transform: none; }
}

/* ---- Breakpoint: room for side navigation ---------------------------- */
@media (min-width: 48em) {
  .app-header { padding: var(--space-3) var(--space-6); }
  .app-header__workspace { display: inline; }

  .layout {
    display: grid;
    grid-template-columns: var(--nav-width) minmax(0, var(--content-max));
    column-gap: var(--space-12);
    row-gap: var(--space-2);
    padding: var(--space-12) var(--space-8) var(--space-16);
  }

  .back-link { grid-column: 1 / -1; justify-self: start; }

  .layout__side {
    position: sticky;
    top: var(--space-6);
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
  }

  .settings-nav {
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    border-bottom: 0;
  }
  .settings-nav__group {
    display: block;
    padding: 0 var(--space-3) var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--text-12);
    font-weight: var(--weight-strong);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
  }
  .settings-nav__group ~ .settings-nav__group { margin-top: var(--space-6); }
  .settings-nav__list { display: flex; flex-direction: column; gap: var(--space-1); }
  .settings-nav__link {
    border-bottom: 0;
    border-radius: var(--radius-sm);
  }
  .settings-nav__link:hover { background: var(--color-surface-hover); }
  .settings-nav__link[aria-current="page"] {
    background: var(--color-accent-subtle);
    color: var(--color-accent-strong-text);
  }

  .view { gap: var(--space-6); }
  .view__title { font-size: var(--text-24); }

  .panel__body { padding: var(--space-6); }
  .panel__body--flush { padding: 0; }
  .panel__title--inset { padding: var(--space-4) var(--space-6); }
  .panel__body--row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .panel__footer { padding: var(--space-3) var(--space-6); }

  .empty { padding: var(--space-4) var(--space-6); }

  .invite-grid { grid-template-columns: minmax(0, 1fr) var(--role-column); align-items: start; }

  .member {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: var(--space-4) var(--space-6);
  }
  .member__actions { grid-column: auto; justify-content: flex-end; }

  .table th:first-child,
  .table td:first-child { padding-left: var(--space-6); }
  .table td.table__action { padding-right: var(--space-4); }

  .toast-region { justify-content: flex-end; left: auto; right: var(--space-6); bottom: var(--space-6); width: var(--toast-max); }
}

/* ---- Hidden wins --------------------------------------------------------
   Last in the file so it beats any single-class `display` rule above.
   Never give a hideable element a selector stronger than one class. */
[hidden] { display: none; }
