/* UbyHost host interface.
   Design language: warm paper background, calm white surfaces, one confident
   accent, and generous spacing. Status colour is reserved for status only, so
   a glance at a row tells you what the law still wants from you. */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font: 15.5px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
        "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink-2);
  background:
    radial-gradient(circle at 82% -8%, color-mix(in srgb, var(--purple-bg) 72%, transparent) 0, transparent 28rem),
    radial-gradient(circle at 36% -12%, color-mix(in srgb, var(--blue-bg) 65%, transparent) 0, transparent 34rem),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-underline-offset: 2px; }
a.plain { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- shell ------------------------------------------------------------- */

.layout-host { display: block; }

.appbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 28;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.3);
}
.appbar .brand { flex: 1; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.appbar-help {
  margin-left: auto;
  margin-right: 4px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
}
.appbar-help:hover { background: var(--surface-2); color: var(--ink); }
.appbar-search {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--blue) 20%, var(--line));
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--blue-bg), var(--purple-bg));
  color: var(--blue);
  font: 22px/1 var(--font-sans);
  cursor: pointer;
}

.nav-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.nav-toggle:hover { background: var(--surface-2); }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(22, 25, 27, 0.36);
  border: 0;
  padding: 0;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--purple-bg) 34%, var(--surface)) 0, var(--surface) 210px);
  border-right: 1px solid var(--line);
  color: var(--ink);
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  z-index: 30;
  transition: transform 0.26s var(--ease);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 6px 20px;
}
.sidebar-brand-actions { display: flex; align-items: center; gap: 6px; }
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--canvas);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.nav-group { display: grid; gap: 2px; }
.nav-label {
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0 10px 6px;
  text-transform: uppercase;
}
.sidebar-brand .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-word {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 12px 16px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line));
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--orange-bg) 55%, var(--surface)));
  box-shadow: 0 4px 14px rgba(35, 30, 28, .05);
}

.sidebar-user-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 15px;
  font-weight: 700;
  flex: 0 0 auto;
}

.sidebar-user-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sidebar-user-meta strong {
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-meta span {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav a, .nav-button {
  color: var(--ink-2);
  text-decoration: none;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  width: 100%;
  transition: background 0.14s ease, color 0.14s ease;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--faint);
}

.sidebar-nav a:hover, .nav-button:hover { background: var(--surface-3); color: var(--ink); }
.sidebar-nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.sidebar-nav a.active .nav-icon { color: var(--brand); }
.nav-group:nth-child(1) .nav-icon { color: var(--blue); }
.nav-group:nth-child(2) .nav-icon { color: var(--purple); }
.nav-group:nth-child(3) .nav-icon { color: var(--teal); }
.nav-group:nth-child(1) a.active { background: var(--blue-bg); color: var(--blue); }
.nav-group:nth-child(2) a.active { background: var(--purple-bg); color: var(--purple); }
.nav-group:nth-child(3) a.active { background: var(--teal-bg); color: var(--teal); }
.sidebar-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 5px;
}
.sidebar-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  padding: 0 2px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
}
.sidebar-footer-links a {
  color: var(--muted);
  text-decoration: none;
}
.sidebar-footer-links a:hover { color: var(--brand); }
.sidebar-footer-sep {
  color: var(--faint);
  font-weight: 400;
  user-select: none;
}
.guest-card-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.sidebar-footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-footer-row .lang-switch.compact {
  flex: 0 0 auto;
  width: fit-content;
}
.sidebar-logout { margin: 0; padding: 0; flex-shrink: 0; }
.sidebar-logout .nav-button {
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.sidebar-logout .nav-button:hover {
  background: var(--surface-3);
  border-color: var(--line-2);
  color: var(--ink);
}

.lang-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-switch button.is-active {
  background: var(--ink);
  color: var(--canvas);
}

.sidebar-collapse, .sidebar-expand {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.sidebar-collapse:hover, .sidebar-expand:hover { background: var(--surface-3); color: var(--ink); }
.sidebar-expand {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 25;
  width: 34px;
  height: 34px;
  box-shadow: var(--shadow);
}
body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar) - 12px));
}
body.sidebar-collapsed .sidebar-expand { display: grid; }
body.sidebar-collapsed .wrap.with-sidebar { margin-left: 0; }

.env-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--pill);
  background: var(--surface-3);
  color: var(--muted);
}
.env-badge.prod { background: var(--bad-soft); color: var(--bad); }
.env-badge.test { background: var(--warn-soft); color: var(--warn); }
/* Dashed, so "practice server" is not mistaken for "test credentials" at a
   glance - the two used to render identically. */
