/* ---------- Buttons: pills; the one main action is solid Midnight ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
  height: 40px; padding: 0 var(--space-5); border-radius: var(--pill); border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--bevel), var(--shadow-resting); color: var(--ink);
  font-size: var(--fs-base); font-weight: 500; white-space: nowrap; cursor: pointer; user-select: none;
  transition: transform var(--fast), box-shadow var(--med), background var(--med), color var(--med);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--bevel), var(--shadow-raised); }
.btn:active { transform: scale(0.97); box-shadow: var(--bevel-pressed), var(--shadow-resting); }
.btn:focus-visible { box-shadow: var(--bevel), var(--shadow-raised), var(--ring); }
.btn.primary { background: var(--midnight); color: var(--ink-inverse); border-color: transparent; box-shadow: var(--shadow-ink); }
.btn.primary:hover { box-shadow: var(--shadow-primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-hover); transform: none; box-shadow: none; }
.btn.danger { color: var(--rose); }
/* An armed primary action is a solid danger surface: white on --rose is 4.67:1. */
.btn.primary.danger { background: var(--rose); color: var(--danger-on-rose); border-color: transparent; }
.btn.primary.danger:hover { background: var(--rose-ink); }
.btn.sm { height: 32px; padding: 0 var(--space-4); font-size: var(--fs-sm); }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
/* A busy button hides its label under the spinner, whatever its variant. */
.btn.loading, .btn.loading:is(.primary, .ghost, .danger) { color: transparent; pointer-events: none; }
.btn.loading > :not(.spinner) { visibility: hidden; }
.btn.loading > .spinner { position: absolute; inset: 0; margin: auto; color: var(--ink); }
.btn.primary.loading > .spinner, .page-head .btn.loading > .spinner { color: var(--ink-inverse); }
.page-head .btn.primary.loading > .spinner { color: var(--midnight); }

/* ---------- Badges: pills with a hairline ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 24px; padding: 0 var(--space-3); border-radius: var(--pill);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; letter-spacing: 0.01em;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); box-shadow: var(--bevel);
}
/* A badge in an action colour is a full bubble with white text (manual de marca); no pale fills,
   no dots. "rose" is the red's older name. Badges without meaning for action stay neutral. */
.badge.green, .badge.orange, .badge.red, .badge.rose, .badge.yellow { border-color: transparent; box-shadow: none; color: var(--on-action); }
.badge.green { background: var(--action-green); }
.badge.orange { background: var(--action-orange); }
.badge.red, .badge.rose { background: var(--action-red); }
.badge.yellow { background: var(--action-yellow); color: var(--on-action-yellow); }
.badge.count { background: var(--midnight); color: var(--ink-inverse); min-width: 24px; justify-content: center; border: 0; }

/* ---------- Cards: the raised white pane ---------- */
.card {
  position: relative; min-width: 0; padding: var(--pad); border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--bevel), var(--shadow-raised);
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); margin-bottom: var(--gap); min-width: 0; min-height: 24px; }
.card-head h2 { font-size: var(--fs-md); letter-spacing: -0.012em; }
@media (max-width: 720px) {
  .card-head { flex-wrap: wrap; row-gap: var(--space-3); }
  .card-head .row { flex-wrap: wrap; }
  .list-item.actionable { flex-wrap: wrap; row-gap: var(--space-2); }
  .list-item.actionable > .grow { flex: 1 0 100%; }
  .list-item.actionable .mt-name > * { white-space: normal; }
}
.card.flush .card-head { padding: var(--pad) var(--pad) 0; }
.card.focal {
  background: var(--midnight);
  color: var(--ink-inverse);
  border-color: transparent;
  box-shadow: var(--shadow-drawer);
}
.card.focal .eyebrow, .card.focal .muted, .card.focal .hint, .card.focal .label, .card.focal .meta { color: var(--ink-inverse-muted); }
.card.focal .spinner { color: var(--ink-inverse); --track: var(--midnight-line); }
.card.focal .quote-refusal { color: var(--ink-inverse); margin: 0; }
.card.focal .badge { background: var(--midnight-raised); color: var(--ink-inverse); border-color: var(--midnight-line); box-shadow: none; }
.card.focal .btn { background: var(--ink-inverse); color: var(--midnight); }
.card-icon.sm { width: 32px; height: 32px; }
.strong { font-weight: 600; }
.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--midnight);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-ink);
  flex: none;
}
.card-icon svg { width: 19px; height: 19px; }

