/* Component styles mirroring the legacy shadcn look: subtle borders,
   0.5rem-ish radii (var(--radius) family), focus rings via --ring. */

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.25rem;
  padding: 0 1.125rem;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--primary) 82%, white);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: color-mix(in oklch, var(--secondary) 80%, var(--foreground) 6%);
}

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-success {
  background: var(--success);
  color: var(--background);
}

.btn-success:hover {
  background: color-mix(in srgb, var(--success) 85%, var(--foreground));
}

.btn-destructive:hover {
  background: color-mix(in oklch, var(--destructive) 88%, black);
}

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}

.btn-ghost:hover {
  background: var(--muted);
}

.btn-outline {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--muted);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  height: 2.75rem;
  padding: 0 1.5rem;
  font-size: 1rem;
}

/* ---------- Form fields ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--foreground);
}

.field-error {
  font-size: 0.8125rem;
  color: var(--destructive);
}

.input,
.select,
.textarea {
  height: 2.25rem;
  width: 100%;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: var(--card);
  color: var(--card-foreground);
  font-size: 0.9375rem;
}

/* Money inputs (price, budget, purse, expense): sized to hold 9999999.99
   (7 integer digits + 2 decimals) and capped at that value. */
.input-money {
  width: 8.5rem;
  min-width: 0;
  max-width: 100%;
}

/* Search fields never stretch past 24rem, wherever they appear. */
input[type="search"] {
  max-width: 24rem;
}

.textarea {
  height: auto;
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-foreground);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: color-mix(in oklch, var(--input) 78%, var(--foreground) 10%);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
  border-color: var(--ring);
}

.input[aria-invalid="true"],
.input.is-invalid {
  border-color: var(--destructive);
}

.input:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
  cursor: not-allowed;
}

.select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
}

/* The inlined chevron can't use currentColor - re-ink it for the dark theme
   so it keeps muted-foreground contrast on dark surfaces. */
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2393a4bd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- Card ---------- */

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.card-body {
  padding: 1.25rem;
}

.card-header {
  padding: 1.25rem 1.25rem 0;
}

.card-footer {
  padding: 0 1.25rem 1.25rem;
}

/* ---------- Badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-accent {
  background: var(--accent);
  color: var(--accent-foreground);
}

.badge-success {
  background: color-mix(in oklch, var(--success) 18%, var(--card));
  color: var(--success);
  border-color: color-mix(in oklch, var(--success) 35%, transparent);
}

.badge-warning {
  background: color-mix(in oklch, var(--warning) 20%, var(--card));
  color: color-mix(in oklch, var(--warning) 70%, black);
  border-color: color-mix(in oklch, var(--warning) 40%, transparent);
}

/* Dark: the black-mixed warning text lands near 3:1 on the tinted chip -
   the full warning color reads cleanly on it. */
[data-theme="dark"] .badge-warning {
  color: var(--warning);
}

/* Converted: the proposal became an event - indigo "moved on" tone,
   themed per palette via --converted. */
.badge-converted {
  background: color-mix(in oklch, var(--converted) 14%, var(--card));
  color: var(--converted);
  border-color: color-mix(in oklch, var(--converted) 35%, transparent);
}

.badge-destructive {
  background: color-mix(in oklch, var(--destructive) 14%, var(--card));
  color: var(--destructive);
  border-color: color-mix(in oklch, var(--destructive) 35%, transparent);
}

.badge-outline {
  background: transparent;
  color: var(--muted-foreground);
  border-color: var(--border);
}

/* ---------- Table ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.table th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
  vertical-align: middle;
}

.table tbody tr {
  transition: background-color 120ms ease;
}

.table tbody tr:hover {
  background: color-mix(in oklch, var(--muted) 55%, transparent);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Tabs ---------- */

/* Tab strip - same treatment as the Reports tab track (.reports-tabs). */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding: 0.375rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-card);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  font-weight: 500;
}

.tab:hover {
  background: color-mix(in oklch, var(--foreground) 5%, transparent);
  color: var(--foreground);
}

