:root {
  --app-bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --border: #e5e7eb;
  --border-strong: #d7dadd;
  --text: #17191c;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --focus: rgba(79, 70, 229, 0.18);
  --chart-primary: #4f46e5;
  --chart-primary-hover: #4338ca;
  --chart-primary-soft: #c7d2fe;
  --chart-secondary: #5378a8;
  --chart-secondary-soft: #b9cbe1;
  --chart-coral: #d46f62;
  --chart-amber: #c68a2b;
  --chart-violet: #7b6ba8;
  --chart-grid: #e7e9eb;
  --chart-track: #f0f1f2;
  --chart-label: #73777d;
  --tblr-primary: #4f46e5;
  --tblr-primary-rgb: 79, 70, 229;
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-border-color: var(--border);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--app-bg);
  color-scheme: light;
}

body {
  color: var(--text);
  background: var(--app-bg);
  font-family: var(--tblr-font-sans-serif), system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

.app-page-wrapper {
  min-width: 0;
  margin-left: 0;
  background: var(--app-bg);
  transition: margin-left 180ms ease;
}

.navbar-vertical .navbar-brand a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.navbar-vertical .navbar-brand-image { width: 32px; height: 32px; }
.navbar-vertical .nav-link.disabled { min-height: 28px; padding-top: 8px; padding-bottom: 2px; opacity: .7; }
.navbar-vertical .dropdown-menu .dropdown-item { white-space: normal; }

.app-page-body {
  margin: 0;
  padding: 24px;
  background: var(--app-bg);
}

.app-container {
  padding: 0;
}

.text-muted { color: var(--text-muted) !important; }

.analytics-filter-card .card-body { padding: 16px; }
.analytics-filter-row { align-items: end; }
.analytics-filter-row > .col-auto:has(.btn-primary) { display: flex; align-items: center; gap: 8px; }
.analytics-filter-row > .col-auto.ms-auto {
  flex: 1 0 100%;
  width: 100%;
  margin-top: 4px;
  margin-left: 0 !important;
  text-align: right;
}
.analytics-kpi-row > [class*="col"] > .card { height: 100%; }
.analytics-kpi-row .card-body { display: flex; flex-direction: column; min-height: 108px; }
.analytics-kpi-row .card-body > .text-muted.small:first-child { min-height: 20px; }
.analytics-kpi-row .kpi-label { min-height: 20px !important; }
.chart-card .card-body { padding: 16px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 6px 0 10px; color: var(--text-muted); font-size: 11px; }
.chart-legend .dot { margin-right: 5px; }

.app-container > p.text-muted { max-width: 920px; }
.filter-card { margin-bottom: 24px; }
.filter-card .card-body { padding: 12px 16px; }
.filter-card .row { align-items: end; }

.app-container > table.table + p.text-muted,
.app-container > .table-responsive + p.text-muted { margin-top: 12px; }

.app-container > table.table:only-of-type,
.app-container > table.table:last-of-type { margin-bottom: 16px; }

.form-switch .form-check-input:checked { background-color: var(--chart-primary); border-color: var(--chart-primary); }

.btn { gap: 6px; }
.btn .ti { flex: 0 0 auto; font-size: 16px; }
.hint-dotted { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.cursor-help { cursor: help; }
.settings-shell { max-width: 760px; }
.settings-table { max-width: 560px; }
.settings-email { max-width: 320px; }
.settings-order { width: 2rem; }
.settings-actions { width: 6rem; white-space: nowrap; }
.control-auto { width: auto; }
.control-title { min-width: 200px; }
.control-number { max-width: 6rem; }
.checkdrop-list { max-height: 260px; overflow-y: auto; }
.dropdown-check-label { cursor: pointer; }

.table a:not(.btn):not(.badge) { color: #4f46e5; text-underline-offset: 2px; }
.table a:not(.btn):not(.badge):hover { color: var(--accent-hover); }

/* Functional table helpers; visual geometry comes from Tabler. */
.data-table-card { overflow: hidden; }
.data-table { width: 100%; margin: 0; font-variant-numeric: tabular-nums; }

@media (min-width: 992px) {
  .navbar-vertical > .container-fluid { height: 100vh; flex-wrap: nowrap; }
  .navbar-vertical .navbar-collapse {
    display: flex !important;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .navbar-vertical .navbar-nav {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    overflow-y: auto;
  }
  .sidebar-account { flex: 0 0 auto; width: 100%; background: var(--surface); }
}

.sort-arrow {
  color: var(--text);
}

.app-container > .app-page-header {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 !important;
  padding: 0 0 24px !important;
  min-height: 44px;
}

.app-container > .app-page-header:has(+ .page-intro) { padding-bottom: 8px !important; }
.page-intro { max-width: 920px; margin: 0 0 24px; color: var(--text-muted); font-size: 13px; }
.section-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin: 28px 0 12px; }
.section-header h2,
h2.section-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.4; }
.section-header .section-note,
.section-title .section-note { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.page-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}

.page-title-count {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

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

.guest-search-form {
  margin-bottom: 16px;
}

.guest-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.guest-search {
  flex: 0 1 360px;
  min-width: 240px;
}

.guest-results {
  margin-left: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.guest-filter-card {
  margin-bottom: 16px;
  background: #fbfbfc;
}

.guest-filter-card .card-body {
  padding: 16px;
}

.guest-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px 12px;
}

.form-field {
  display: block;
  min-width: 0;
  margin: 0;
}

.form-field .form-label {
  display: block;
  margin-bottom: 6px;
  color: #666b72;
  font-size: 11px;
  font-weight: 600;
}

.filter-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(64px, 1fr));
  gap: 6px;
}

.filter-range-date {
  grid-template-columns: repeat(2, minmax(125px, 1fr));
}

.guest-filter-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.guest-filter-options fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.guest-filter-options legend {
  margin: 0 0 9px;
  color: #666b72;
  font-size: 11px;
  font-weight: 600;
}

.filter-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.filter-checks .form-check-label {
  font-size: 12px;
}

.guest-filter-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
}