.env-badge.mock {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px dashed currentColor;
  padding: 2px 7px;
}
.env-badge.production { background: var(--bad-soft); color: var(--bad); }
.env-badge.staging { background: var(--accent-soft); color: var(--accent); }
.env-badge.local { background: var(--muted-soft, #eee); color: var(--muted); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 24px 96px; }
.wrap.with-sidebar {
  margin-left: var(--sidebar);
  max-width: none;
  transition: margin-left 0.26s var(--ease);
}
.wrap.with-sidebar > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.wrap.narrow { max-width: 620px; }
.no-nav .wrap { max-width: 840px; }
.no-nav .page-header {
  position: static;
  margin: -8px 0 24px;
  padding: 28px;
  border: 1px solid color-mix(in srgb, var(--purple) 14%, var(--border));
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 88% 15%, var(--purple-bg), transparent 42%),
    linear-gradient(135deg, var(--brand-soft), var(--surface));
  backdrop-filter: none;
}
.no-nav .panel { border-radius: var(--radius-lg); padding: 24px; }

/* --- type -------------------------------------------------------------- */

h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.035em; margin: 0 0 6px; font-weight: 700; color: var(--ink); }
h2 { font-size: 19px; margin: 32px 0 12px; font-weight: 660; letter-spacing: -0.02em; color: var(--ink); }
h3 { font-size: 14px; margin: 22px 0 8px; font-weight: 660; color: var(--ink); letter-spacing: -0.01em; }
p.lede { color: var(--muted); margin: 0 0 20px; font-size: 15.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.page-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: -32px -24px 24px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--canvas) 94%, transparent);
  backdrop-filter: blur(12px);
}
.page-header-main { flex: 1 1 auto; min-width: 0; }
.page-header .lede { margin-bottom: 0; max-width: 660px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 6px; }
.back-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; font-weight: 600; margin-bottom: 12px; text-decoration: none; color: var(--muted); }
.back-link:hover { color: var(--brand); }

.breadcrumbs { margin: 0 0 14px; }
.breadcrumbs ol { display: flex; gap: 7px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.breadcrumbs li { color: var(--faint); font-size: 13px; }
.breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 7px; color: var(--line-2); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--brand); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
input.sr-only { width: 1px !important; height: 1px !important; padding: 0 !important; }

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 10000;
  padding: 10px 16px;
  background: var(--brand-ink);
  color: var(--canvas);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus {
  top: 12px;
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* --- surfaces ---------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.panel.tight { padding: 0; overflow: hidden; }
.panel.quiet { background: var(--surface-2); box-shadow: none; }

.empty { text-align: center; padding: 48px 22px; color: var(--muted); }
.empty h2 { margin-top: 0; }

/* --- banners and toasts ------------------------------------------------ */

.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  font-size: 14.5px;
}
.banner .grow { flex: 1; min-width: 0; }
.banner strong { display: block; color: inherit; }
.banner small { display: block; opacity: 0.9; margin-top: 4px; }
.banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }
.banner.err, .banner.critical { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); color: var(--bad); }
.banner.warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.banner.info { background: var(--brand-soft); border-color: rgba(31, 86, 214, 0.18); color: var(--brand-ink); }
.banner a { color: inherit; font-weight: 650; }

.toast-stack {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 460px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--canvas);
  box-shadow: var(--shadow-lg);
  font-size: 14.5px;
  pointer-events: auto;
  animation: toast-in 0.26s var(--ease);
}
.toast.err { background: #8e241c; }
.toast .grow { flex: 1; }
.toast button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.toast button:hover { color: var(--canvas); }
.toast form { margin: 0; }
.toast button.toast-undo {
  padding: 2px 4px;
  color: var(--canvas);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.toast.leaving { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Environment honesty. Status colour is reserved for status, so these read as
   a standing condition of the workspace rather than a row state. */
.env-banner {
  display: grid;
  gap: 2px;
  margin-bottom: 20px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid;
  border-left-width: 4px;
}
.env-banner strong { font-size: 14px; font-weight: 700; }
.env-banner span { font-size: 13px; line-height: 1.5; }
.env-banner.mock {
  border-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
}
.env-banner.prod {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

.impersonation-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid rgba(200, 90, 82, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--brand-soft), var(--surface));
}

.impersonation-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.impersonation-eyebrow {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-ink);
}

.impersonation-copy strong {
  font-size: 16px;
  color: var(--ink);
}

.impersonation-handle {
  font-size: 13px;
  color: var(--muted);
}

.impersonation-bar form { margin: 0; flex: 0 0 auto; }

.user-table .row-actions { min-width: 56px; }

.admin-dialog {
  width: min(100%, 420px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.admin-dialog::backdrop { background: rgba(22, 25, 27, 0.42); }

.admin-dialog-form {
  display: grid;
  gap: 12px;
  padding: 24px;
  margin: 0;
}

/* Alerts behave like phone notifications: they arrive above the page instead
   of moving it, the whole message opens the relevant item, and × dismisses it
   without a navigation. */
.notification-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 70;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}
.notification-bubble {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: notification-in 0.32s var(--ease);
}
.notification-bubble.leaving { animation: notification-out 0.22s ease forwards; }
.notification-link {
  display: flex;
  gap: 12px;
  padding: 14px 42px 14px 14px;
  color: var(--ink);
  text-decoration: none;
}
a.notification-link:hover { background: var(--surface-2); }
.notification-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--bad);
  color: var(--canvas);
  font-weight: 750;
}
.notification-bubble.warning .notification-icon { background: var(--warn); }
.notification-bubble.info .notification-icon { background: var(--brand); }
.notification-bubble strong { display: block; font-size: 14px; line-height: 1.35; }
.notification-bubble small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.4; }
.notification-bubble .notification-action { color: var(--brand); font-weight: 650; }
.notification-bubble form { position: absolute; top: 9px; right: 9px; }
.notification-bubble form button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}
.notification-bubble form button:hover { background: var(--surface-3); color: var(--ink); }
@keyframes notification-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
}
@keyframes notification-out {
  to { opacity: 0; transform: translateX(24px) scale(0.97); }
}