.grid { display: grid; gap: var(--gap); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1150px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

/* The stay as time: before arrival, in house, after departure. One column per moment. */
.journey { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.journey-phase { min-width: 0; padding: var(--space-4) var(--space-4) 0; border-right: 1px solid var(--line); }
.journey-phase:last-child { border-right: 0; }
.journey-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.journey-head h3 { font-size: var(--fs-sm); color: var(--ink-2); letter-spacing: 0.02em; }
.journey-mark { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; color: var(--ink-2); }
.journey-mark svg { width: 17px; height: 17px; }
.journey-rows { display: flex; flex-direction: column; gap: var(--space-3); }
.journey-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-width: 0; }
.journey-label { color: var(--muted); font-size: var(--fs-sm); }
.journey-value { text-align: right; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .journey { grid-template-columns: 1fr; }
  .journey-phase { border-right: 0; border-bottom: 1px solid var(--line); padding: var(--space-4); }
  .journey-phase:last-child { border-bottom: 0; }
}

.stat .label { color: var(--muted); font-size: var(--fs-base); font-weight: 500; }
.stat .value { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.035em; margin-top: var(--space-3); font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--faint); font-size: var(--fs-sm); margin-top: var(--space-0); }
.meter-caption { margin-top: var(--space-3); }
.stat-figure { margin-top: var(--space-3); }
.meter { height: 6px; border-radius: var(--pill); background: var(--slate-tint); margin-top: var(--space-4); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--midnight); border-radius: inherit; }

/* ---------- Eyebrow, figures, meta, allocation ---------- */
.eyebrow { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 var(--space-3);
  border-radius: var(--pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--bevel);
}
.figure { font-size: var(--fs-3xl); font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.figure .unit, .figure .decimals { font-size: 0.5em; font-weight: 600; letter-spacing: -0.02em; opacity: 0.55; }
.figure.sm { font-size: var(--fs-2xl); }
.meta { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--gap); }
.legend > div { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-base); min-width: 0; white-space: nowrap; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.legend .val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Tables and lists ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th {
  text-align: left;
  background: var(--surface);
  font-family: var(--mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: var(--space-4) var(--pad);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: var(--space-3) var(--pad); border-bottom: 1px solid var(--line); vertical-align: middle; max-width: 320px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--med); }
.table tbody tr.link { cursor: pointer; }
.table tbody tr.link:hover { background: var(--surface-hover); }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
button.list-item { font: inherit; color: inherit; text-align: left; background: none; border-width: 0 0 1px; width: calc(100% + 16px); }
.list-item.link {
  cursor: pointer;
  border-radius: var(--radius-inner);
  margin: 0 -8px;
  padding: var(--space-3) var(--space-3);
  transition: background var(--fast);
}
.list-item.link:hover { background: var(--surface-hover); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: none;
  background: var(--slate-tint);
  color: var(--slate);
}