.guest-table-card {
  overflow: hidden;
}

.table-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.table-sort-link:hover,
.guest-name:hover {
  color: var(--text);
}

.guest-name {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.guest-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 10px 12px;
  font-size: 12px;
}

.client-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.client-search { flex: 0 1 420px; min-width: 260px; }
.directory-table-card { overflow: hidden; }
.directory-name,
.directory-name-link { color: var(--text); font-weight: 600; }
.directory-name-link { text-decoration: none; }
.directory-name-link:hover { color: var(--text); text-decoration: underline; }
.directory-meta { margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.directory-number { color: #2c3035; font-variant-numeric: tabular-nums; font-weight: 600; }
.directory-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.directory-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.directory-table-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 10px 12px; font-size: 12px; }

.client-profile-header .page-pretitle a { color: inherit; text-decoration: none; }
.client-profile-header .page-pretitle .ti { margin: 0 4px; font-size: 9px; }
.client-profile-subtitle { margin-top: 6px; color: var(--text-muted); font-size: 12px; }
.client-profile-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(420px, 1.2fr); gap: 16px; }
.client-contact-card .card-header { min-height: 48px; padding: 12px 16px; }
.client-contact-card .card-title { font-size: 14px; }
.client-detail-list { padding: 0; }
.client-detail { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(120px, 1.2fr); gap: 16px; padding: 11px 16px; border-bottom: 1px solid #eceeef; }
.client-detail:last-child { border-bottom: 0; }
.client-detail-label { color: var(--text-muted); font-size: 12px; }
.client-detail-value { min-width: 0; overflow-wrap: anywhere; font-weight: 500; text-align: right; }
.client-metrics { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 12px; }
.client-metric .card-body { display: flex; flex-direction: column; min-height: 122px; padding: 16px; }
.client-metric-label { color: var(--text-muted); font-size: 11px; font-weight: 600; }
.client-metric strong { margin-top: auto; font-size: 24px; line-height: 1.2; }
.client-metric-meta { min-height: 17px; margin-top: 5px; color: var(--text-muted); font-size: 11px; }
.client-metric-meta .status-dot { margin-right: 4px; }
.client-history-section { margin-top: 24px; }
.client-section-header { margin-bottom: 12px; }
.client-section-header h2 { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: 17px; }
.client-services { min-width: 220px; max-width: 440px; color: #44484e; font-size: 12px; }

/* Guest profile: Tabler cards with a domain-specific timeline. */
.guest-head-contacts { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 16px; }
.guest-head-contacts .ti { margin-right: 5px; }
.guest-kpi-card { overflow: hidden; }
.guest-kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guest-kpi-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 14px 16px; border-right: 1px solid var(--border); }
.guest-kpi-cell:last-child { border-right: 0; }
.guest-kpi-label { color: var(--text-muted); font-size: 12px; }
.guest-kpi-value { font-size: 23px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.guest-kpi-unit { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.guest-kpi-meta { min-height: 18px; margin-top: auto; color: var(--text-muted); font-size: 11px; }
.guest-detail-label { min-width: 0; }
.guest-detail-value { margin-left: auto; color: var(--text-muted); text-align: right; }
.guest-payload { white-space: pre-wrap; }
.guest-email-preview { display: block; width: 100%; height: 420px; margin-top: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.guest-timeline { padding: 8px 16px 12px; }
.guest-timeline-day { padding: 12px 0 4px; color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.guest-timeline-item { position: relative; padding: 5px 0 5px 24px; }
.guest-timeline-item::before { position: absolute; top: 0; bottom: 0; left: 6px; width: 2px; content: ""; background: var(--border); }
.guest-timeline-dot { position: absolute; top: 10px; left: 0; z-index: 1; width: 14px; height: 14px; background: var(--surface); border: 2px solid var(--text-muted); border-radius: 50%; }
.tl-booking .guest-timeline-dot { border-color: var(--chart-secondary); }
.tl-cancel .guest-timeline-dot { border-color: var(--chart-coral); }
.tl-noshow .guest-timeline-dot { border-color: var(--chart-amber); }
.tl-visit .guest-timeline-dot { background: var(--chart-primary); border-color: var(--chart-primary); }
.tl-mailing .guest-timeline-dot { border-color: var(--chart-violet); }
.tl-call .guest-timeline-dot { border-color: #5f9ca2; }
.guest-timeline-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }

@media (min-width: 768px) { .guest-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .guest-kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.login-page {
  background: var(--app-bg);
}

.login-page .container {
  max-width: 390px !important;
}

.login-page .card {
  border: 1px solid var(--border);
}

@media (max-width: 767.98px) {
  html,
  body,
  .app-page,
  .app-page-wrapper,
  .app-container { max-width: 100%; overflow-x: hidden; }

  .app-page-body {
    padding: 16px !important;
  }

  .app-page-header {
    align-items: flex-start;
  }

  .analytics-filter-row > .col-auto { max-width: 100%; }
  .analytics-filter-row > .col-auto.ms-auto { text-align: left; }
  .analytics-computed { display: none; }

  .app-container > table.table {
    display: block;
    width: 100% !important;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-container > .d-flex.justify-content-between {
    align-items: flex-start !important;
    flex-wrap: wrap;
    gap: 10px;
  }

  .app-container > .d-flex.justify-content-between > .d-flex.gap-2 {
    width: 100%;
    flex-wrap: wrap;
  }

  .app-page-header .page-actions {
    width: auto;
    margin-top: 0 !important;
    margin-left: auto;
  }

  .page-actions .btn span {
    display: none;
  }

  .guest-toolbar {
    align-items: stretch;
  }

  .guest-search {
    flex-basis: 100%;
    min-width: 100%;
  }

  .client-toolbar { align-items: stretch; flex-wrap: wrap; }
  .client-search { flex-basis: 100%; min-width: 100%; }
  .directory-table-footer { align-items: flex-start; flex-direction: column; }
  .client-profile-grid { grid-template-columns: 1fr; }
  .client-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-metric .card-body { min-height: 110px; padding: 14px; }
  .client-metric strong { font-size: 20px; }

  .guest-filter-grid,
  .guest-filter-options {
    grid-template-columns: 1fr;
  }

  .filter-range-date {
    grid-template-columns: 1fr;
  }

  .guest-table-footer {
    align-items: flex-start;
    flex-direction: column;
  }

}