/* --- metric tiles ------------------------------------------------------ */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}
.stat-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.stat .n { font-size: 30px; font-weight: 720; letter-spacing: -0.035em; color: var(--ink); line-height: 1.1; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 550; margin-top: 2px; }
.stat.bad .n { color: var(--bad); }
.stat.warn .n { color: var(--warn); }
.stat.ok .n { color: var(--ok); }
/* A count of nothing is not news. Fading the zeros leaves only the numbers
   that actually want the host's attention. */
.stat.zero .n { color: var(--line-2); }

/* --- focus card: the one thing to do next ------------------------------ */

.focus-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 20px 22px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  box-shadow: var(--shadow);
}
.focus-card .focus-main { flex: 1 1 280px; min-width: 0; }
.focus-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.focus-eyebrow .dot { width: 7px; height: 7px; border-radius: var(--pill); background: var(--brand); }
.focus-card.is-overdue .focus-eyebrow .dot { background: var(--bad); }
.focus-card.is-overdue { border-color: rgba(195, 47, 36, 0.24); }
.focus-title { font-size: 21px; font-weight: 700; letter-spacing: -0.025em; color: var(--ink); margin: 0 0 4px; }
.focus-title a { color: inherit; text-decoration: none; }
.focus-title a:hover { color: var(--brand); }
.focus-meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.focus-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.focus-actions .btn.accent { white-space: nowrap; }
.page-toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}
.page-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.page-toolbar-row form { margin: 0; }
.page-toolbar-meta { margin: 0; font-size: 12px; line-height: 1.35; }
.entity-edit-panel { margin-bottom: 16px; }

/* --- tables ------------------------------------------------------------ */

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th {
  text-align: left;
  font-size: 12.5px;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  font-weight: 600;
}
td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.clickable-row { cursor: pointer; }
.clickable-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; background: var(--brand-soft); }
.clickable-row.row-selected { background: var(--brand-soft); }
.password-generate {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}
.password-generate input {
  flex: 1 1 180px;
  min-width: 0;
}
.row-primary-link { color: var(--ink); font-weight: 650; text-decoration: none; }
.clickable-row:hover .row-primary-link { color: var(--brand); }
.scroll-x { overflow-x: auto; }
/* Eleven columns of legal record. The columns holding free text need a width
   floor of their own, or the browser spends the room on the short ones and
   folds every name onto three lines. Past that the table scrolls sideways. */
.col-name { min-width: 122px; }
.col-address { min-width: 176px; }
.col-purpose { min-width: 100px; }

/* --- status pills ------------------------------------------------------ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--pill);
  white-space: nowrap;
  line-height: 1.35;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--pill);
  background: currentColor;
  opacity: 0.75;
  flex: 0 0 auto;
}
.pill.no-dot::before { display: none; }
.pill.grey { background: var(--gray-bg); color: var(--gray); }
.pill.blue { background: var(--brand-soft); color: var(--brand-ink); }
.pill.green { background: var(--ok-soft); color: var(--ok); }
.pill.amber { background: var(--warn-soft); color: var(--warn); }
.pill.red { background: var(--bad-soft); color: var(--bad); }
.pill.orange, .tone-orange { background: var(--orange-bg); color: var(--orange); }
.pill.teal, .tone-teal { background: var(--teal-bg); color: var(--teal); }
.pill.indigo, .tone-indigo { background: var(--indigo-bg); color: var(--indigo); }
.pill.purple, .tone-purple { background: var(--purple-bg); color: var(--purple); }
.pill.pink, .tone-pink { background: var(--pink-bg); color: var(--pink); }
.pill.brown, .tone-brown { background: var(--brown-bg); color: var(--brown); }

.deadline { font-weight: 600; font-size: 13.5px; }
.deadline.urgent { color: var(--bad); }
/* "Act today" and "already late" are different jobs: one is still compliant,
   the other is a breach where re-sending is penalised. Same red read as the
   same row, so past-deadline gets the filled treatment. */