/* ---------- Fields: pills ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.field > .label { font-size: var(--fs-base); font-weight: 500; color: var(--ink-2); display: flex; gap: var(--space-1); align-items: baseline; }
.field > .label .req { color: var(--rose); }
.field > .help { font-size: var(--fs-sm); color: var(--faint); line-height: 1.4; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 var(--space-5); border-radius: var(--pill); border: 1px solid var(--control-line);
  background: var(--surface);
  box-shadow: var(--bevel), var(--shadow-resting); font-size: var(--fs-md); color: var(--ink);
  transition: box-shadow var(--med), border-color var(--med);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { height: auto; min-height: 96px; padding: var(--space-3) var(--space-5); border-radius: var(--radius-inner); resize: vertical; line-height: 1.5; }
.textarea.code { font-family: var(--mono); font-size: var(--fs-sm); }
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--ink-edge);
  box-shadow: var(--bevel), var(--shadow-raised), var(--ring);
}
.select {
  appearance: none;
  padding-right: var(--space-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236E7684' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
.field.invalid .input, .field.invalid .select { border-color: var(--rose); }
.field .error { color: var(--rose); font-size: var(--fs-sm); }
.search { position: relative; min-width: min(320px, 100%); }
.search svg { position: absolute; left: 18px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); z-index: 1; }
.search .input { padding-left: var(--space-7); }

.switch { display: inline-flex; align-items: center; gap: var(--space-4); cursor: pointer; user-select: none; font-size: var(--fs-base); font-weight: 500; }
.switch input {
  appearance: none;
  width: 46px;
  height: 28px;
  border-radius: var(--pill);
  background: var(--control-line);
  position: relative;
  cursor: pointer;
  transition: background var(--med);
  margin: 0;
  flex: none;
  box-shadow: inset 0 1px 2px var(--ink-glow-soft);
}
.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-control);
  transition: transform var(--med) var(--spring);
}
.switch input:checked { background: var(--midnight); }
.switch input:checked::after { transform: translateX(18px); }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  height: 32px;
  padding: 0 var(--space-4);
  border-radius: var(--pill);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--bevel);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--med), border-color var(--med), color var(--med), box-shadow var(--med);
}
.chip:hover { color: var(--ink); background: var(--surface-hover); }
.chip[aria-pressed="true"] { background: var(--midnight); color: var(--ink-inverse); border-color: transparent; box-shadow: var(--shadow-ink-soft); }

/* ---------- Segmented control and tabs: one shared track ---------- */
.segmented, .tabs {
  display: inline-flex; align-items: center; gap: var(--space-0); padding: var(--space-1); border-radius: var(--pill); max-width: 100%; overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--bevel), var(--shadow-resting);
}
.segmented button, .tabs button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  height: 34px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--pill);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--med), background var(--med), box-shadow var(--med);
}
.segmented button:hover, .tabs button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"], .tabs button[aria-selected="true"] {
  background: var(--midnight);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-ink-soft);
}
.tabs { align-self: flex-start; flex: none; }

/* ---------- Generated forms ---------- */
.form { display: flex; flex-direction: column; gap: var(--gap); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.form-grid > .wide { grid-column: 1 / -1; }
.group {
  border: 1px solid var(--line);
  border-radius: var(--radius-inner);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  background: var(--surface-sunken);
}
.group .group-title {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.repeat-item { position: relative; border: 1px dashed var(--line-strong); border-radius: var(--radius-inner); padding: var(--pad); }
.repeat-item > .remove { position: absolute; top: 8px; right: 8px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: var(--space-3) var(--gap); font-size: var(--fs-base); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.json {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-inner);
  padding: var(--pad);
  overflow: auto;
  max-height: 380px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* ---------- Empty, skeleton, notice ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-5);
  color: var(--muted);
}
.empty .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--midnight);
  color: var(--ink-inverse);
  display: grid;
  place-items: center;
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-ink);
}
.empty .empty-icon svg { width: 20px; height: 20px; }
.empty h2 { color: var(--ink); font-size: var(--fs-md); }
.empty p { max-width: 46ch; }
.empty .btn { margin-top: var(--space-4); }
/* ---------- Loading: ghosts for content, the spinner for actions ---------- */
.skeleton {
  border-radius: var(--pill);
  height: 12px;
  background: linear-gradient(90deg, var(--slate-tint) 0%, var(--slate-tint) 40%, var(--ink-inverse) 50%, var(--slate-tint) 60%, var(--slate-tint) 100%);
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skeleton.title { width: 38%; height: 16px; margin-bottom: var(--gap); }
.skeleton.dot { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.ghost-lines { display: flex; flex-direction: column; gap: var(--space-3); }
.card.ghost { pointer-events: none; }
.card.ghost.tall .ghost-lines { gap: var(--space-4); }
.ghost-row { display: flex; align-items: center; gap: var(--pad); padding: var(--space-4) var(--pad); border-bottom: 1px solid var(--line); }
.ghost-row:last-child { border-bottom: 0; }
.ghost-row.head .skeleton { height: 9px; }
.ghost-row .skeleton:not(.dot) { flex: none; }

.spinner { --track: var(--line-strong); display: inline-grid; place-items: center; width: 28px; height: 28px; color: var(--midnight); flex: none; }
.spinner.sm { width: 20px; height: 20px; }
.spinner.lg { width: 44px; height: 44px; }
.spinner svg { width: 100%; height: 100%; overflow: visible; animation: spinner-turn 1.8s linear infinite; }
.spinner .track { fill: none; stroke: var(--track); stroke-width: 4; }
.spinner .arc {
  fill: none;
  stroke: currentColor;
  stroke-width: 4.4;
  stroke-linecap: round;
  stroke-dasharray: 1 101;
  animation: spinner-arc 1.4s cubic-bezier(0.45, 0, 0.25, 1) infinite;
}
.btn .spinner { --track: var(--line); }
.btn.primary .spinner, .page-head .btn:not(.primary) .spinner { --track: var(--midnight-line); }
.page-head .btn.primary .spinner { --track: var(--line-strong); }
@keyframes spinner-turn { to { transform: rotate(360deg); } }
@keyframes spinner-arc {
  0% { stroke-dasharray: 1 101; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 62 101; stroke-dashoffset: -18; }
  100% { stroke-dasharray: 1 101; stroke-dashoffset: -100; }
}
.notice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--pad);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-resting);
  font-size: var(--fs-base);
  color: var(--ink-2);
}
.notice.warn { background: var(--action-orange); border-color: transparent; color: var(--on-action); }
.notice.err { background: var(--action-red); border-color: transparent; color: var(--on-action); }
.notice svg { width: 17px; height: 17px; flex: none; }

