:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #687384;
  --line: #d9dee7;
  --accent: #1f7a6d;
  --sidebar-width: 320px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  min-height: 100vh;
}

.app-main {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.app-main--wide {
  width: min(1240px, calc(100% - 32px));
}

.tenant-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 0;
}

.brand-home-link,
.menu-button,
.profile-button,
.sidebar-close-button {
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.brand-home-link {
  color: inherit;
  text-decoration: none;
}

.tenant-brand-control {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.brand-home-link {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.hamburger-icon {
  display: grid;
  gap: 5px;
  width: 20px;
  margin: 0 auto;
}

.hamburger-icon span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--accent) 0 26%, transparent 27%),
    var(--surface);
}

.brand-lockup,
.brand-home-text {
  display: grid;
  min-width: 0;
}

.brand-lockup {
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.brand-name {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-mode-list {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-home-link strong,
.brand-lockup strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu {
  position: relative;
  flex: 0 0 auto;
}

.profile-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.profile-icon {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.profile-icon::before {
  position: absolute;
  top: 4px;
  left: 6px;
  width: 6px;
  height: 6px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  content: "";
}

.profile-icon::after {
  position: absolute;
  right: 4px;
  bottom: 3px;
  left: 4px;
  height: 6px;
  border: 2px solid var(--ink);
  border-radius: 999px 999px 0 0;
  content: "";
}

.profile-popover {
  position: absolute;
  z-index: 50;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  gap: 4px;
  width: min(280px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(23, 32, 42, 0.14);
  animation: profile-popover-in 180ms ease-out;
}

.profile-popover[hidden] {
  display: none;
}

@keyframes profile-popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-link,
.profile-link--button {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  text-decoration: none;
}

.profile-link--button {
  width: 100%;
  cursor: pointer;
}

.profile-menu-form {
  margin: 0;
}

.profile-current-account {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.profile-current-account span,
.profile-current-account small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.profile-current-account strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-link small,
.sidebar-link small {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8f9fb;
  font-size: 11px;
  font-weight: 900;
}

.tenant-sidebar-overlay {
  position: fixed;
  z-index: 35;
  inset: 0;
  background: rgba(23, 32, 42, 0.28);
}

.tenant-sidebar-overlay[hidden] {
  display: none;
}

.tenant-sidebar {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(var(--sidebar-width), calc(100vw - 24px));
  padding: 20px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 18px 0 46px rgba(23, 32, 42, 0.16);
  transform: translateX(-100%);
  transition: transform 360ms ease;
}

.is-sidebar-open .tenant-sidebar {
  transform: translateX(0);
}

.tenant-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
  font-size: 20px;
  font-weight: 900;
}

.tenant-sidebar-nav {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 18px 0 4px;
}

.tenant-sidebar-nav::-webkit-scrollbar {
  display: none;
}

.sidebar-section {
  display: grid;
  gap: 6px;
}

.sidebar-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  list-style: none;
  text-transform: uppercase;
  cursor: pointer;
}

.sidebar-section-summary::-webkit-details-marker {
  display: none;
}

.sidebar-section-summary::after {
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}

.sidebar-section[open] .sidebar-section-summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.sidebar-section-items {
  display: grid;
  gap: 6px;
}

.sidebar-section-label {
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.sidebar-section-label:first-child {
  margin-top: 0;
}

.sidebar-link,
.sidebar-link--button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 850;
  text-align: left;
  text-decoration: none;
}

.sidebar-link:hover,
.sidebar-section-summary:hover,
.profile-button:hover,
.brand-home-link:hover,
.menu-button:hover,
.sidebar-close-button:hover {
  background: #f8f9fb;
}

.sidebar-link--current,
.sidebar-link--current:hover {
  background: #fff4e5;
  box-shadow: inset 0 0 0 1px #f2d6ad;
}

.sidebar-link--button {
  width: 100%;
  cursor: pointer;
}

.sidebar-menu-form {
  margin: 0;
}

.sidebar-roadmap,
.profile-roadmap {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.sidebar-roadmap ul,
.profile-roadmap ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-roadmap li,
.profile-roadmap li {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.sidebar-link-icon {
  position: relative;
  display: inline-flex;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 4px;
}

.sidebar-link-icon::after {
  position: absolute;
  inset: 3px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
}

.tenant-header h1 {
  margin: 4px 0 0;
  font-size: 24px;
}

.tenant-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
}

.status-panel {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(23, 32, 42, 0.08);
}

.status-panel h2 {
  max-width: 720px;
  margin: 0 0 28px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
}

.system-status-panel h2 {
  margin-bottom: 12px;
  font-size: 28px;
}

.status-description {
  max-width: 680px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

.status-grid div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-grid dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.status-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 700;
}

.preset-switch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.preset-switch-card {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.preset-switch-card--active {
  border-color: var(--accent);
  background: #eef7f4;
}

.preset-switch-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.preset-switch-heading h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.preset-switch-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.preset-active-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: #126457;
  background: #dff2ec;
  font-size: 11px;
  font-weight: 900;
}

.preset-switch-summary {
  display: grid;
  gap: 10px;
  margin: 0;
}

.preset-switch-summary div {
  display: grid;
  gap: 4px;
}

.preset-switch-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.preset-switch-summary dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.preset-switch-card form,
.preset-switch-card .button_to {
  margin: 0;
}

.preset-switch-card .button {
  width: 100%;
}

.test-visit-event-list {
  display: grid;
  gap: 10px;
}

.test-visit-event-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.test-visit-event-summary {
  display: grid;
  grid-template-columns: 110px minmax(120px, 0.7fr) minmax(100px, 0.6fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.test-visit-event-summary time,
.test-visit-event-summary span,
.test-visit-event-summary strong {
  min-width: 0;
}

.test-visit-event-summary time {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.test-visit-event-summary strong,
.test-visit-event-summary > span:not(.visit-status) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.test-visit-event-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.test-visit-event-actions form,
.test-visit-event-actions .button_to {
  margin: 0;
}

.visits-panel,
.settings-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.settings-panel--stacked {
  margin-top: 18px;
}

.visits-heading,
.settings-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.visits-heading h2,
.settings-heading h2 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

.settings-lock-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
}

.settings-lock-badge--open {
  border-color: #7bc6b7;
  color: #126457;
  background: #e8f6f3;
}

.settings-lock-badge--locked {
  border-color: #e0b3b3;
  color: #8a3333;
  background: #fbeeee;
}

.visits-heading time {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.visits-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.live-refresh-toast {
  position: fixed;
  z-index: 80;
  top: 18px;
  right: 18px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: min(390px, calc(100vw - 36px));
  padding: 15px 16px;
  border: 1px solid #9fcfc5;
  border-radius: 10px;
  color: #18332e;
  background: #f5fbfa;
  box-shadow: 0 16px 40px rgba(23, 32, 42, 0.18);
}

.live-refresh-toast[hidden] {
  display: none;
}

.live-refresh-toast--visible {
  animation: live-refresh-toast-in 180ms ease-out;
}

.live-refresh-toast-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  border: 2px solid #278979;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #278979 0 20%, transparent 22%),
    #ffffff;
}

.live-refresh-toast strong,
.live-refresh-toast span span {
  display: block;
}

.live-refresh-toast strong {
  margin-bottom: 3px;
  font-size: 14px;
  font-weight: 900;
}

.live-refresh-toast span span {
  color: #43635d;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
}

.live-refresh-row--changed > td,
.live-refresh-row--changed:not(tr) {
  animation: live-refresh-row-pulse 4s ease-out;
}

.live-refresh-field--changed {
  color: #a52d2d !important;
  font-weight: 900 !important;
  animation: live-refresh-field-pulse 4s ease-out;
}

@keyframes live-refresh-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes live-refresh-row-pulse {
  0%,
  42% {
    background: #fff3f3;
  }

  20%,
  62% {
    background: #ffe3e3;
  }

  100% {
    background: transparent;
  }
}

@keyframes live-refresh-field-pulse {
  0%,
  42% {
    color: #8f2424;
  }

  20%,
  62% {
    color: #d13a3a;
  }

  100% {
    color: #a52d2d;
  }
}

.visits-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 12px;
}

.visits-table-toolbar time {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.date-filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-filter-form input[type="date"] {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
}

.results-filter-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.3fr);
  align-items: end;
  gap: 12px;
  margin: 18px 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.results-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.visit-status-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.visit-status-summary--with-total {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.visit-status-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.visit-status-summary strong {
  font-size: 22px;
}

.test-schedule-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.test-schedule-panel h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.test-schedule-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.visits-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.visits-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 14px;
}

.visits-table--compact,
.visits-table--results {
  min-width: 860px;
  table-layout: fixed;
}

.visits-table--results {
  min-width: 1040px;
}

.visit-table-col--date,
.visit-results-col--date {
  width: 96px;
}

.visit-table-col--schedule,
.visit-results-col--schedule {
  width: 104px;
}

.visit-table-col--people,
.visit-results-col--people {
  width: 128px;
}

.visit-table-col--status,
.visit-results-col--status {
  width: 74px;
}

.visit-table-col--actual,
.visit-results-col--actual {
  width: 124px;
}

.visit-table-col--event,
.visit-results-col--event {
  width: 108px;
}

.visit-results-col--record {
  width: 90px;
}

.visit-table-col--attention {
  width: 90px;
}

.visit-table-col--action,
.visit-results-col--action {
  width: 80px;
}

.visits-table.visits-table--compact th,
.visits-table.visits-table--compact td,
.visits-table.visits-table--results th,
.visits-table.visits-table--results td {
  padding: 12px 10px;
}

.visits-table--compact .visit-table-cell--compact,
.visits-table--compact .visit-table-cell--status,
.visits-table--compact .visit-table-cell--attention,
.visits-table--compact .visit-table-cell--action,
.visits-table--results .visit-result-cell--compact,
.visits-table--results .visit-result-cell--status,
.visits-table--results .visit-result-cell--action {
  text-align: center;
}

.visits-table--compact .visit-table-cell--people,
.visits-table--results .visit-result-cell--people {
  padding-right: 14px;
  padding-left: 14px;
  white-space: normal;
}

.visit-table-cell--people span,
.visit-result-cell--people span {
  display: block;
}

.visit-table-person,
.visit-table-worker,
.visit-result-person,
.visit-result-worker {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-table-worker,
.visit-result-worker {
  margin-top: 4px;
}

.visit-table-cell--action .button,
.visit-result-cell--action .button {
  min-height: 36px;
  padding: 0 10px;
}

.visits-table th,
.visits-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.visits-table th {
  color: var(--muted);
  background: #f8f9fb;
  font-size: 12px;
  font-weight: 800;
}

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

.visit-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
  font-size: 13px;
  font-weight: 800;
}

.visit-status--in-progress {
  border-color: #7bc6b7;
  color: #126457;
  background: #e8f6f3;
}

.visit-status--completed {
  border-color: #b5c6d9;
  color: #314d69;
  background: #eef4fa;
}

.visit-status--cancelled {
  border-color: #e0b3b3;
  color: #8a3333;
  background: #fbeeee;
}

.visit-attention {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #46515f;
  background: #f3f5f8;
  font-size: 12px;
  font-weight: 900;
}

.visit-attention--late-start,
.visit-attention--late-finish {
  border-color: #d9b35c;
  color: #6e4700;
  background: #fff4d8;
}

.account-id {
  font-weight: 850;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #46515f;
  background: #f3f5f8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.account-badge--admin {
  border-color: #b8c7df;
  color: #24456f;
  background: #edf3fb;
}

.account-badge--staff {
  border-color: #d6dbe3;
  color: #46515f;
  background: #f7f8fa;
}

.account-badge--active {
  border-color: #9fcfc5;
  color: #126457;
  background: #e8f6f3;
}

.account-badge--pending-approval,
.account-badge--multiple-candidates,
.account-badge--no-actionable-visit {
  border-color: #d9b35c;
  color: #6e4700;
  background: #fff4d8;
}

.account-badge--disabled {
  border-color: #d6dbe3;
  color: #6d7480;
  background: #f2f4f7;
}

.account-badge--disabled-tag,
.account-badge--unknown-tag,
.account-badge--forbidden-tag,
.account-badge--no-care-worker {
  border-color: #e0b3b3;
  color: #8a3333;
  background: #fbeeee;
}

.visits-empty {
  margin: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8f9fb;
}

.visit-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.visit-dashboard-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.visit-dashboard-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.visit-dashboard-section-heading h3 {
  margin: 0;
  font-size: 16px;
}

.visit-dashboard-section-heading strong {
  font-size: 24px;
}

.visit-dashboard-section-heading time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.visit-dashboard-section .visits-empty {
  padding: 14px;
  font-size: 13px;
}

.visit-mini-list,
.visit-event-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.visit-mini-list li,
.visit-event-list li {
  display: grid;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.visit-mini-list li {
  grid-template-columns: minmax(0, 1fr) auto;
}

.visit-mini-list span,
.visit-event-list strong,
.visit-event-list span {
  min-width: 0;
}

.visit-mini-list strong,
.visit-mini-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-mini-list small,
.visit-event-list span,
.visit-mini-list time,
.visit-event-list time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.visit-event-list li {
  grid-template-columns: auto minmax(0, 1fr) minmax(120px, 0.35fr) auto;
}

.pagination-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.pagination-current {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.pagination-nav-disabled {
  color: #7b8594;
  background: #f3f5f8;
  cursor: not-allowed;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.button--primary {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.button--warning {
  border-color: #9b6b1b;
  color: #5c3b00;
  background: #fff4d8;
}

.flash {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #9fcfc5;
  border-radius: 8px;
  color: #126457;
  background: #e8f6f3;
  font-size: 14px;
  font-weight: 800;
}

.flash--alert {
  border-color: #e0b3b3;
  color: #8a3333;
  background: #fbeeee;
}

.login-panel {
  max-width: 560px;
  width: 100%;
}

.login-brand {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 30px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.login-brand-mark {
  width: 70px;
  height: 70px;
  border-width: 3px;
  box-shadow: 0 10px 24px rgba(31, 122, 109, 0.14);
}

.login-brand-copy {
  min-width: 0;
}

.login-brand-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

.login-brand-title {
  margin: 3px 0 0;
  font-size: clamp(36px, 7vw, 54px);
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.login-office-name {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
}

.login-heading {
  margin-bottom: 18px;
}

.login-heading h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

.visit-form {
  display: grid;
  gap: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.form-grid--single {
  grid-template-columns: 1fr;
}

.form-field,
.form-field--split > div {
  display: grid;
  gap: 8px;
}

.form-field--wide {
  grid-column: 1 / -1;
}

.form-field label,
.form-field--split label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.form-field input,
.form-field textarea,
.form-field select,
.form-field--split input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 15px;
}

.form-field textarea {
  min-height: 86px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

.form-field input:disabled,
.form-field textarea:disabled,
.form-field select:disabled,
.button:disabled {
  color: #7b8594;
  background: #f3f5f8;
  cursor: not-allowed;
}

.form-field--split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.actual-time-grid {
  display: grid;
  grid-template-columns: minmax(160px, 0.5fr) minmax(120px, 0.3fr);
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-actions--left {
  justify-content: flex-start;
  margin-top: 12px;
}

.form-errors {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid #e0b3b3;
  border-radius: 8px;
  color: #8a3333;
  background: #fbeeee;
}

.form-errors p {
  margin: 0 0 8px;
  font-weight: 800;
}

.form-errors ul {
  margin: 0;
  padding-left: 20px;
}

.settings-list {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-list div {
  display: grid;
  grid-template-columns: minmax(160px, 0.35fr) minmax(0, 1fr);
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.settings-list div:last-child {
  border-bottom: 0;
}

.settings-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 800;
}

.settings-form {
  display: grid;
  gap: 18px;
}

.settings-section {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.settings-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.settings-section-heading h3 {
  margin: 0;
  font-size: 16px;
}

.settings-section-note {
  max-width: 760px;
  margin: -6px 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.staff-ic-tag-form {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.staff-ic-tag-table-wrap {
  margin-top: 14px;
}

.staff-ic-tag-table {
  min-width: 780px;
}

.staff-ic-tag-subtext {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.staff-ic-tag-log {
  margin-top: 20px;
}

.staff-ic-tag-log h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-actions form,
.inline-actions .button_to {
  margin: 0;
}

.inline-actions .button {
  min-height: 34px;
  padding: 0 10px;
}

.test-staff-ic-tag-form {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.test-staff-ic-tag-list {
  display: grid;
  gap: 12px;
}

.form-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.test-staff-ic-tag-staff strong {
  font-size: 16px;
}

.test-staff-ic-tag-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.test-staff-ic-tag-submit {
  align-self: end;
}

.development-force-control {
  padding: 0;
}

.development-force-control-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 32px;
  cursor: pointer;
  list-style: none;
}

.development-force-control-summary::-webkit-details-marker {
  display: none;
}

.development-force-control-heading {
  display: grid;
  gap: 4px;
}

.development-force-control-heading strong {
  color: var(--ink);
  font-size: 20px;
}

.development-force-control-hint {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.development-force-control-hint::after {
  content: " +";
}

.development-force-control[open] .development-force-control-hint::after {
  content: " -";
}

.development-force-control-body {
  padding: 24px 32px 32px;
  border-top: 1px solid var(--line);
}

.settings-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
  font-size: 14px;
  font-weight: 850;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-field--compact {
  min-height: 40px;
  font-size: 13px;
}

.settings-check-grid--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.master-nested-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.master-nested-list h4 {
  margin: 0;
  font-size: 15px;
}

.master-nested-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.settings-control-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.settings-control-summary div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fb;
}

.settings-control-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.settings-control-summary strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

@media (max-width: 640px) {
  .tenant-topbar {
    gap: 12px;
  }

  .tenant-brand-control {
    grid-template-columns: 50px minmax(0, 1fr);
    max-width: calc(100vw - 92px);
  }

  .menu-button {
    width: 50px;
  }

  .brand-home-link {
    grid-template-columns: 34px minmax(0, 1fr);
    padding: 8px 10px;
  }

  .status-panel {
    padding: 24px;
  }

  .development-force-control {
    padding: 0;
  }

  .development-force-control-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 20px 24px;
  }

  .development-force-control-body {
    padding: 20px 24px 24px;
  }

  .preset-switch-grid {
    grid-template-columns: 1fr;
  }

  .test-visit-event-card,
  .test-visit-event-summary {
    grid-template-columns: 1fr;
  }

  .test-visit-event-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .login-brand {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 26px;
    padding-bottom: 22px;
  }

  .login-brand-mark {
    width: 56px;
    height: 56px;
  }

  .login-brand-title {
    font-size: 34px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .visits-panel,
  .settings-panel {
    padding: 20px;
  }

  .visits-heading,
  .settings-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .visits-heading-actions,
  .visits-table-toolbar,
  .test-schedule-panel,
  .form-actions,
  .inline-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .visit-status-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-filter-form,
  .results-filter-form,
  .actual-time-grid,
  .visit-dashboard-grid,
  .visit-event-list li {
    grid-template-columns: 1fr;
  }

  .date-filter-form {
    display: grid;
  }

  .visit-dashboard-grid {
    display: grid;
  }

  .visit-mini-list li {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .form-grid,
  .form-field--split,
  .settings-check-grid,
  .settings-control-summary,
  .master-nested-row {
    grid-template-columns: 1fr;
  }

  .settings-list div {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (min-width: 768px) {
  .form-grid:not(.form-grid--single) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1180px) {
  .tenant-shell {
    padding-left: var(--sidebar-width);
  }

  .tenant-sidebar {
    transform: translateX(0);
    box-shadow: none;
  }

  .tenant-sidebar-overlay,
  .sidebar-close-button {
    display: none;
  }

  .tenant-brand-control {
    grid-template-columns: minmax(0, 1fr);
  }

  .menu-button {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-refresh-toast--visible,
  .live-refresh-row--changed > td,
  .live-refresh-row--changed:not(tr),
  .live-refresh-field--changed {
    animation: none;
  }

  .live-refresh-row--changed > td,
  .live-refresh-row--changed:not(tr) {
    background: #fff3f3;
  }
}

.tenant-shell--guest {
  padding-left: 0;
}

.tenant-shell--guest .app-main {
  display: grid;
  align-content: center;
  width: min(560px, calc(100% - 32px));
  min-height: 100vh;
  padding: 48px 0;
}

.tenant-shell--guest .login-panel {
  width: 100%;
  margin: 0 auto;
}

.rulebook-shell {
  min-height: 100vh;
  margin: 0;
  background: #171512;
  color: #f3efe8;
}

.rulebook-header {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid #3e3932;
  background: #211e1a;
}

.rulebook-brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.rulebook-brand span:last-child { display: grid; gap: 2px; }
.rulebook-brand small { color: #bdb4a8; }
.rulebook-nav { display: flex; flex: 1; gap: 8px; }
.rulebook-nav a { padding: 10px 12px; border-radius: 8px; color: #d8d0c5; text-decoration: none; font-weight: 800; }
.rulebook-nav a:hover { background: #332f29; color: #fff; }
.rulebook-account { display: flex; align-items: center; gap: 12px; }
.rulebook-main { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 64px; }
.rulebook-warning { margin-bottom: 20px; padding: 12px 16px; border: 1px solid #786538; border-radius: 8px; background: #302a1b; color: #f0d797; font-weight: 750; }
.rulebook-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin: 22px 0; }
.rulebook-heading h1 { margin: 3px 0; font-size: clamp(28px, 4vw, 44px); }
.rulebook-heading p { color: #bdb4a8; }
.rulebook-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.rulebook-metrics article { display: grid; gap: 8px; padding: 18px; border: 1px solid #3e3932; border-radius: 10px; background: #24211d; }
.rulebook-metrics span { color: #bdb4a8; font-size: 12px; font-weight: 900; text-transform: uppercase; }
.rulebook-metrics strong { font-size: 30px; }
.rulebook-metrics .is-warning { border-color: #9f7a32; }
.rulebook-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.rulebook-panel { margin-bottom: 20px; padding: 24px; border: 1px solid #3e3932; border-radius: 12px; background: #24211d; }
.rulebook-panel h2 { margin-top: 0; }
.rulebook-list { display: grid; gap: 8px; }
.rulebook-list a { display: grid; gap: 4px; padding: 12px; border-radius: 8px; color: inherit; text-decoration: none; background: #2d2924; }
.rulebook-list span, .rulebook-table small, .rulebook-source-list span { display: block; margin-top: 4px; color: #bdb4a8; font-size: 12px; }
.rulebook-login-card { width: min(520px, 100%); margin: 7vh auto; padding: 32px; border: 1px solid #3e3932; border-radius: 14px; background: #24211d; }
.rulebook-login-card .form-field, .rulebook-panel .form-field { margin-bottom: 16px; }
.rulebook-shell input, .rulebook-shell textarea { width: 100%; border-color: #554e45; background: #171512; color: #fff; }
.rulebook-status { display: inline-flex; padding: 5px 9px; border: 1px solid #5f584f; border-radius: 999px; color: #d8d0c5; font-size: 12px; font-weight: 900; }
.rulebook-status--published, .rulebook-status--validated, .rulebook-status--verified { border-color: #42735b; color: #98ddb7; }
.rulebook-status--invalid, .rulebook-status--unverified { border-color: #8b4545; color: #f0a3a3; }
.rulebook-status--reviewed, .rulebook-status--partial { border-color: #8f7336; color: #e7cd8b; }
.rulebook-table-wrap { overflow-x: auto; }
.rulebook-table { width: 100%; border-collapse: collapse; }
.rulebook-table th, .rulebook-table td { padding: 13px 12px; border-bottom: 1px solid #3e3932; text-align: left; vertical-align: top; }
.rulebook-table th { color: #bdb4a8; font-size: 12px; }
.rulebook-table a { color: #f0d797; }
.rulebook-details { display: grid; gap: 12px; }
.rulebook-details div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; }
.rulebook-details dt { color: #bdb4a8; font-weight: 800; }
.rulebook-details dd { margin: 0; overflow-wrap: anywhere; }
.rulebook-source-list { display: grid; gap: 12px; padding: 0; list-style: none; }
.rulebook-source-list li { padding: 14px; border-radius: 8px; background: #2d2924; }
.rulebook-source-list a { color: #f0d797; }
.rulebook-json { max-height: 300px; overflow: auto; white-space: pre-wrap; }
.rulebook-action-box, .rulebook-inline-form { display: flex; align-items: center; gap: 14px; margin-top: 20px; padding: 16px; border-radius: 8px; background: #2d2924; }
.rulebook-inline-form input { flex: 1; }

@media (max-width: 800px) {
  .rulebook-header, .rulebook-heading, .rulebook-action-box, .rulebook-inline-form, .rulebook-account { align-items: stretch; flex-direction: column; }
  .rulebook-nav { flex-wrap: wrap; }
  .rulebook-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rulebook-columns { grid-template-columns: 1fr; }
  .rulebook-details div { grid-template-columns: 1fr; gap: 4px; }
}