.deadline.overdue {
  color: var(--bad);
  background: var(--bad-soft);
  padding: 2px 8px;
  border-radius: var(--pill);
  white-space: nowrap;
}
.deadline.soon { color: var(--warn); }
.deadline.ok { color: var(--ok); }
.deadline.future { color: var(--muted); font-weight: 500; }

/* --- forms ------------------------------------------------------------- */

form.inline { display: inline; }
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
label .opt { font-weight: 400; color: var(--faint); text-transform: none; }

input[type=text], input[type=password], input[type=date], input[type=number], input[type=email],
input[type=url], input[type=file], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%236b7378' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}
input.bad, select.bad, textarea.bad { border-color: var(--bad); background: var(--bad-soft); }
textarea { min-height: 82px; resize: vertical; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.field .err { font-size: 13px; color: var(--bad); margin-top: 5px; font-weight: 550; }
.field-disabled label, .field-disabled .hint { color: var(--faint); }
.field-disabled input, .field-disabled select {
  opacity: 0.6;
  background: var(--surface-3);
  pointer-events: none;
}

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(275px, 1fr)); }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.checkline input { width: auto; margin-top: 3px; accent-color: var(--brand); }
.checkline label { font-weight: 500; margin: 0; font-size: 14.5px; }

/* --- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 17px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(0.985); }

/* Dark = the main action of a form or page. */
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }

/* Blue = send to the police. The one thing the law is waiting for. */
.btn.accent, .btn.send-all {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(31, 86, 214, 0.24), 0 6px 16px rgba(31, 86, 214, 0.18);
}
.btn.accent:hover, .btn.send-all:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}
.btn.send-all { font-weight: 680; }
.btn.send-all:disabled, .btn.accent:disabled {
  background: var(--surface);
  border-color: var(--line-2);
  color: var(--faint);
  box-shadow: none;
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: rgba(195, 47, 36, 0.3); }
.btn.danger:hover { background: var(--bad-soft); border-color: rgba(195, 47, 36, 0.45); }
.btn.small { padding: 7px 13px; font-size: 13.5px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: var(--surface); border-color: var(--line-2); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.btn.disabled { opacity: 0.45; pointer-events: none; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 20px 0;
}
.pagination-label { color: var(--muted); font-size: 13.5px; font-weight: 600; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.btn-icon:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand); }
.btn-icon.copied { color: var(--ok); border-color: rgba(15, 122, 74, 0.4); background: var(--ok-soft); }

/* --- sticky action bar ------------------------------------------------- */

.action-bar {
  position: sticky;
  top: 12px;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.action-bar .bar-note { flex: 1 1 220px; color: var(--muted); font-size: 13.5px; min-width: 0; }
.inline-edit-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: -8px 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.inline-edit-bar > strong { align-self: center; font-size: var(--text-sm); }
.inline-edit-bar label { flex: 1; margin: 0; color: var(--ink-muted); font-size: var(--text-xs); }
.inline-edit-bar input { height: 34px; margin-top: 3px; padding: 6px 8px; font-size: var(--text-sm); }
.inline-edit-bar label:nth-of-type(2) { max-width: 130px; }
.inline-edit-status { align-self: center; min-width: 48px; color: var(--green); font-size: var(--text-sm); }
@media (max-width: 720px) {
  .inline-edit-bar { align-items: stretch; flex-direction: column; }
  .inline-edit-bar label:nth-of-type(2) { max-width: none; }
}

/* --- row actions and menus --------------------------------------------- */

/* Always a <td>. Flexing it would take the cell out of the table layout, so
   the column grid and the row hairlines stop lining up. Keep it a table cell
   and space the buttons with margins instead. */
.row-actions { text-align: right; }
.row-actions > * { vertical-align: middle; }
.row-actions > * + * { margin-left: 6px; }
.row-actions .btn.small { padding: 6px 12px; font-size: 13px; }
.row-actions .row-action-form { display: inline-flex; margin: 0; }
.row-actions .btn.small.row-action-send:disabled { opacity: 0.45; }

.row-menu { position: relative; display: inline-flex; }
/* Only the icon-only trigger is a fixed square; a trigger with a label in it
   has to size to its text. */
.btn-icon.row-menu-trigger { width: 34px; height: 34px; }
.row-menu-panel {
  min-width: 180px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  z-index: 10000;
}
.row-menu-panel.is-open { position: fixed; }
.row-menu-panel[hidden] { display: none; }
.row-menu-form { display: block; margin: 0; }
.row-menu-item {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.row-menu-item:hover { background: var(--brand-soft); color: var(--brand-ink); }
.row-menu-item.danger { color: var(--bad); }
.row-menu-item.danger:hover { background: var(--bad-soft); color: var(--bad); }
/* A supporting item, set below a hairline so it does not compete with the
   actions above it. */
.row-menu-item.quiet {
  margin-top: 5px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  border-radius: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.help-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  cursor: help;
}
.technical-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 8px;
}
.technical-download { display: inline-flex; align-items: center; }
.help-dot:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
.action-menu .menu-caret { font-size: 10px; opacity: 0.6; }
.page-actions .action-menu .row-menu-panel { min-width: 210px; }

/* --- chips and filters ------------------------------------------------- */

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: var(--pill);
  padding: 7px 15px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-2);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.chip:hover { background: var(--surface-2); border-color: var(--border-strong); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--canvas); }

.filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters .field { flex: 1 1 150px; min-width: 140px; max-width: 210px; margin: 0; }
.filters .filter-actions {
  flex: 0 0 auto;
  max-width: none;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.filters .filter-actions .btn, .filters > .btn {
  height: 44px;
  padding-top: 0;
  padding-bottom: 0;
}
.filters .filter-actions-end {
  flex: 0 0 auto;
  max-width: none;
  justify-content: flex-end;
  align-items: flex-end;
  margin-left: auto;
  padding-top: 0;
}
.filters .housebook-toolbar-actions {
  flex: 1 1 100%;
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin-left: 0;
  padding-top: 4px;
}
.filters .housebook-toolbar-actions .btn { height: 44px; }
.filters .housebook-toolbar-actions .action-menu { margin: 0; }
.filters .csv-in-filter .row-menu-trigger { height: 44px; }
.housebook-pdf-warn {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--ink-2);
}
.housebook-legal-dialog .legal-list { margin-top: 8px; }
.filters input[type=date], .filters input[type=text], .filters select { height: 44px; }

.minutes-saved {
  margin: -6px 0 14px;
  font-size: 12px;
  color: var(--faint);
  text-align: right;
}
.reporting-modes-panel {
  padding: 14px 16px;
  margin-bottom: 14px;
}
.reporting-modes-panel h2 { font-size: 15px; margin: 0 0 6px; }

.signature-pad {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.signature-pad canvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none;
  background: var(--surface);
  cursor: crosshair;
}
.signature-pad-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
}
.signature-pad-bar button {
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.passport-preview {
  margin: 12px 0;
  max-width: 420px;
}
.passport-preview img,
.passport-preview-pdf {
  display: block;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.passport-preview-pdf {
  height: 520px;
  background: #fff;
}
.verify-panel .verify-form {
  margin-top: 8px;
}
.verify-inline {
  margin-top: 12px;
  padding: 12px 14px;
}

.legal-fineprint {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--faint);
}
.housebook-legal {
  margin-top: 28px;
}
.housebook-legal > summary {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}
.legal-list {
  margin: 10px 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}
.legal-list li {
  margin: 0.45rem 0;
}
.guide-legal h3 {
  font-size: 14px;
  margin: 18px 0 6px;
}
.legal-disclaimer {
  margin-top: 18px;
  border-color: var(--line);
}
.compact-filters summary { color: var(--brand); font-size: 13.5px; font-weight: 600; }
/* With scripting the filters apply themselves, so Apply is only a fallback. */
.has-js form[data-auto-submit] .filter-apply { display: none; }

/* --- layout helpers ---------------------------------------------------- */

.split { display: grid; gap: 20px; grid-template-columns: 1fr; }
/* Grid items default to min-width:auto, so a wide table would push its column
   past its share and squeeze the sidebar into a ribbon. */
.split > * { min-width: 0; }
@media (min-width: 960px) {
  .split.wide { grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); align-items: start; }
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink-2); }

.copyrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copyrow input { flex: 1 1 220px; min-width: 0; font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; }
.copyrow.pin-row input { flex: 0 0 110px; text-align: center; letter-spacing: 0.12em; }

/* A guest-link card carries a full URL, a PIN, and a message to paste, so it
   needs real width. Two up on a laptop, one up on a phone. */
.link-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.link-card { display: flex; flex-direction: column; }
/* Push the trailing actions down so cards of unequal height still line up, and
   rule them off so they read as a card footer rather than a second button row. */