/* ---------- Failure and stale states: the frame stays, the content says what happened ---------- */
.page-status { display: flex; flex-direction: column; gap: var(--gap); }
.page-status:empty { display: none; }
.stale-banner { flex-wrap: wrap; box-shadow: none; }
.stale-banner .grow { min-width: 200px; }
.stale-banner .btn { height: 32px; flex: none; }
.failure-card { display: flex; flex-direction: column; gap: var(--gap); max-width: 560px; padding: var(--pad); }
.failure-head { display: flex; align-items: center; gap: var(--space-4); }
.failure-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  /* A state icon sits in a full bubble of its action colour, white stroke (manual de marca). */
  background: var(--action-red);
  color: var(--ink-inverse);
  flex: none;
}
.failure-icon svg { width: 19px; height: 19px; }
.failure-card h2 { font-size: var(--fs-md); }
.failure-actions { margin-top: var(--space-1); }
@media (max-width: 900px) { .failure-card { max-width: none; } }

/* ---------- Overlays: a sheet for records, a dialog for confirmations ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 100; animation: fade var(--med); }
.sheet {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(600px, calc(100vw - 24px)); z-index: 101;
  display: flex; flex-direction: column; border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--bevel), var(--shadow-sheet); animation: slide var(--med);
}
.sheet.wide { width: min(780px, calc(100vw - 24px)); }
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap);
  padding: var(--pad);
  border-bottom: 1px solid var(--line);
}
.sheet-head .eyebrow { margin-bottom: var(--space-1); }
.sheet-head h2 { font-size: var(--fs-xl); letter-spacing: -0.025em; }
.sheet-body > * { flex-shrink: 0; }
.sheet-body { flex: 1; overflow-y: auto; scrollbar-width: thin; padding: var(--pad); display: flex; flex-direction: column; gap: var(--gap); }
.sheet-foot[hidden] { display: none; }
.sheet-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-3);
  padding: var(--gap) var(--pad);
  border-top: 1px solid var(--line);
}
.sheet-foot > :first-child:not(:only-child) { margin-right: auto; }
.dialog {
  position: fixed; left: 50%; top: 20vh; transform: translateX(-50%); width: min(460px, calc(100vw - 32px)); z-index: 102;
  display: flex; flex-direction: column; gap: var(--gap); padding: var(--pad); border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-raised); animation: pop var(--med);
}
.dialog h2 { font-size: var(--fs-lg); letter-spacing: -0.02em; }
.dialog .actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-1); }

.menu {
  position: fixed; z-index: 120; min-width: 220px; padding: var(--space-2); border-radius: var(--radius-inner);
  background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-raised); animation: fade var(--fast);
}
.menu button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-3);
  height: 36px;
  padding: 0 var(--space-4);
  border: 0;
  background: none;
  border-radius: var(--pill);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.menu button:hover { background: var(--surface-hover); }
.menu button.danger { color: var(--rose); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-1) var(--space-3); }

/* ---------- The property picker: a search over the account's properties ---------- */
.picker-trigger { width: 100%; text-align: left; cursor: pointer; overflow: hidden; }
.picker-current { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { display: flex; flex-direction: column; gap: var(--space-2); max-width: calc(100vw - 16px); }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: min(360px, 60vh); overflow-y: auto; }
.picker-option {
  display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-inner); cursor: pointer; font-size: var(--fs-base);
}
.picker-option .muted { font-size: var(--fs-sm); }
.picker-option:hover, .picker-option.active { background: var(--surface-hover); }
.picker-option[aria-selected="true"] .picker-title { font-weight: 600; }
.picker-note:empty { display: none; }
.picker-note { font-size: var(--fs-sm); padding: 0 var(--space-4); }