.tab.active {
  background: var(--accent);
  color: var(--accent-foreground);
}

/* ---------- Popover ---------- */

.popover {
  position: absolute;
  z-index: 50;
  min-width: 10rem;
  padding: 0.25rem;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow-pop);
}

.popover-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: calc(var(--radius) - 0.5rem);
  font-size: 0.875rem;
  text-align: left;
}

.popover-item:hover {
  background: var(--muted);
}

/* ---------- Sheet (side drawer) ---------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 18, 15, 0.5);
  }

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  z-index: 61;
  display: flex;
  flex-direction: column;
  width: min(30rem, 100vw);
  max-width: none;
  height: auto;
  max-height: none;
  margin: 0;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  padding: 0;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-pop);
  overflow: visible;
  /* No entry animation: the sheet is a top-layer modal dialog, and Chromium
     freezes ANY animation on an element promoted to the top layer at its
     first frame - translateX(100%) here = a full width off-screen, which
     dead-zones every click in the sheet. Sheets render docked instantly. */
  animation: none;
}

/* Contact details sheets run 15% wider than the default sheet so the
   email / phone / ext row breathes. */
.sheet.contacts-sheet {
  width: min(34.5rem, 100vw);
}

/* ---------- Event logistics sheet ---------- */
.logistics-title {
  margin: 0.25rem 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.logistics-title-name {
  font-size: inherit;
  color: var(--brand-navy);
}

.logistics-title-by {
  font-size: inherit;
  letter-spacing: inherit;
  font-weight: 700;
  color: var(--muted-foreground);
  margin: 0 0.5rem;
}

.logistics-section {
  margin-top: 1.25rem;
}

/* The SCHEDULE section separates from the roster with a hairline. */
.logistics-rule {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* The Day section separates from the INFO block with a hairline. */
.logistics-day {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.logistics-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* The day pulldown for multi-day events. */
.logistics-day-select {
  flex: 0 0 9rem;
  width: 9rem;
}

/* SCHEDULE section: one row per activity line - time window + activity +
   notes + reorder/remove actions. */
.logistics-schedule-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logistics-schedule-row .input {
  flex: 1 1 auto;
  min-width: 0;
}

.logistics-schedule-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
}

.logistics-add-line {
  margin-top: 0.5rem;
}

/* The schedule footer carries "Add line" + "Generate" side by side. */
.logistics-schedule-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Schedule activity lines pick from the Activities templates. */
.logistics-schedule-row .select {
  flex: 1 1 auto;
  min-width: 0;
}

/* Notes hold person names - keep them readable; the activity pulldown
   takes the remaining space. */
.logistics-schedule-row input[type="text"] {
  flex: 0 0 11rem;
}

/* Logistics runs a step wider than .dialog-wide: the on-site team grid and
   schedule rows (time pair + activity + notes + actions) need the room. */
.dialog.logistics-dialog-wide {
  max-width: min(60rem, calc(100vw - 2rem));
}

/* EVENT INFO as one compact meta line, tight under the Logistics title. */
.logistics-info {
  margin-top: 0.5rem;
}

.logistics-info-line {
  margin: 0 0 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

/* Location row under the meta line: maps icon + address link that opens
   the default maps application. */
.logistics-info-location {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  font-size: 0.8125rem;
}

.logistics-info-location svg {
  flex: 0 0 auto;
  color: var(--muted-foreground);
}

/* On-site section heads: neutralize the schedule block's indent and use
   the arrival header's exact padding, so the "All" switch lands on the
   arrival switch's x (1rem pad + 10rem title + gap). */
.logistics-row.logistics-onsite-head {
  margin-left: -0.5rem;
  padding-left: 0;
}

.logistics-onsite-head .logistics-onsite-title {
  flex: 0 0 10rem;
  margin: 0;
}

.logistics-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0 0.25rem 1rem;
}

.logistics-row-wrap {
  flex-wrap: wrap;
}

.logistics-label {
  flex: 0 0 10rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* The day-plan entry labels (Time, Customer on-site, Our contact, Meals)
   read like the roster's talent column: normal-size muted text instead of
   the tiny 0.75rem label. */
.logistics-entry-label {
  font-size: inherit;
}

.logistics-name {
  flex: 0 0 10rem;
  font-weight: 500;
}

.logistics-discipline {
  flex: 0 0 auto;
  max-width: 12rem;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The quantity/minutes factor ("1 × 30min") beside the talent. */
.logistics-timing {
  margin-left: 0.375rem;
  white-space: nowrap;
}

/* On-site rows reuse the Edit-event team grid (selector-team-*); the
   on/off switch rides in the name cell and talent stays muted text. */
.logistics-onsite-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logistics-onsite-talent {
  color: var(--muted-foreground);
}

.logistics-row .input {
  flex: 1 1 14rem;
  min-width: 0;
}

.logistics-row .input.input-time {
  flex: 0 0 auto;
  width: auto;
}

.logistics-value {
  font-weight: 500;
}

.logistics-subtitle {
  margin: 0.75rem 0 0.25rem;
  font-weight: 600;
}

.logistics-arrival-label {
  flex: 0 0 10rem;
  margin: 0;
}

.logistics-forall {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logistics-forall .logistics-discipline {
  flex: 0 0 auto;
}

.logistics-schedule-title {
  margin-top: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.logistics-schedule-block {
  padding-left: 1.5rem;
}

/* The arrival block sits at the base indent, one level out from the
   schedule content, with the same block gap as the other sections. */
.logistics-arrival {
  margin-top: 0.75rem;
  margin-left: -1.5rem;
}

/* The shared arrival time aligns with the "Set for all" switch: the
   header's label is 10rem wide plus the row gap, over the row's 1rem
   base indent. */
.logistics-arrival-shared {
  padding-left: 11.5rem;
}

/* Bottom banner: company name left, social icons right. */
.logistics-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.logistics-banner-name {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.logistics-time-pair {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.logistics-time-pair .input-time {
  flex: 0 0 auto;
  width: auto;
}

.logistics-contact-select {
  flex: 0 0 14rem;
  width: 14rem;
}

.logistics-per-artist-arrivals {
  padding-left: 2rem;
}

/* Time From/To pair and the Meals pulldown share the same fixed width so
   the Meals pulldown lines up with the two time fields combined. */
.logistics-time-width {
  width: 18rem;
  flex-wrap: nowrap;
}

.logistics-time-width .logistics-label {
  flex: 0 0 auto;
}

.logistics-time-width .input-time {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.logistics-meals-width {
  width: 18rem;
}

.logistics-meals-width .select {
  width: 100%;
  min-width: 0;
}

.logistics-dash {
  color: var(--muted-foreground);
}

/* Technical requirements: one row per artist - the three template
   pulldowns share the row after the name in equal, aligned columns. */
.logistics-tech .logistics-row {
  width: 100%;
}

.logistics-tech .logistics-time-pair {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.375rem;
}

/* Column titles centered above the three technical pulldowns. */
.logistics-tech-header {
  display: grid;
  grid-template-columns: 10rem repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  padding-left: 1rem;
}

.logistics-tech-title {
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

.logistics-tech .logistics-time-pair .select {
  width: 100%;
  min-width: 0;
}

/* The sheet is a modal <dialog>: override the UA dialog box (centered,
   fit-content, margin auto) so it docks full-height to the right edge, and
   style its backdrop like the old overlay. */
dialog.dialog-sheet {
  height: 100dvh;
}
dialog.dialog-sheet[open] {
  display: flex;
  flex-direction: column;
}
dialog.dialog-sheet::backdrop {
  background: rgba(20, 18, 15, 0.5);
}

.sheet-header {
  display: flex;
  align-items: center;
  /* The title's margin-right:auto absorbs the remaining space, so this gap
     is only the minimum spacing between the help and close buttons. */
  justify-content: space-between;
  gap: 0.25rem;
  /* Small right padding: the help/close pair hugs the panel edge (the round
     buttons already carry ~0.8rem of internal space around the glyph). */
  padding: 0.875rem 0.375rem 0.875rem 1.25rem;
  /* Shared brand header: same ivory surface as the page banners. */
  background:
    radial-gradient(120% 180% at 8% 0%, color-mix(in oklch, white 55%, transparent), transparent 46%),
    var(--brand-deep);
  color: var(--brand-ink);
  box-shadow: inset 0 1px 0 color-mix(in oklch, white 55%, transparent);
  border-bottom: 1px solid color-mix(in oklch, var(--brand-ink) 14%, var(--border));
}

/* Title left, help + close grouped right (same pattern as .dialog-title). */
.sheet-title {
  margin-right: auto;
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem;
  }


/* Event expenses sheet: narrower panel; the Add-expense button stays pinned
   at the top and the expense list scrolls beneath it. */
.sheet.expenses-sheet {
  width: min(24rem, 100vw);
}

.sheet.expenses-sheet .sheet-body,
.sheet.expenses-sheet .selector-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet.expenses-sheet .selector-body {
  flex: 1 1 auto;
  min-height: 0;
}

.sheet.expenses-sheet .selector-filter-row {
  flex: 0 0 auto;
}

.sheet.expenses-sheet .selector-details {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 0.75rem;
  /* The scroll area may be taller than the cards; without this the stretched
     row track drags each expense card to full height, leaving dead space
     below the notes field. */
  align-content: start;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-top: 1px solid color-mix(in oklch, var(--brand-ink) 14%, var(--border));
  background: color-mix(in srgb, var(--brand-deep) 72%, white);
}

/* Dark: the hardcoded white in the light mix yields a mid-gray footer that
   drops muted text below contrast - use the dark card surface instead. */
[data-theme="dark"] .sheet-footer {
  background: var(--card);
}

/* The hoisted dialog footer and inline form footer share the same light
   mix - dark gets the card surface too (same fix as the sheet footer). */
[data-theme="dark"] .dialog-footer,
[data-theme="dark"] .dialog-panel > .form-footer {
  background: var(--card);
}

/* ---------- Dialog ---------- */

.dialog {
  /* Center in the viewport explicitly: the global margin reset killed the UA
     stylesheet's centering, and UA dialog styles vary per browser. Fixed +
     inset 0 + auto margins + fit-content height centers on both axes, while
     .dialog-panel's max-height keeps tall forms scrollable. */
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-pop);
  max-width: min(32rem, calc(100vw - 2rem));
  width: 100%;
}

.dialog::backdrop {
  background: rgba(20, 18, 15, 0.5);
}

.dialog-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 4rem);
  max-height: calc(100dvh - 4rem);
}

/* Hoisted form footer (dialog.js): a pinned panel sibling, below the
   scrollbar, always visible, buttons vertically centered and right-aligned. */
.dialog-panel > .form-footer {
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  padding: 0.625rem 1.5rem;
  margin: 0;
  background: color-mix(in srgb, var(--brand-deep) 72%, white);
}

.dialog-header {
  display: flex;
  align-items: center;
  /* The title's margin-right:auto absorbs the remaining space, so this gap
     is only the minimum spacing between the help and close buttons. */
  justify-content: space-between;
  gap: 0.25rem;
  padding: 0.625rem 0.375rem 0.625rem 1.5rem;
  /* Solid brand header surface. */
  background: var(--brand-deep);
  color: var(--brand-ink);
  border-bottom: 1px solid color-mix(in oklch, var(--brand-ink) 14%, var(--border));
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

.dialog-title {
  margin-right: auto;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--brand-ink);
}

.dialog-close,
.dialog-help {
  display: grid;
  place-items: center;
  height: 2.5rem;
  width: 2.5rem;
  border-radius: 9999px;
  color: color-mix(in oklch, var(--brand-ink) 72%, transparent);
  font-size: 1.5rem;
  line-height: 1;
}

.dialog-close:hover,
.dialog-help:hover {
  background: color-mix(in oklch, var(--brand-ink) 8%, transparent);
  color: var(--brand-ink);
}

/* Linked inputs (email/phone/website): trailing action icon inside the
   field - mailto:, tel:, or the website in a new tab. Disabled while the
   field is empty. */
.input-link {
  position: relative;
  display: block;
}

.input-link .input {
  width: 100%;
  padding-right: 2.5rem;
}

.input-link-btn {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  height: 1.75rem;
  width: 1.75rem;
  border-radius: calc(var(--radius) - 4px);
  color: var(--muted-foreground);
  transition: background-color var(--dur-fast) ease-out, color var(--dur-fast) ease-out;
}

.input-link-btn:hover {
  background: color-mix(in oklch, var(--foreground) 8%, transparent);
  color: var(--foreground);
}

.input-link-btn.is-empty {
  pointer-events: none;
  opacity: 0.4;
}

/* Phone + extension pair: the linked phone input fills the row, the
   5-digit ext box rides after it (fixed narrow column, centered digits). */
.input-phone-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.input-phone-row .input-link {
  flex: 1 1 auto;
  min-width: 0;
}

.input-phone-row .input-ext {
  flex: 0 0 4.25rem;
  min-width: 0;
  text-align: center;
}

.dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.5rem 1.25rem;
  scrollbar-gutter: stable;
}

/* Help modal (page-scoped "?" in the banner) */
.help-body p { margin: 0 0 0.5rem; }
.help-body .help-heading { margin: 0.75rem 0 0.25rem; }
.help-body .help-list { margin: 0 0 0.75rem; padding-left: 1.1rem; }
.help-body .help-list li { margin-bottom: 0.25rem; }

/* Draggable dialogs: grab anywhere on the header (except the close ×) */
.dialog-header.dialog-draggable {
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.dialog-header.dialog-draggable:active { cursor: grabbing; }

.dialog-message {
  color: var(--muted-foreground);
  line-height: 1.6;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  border-top: 1px solid color-mix(in oklch, var(--brand-ink) 14%, var(--border));
  background: color-mix(in srgb, var(--brand-deep) 72%, white);
}

/* ---------- Toast ---------- */

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(24rem, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-left: 3px solid var(--toast-success);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow-pop);
  font-size: 0.875rem;
  cursor: pointer;
  animation: toast-in 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.toast-error {
  border-left-color: var(--toast-error);
}

.toast-out {
  opacity: 0;
  transform: translateY(0.375rem);
  transition: opacity 200ms ease, transform 200ms ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Shell / sidebar ---------- */

.shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Content column next to the sidebar: pinned banner host on top, outlet
   below. The column is its own scroll container, so the page scrollbar
   starts beneath the banner instead of running the full window edge. */
.shell-main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.banner-host {
  position: relative;
  z-index: 40;
  flex: 0 0 auto;
  padding: 0.5rem;
  background: var(--background);
}

.banner-host:empty {
  display: none;
}

/* The hoisted banner floats on the host with rounded corners and a small
   padding gap, pinned above the scrolling content. */
.banner-host .roster-banner {
  border-radius: var(--radius);
}

body[data-layout="standalone"] .shell {
  display: block;
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

body[data-layout="standalone"] .sidebar {
  display: none;
}

/* Standalone pages (login/signup/public/invite) own the full viewport:
   no shell chrome padding, no floating hamburger. .shell-main must give up
   its fixed height and hidden overflow too, or it clips standalone pages
   with no way to scroll. */
body[data-layout="standalone"] .shell-main {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
  padding: 0;
}

body[data-layout="standalone"] main#outlet {
  padding: 0;
  overflow: visible;
}

body[data-layout="standalone"] .nav-toggle {
  display: none !important;
}

/* Demo site mode (Administrator > Demo site): mail, phone, website, and
   maps actions are disabled everywhere - field link icons, invite-card
   email, public pages, detail-row contact icons. */
body.demo-mode a[href^="mailto:"],
body.demo-mode a[href^="tel:"],
body.demo-mode a.detail-row-icon {
  pointer-events: none;
  opacity: 0.45;
  cursor: not-allowed;
}

/* Collapsed rail: icons only, labels hidden. */
body.sidebar-rail:not(.nav-open) .sidebar {
  flex-basis: 3.75rem;
}

body.sidebar-rail:not(.nav-open) .sidebar-header {
  justify-content: center;
  padding-inline: 0.25rem;
}

body.sidebar-rail:not(.nav-open) .sidebar-brand {
  display: none;
}

body.sidebar-rail:not(.nav-open) .sidebar-brand-text,
body.sidebar-rail:not(.nav-open) .sidebar-section-label,
body.sidebar-rail:not(.nav-open) .sidebar-link > span:not(.icon),
body.sidebar-rail:not(.nav-open) .sidebar-user-meta {
  display: none;
}

body.sidebar-rail:not(.nav-open) .sidebar-nav {
  padding: 0.375rem;
}

body.sidebar-rail:not(.nav-open) .sidebar-link {
  justify-content: center;
  padding: 0;
  height: 2.5rem;
  width: 2.5rem;
  margin: 0 auto 0.25rem;
}

body.sidebar-rail:not(.nav-open) .sidebar-user {
  flex-direction: column;
  justify-content: center;
  gap: 0.375rem;
  padding: 0;
}

body.sidebar-rail:not(.nav-open) .sidebar-theme-row {
  justify-content: center;
}

/* In the collapsed rail the auto-margin pin is dropped so all footer
   icons center together. */
body.sidebar-rail:not(.nav-open) .sidebar-tour-btn {
  margin-right: 0;
}

body.sidebar-rail:not(.nav-open) .sidebar-footer {
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-width, 272px);
  height: 100vh;
  height: 100dvh;
  border-right: 1px solid var(--border);
  background: color-mix(in oklch, var(--sidebar-bg) 78%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 5rem;
  padding: 0 0.75rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  height: 2rem;
  width: 2rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
}

.icon-btn:hover {
  background: color-mix(in oklch, var(--muted) 80%, transparent);
  color: var(--foreground);
}

.sidebar-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  height: 2rem;
  width: 2rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--brand-deep);
  border: 1px solid var(--border);
  color: var(--brand-ink);
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-brand-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.2;
}

.sidebar-brand-sub {
  display: block;
  margin-top: 0.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--brand-navy);
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 0.75rem 0;
}

.sidebar-section + .sidebar-section {
  margin-top: 1rem;
}

.sidebar-section-label {
  padding: 0 0.5rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted-foreground);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  height: 2.75rem;
  margin-bottom: 0.125rem;
  padding: 0 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--foreground);
}

.sidebar-link:hover {
  background: color-mix(in oklch, var(--muted) 85%, transparent);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--accent-foreground);
  box-shadow: 0 1px 2px rgba(20, 22, 30, 0.06);
}

[data-theme="dark"] .sidebar-link.active {
  color: var(--accent-foreground);
  box-shadow: none;
}

/* Shared tooltip (lib/tooltip.js) for icon-only controls: sidebar nav
   items and the footer icon row. position: fixed escapes the sidebar-nav
   overflow clipping; the element itself is invisible unless .show. */
.app-tooltip {
  position: fixed;
  z-index: 1200;
  padding: 0.3125rem 0.5625rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--foreground);
  color: var(--background);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(20, 22, 30, 0.18);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.app-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Dialog (window) tours ---------- */

/* The stepper tip lives INSIDE the <dialog> so it shares the dialog's
   top layer and paints above the modal content. Fixed positioning
   anchors it to the highlighted field's viewport coordinates. */
.dialog-tour-tip {
  /* Anchored to the <dialog> itself (position: fixed root), so the tip
     shares the dialog's top layer and stays correct even after the
     window is dragged (transforms don't shift absolute children). */
  position: absolute;
  z-index: 50;
  max-width: 20rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  background: var(--popover-bg, var(--foreground));
  color: var(--popover-ink, var(--background));
  font-size: 0.8125rem;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(20, 22, 30, 0.28);
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: auto;
}

.dialog-tour-tip.show {
  opacity: 1;
}

.dialog-tour-title {
  margin: 0 0 0.25rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.dialog-tour-body {
  margin: 0;
}

.dialog-tour-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dialog-tour-progress {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

.dialog-tour-buttons {
  display: flex;
  gap: 0.375rem;
}

/* Outline the field being explained; drawn over inputs, selects,
   textareas and picker grids alike. */
.tour-highlight {
  outline: 2px solid var(--brand-accent, #e0a13d);
  outline-offset: 2px;
  border-radius: calc(var(--radius) - 2px);
}

/* The little × in the tip's corner. */
.dialog-tour-close {
  position: absolute;
  top: 0.25rem;
  right: 0.375rem;
  height: 1.5rem;
  width: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: calc(var(--radius) - 2px);
  font-size: 1rem;
  line-height: 1;
  color: inherit;
  opacity: 0.7;
}

.dialog-tour-close:hover {
  opacity: 1;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem;
  border-radius: calc(var(--radius) - 2px);
}

.sidebar-user:hover {
  background: color-mix(in oklch, var(--muted) 80%, transparent);
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  height: 2.25rem;
  width: 2.25rem;
  border-radius: 9999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.8125rem;
  font-weight: 600;
}

.sidebar-user-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-user-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
}

.sidebar-user-email {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.sidebar-theme-row {
  display: flex;
  justify-content: flex-end;
}

/* Tour replay rocket pinned to the left end of the footer icon row;
   the bell and theme toggle stay grouped on the right. */
.sidebar-tour-btn {
  margin-right: auto;
}

.shell main#outlet {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  padding: 0.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
}

/* ---------- Page scaffolding ---------- */

.page {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-title {
  font-family: var(--font-serif);
  font-size: clamp(1.625rem, 3.2vw, 2.25rem);
  letter-spacing: -0.01em;
}

.page-subtitle {
  margin-top: 0.25rem;
  color: var(--muted-foreground);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 0.375rem;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted-foreground);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state strong,
.empty-state h2,
.empty-state h3 {
  color: var(--foreground);
}

/* ---------- Auth (login/signup) ---------- */

.auth-backdrop {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background-color: #1b1917;
  background-image: radial-gradient(circle at 15% 25%, rgba(255, 255, 255, 0.055), transparent 28%),
    radial-gradient(circle at 82% 84%, rgba(243, 212, 138, 0.09), transparent 24%);
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  padding: 2rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.95);
  color: var(--foreground);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .auth-card {
  background: var(--card);
}

.auth-mark {
  display: grid;
  place-items: center;
  margin: 0 auto;
  height: 3rem;
  width: 3rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--primary);
  color: var(--primary-foreground);
}

.auth-title {
  margin-top: 1.25rem;
  font-family: var(--font-serif);
  font-size: 1.875rem;
}

.auth-subtitle {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5rem;
  color: var(--muted-foreground);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
  text-align: left;
}

.auth-error {
  padding: 0.5rem 0.75rem;
  border: 1px solid color-mix(in oklch, var(--destructive) 35%, transparent);
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in oklch, var(--destructive) 10%, var(--card));
  color: var(--destructive);
  font-size: 0.875rem;
  text-align: left;
}

.auth-switch {
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.auth-switch a {
  font-weight: 600;
  color: var(--brand-navy);
  text-decoration: underline;
}

/* ---------- Not found ---------- */

.notfound {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(to bottom right, var(--background), var(--muted));
}

.notfound-card {
  max-width: 32rem;
  width: 100%;
  padding: 2.5rem 2rem;
  text-align: center;
}

.notfound-code {
  font-size: 2.5rem;
  font-weight: 700;
}

.notfound-title {
  margin-top: 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.notfound-copy {
  margin: 1rem 0 2rem;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.notfound-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

/* Small screens: floating hamburger opens the sidebar as an overlay. Lives at
   the END of the sheet so its rules win the cascade over the base sidebar. */
.nav-toggle {
  display: none;
}

@media (max-width: 48rem) {
  /* The nav toggle lives inside the roster banner (prepended by main.js),
     so the shell only needs a slim top pad - no reserved hamburger strip. */
  body[data-layout="shell"] .shell-main {
    padding-top: 0.75rem;
  }

  /* In-flow pill on the banner's title row: menu icon when the sidebar is
     hidden, X while the overlay is displayed (mutually exclusive states). */
  .nav-toggle {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    height: 2.75rem;
    width: 2.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in oklch, var(--card) 85%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
    color: var(--foreground);
  }

  .sidebar {
    display: none;
  }

  /* Mutual exclusion: hamburger hides while the sidebar overlay is displayed.
     The overlay's own panel icon (sidebar header) closes it again. */
  body.nav-open .nav-toggle {
    display: none;
  }

  body.nav-open .sidebar {
    display: flex;
    position: fixed;
    top: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
    height: auto;
    margin: 0;
    width: min(17rem, calc(100vw - 1.5rem));
    z-index: 71;
  }

  body.nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(20, 18, 15, 0.45);
  }

  .shell main#outlet {
    /* The hoisted banner already clears the floating hamburger (shell-main
       padding-top), so the outlet itself only needs a slim top pad. */
    padding: 0.75rem 1rem 1rem;
  }

  /* ---- Phase 1 mobile sizing: typography, inputs, touch targets ---- */

  /* Slightly denser chrome: every rem-based size scales down together. */
  html {
    font-size: 15px;
  }

  /* 16px inputs (px, not rem): iOS Safari zooms the page on focus for
     smaller input fonts. Height lands at ~41px for comfortable touches. */
  .input,
  .select,
  .textarea {
    font-size: 16px;
    height: 2.75rem;
  }

  /* 44px minimum touch targets for the icon-only buttons (row actions,
     record hero, dialog corners). */
  .icon-btn {
    width: 2.75rem;
    height: 2.75rem;
  }

  .btn {
    min-height: 2.75rem;
  }

  /* Wide tables scroll inside their card instead of stretching the page. */
  .roster-table-card,
  .table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- Phase 3: list tables become stacked cards ---- */
  /* The column header row goes away; each row renders as its own card and
     every cell (except the first, which acts as the card title) becomes a
     label/value line, with the label taken from the cell's data-label. */
  .roster-table-card .table thead {
    display: none;
  }

  .roster-table-card .table,
  .roster-table-card .table tbody {
    display: block;
  }

  .roster-table-card .table tr {
    display: block;
    margin: 0 0 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
  }

  .roster-table-card .table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.375rem 0;
    border: 0;
  }

  .roster-table-card .table td + td {
    border-top: 1px solid var(--border);
  }

  .roster-table-card .table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted-foreground);
  }

  /* First cell = card title: full width, no label. */
  .roster-table-card .table td:first-child {
    display: block;
    padding-bottom: 0.5rem;
  }

  .roster-table-card .table td:first-child::before {
    display: none;
  }

  /* Actions line: no label, buttons right-aligned. */
  .roster-table-card .table td:has(> .cell-actions) {
    justify-content: flex-end;
  }

  .roster-table-card .table td:has(> .cell-actions)::before {
    display: none;
  }

  /* The empty state spans the card like any other row. */
  .roster-table-card .table .table-empty-cell {
    justify-content: center;
  }

  .roster-table-card .table .table-empty-cell::before {
    display: none;
  }

  /* ---- Phase 4: dialogs become full-screen sheets ---- */
  .dialog {
    /* 100% (not 100vw): the viewport unit would count the page scrollbar
       and leave a sliver of backdrop visible on the right. */
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .dialog-panel {
    height: 100%;
    max-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Keep interactive elements clear of the home-indicator area. */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Invalid input state (postal format check, etc.). */
.input-invalid {
  border-color: var(--destructive);
}

.input-invalid:focus {
  border-color: var(--destructive);
  outline-color: color-mix(in oklch, var(--destructive) 35%, transparent);
}