.link-card > .actions:last-child {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.message-details .actions { margin-top: 12px; }
@media (max-width: 560px) {
  .link-cards { grid-template-columns: 1fr; }
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 0 12px;
}
.section-heading h2 { margin: 0; }
.section-heading a { font-size: 13.5px; font-weight: 600; text-decoration: none; }
.section-heading a:hover { text-decoration: underline; }

.task-row-main { min-width: 230px; }
.task-title { color: var(--ink); font-weight: 650; text-decoration: none; }
.next-action { color: var(--muted); font-size: 13px; margin-top: 4px; }
.status-summary { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

.detail-hero {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.detail-metric { padding: 18px 20px; background: var(--surface); }
.detail-metric + .detail-metric { border-left: 1px solid var(--line); }
.metric-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.metric-value { font-size: 21px; font-weight: 700; letter-spacing: -0.025em; color: var(--ink); margin-top: 6px; }
.metric-value.small-value { font-size: 15px; font-weight: 600; }
.metric-value.deadline { font-size: 21px; font-weight: 700; }
.metric-note { color: var(--muted); font-size: 13px; margin-top: 5px; }

/* --- guest cards -------------------------------------------------------- */

.guest-cards { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 14px; }
.guest-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.guest-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.guest-card-who { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; min-width: 0; }
.guest-card-who h3 { margin: 0; font-size: 17.5px; letter-spacing: -0.01em; }
.guest-card-state { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.guest-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 24px;
  margin: 0;
}
.guest-facts > div { min-width: 0; }
.guest-facts .fact-wide { grid-column: span 2; }
.guest-facts dt {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.guest-facts dd { margin: 0; color: var(--ink); font-size: 14.5px; overflow-wrap: anywhere; }
.guest-facts .fact-extra { color: var(--muted); font-family: inherit; font-size: 13px; }

.guest-card-note { margin: 14px 0 0; font-size: 13.5px; color: var(--muted); }
.warn-text { color: var(--warn); }

@media (max-width: 560px) {
  .guest-facts { grid-template-columns: 1fr; }
  .guest-facts .fact-wide { grid-column: auto; }
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 22px;
  margin-top: 14px;
}
.settings-grid .settings-actions { grid-column: 1 / -1; margin-top: 4px; }

.setup-list { display: grid; gap: 2px; margin-top: 16px; }
.setup-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.setup-item:first-child { border-top: 0; }
.setup-item .grow { flex: 1; min-width: 0; }
.setup-item .mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--pill);
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 800;
  font-size: 13px;
  flex: 0 0 auto;
}
a.setup-item { color: inherit; text-decoration: none; }
a.setup-item:hover .grow strong { color: var(--brand); }

/* One disclosure affordance everywhere: a chevron that turns. The browser
   default triangle is drawn differently by each engine and reads as debug UI. */
summary { display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.45;
  transform: rotate(-45deg);
  transition: transform 0.16s var(--ease);
}
details[open] > summary::before { transform: rotate(45deg); }

details.panel > summary { font-size: 15.5px; font-weight: 600; color: var(--ink); }
details.panel[open] > summary { margin-bottom: 8px; }
.technical summary, .danger-zone summary, .message-details summary { font-weight: 650; }
.message-details { margin-top: 20px; }
.message-details[open] .message-template { margin-top: 10px; }
.danger-zone { border-color: rgba(195, 47, 36, 0.22); box-shadow: none; }

details.raw summary { font-weight: 600; font-size: 13.5px; margin-top: 10px; }
details.raw pre {
  background: #14181a;
  color: #d8e0e6;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: 12px;
  max-height: 340px;
}

.section-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.section-nav a {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--pill);
  text-decoration: none;
}
.section-nav a:hover { color: var(--brand-ink); background: var(--brand-soft); }

.message-template {
  white-space: pre-wrap;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--ink-2);
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.import-guide { font-size: 14px; color: var(--muted); }

.code-block {
  margin: 8px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  overflow: auto;
  max-height: 320px;
}

.err-text { color: var(--bad); }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { .truncate { max-width: none; white-space: normal; overflow-wrap: anywhere; } }
.import-guide ol { margin: 8px 0 0; padding-left: 18px; }
.import-guide li { margin-bottom: 6px; }

.action-panel { margin-bottom: 18px; }
.action-panel.hidden { display: none; }

.csv-export-dialog {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
}
.csv-export-dialog::backdrop { background: rgba(22, 25, 27, 0.4); }
.csv-export-dialog form { padding: 24px; margin: 0; }

/* --- responsive -------------------------------------------------------- */

@media (max-width: 960px) {
  .appbar { display: flex; }
  .sidebar {
    width: min(86vw, 320px);
    transform: translateX(-105%);
    box-shadow: var(--shadow-lg);
    border-radius: 0 18px 18px 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .sidebar-collapse { display: none; }
  .sidebar-expand { display: none !important; }
  body.sidebar-collapsed .sidebar { transform: translateX(-105%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; }
  .wrap.with-sidebar { margin-left: 0; padding: 20px 16px 80px; }
  body.sidebar-collapsed .wrap.with-sidebar { margin-left: 0; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-header { top: 59px; margin: -20px -16px 20px; padding: 16px; }
  .detail-hero { grid-template-columns: 1fr; }
  .detail-metric + .detail-metric { border-left: 0; border-top: 1px solid var(--line); }
  h1 { font-size: 25px; }
  .no-nav .wrap { padding-top: 16px; }
  .no-nav .page-header { margin: 0 0 18px; padding: 22px 20px; }
}

@media (max-width: 420px) {
  .appbar { padding: 8px 10px; }
  .appbar-help { display: none; }
  .appbar .env-badge { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-user { margin-inline: 4px; }
  .sidebar-nav { gap: 15px; }
}

/* Stacked table rows: on a phone a row becomes a small card, so the daily
   work stays usable without pinch-zooming. */
@media (max-width: 720px) {
  .notification-stack { top: 10px; right: 10px; width: calc(100vw - 20px); }
  .pagination { justify-content: space-between; }
  .table-cards thead { display: none; }
  .col-name, .col-address, .col-purpose { min-width: 0; }
  /* The row becomes the card and each cell becomes a labelled fact, laid out
     like .guest-facts so both halves of the app read the same way. Two facts
     fit side by side; the identifying cell and the actions span the width. */
  .table-cards tr {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 13px 18px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
  }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }
  .table-cards td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 3px;
  }
  .table-cards td:empty { display: none; }
  .table-cards td[data-label=""]::before { display: none; }
  .table-cards td:first-child,
  .table-cards td.row-actions { grid-column: 1 / -1; }
  .table-cards td.num, .table-cards td.row-actions { text-align: left; }
  .table-cards td.nowrap { white-space: normal; }
  .table-cards td.row-actions > * + * { margin-left: 6px; }
  .filters .field { max-width: none; }
  .action-bar { position: static; }
}

/* --- onboarding -------------------------------------------------------- */

.onboarding-welcome {
  text-align: center;
  padding: 42px 28px 36px;
  background:
    radial-gradient(ellipse at top, rgba(200, 90, 82, 0.08), transparent 58%),
    var(--surface);
}

.onboarding-logo {
  display: block;
  width: min(220px, 72vw);
  height: auto;
  margin: 0 auto 18px;
}

.onboarding-welcome h2 {
  margin: 0 0 10px;
  font-size: clamp(26px, 5vw, 32px);
  letter-spacing: -0.03em;
}

.onboarding-welcome .lede {
  max-width: 52ch;
  margin: 0 auto 24px;
}

.onboarding-steps {
  display: grid;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto 24px;
  text-align: left;
}

.onboarding-step {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.onboarding-step.is-current {
  border-color: rgba(200, 90, 82, 0.35);
  background: var(--brand-soft);
  box-shadow: var(--shadow-sm);
}

.onboarding-step.is-done { opacity: 0.82; }

.onboarding-step-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.onboarding-step.is-done .onboarding-step-index {
  background: var(--ok-soft);
  border-color: rgba(15, 122, 74, 0.25);
  color: var(--ok);
}

.onboarding-step.is-current .onboarding-step-index {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.onboarding-step h3 {
  margin: 0;
  font-size: 15px;
}

.onboarding-step p {
  margin: 3px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}

.onboarding-banner {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid rgba(200, 90, 82, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--brand-soft), var(--surface));
}

.onboarding-banner strong { display: block; font-size: 14px; }
.onboarding-banner small { color: var(--muted); }

.onboarding-demo {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.brand-logo,
.auth-logo,
.auth-hero-mark,
.onboarding-logo {
  display: block;
  height: auto;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: transparent;
}

.brand-logo { height: 30px; }
.sidebar-brand .brand-logo { height: 28px; }
.appbar .brand-logo { height: 24px; }
.onboarding-logo { width: min(120px, 34vw); height: auto; }
.auth-logo { width: min(220px, 70vw); height: auto; }
.auth-hero-mark { width: 72px; height: 72px; margin-bottom: 18px; opacity: 0.95; }

/* --- auth pages (login, first password) -------------------------------- */

.auth-page {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 6vw, 72px) clamp(24px, 5vw, 64px);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.auth-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(32px, 6vw, 72px);
  background:
    radial-gradient(120% 80% at 20% 20%, rgba(232, 106, 88, 0.14), transparent 55%),
    linear-gradient(160deg, var(--surface) 0%, var(--canvas-subtle) 100%);
  border-left: 1px solid var(--line);
}

.auth-hero-inner {
  max-width: 420px;
}

.auth-hero h2 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.auth-hero p {
  margin: 0;
  font-size: 17px;
  line-height: 1.55;
  color: var(--muted);
}

.auth-lang-switch {
  margin-bottom: 18px;
  width: fit-content;
}

.auth-brand {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 36px;
}

.auth-card { text-align: left; }

.auth-title {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--ink);
}

.auth-lede {
  margin: 0 0 28px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--muted);
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.auth-remember input { width: 16px; height: 16px; accent-color: var(--brand); }

.auth-alert {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--bad) 28%, transparent);
  border-radius: 12px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
}

.auth-form {
  display: grid;
  gap: 16px;
  text-align: left;
}

.auth-field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.auth-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input::placeholder { color: var(--ink-faint); }

.auth-field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.auth-hint {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease;
}

.auth-submit:hover { background: var(--brand-hover); }

.auth-foot-legal {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  line-height: 1.45;
}

.auth-foot-acceptance {
  margin: 0 0 8px;
  color: var(--muted);
}

.auth-foot-links {
  margin: 0;
  font-size: 12.5px;
}

.auth-foot-legal a { color: var(--muted); text-decoration: none; }
.auth-foot-legal a:hover { color: var(--brand); }

.auth-acceptance {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.auth-acceptance a {
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-acceptance a:hover { color: var(--brand); }

.auth-foot {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.auth-foot p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.auth-foot p:last-child { margin-bottom: 0; }

.auth-foot strong { color: var(--ink-2); font-weight: 650; }

.auth-setup-hint {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--canvas-subtle);
  border: 1px solid var(--border);
}

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { max-width: none; }
}

/* --- help guide -------------------------------------------------------- */

.guide-layout {
  display: grid;
  gap: 18px;
  align-items: start;
}
@media (min-width: 900px) {
  .guide-layout { grid-template-columns: 200px minmax(0, 1fr); }
}
.guide-nav {
  display: grid;
  gap: 2px;
  padding: 12px;
  position: sticky;
  top: 16px;
}
.guide-nav-link {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.guide-nav-link:hover { background: var(--surface-3); color: var(--ink); }
.guide-section h2 { margin-top: 0; }
.guide-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: 10px; }
.guide-figure {
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}
.guide-figure img {
  display: block;
  width: 100%;
  height: auto;
}
.guide-figure figcaption {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.guide-shot {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.guide-shot-bar { height: 10px; background: var(--surface-3); }
.guide-shot-body { display: flex; min-height: 120px; }
.guide-shot-sidebar {
  width: 22%;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.guide-shot-main { flex: 1; padding: 14px; display: grid; gap: 10px; align-content: start; }
.guide-shot-card {
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
.guide-shot-card.short { width: 55%; }
.guide-shot.guest { display: grid; place-items: center; padding: 20px; }
.guide-shot-phone {
  width: 140px;
  padding: 16px 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.guide-shot-line { height: 8px; border-radius: 4px; background: var(--surface-3); }
.guide-shot-line.wide { width: 80%; }
.guide-shot-btn {
  height: 28px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid rgba(200, 90, 82, 0.25);
}

/* --- milestone celebration --------------------------------------------- */

.celebration-dialog {
  border: 0;
  padding: 0;
  max-width: min(420px, calc(100vw - 32px));
  background: transparent;
}
.celebration-dialog::backdrop {
  background: rgba(31, 26, 24, 0.45);
  backdrop-filter: blur(3px);
}
.celebration-card {
  padding: 28px 24px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, var(--surface) 0%, var(--brand-soft) 100%);
  border: 1px solid rgba(200, 90, 82, 0.2);
  box-shadow: var(--shadow-pop);
  text-align: center;
}
.celebration-badge {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brand), #e07a5f);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  box-shadow: 0 8px 24px rgba(200, 90, 82, 0.35);
}
.celebration-card h2 { margin: 0 0 8px; font-size: 22px; }
.celebration-card p { margin: 0 0 18px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }

/* Shown once, in the response body, because a credential must never travel in
   a URL where history and proxy logs would keep it. */
.credential-once { border-left: 4px solid var(--warn); background: var(--warn-soft); margin-bottom: 18px; }
.credential-once h2 { margin: 0 0 6px; font-size: 17px; }
.credential-once p { margin: 0 0 12px; }
.credential-pair { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; align-items: baseline; }
.credential-pair dt { color: var(--muted); font-size: 13px; }
.credential-pair dd { margin: 0; }
.credential-secret { font-size: 18px; font-weight: 600; user-select: all; letter-spacing: 0.02em; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #111; font-size: 10pt; }
  .sidebar, .appbar, .sidebar-expand, .page-actions, .filters, .chips,
  .row-actions, .action-bar, .toast-stack, .notification-stack,
  .onboarding-banner, dialog { display: none !important; }
  .wrap.with-sidebar, .wrap { max-width: none; margin: 0; padding: 0; }
  .page-header { position: static; margin: 0 0 16pt; padding: 0 0 8pt; background: none; }
  .panel { break-inside: avoid; border-color: #bbb; background: #fff; }
  table { font-size: 8pt; }
  th, td { padding: 5pt; color: #111; background: #fff; }
  a { color: #111; text-decoration: none; }
}