/* ---------- Toasts: a pill with an ink badge ---------- */
.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}
.toast {
  display: flex; align-items: center; gap: var(--space-4); max-width: min(520px, 92vw); padding: var(--space-3) var(--space-5) var(--space-3) var(--space-3);
  border-radius: var(--pill);
  background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--bevel), var(--shadow-raised); font-size: var(--fs-base); font-weight: 500; animation: rise var(--med);
}
.toast-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--midnight);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-ink);
}
.toast-icon svg { width: 16px; height: 16px; }
.toast.err .toast-icon { background: var(--rose); }

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(28px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px) scale(0.98); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.table-note { padding: var(--space-3) var(--pad); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }

/* On a phone every table becomes a list of cards: the first column is the title,
   the others are label / value lines. Nothing scrolls sideways out of sight. */
@media (max-width: 900px) {
  .table-wrap > .table:not(.ari), .table-wrap > .table:not(.ari) tbody, .table-wrap > .table:not(.ari) tr { display: block; }
  .table-wrap > .table:not(.ari) thead { display: none; }
  .table-wrap > .table:not(.ari) tr { padding: var(--space-3) var(--pad); border-bottom: 1px solid var(--line); }
  .table-wrap > .table:not(.ari) td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-0) 0;
    border: 0;
    text-align: right;
    min-height: 26px;
  }
  .table-wrap > .table:not(.ari) td::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
    text-align: left;
  }
  .table-wrap > .table:not(.ari) td:first-child { justify-content: flex-start; text-align: left; padding-bottom: var(--space-2); }
  .table-wrap > .table:not(.ari) td:first-child::before { display: none; }
}
/* A whole card that opens something: a real button, reachable by keyboard. */
.card-button { font: inherit; color: inherit; text-align: left; border: 0; cursor: pointer; width: 100%; }
.card-button:hover { box-shadow: var(--shadow-raised); }
.field-error:empty { display: none; }
.field-error { color: var(--action-red); font-size: var(--fs-sm); }
:is(.input, .select, .textarea)[aria-invalid="true"], :is(.input, .select, .textarea)[aria-invalid="true"]:focus { border-color: var(--rose); }
.breakdown summary { cursor: pointer; color: var(--muted); font-size: var(--fs-base); }
.breakdown .kv { margin-top: var(--space-3); }
.sheet-head h2:focus { outline: none; }
[role="tabpanel"]:focus, [role="tabpanel"]:focus-visible { outline: none; }
.focal .breakdown summary, .focal .breakdown dt { color: var(--ink-inverse-muted); }
.focal .breakdown dd { color: var(--ink-inverse); }
.toast-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: var(--space-1);
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}
.toast-close svg { width: 14px; height: 14px; }
@media (max-width: 900px) { .toasts { bottom: calc(64px + var(--gap) * 2 + env(safe-area-inset-bottom)); } }
/* Codes (booking references) keep their exact case inside upper-case labels. */
.code { text-transform: none; letter-spacing: 0; }

/* Account: full width like every page; how complete it is, the person and the company, then the rest. */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
.avatar.xl { width: 72px; height: 72px; font-size: var(--fs-xl); }
.account-head { gap: var(--gap); align-items: center; }
.account-head h2 { font-size: var(--fs-lg); }
.account-photo-button { position: relative; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.account-photo-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--midnight);
  color: var(--bone);
  border: 2px solid var(--surface);
}
.account-photo-edit svg { width: 12px; height: 12px; }
.account-photo-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tool-row { width: 100%; }
.tool-row .tool-title { font-weight: 600; }
.tool-row > .icon svg { width: 16px; height: 16px; flex: none; color: var(--faint); }

/* A company logo replaces its initials once it has loaded, on white. */
/* `!important` on purpose: the logo must win over any channel or palette fill on the mark. */
.has-logo { background: none !important; padding: 0 !important; box-shadow: var(--shadow-logo); }
.brand-img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
/* Channel marks: the brand's own logo, the property icon for direct bookings. */
.mark-sm {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-inner);
  flex: none;
  display: inline-grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--slate-tint);
  color: var(--slate);
}
.is-direct svg { width: 60%; height: 60%; }
.plan-code.has-logo { width: 22px; box-shadow: 0 0 0 1px var(--bone-veil), 0 1px 2px var(--ink-glow); }
.plan-code.is-direct { width: 22px; padding: 0; }
.row-inline { display: inline-flex; align-items: center; gap: var(--space-2); }
/* Channel brand tones, everywhere a channel is drawn (bars, legend, logos, avatars). Each channel
   sets its fill and the ink that reads on it at 4.5:1 or better; the rules below apply them. */
.ch-booking { --ch: var(--ch-booking); --ch-ink: var(--ch-booking-ink); }
.ch-airbnb { --ch: var(--ch-airbnb); --ch-ink: var(--ch-airbnb-ink); }
.ch-expedia { --ch: var(--ch-expedia); --ch-ink: var(--ch-expedia-ink); }
.ch-agoda { --ch: var(--ch-agoda); --ch-ink: var(--ch-agoda-ink); }
.ch-vrbo { --ch: var(--ch-vrbo); --ch-ink: var(--ch-vrbo-ink); }
.ch-google { --ch: var(--ch-google); --ch-ink: var(--ch-google-ink); }
.ch-direct { --ch: var(--ch-direct); --ch-ink: var(--ch-direct-ink); }
/* The plain palette swatches (the restriction flags of the rates grid). */
.tone-blue { background: var(--blue); } .tone-orange { background: var(--action-orange); } .tone-green { background: var(--action-green); }
.tone-yellow { background: var(--action-yellow); } .tone-red { background: var(--action-red); }
.tone-rose { background: var(--rose); } .tone-lilac { background: var(--lilac); } .tone-slate { background: var(--slate); }
/* A mark carries text on the fill; a channel without a brand of its own is neutral. */
.ch-booking, .ch-airbnb, .ch-expedia, .ch-agoda, .ch-vrbo, .ch-google, .ch-direct,
/* The calendar's stays wear their channel's colour, whole: the owner's exception to the manual (03/11/2026). */
:is(.plan-bar, .channel-logo):is(.ch-booking, .ch-airbnb, .ch-expedia, .ch-agoda, .ch-vrbo, .ch-google, .ch-direct) {
  background: var(--ch);
  color: var(--ch-ink);
}
.plan-bar.slate, .channel-logo.slate { background: var(--slate); color: var(--ink-inverse); }
/* An armed icon-only button grows to hold its "Sure?". */
.btn.icon.armed { width: auto; padding: 0 var(--space-4); }

/* Small shared pieces that used to be inline styles. */
.pre { white-space: pre-wrap; }
.input.file { padding-top: var(--space-2); }
.photo-full { width: 100%; border-radius: var(--radius-inner); border: 1px solid var(--line); }
.photo-thumb { display: block; width: 56px; height: 40px; object-fit: cover; border-radius: var(--r-xs); }
.score-card { gap: calc(var(--gap) * 2); }
.thread-flags { margin-top: var(--space-1); }

/* Progress: a ring that fills to its share in the colour of its state, and the card it leads. */
.progress-ring {
  --size: 72px;
  --stroke: 7px;
  --track: var(--line);
  --fill: var(--surface);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--track) 0);
}
.progress-ring::before { content: ""; position: absolute; inset: var(--stroke); border-radius: 50%; background: var(--fill); }
.progress-ring span { position: relative; font-weight: 600; letter-spacing: -0.03em; font-size: var(--fs-md); }
.progress-ring.lg { --size: 104px; --stroke: 8px; }
.progress-ring.lg span { font-size: var(--fs-2xl); letter-spacing: -0.04em; }
/* The quarter gives the colour, the 5% step its depth: from 60% of the colour (on white) to all of it. */
.progress-ring { --depth: 100%; --ring: color-mix(in srgb, var(--state-colour, var(--ink)) var(--depth), var(--surface)); }
.progress-ring[data-state="ready"] { --state-colour: var(--state-ready); }
.progress-ring[data-state="going"] { --state-colour: var(--state-going); }
.progress-ring[data-state="todo"] { --state-colour: var(--state-todo); }
.progress-ring[data-state="missing"] { --state-colour: var(--state-missing); }
.progress-ring[data-step="0"] { --depth: 60%; }
.progress-ring[data-step="1"] { --depth: 70%; }
.progress-ring[data-step="2"] { --depth: 80%; }
.progress-ring[data-step="3"] { --depth: 90%; }
.progress-ring[data-step="4"] { --depth: 100%; }
.card.focal .progress-ring { --track: var(--midnight-line); --fill: var(--midnight); }
/* The card split in two that every progress uses: an empty midnight cover, the ring on its edge as a
   profile's photo, the aside across from it; under a hairline, the info and the actions. */
.progress-card { overflow: hidden; }
.progress-band { height: 72px; background: var(--midnight); }
.progress-top { align-items: flex-start; gap: var(--space-5); padding: 0 var(--pad) var(--space-4); }
.progress-open { margin-top: -52px; padding: 0; border: 0; background: none; border-radius: 50%; flex: none; color: inherit; }
button.progress-open { cursor: pointer; }
.progress-open .progress-ring { box-shadow: 0 0 0 4px var(--surface); }
button.progress-open:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.progress-status { padding-top: var(--space-4); }
/* No measure, no ring: the word for unknown stands where the ring would, in the ring's size. */
.progress-unmeasured { --size: 72px; width: var(--size); height: var(--size); flex: none; display: grid; place-items: center; color: var(--muted); font-weight: 600; font-size: var(--fs-md); }
.progress-unmeasured.lg { --size: 104px; font-size: var(--fs-2xl); }
.progress-unmeasured.sm { --size: 44px; font-size: var(--fs-sm); }
.progress-aside { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); text-align: right; padding-top: var(--space-5); min-width: 0; }
.progress-aside h2 { font-size: var(--fs-lg); }
.progress-foot { align-items: center; gap: var(--space-3); padding: var(--space-4) var(--pad); border-top: 1px solid var(--line); }
.progress-info { gap: var(--space-3); color: var(--muted); }
.progress-info svg { width: 16px; height: 16px; }
.progress-actions { justify-content: flex-end; gap: var(--space-2); }
.progress-state { font-weight: 600; }
.progress-state[data-state="ready"] { color: var(--state-ready); }
.progress-state[data-state="going"] { color: var(--action-yellow-text); }
.progress-state[data-state="todo"] { color: var(--state-todo); }
.progress-state[data-state="missing"] { color: var(--state-missing); }
/* A booking's aside: the channel's logo, the dates and the stay, on one line. */
.booking-line { justify-content: flex-end; flex-wrap: wrap; gap: var(--space-3); }
.booking-line .mark-sm { width: 24px; height: 24px; border-radius: 50%; }
.booking-dates { font-weight: 600; font-size: var(--fs-lg); letter-spacing: -0.01em; }
.check-ok, .check-missing { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check-ok { background: var(--action-green); color: var(--on-action); }
.check-missing { background: var(--action-red); color: var(--on-action); }
.check-ok svg, .check-missing svg { width: 13px; height: 13px; }

/* Printing: only the top sheet, on white, without its buttons. */
@media print {
  body { background: var(--paper) !important; }
  /* No printable sheet open: leave the screen alone. A sheet open: print only its top layer. */
  body.has-print-sheet > *:not(.print-sheet) { display: none !important; }
  .print-sheet {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
    border: 0 !important;
    transform: none !important;
    overflow: visible !important;
  }
  .print-sheet .sheet-body { overflow: visible !important; }
  /* Buttons are controls, never paper, wherever they sit; a button that carries content (a list
     row, the progress ring) is content and prints. */
  .print-sheet button:not(.list-item):not(.progress-open), .print-sheet .sheet-foot, .print-sheet .tabs { display: none !important; }
  /* A quote printed from the new-booking form: only the quote, never the form behind it. */
  body.printing-quote > *:not(.print-quote) { display: none !important; }
  body.printing-quote > .print-quote { display: block !important; }
}
/* The quote exists only on paper. */
.print-quote { display: none; color: var(--paper-ink); font-size: 12pt; }
.print-quote h1 { font-size: 22pt; margin: 4pt 0 2pt; }
.print-quote .kv { margin: 16pt 0; }
.print-quote-nights { width: 100%; border-collapse: collapse; margin: 8pt 0 12pt; }
.print-quote-nights th, .print-quote-nights td { text-align: left; padding: 4pt 0; border-bottom: 0.5pt solid var(--paper-rule); }
.print-quote-nights th:last-child, .print-quote-nights td:last-child { text-align: right; }
.print-page + .print-page { break-before: page; }
.print-page h1 { font-size: 20pt; margin: 4pt 0 2pt; }
.print-table { width: 100%; border-collapse: collapse; margin-top: 12pt; font-size: 10.5pt; }
.print-table th, .print-table td { text-align: left; vertical-align: top; padding: 6pt 6pt 6pt 0; border-bottom: 0.5pt solid var(--paper-rule); }
.print-table .print-box { font-size: 16pt; width: 18pt; }
.print-quote-nights tfoot th { border-bottom: 0; border-top: 1pt solid var(--paper-ink); font-size: 14pt; padding-top: 8pt; }
/* Photos as proof: small square thumbnails, removable, then the button that adds more. */
.photo-strip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.photo-thumb { position: relative; width: 72px; height: 72px; border-radius: var(--r-xs); overflow: hidden; border: 1px solid var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--midnight); color: var(--ink-inverse); cursor: pointer; padding: 0; }
.photo-remove svg { width: 12px; height: 12px; }
/* A line that says something can be done now (an early check-in can be sold). */
.meta.ok { color: var(--action-green); }

/* A place of the official tables, found by typing: the menu's look, under its field. */
.place-picker { position: relative; }
.place-list { position: absolute; top: calc(100% + var(--space-1)); left: 0; right: 0; max-height: 260px; overflow-y: auto; }
.place-list [aria-selected="true"] { background: var(--surface-hover); }
.place-list .ceased { color: var(--muted); }
.place-none { padding: var(--space-2) var(--space-4); }

/* The band card (kit-band.js): the figure on the left and its ring (or the channels) on the
   right, then the title with its actions and the body under a hairline. Oggi and the booking. */
.band-card { overflow: hidden; }
.head-band { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4) var(--space-6); padding: var(--pad); background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); }
.band-figures { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.head-band .mix { margin-top: 0; min-width: 200px; }
.band-ring { padding: 0; border: 0; background: none; border-radius: 50%; color: inherit; flex: none; }
button.band-ring { cursor: pointer; }
button.band-ring:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.head-band .progress-ring { --size: 84px; --stroke: 6px; --track: var(--line); --fill: var(--surface); }
.card.flush .band-title { padding: var(--space-4) var(--pad); margin-bottom: 0; border-bottom: 1px solid var(--line); }
.band-line { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.012em; }
.head-band .progress-ring span { font-size: var(--fs-lg); }
.band-body { padding: var(--space-2) var(--pad) var(--pad); }
.card.flush .band-title.actions-only { justify-content: flex-end; }
/* A card folded by default (details/summary): the head opens it. */
.fold-card > summary { list-style: none; cursor: pointer; padding: var(--pad); margin: 0; }
.fold-card > summary::-webkit-details-marker { display: none; }
.fold-card[open] > summary { border-bottom: 1px solid var(--line); }
.account-summary { font-weight: 600; margin: 0; }

/* A lease contract (contract-paper.js), on screen and on paper: the parties, the clauses, the
   signature that stays with the document. */
.contract-text { display: flex; flex-direction: column; gap: var(--space-3); font-size: var(--text-sm); line-height: 1.55; }
.contract-text h3 { font-size: var(--text-sm); margin: 0; }
.contract-text p { margin: 0; }
.contract-text .contract-parties { display: flex; flex-direction: column; gap: var(--space-1); }
.contract-details summary { cursor: pointer; font-weight: 600; }
.contract-page h2 { font-size: 12pt; margin: 14pt 0 4pt; }
.contract-page p { margin: 0 0 6pt; line-height: 1.5; }
.contract-page .contract-parties { margin: 12pt 0; }
.contract-signature { margin-top: 18pt; border-top: 0.5pt solid var(--paper-rule); padding-top: 10pt; }
