:root {
  color-scheme: light;
  --bg: #eef3f4;
  --surface: #ffffff;
  --surface-2: #f7fafb;
  --line: #d8e2e4;
  --line-strong: #b7c7cb;
  --text: #13252b;
  --muted: #66767b;
  --brand: #0c5b66;
  --brand-2: #0b7480;
  --brand-soft: #e6f4f6;
  --good: #16724f;
  --good-soft: #e6f6ef;
  --warn: #9a5b00;
  --warn-soft: #fff4df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --blue: #255f9d;
  --blue-soft: #e8f1fb;
  --shadow: 0 12px 28px rgba(16, 37, 43, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: var(--brand-2);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  flex: 0 0 48px;
}

.brand-title {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.login-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
}

.auth-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid #d9a3a3;
  border-radius: 6px;
  background: #fff4f4;
  color: #8a2424;
  font-size: 13px;
}

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

.remember-device-option {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #304b52;
  font-size: 13px;
}

.remember-device-option input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.password-strength {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.field-title {
  font-weight: 740;
  font-size: 13px;
  color: #21373d;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: 0;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(12, 116, 128, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.tiny-button,
.toggle-button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 38px;
  padding: 9px 12px;
  font-weight: 760;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

.secondary-button {
  background: #fff;
  border-color: var(--brand-2);
  color: var(--brand);
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.tiny-button {
  min-height: 30px;
  padding: 5px 9px;
  background: #fff;
  border-color: var(--line);
  color: var(--text);
  font-size: 12px;
}

.tiny-button.danger-tiny-button {
  border-color: #d9a1a1;
  color: #9f2525;
}

.tiny-button.danger-tiny-button:hover {
  background: #fff1f1;
  border-color: #c66e6e;
}

.toggle-button {
  background: var(--good-soft);
  border-color: #a7d8c0;
  color: var(--good);
}

.toggle-button.is-off {
  background: var(--danger-soft);
  border-color: #f2b7b0;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: #fbfdfd;
  border-right: 1px solid var(--line);
  padding: 18px 14px 20px;
}

.sidebar .brand-lockup {
  margin: 0 0 18px;
  padding: 0 6px;
}

.nav-section {
  margin-top: 16px;
}

.nav-heading {
  margin: 0 8px 7px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #263c42;
  padding: 10px 11px;
  text-align: left;
  font-weight: 690;
}

.nav-button:hover {
  background: var(--surface-2);
}

.nav-button.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-count {
  min-width: 22px;
  text-align: center;
  border-radius: 999px;
  background: #e8eef0;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 11px;
}

.main-shell {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.mobile-menu {
  display: none;
}

.page-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.operator-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 6px 10px;
  white-space: nowrap;
}

.avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.content {
  min-width: 0;
  padding: 22px 24px 44px;
}

.mock-banner {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  background: #fff9ed;
  border: 1px solid #efd7a7;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  color: #694500;
}

.mock-banner strong {
  color: #4a3200;
}

.grid,
.metric-grid,
.two-column,
.three-column {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-column {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.card {
  padding: 16px;
}

.panel {
  overflow: hidden;
}

.panel-header,
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface-2);
}

.panel-body {
  padding: 16px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.metric-label,
.muted {
  color: var(--muted);
}

.metric-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  margin-top: 7px;
  font-size: 25px;
  font-weight: 820;
}

.metric-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.status-dot.is-good::before {
  background: var(--good);
}

.status-dot.is-warn::before {
  background: var(--warn);
}

.status-dot.is-danger::before {
  background: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf2f3;
  color: #3d5359;
  font-size: 12px;
  font-weight: 740;
  white-space: nowrap;
}

.badge.good {
  background: var(--good-soft);
  color: var(--good);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.mock {
  background: #edf2f3;
  color: var(--muted);
}

.alert {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 740;
  line-height: 1.45;
}

.alert.success {
  background: var(--good-soft);
  border-color: #b9e7d1;
  border-left-color: var(--good);
  color: var(--good);
}

.alert.danger {
  background: var(--danger-soft);
  border-color: #ffd5d0;
  border-left-color: var(--danger);
  color: var(--danger);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar .field {
  min-width: 180px;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 14px;
}

.conversation-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 68px;
  gap: 14px;
  min-height: 690px;
}

.conversation-layout.copilot-open {
  grid-template-columns: 310px minmax(0, 1fr) 340px;
}

.conversation-list,
.chat-panel,
.detail-panel {
  min-height: 690px;
}

.conversation-list .panel-body,
.detail-panel .panel-body {
  padding: 0;
}

.conversation-item {
  width: 100%;
  display: grid;
  gap: 7px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 13px 14px;
  text-align: left;
}

.conversation-item:hover,
.conversation-item.is-active {
  background: var(--brand-soft);
}

.conversation-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.conversation-name {
  font-weight: 780;
}

.conversation-preview {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-thread {
  height: 486px;
  overflow: auto;
  padding: 16px;
  background: #f6fafb;
}

.message {
  width: min(84%, 620px);
  margin-bottom: 12px;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: 0 1px 0 rgba(16, 37, 43, 0.04);
}

.message.guest {
  background: #fff;
  border: 1px solid var(--line);
}

.message.bot {
  margin-left: auto;
  background: #e7f4ef;
  border: 1px solid #bfe0d3;
}

.message.human {
  margin-left: auto;
  background: #e8f1fb;
  border: 1px solid #c3d8ef;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.conversation-commandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.conversation-search {
  display: grid;
  grid-template-columns: minmax(220px, 420px) auto;
  gap: 8px;
  width: min(100%, 540px);
}

.conversation-commandbar-status,
.conversation-languagebar,
.composer-heading,
.composer-preview-meta,
.message-footer,
.copilot-draft-heading,
.copilot-draft-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conversation-layout {
  align-items: start;
}

.conversation-list .panel-body {
  max-height: 720px;
  overflow-y: auto;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(360px, 1fr) auto;
  overflow: hidden;
}

.conversation-languagebar {
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.assistant-trace {
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 9px 14px;
}

.assistant-trace summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  font-weight: 760;
  list-style: none;
}

.assistant-trace summary::-webkit-details-marker {
  display: none;
}

.assistant-trace-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.assistant-trace-grid > div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.assistant-trace-grid span,
.assistant-trace-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.assistant-trace-grid span {
  color: var(--muted);
  font-size: 11px;
}

.assistant-trace-grid strong {
  margin-top: 3px;
  font-size: 12px;
}

.conversation-live-notice {
  margin: 10px 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.conversation-languagebar .compact-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conversation-languagebar select,
.composer-heading select {
  min-height: 36px;
  padding: 6px 30px 6px 9px;
}

.conversation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 720;
}

.conversation-toggle input {
  width: 18px;
  height: 18px;
}

.composer-heading {
  justify-content: space-between;
}

.guest-message-preview {
  background: #f2f5f5;
  border-color: #9aabad;
}

.composer-preview-meta,
.message-footer,
.copilot-draft-meta {
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.message-footer {
  margin-top: 7px;
  flex-wrap: wrap;
}

.message-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--brand-strong);
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

.message-status,
.message-authoring {
  color: var(--muted);
  font-size: 11px;
}

.message-authoring {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.danger-text {
  color: var(--danger);
}

.warn-text {
  color: var(--warn);
}

.conversation-copilot {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 116px);
  overflow: hidden;
}

.conversation-copilot:not(.is-open) {
  min-height: 0;
}

.conversation-copilot:not(.is-open) .copilot-expanded-content {
  display: none;
}

.copilot-collapsed-toggle {
  width: 100%;
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 9px;
  border: 0;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.copilot-collapsed-toggle:hover,
.copilot-collapsed-toggle:focus-visible {
  background: var(--brand-soft);
}

.copilot-collapsed-title {
  font-weight: 820;
}

.copilot-collapsed-subtitle {
  color: var(--muted);
  font-size: 10px;
}

.conversation-copilot.is-open .copilot-collapsed-toggle {
  display: none;
}

.copilot-body {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.copilot-instruction-form,
.copilot-draft {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.copilot-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.copilot-draft-heading,
.copilot-draft-meta {
  justify-content: space-between;
  flex-wrap: wrap;
}

.copilot-draft.is-stale {
  background: var(--warn-soft);
}

.copilot-draft textarea {
  min-height: 112px;
}

.copilot-stale-warning {
  display: grid;
  gap: 8px;
}

.copilot-data-used {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.copilot-data-used summary {
  cursor: pointer;
  color: var(--brand-strong);
  font-weight: 780;
}

.copilot-data-used .kv-list {
  margin-top: 10px;
}

.conversation-copilot-backdrop {
  display: none;
}

.conversation-copilot-trigger {
  display: none;
}

.conversation-copilot-inline {
  display: none;
}

.copilot-close {
  display: inline-flex;
}

.conversation-empty-panel {
  min-height: 320px;
}

.empty-state.compact {
  padding: 18px 14px;
}

.kv-list {
  display: grid;
  gap: 8px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.kv strong {
  color: var(--text);
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
}

.contact-table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  scrollbar-gutter: stable;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--surface-2);
  color: #30464d;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.marketing-dashboard {
  display: grid;
  gap: 24px;
}

.analytics-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.analytics-hero h2,
.section-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.analytics-hero p,
.section-heading p,
.analytics-panel .panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.analytics-period,
.compact-field {
  display: grid;
  gap: 6px;
  min-width: 220px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.analytics-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: end;
  justify-content: flex-end;
}

.analytics-currency {
  min-width: 86px;
  width: 86px;
}

.analytics-period select,
.compact-field select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
}

.marketing-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.marketing-kpi-grid .metric-value {
  font-size: 22px;
}

.analytics-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: grid;
  gap: 2px;
}

.analytics-panel .panel-header {
  align-items: flex-start;
}

.analytics-panel .panel-body {
  display: grid;
  gap: 14px;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 5px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
}

.bar-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-label strong {
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #e7eef0;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.analytics-table {
  min-width: 640px;
  font-size: 13px;
}

.compact-metrics {
  display: grid;
  gap: 10px;
}

.compact-metrics div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.compact-metrics span {
  color: var(--muted);
  line-height: 1.4;
}

.heatmap-table {
  min-width: 900px;
}

.heatmap-table th,
.heatmap-table td {
  text-align: center;
}

.heatmap-table th:first-child,
.heatmap-table td:first-child {
  text-align: left;
}

.heat-cell {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 28px;
  border-radius: 6px;
  background: rgba(12, 74, 85, var(--heat));
  color: var(--text);
  font-weight: 760;
}

.insight-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  line-height: 1.45;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.panel > .tabs {
  padding: 14px 16px 0;
}

.tab-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  font-weight: 740;
}

.tab-button.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.setting-row h3 {
  margin: 0;
  font-size: 14px;
}

.setting-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.assistant-ai-settings {
  display: grid;
  gap: 14px;
}

.assistant-ai-tabs {
  position: sticky;
  top: 70px;
  z-index: 8;
  padding: 10px 0;
  margin: -10px 0 0;
  background: var(--app-bg, #f3f7f8);
}

.assistant-ai-loading {
  padding: 28px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.assistant-config-split {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
  align-items: start;
}

.assistant-settings-form {
  overflow: hidden;
}

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

.settings-grid-span {
  grid-column: 1 / -1;
}

.assistant-inline-form {
  border-top: 1px solid var(--line);
}

.setting-row.is-selected {
  border-color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.glossary-term-list {
  max-height: 430px;
  overflow-y: auto;
}

.danger-quiet {
  color: var(--danger, #b42318);
  border-color: transparent;
  background: transparent;
  font-size: 22px;
}

@media (max-width: 860px) {
  .assistant-ai-tabs {
    top: 61px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .assistant-ai-tabs .tab-button {
    flex: 0 0 auto;
  }

  .assistant-config-split,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-grid-span {
    grid-column: auto;
  }
}

.template-preview,
.code-preview {
  background: #10252b;
  color: #eaf7f9;
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.45;
  overflow: auto;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fff;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
}

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

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

.reservation-create-layout {
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
}

.reservation-baby-field {
  align-items: flex-start;
}

.reservation-baby-field span {
  display: grid;
  gap: 3px;
}

.reservation-baby-field small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
}

.reservation-form-grid > * {
  min-width: 0;
}

.reservation-form-grid > .field {
  grid-column: span 6;
  order: 8;
  align-content: start;
}

.reservation-form-grid > .field:has([name="guest_email"]) { grid-column: span 12; order: 1; }
.reservation-form-grid > .field:has([name="guest_first_name"]),
.reservation-form-grid > .field:has([name="guest_last_name"]) { grid-column: span 6; order: 2; }
.reservation-form-grid > .field:has([name="guest_phone"]) { grid-column: span 6; order: 3; }
.reservation-form-grid > .field:has([name="pax"]) { grid-column: span 2; order: 3; }
.reservation-form-grid > .checkbox-line:has([name="travels_with_baby"]) { grid-column: span 4; order: 3; }

.reservation-stay-dates {
  display: contents;
}

.reservation-stay-dates > .field:nth-child(1),
.reservation-stay-dates > .field:nth-child(2) { grid-column: span 6; order: 4; }
.reservation-stay-dates > .reservation-expiration-field { grid-column: span 6; order: 5; }
.reservation-expiration-rule {
  grid-column: span 6;
  order: 5;
  align-self: end;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1f3f4;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.reservation-form-grid > .field:has([name="unit_id"]) { grid-column: span 3; order: 6; }
.reservation-form-grid > .field:has([name="unit_name"]) { grid-column: span 9; order: 6; }
.reservation-form-grid > .field:has([name="guest_country"]),
.reservation-form-grid > .field:has([name="guest_language"]) { grid-column: span 6; order: 7; }
.reservation-form-grid > .field:has([name="reservation_currency"]) { grid-column: span 4; order: 8; }
.reservation-form-grid > .field:has([name="base_price"]) { grid-column: span 8; order: 8; }
.reservation-form-grid > .checkbox-line:has([name="loyalty_enabled"]),
.reservation-form-grid > .field:has([name="loyalty_tier"]) { grid-column: span 6; order: 9; }
.reservation-form-grid > .field:has([name="final_price"]) { grid-column: span 12; order: 10; }
.reservation-form-grid > .action-row { grid-column: span 12; order: 11; }
.reservation-form-grid > .alert { grid-column: span 12; order: 12; }

.reservation-expiration-input {
  background: #e7e9ec;
  border-color: #aeb4bc;
}

.reservation-expiration-input:focus {
  background: #f2f3f5;
}

@media (max-width: 760px) {
  .reservation-form-grid > .field:has([name="guest_first_name"]),
  .reservation-form-grid > .field:has([name="guest_last_name"]),
  .reservation-form-grid > .field:has([name="guest_phone"]),
  .reservation-stay-dates > .field:nth-child(1),
  .reservation-stay-dates > .field:nth-child(2),
  .reservation-stay-dates > .reservation-expiration-field,
  .reservation-expiration-rule,
  .reservation-form-grid > .field:has([name="unit_id"]),
  .reservation-form-grid > .field:has([name="unit_name"]),
  .reservation-form-grid > .field:has([name="guest_country"]),
  .reservation-form-grid > .field:has([name="guest_language"]),
  .reservation-form-grid > .field:has([name="reservation_currency"]),
  .reservation-form-grid > .field:has([name="base_price"]),
  .reservation-form-grid > .checkbox-line:has([name="loyalty_enabled"]),
  .reservation-form-grid > .field:has([name="loyalty_tier"]) { grid-column: span 12; }

  .reservation-form-grid > .field:has([name="pax"]) { grid-column: span 4; }
  .reservation-form-grid > .checkbox-line:has([name="travels_with_baby"]) { grid-column: span 8; }
}

@media (max-width: 1050px) {
  .reservation-create-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.span-2 {
  grid-column: 1 / -1;
}

.field[hidden] {
  display: none !important;
}

input.unit-unavailable {
  color: var(--danger);
  border-color: var(--danger);
}

.reservation-unit-combobox {
  position: relative;
}

.reservation-unit-suggestions {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  width: min(520px, calc(100vw - 48px));
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 43, 52, 0.16);
}

.reservation-unit-suggestion {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.reservation-unit-suggestion:last-child {
  border-bottom: 0;
}

.reservation-unit-suggestion:hover,
.reservation-unit-suggestion:focus-visible {
  background: var(--brand-soft);
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.reservation-unit-suggestion strong {
  color: var(--brand-deep);
}

.reservation-unit-suggestion span {
  min-width: 0;
  line-height: 1.35;
}

.reservation-unit-suggestion small {
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .reservation-unit-suggestions {
    width: 100%;
    max-width: 100%;
  }

  .reservation-unit-suggestion {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .reservation-unit-suggestion small {
    grid-column: 2;
  }
}

.reservation-date-control {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
}

.reservation-date-control > input[type="text"] {
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.date-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: #fff;
  color: var(--brand);
  font-size: 20px;
  cursor: pointer;
}

.date-picker-button:hover,
.date-picker-button:focus-visible {
  background: var(--brand-soft);
}

.date-picker-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reservation-native-date {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.email-search-row {
  display: grid;
  grid-template-columns: minmax(0, 10fr) minmax(96px, 2fr);
  gap: 8px;
  align-items: stretch;
}

.icon-button {
  min-width: 48px;
  border: 1px solid var(--brand-2);
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
}

.readonly-input {
  background: var(--surface-2);
  color: #4e6268;
}

.result-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin: 0 16px 14px;
  padding: 10px 12px;
  border: 1px solid #b9d9df;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 37, 43, 0.45);
}

.modal-card {
  width: min(100%, 760px);
  max-height: min(88vh, 820px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-card.wide {
  width: min(100%, 1120px);
}

body.accessible-modal-open {
  overscroll-behavior: none;
}

.accessible-modal-backdrop {
  isolation: isolate;
}

.accessible-modal-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.accessible-modal-card .accessible-modal-header {
  flex: 0 0 auto;
  align-items: center;
  flex-direction: row;
}

.accessible-modal-header .panel-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal-close-button {
  display: inline-grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.modal-close-button:hover {
  border-color: var(--brand-2);
  background: var(--brand-soft);
  color: var(--brand);
}

.modal-close-button:focus-visible {
  outline: 3px solid rgba(16, 121, 134, 0.28);
  outline-offset: 2px;
}

.accessible-modal-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.accessible-modal-card .accessible-modal-footer {
  display: grid;
  flex: 0 0 auto;
  align-items: stretch;
}

.checkbox-line {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  font-weight: 760;
  color: var(--text);
}

.spreadsheet-table td {
  min-width: 120px;
}

.contact-table {
  min-width: 1580px;
}

.contact-editor-modal .panel-body {
  padding-top: 16px;
}

.export-contacts-form {
  display: grid;
  gap: 16px;
}

.export-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.export-filter-group {
  margin: 0;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.export-filter-group legend {
  padding: 0 6px;
  font-weight: 800;
}

.export-filter-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  max-height: 190px;
  overflow: auto;
}

.export-filter-options.months {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: none;
}

.export-filter-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: var(--text);
}

.export-filter-option input {
  width: 17px;
  height: 17px;
}

.export-contact-toggles {
  padding: 0 4px;
}

.spreadsheet-table td:first-child,
.spreadsheet-table th:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.spreadsheet-table th:first-child {
  background: var(--surface-2);
}

/* Contactos conserva nombre y apellido al recorrer las columnas horizontales. */
.contact-table th:nth-child(1),
.contact-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 152px;
  box-sizing: border-box;
  background: #fff;
}

.contact-table th:nth-child(2),
.contact-table td:nth-child(2) {
  position: sticky;
  left: 152px;
  z-index: 2;
  min-width: 168px;
  box-sizing: border-box;
  background: #fff;
  box-shadow: 2px 0 0 var(--line);
}

.contact-table th:nth-child(1),
.contact-table th:nth-child(2) {
  z-index: 4;
  background: var(--surface-2);
}

.mobile-card-list {
  display: none;
  gap: 12px;
  padding: 0 16px 16px;
}

.mobile-data-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.mobile-data-card h3 {
  margin: 0;
  font-size: 16px;
}

.mobile-data-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.whatsapp-button {
  border-color: #1f9d63;
  color: #0f6a43;
  background: #ecfbf3;
}

.email-marketing-dashboard,
.email-editor-layout,
.email-builder,
.email-block-list,
.timeline-list,
.audience-filter-grid {
  display: grid;
  gap: 14px;
}

.email-hero {
  align-items: center;
}

.email-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.email-tabs {
  margin-bottom: 0;
}

.email-layout {
  align-items: start;
  grid-template-columns: minmax(0, 7fr) minmax(280px, 3fr);
}

.row-highlight {
  background: var(--brand-soft);
}

.provider-grid,
.template-card-grid,
.email-toggle-grid,
.email-send-summary,
.report-grid {
  display: grid;
  gap: 10px;
}

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

.provider-card,
.template-card,
.report-card,
.timeline-item,
.email-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.provider-card,
.template-card,
.report-card,
.timeline-item {
  padding: 12px;
}

.provider-card h3,
.template-card p,
.timeline-item p {
  margin: 6px 0 0;
}

.template-card {
  display: grid;
  gap: 8px;
}

.email-editor-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
}

.email-editor-layout.is-wide {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1320px;
}

.email-campaign-name {
  display: block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tiny-button.danger {
  border-color: #f0b7b0;
  color: var(--danger);
  background: #fff8f7;
}

.email-style-toolbar {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(86px, 0.7fr) minmax(90px, 0.7fr) minmax(210px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.email-style-toolbar label {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}

.email-style-toolbar select,
.email-style-toolbar input {
  min-height: 36px;
}

.segmented-control.compact {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.segmented-control.compact label {
  display: block;
}

.segmented-control.compact input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control.compact span {
  display: grid;
  place-items: center;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.segmented-control.compact input:checked + span {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.image-layout-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.image-layout-option {
  display: grid;
  gap: 8px;
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.image-layout-option input {
  width: 18px;
  height: 18px;
}

.email-editor-layout > .panel:last-child {
  grid-column: 1 / -1;
}

.email-contact-block-fields {
  padding: 16px;
  border: 1px solid var(--border);
  background: #f6fbff;
}

.email-contact-options {
  display: grid;
  gap: 8px;
  align-content: start;
}

.email-toggle-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.checkbox-line small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.email-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.email-block p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.email-block-order {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 820;
}

.muted-block {
  background: var(--surface-2);
  border-style: dashed;
}

.audience-filter-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.email-audience-form {
  display: grid;
  gap: 14px;
}

.audience-multi-select {
  min-height: 112px;
}

.email-audience-table {
  max-height: 440px;
  overflow: auto;
}

.email-audience-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.inline-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 720;
}

.inline-status.good {
  border-color: #b8e5cf;
  background: var(--good-soft);
  color: var(--good);
}

.email-recommendation-card {
  border-left: 5px solid var(--brand);
}

.email-recommendation-card.risk-low {
  border-left-color: var(--good);
}

.email-recommendation-card.risk-medium,
.email-recommendation-card.risk-high {
  border-left-color: var(--warn);
}

.email-recommendation-card.risk-critical {
  border-left-color: var(--danger);
}

.recommendation-grid,
.recommendation-detail {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.recommendation-grid div,
.recommendation-detail > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.recommendation-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 720;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.recommendation-grid strong {
  font-size: 18px;
}

.recommendation-reason {
  margin: 14px 0 0;
}

.recommendation-reason p {
  margin: 4px 0 0;
}

.recommendation-warning-list,
.compact-list {
  display: grid;
  gap: 8px;
}

.recommendation-warning-list {
  margin-top: 12px;
}

.recommendation-warning-list span {
  border-left: 3px solid var(--warn);
  padding: 8px 10px;
  background: var(--warn-soft);
  border-radius: 6px;
}

.recommendation-detail {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.recommendation-detail h3 {
  margin: 0 0 10px;
}

.compact-list {
  margin: 0;
  padding-left: 18px;
}

.warning-state {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.contact-chip-list,
.email-checklist {
  display: grid;
  gap: 8px;
}

.contact-chip {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--surface-2);
  font-weight: 730;
}

.email-preview-frame {
  display: grid;
  justify-content: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8eef0;
}

.email-preview-frame.is-mobile .email-preview-card {
  max-width: 340px;
}

.email-preview-card {
  width: min(100%, 640px);
  display: grid;
  gap: 12px;
  background: #fff;
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.email-preview-card h2,
.email-preview-card p {
  margin: 0;
}

.email-preview-card .preheader,
.email-footer {
  color: var(--muted);
  font-size: 12px;
}

.email-preview-hero {
  display: grid;
  place-items: center;
  min-height: 140px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 760;
}

.email-preview-button {
  display: inline-flex;
  justify-content: center;
  width: fit-content;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  font-weight: 780;
  text-decoration: none;
}

.checklist-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.checklist-row span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 820;
}

.checklist-row.ok span {
  background: var(--good-soft);
  color: var(--good);
}

.checklist-row.warn span {
  background: var(--warn-soft);
  color: var(--warn);
}

.checklist-row.error span {
  background: var(--danger-soft);
  color: var(--danger);
}

.email-send-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 14px 0;
}

.email-send-summary div,
.report-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.email-send-summary span,
.report-card span,
.timeline-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.email-kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.drawer-backdrop {
  display: none;
}

@media (max-width: 1180px) {
  .conversation-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

  .conversation-copilot {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 45;
    width: min(420px, 92vw);
    max-height: 100vh;
    border-radius: 0;
    transform: translateX(104%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .conversation-copilot.is-open {
    transform: translateX(0);
  }

  .conversation-copilot:not(.is-open) .copilot-expanded-content {
    display: none;
  }

  .conversation-copilot.is-open .copilot-expanded-content {
    display: block;
  }

  .copilot-collapsed-toggle {
    display: none;
  }

  .conversation-copilot-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 44;
    border: 0;
    background: rgba(16, 37, 43, 0.34);
  }

  .conversation-copilot .copilot-body {
    max-height: calc(100vh - 72px);
  }

  .copilot-close,
  .conversation-copilot-inline {
    display: inline-flex;
  }

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(86vw, 310px);
    transform: translateX(-104%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow);
  }

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

  body.sidebar-open .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(16, 37, 43, 0.35);
  }

  .mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 22px;
  }

  .topbar {
    align-items: flex-start;
    padding: 10px 14px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .operator-pill {
    display: none;
  }

  .content {
    padding: 16px 14px 34px;
  }

  .conversation-layout,
  .two-column,
  .three-column,
  .metric-grid,
  .marketing-kpi-grid,
  .email-kpi-grid,
  .provider-grid,
  .recommendation-grid,
  .recommendation-detail,
  .email-editor-layout,
  .audience-filter-grid,
  .email-toggle-grid,
  .email-send-summary,
  .email-style-toolbar,
  .image-layout-options,
  .form-grid,
  .toolbar-grid {
    grid-template-columns: 1fr;
  }

  .analytics-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .analytics-filters {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    width: 100%;
  }

  .analytics-period,
  .analytics-currency {
    min-width: 0;
    width: 100%;
  }

  .panel-header,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .email-hero-actions {
    justify-content: stretch;
  }

  .email-hero-actions > *,
  .email-block .action-row > * {
    width: 100%;
  }

  .email-block {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .email-block .action-row {
    grid-column: 1 / -1;
  }

  .action-row > *,
  .compact-field {
    max-width: 100%;
    width: 100%;
  }

  .conversation-list,
  .chat-panel,
  .detail-panel {
    min-height: auto;
  }

  .chat-thread {
    height: 420px;
  }

  .conversation-commandbar,
  .conversation-commandbar-status,
  .conversation-languagebar,
  .composer-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .conversation-live-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .assistant-trace-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .conversation-search {
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .conversation-list .panel-body {
    max-height: 280px;
  }

  .conversation-copilot {
    inset: auto 0 0 0;
    width: 100%;
    max-height: 88vh;
    border-radius: 8px 8px 0 0;
    transform: translateY(104%);
  }

  .conversation-copilot.is-open {
    transform: translateY(0);
  }

  .conversation-copilot .copilot-body {
    max-height: calc(88vh - 72px);
  }

  .audit-item {
    grid-template-columns: 1fr;
  }

  .mobile-table-source {
    display: none;
  }

  .mobile-card-list {
    display: grid;
  }

  .modal-backdrop {
    align-items: start;
    padding: 12px;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
  }

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

  .export-filter-group.span-2 {
    grid-column: auto;
  }

  .export-filter-options.months {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 10px;
  }

  .page-title h1 {
    font-size: 18px;
  }

  .mock-banner {
    display: grid;
  }

  .panel-header,
  .panel-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .message {
    width: 96%;
  }
}

.payment-links-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

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

.section-heading h2,
.payment-provider-header h3,
.payment-settings-provider h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.section-heading p,
.payment-provider-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.payment-provider-grid,
.payment-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.payment-provider-card,
.payment-settings-provider {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(24, 41, 46, 0.06);
}

.payment-provider-card.mercadopago {
  border-top: 4px solid #168ad5;
}

.payment-provider-card.paypal {
  border-top: 4px solid #253b80;
}

.payment-provider-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 13px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.payment-link-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.payment-link-form .form-grid {
  gap: 11px;
}

.payment-link-form .field small {
  color: var(--muted);
  font-size: 11px;
}

.payment-source-note,
.payment-notices {
  color: #4b5b5f;
  font-size: 12px;
}

.payment-source-note {
  padding: 9px 10px;
  border-left: 3px solid #6c7a7d;
  background: #f1f4f4;
}

.payment-reservation-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.payment-search-results {
  display: grid;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
}

.payment-search-results button {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
}

.payment-search-results button:hover {
  background: #f3f8f8;
}

.money-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.money-input span {
  align-self: stretch;
  display: grid;
  place-items: center;
  min-width: 48px;
  padding: 0 9px;
  background: #e7ecec;
  color: #34474b;
  font-size: 12px;
  font-weight: 800;
}

.money-input input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}

.payment-calculation {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f7f9f9;
}

.payment-calculation div,
.payment-override > div:not(.field),
.payment-link-result > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.payment-calculation strong,
.payment-override strong,
.payment-link-result strong {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.payment-final-field {
  display: grid;
  gap: 7px;
  padding: 13px;
  border: 2px solid #314f55;
  background: #edf1f1;
}

.payment-final-field > label {
  font-weight: 850;
}

.payment-final-field .money-input input {
  font-size: 17px;
  font-weight: 850;
}

.payment-override {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid #d5a84b;
  background: #fff9e9;
}

.payment-override[hidden] {
  display: none;
}

.payment-override .field {
  min-width: 0;
}

.payment-bottom-fields {
  align-items: end;
}

.payment-notices {
  display: grid;
  gap: 3px;
}

.payment-notices p {
  margin: 0;
}

.payment-create-button {
  width: 100%;
  min-height: 42px;
}

.payment-link-result {
  display: grid;
  gap: 8px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: #eef8f2;
}

.payment-link-result input {
  width: 100%;
  min-width: 0;
}

.danger-button {
  color: #fff;
  border-color: #e1b0b0;
}

.payment-request-list {
  margin-top: 18px;
}

@media (prefers-reduced-motion: reduce) {
  .conversation-copilot,
  .conversation-copilot-trigger,
  .sidebar {
    transition: none;
  }
}

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

.external-payment-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(24, 41, 46, 0.05);
}

.external-payment-form .primary-button {
  justify-self: start;
  min-width: 210px;
}

.external-payment-history {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.external-payment-history .panel-header {
  padding: 12px 14px;
}

.external-payment-history h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.payment-request-list .tabs {
  overflow-x: auto;
}

.payment-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f7f9f9;
}

.payment-filter-grid .action-row {
  align-self: end;
}

.payment-settings-provider {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.payment-settings-provider .panel-header {
  padding: 0;
  border: 0;
}

.alert.warn {
  border-color: #dec98d;
  background: #fff9e9;
  color: #6d551d;
}

@media (max-width: 920px) {
  .payment-provider-grid,
  .payment-settings-grid,
  .payment-filter-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .payment-provider-header,
  .payment-calculation div,
  .payment-link-result > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .payment-override,
  .payment-reservation-search {
    grid-template-columns: 1fr;
  }

  .external-payment-form .primary-button {
    width: 100%;
  }
}

.reservation-guest-matches {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #d6e0e3;
  padding: 6px;
  background: #f7fafb;
}

.reservation-guest-match {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 54px;
  border: 1px solid transparent;
  padding: 8px 10px;
  background: #ffffff;
  color: #102d35;
  text-align: left;
  cursor: pointer;
}

.reservation-guest-match:hover,
.reservation-guest-match:focus-visible {
  border-color: #178393;
  background: #edf8f9;
  outline: none;
}

.reservation-guest-match span {
  color: #62777e;
  font-size: 13px;
}

@media (max-width: 700px) {
  .reservation-guest-matches {
    max-height: 180px;
  }
}

.access-category-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.access-category-card { border:1px solid var(--border); border-radius:6px; padding:12px; background:#fff; }
.access-category-card.selected { border-color:#0b7285; background:#f0f9fa; }
.access-category-heading { display:flex; gap:10px; align-items:flex-start; cursor:pointer; }
.access-category-heading input { margin-top:4px; }
.access-category-heading span { display:grid; gap:4px; }
.access-category-heading small { color:var(--muted); font-size:12px; line-height:1.35; }
.access-scope-fields { display:grid; gap:8px; margin-top:12px; padding-top:10px; border-top:1px solid var(--border); }
.access-scope-fields label { display:grid; gap:5px; font-size:12px; font-weight:700; }
.access-summary { display:flex; flex-wrap:wrap; gap:8px 16px; padding:12px; border-left:3px solid #0b7285; background:#eef7f8; }
.access-chip-row { display:flex; flex-wrap:wrap; gap:5px; }
.access-chip { display:inline-flex; padding:4px 7px; border-radius:4px; background:#e7f4f6; color:#075b69; font-size:12px; font-weight:700; }
.security-access-table { min-width:1180px; }
.access-editor-modal { max-width:960px; max-height:90vh; overflow:auto; }
.compact-heading { margin:0 0 8px; font-size:16px; }
@media (max-width:760px) {
  .access-category-grid { grid-template-columns:1fr; }
  .access-editor-modal { width:calc(100vw - 20px); }
}

.access-option-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; max-height:130px; overflow:auto; }
.access-option-list label { display:flex; align-items:center; gap:6px; font-weight:500; }
.access-scope-values { border:0; padding:0; margin:0; }
.access-scope-values legend { font-size:12px; font-weight:700; margin-bottom:5px; }
.fiscal-access-section { display:grid; gap:8px; padding:12px; border:1px solid var(--border); border-radius:6px; }
.fiscal-owner-row { display:grid; grid-template-columns:minmax(160px,1fr) repeat(4,auto); align-items:center; gap:8px 14px; padding:9px 0; border-top:1px solid var(--border); }
.fiscal-owner-row label { display:flex; gap:5px; align-items:center; font-size:12px; }
@media (max-width:760px) {
  .access-option-list { grid-template-columns:1fr; }
  .fiscal-owner-row { grid-template-columns:1fr 1fr; }
}


/* Universal guest search */
.reservation-guest-search-field { position: relative; z-index: 8; }
.field-label-row, .reservation-selected-guest, .reservation-guest-results-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.badge.neutral { background: #eef2f3; color: #52666c; }
.reservation-guest-combobox { position: relative; }
.reservation-guest-combobox .email-search-row { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 0; }
.reservation-search-icon {
  display: grid; place-items: center; border: 1px solid var(--line-strong); border-right: 0;
  border-radius: 6px 0 0 6px; background: #f5f7f7; color: var(--muted); font-size: 17px;
}
.reservation-guest-combobox input { border-radius: 0; }
.reservation-guest-combobox .icon-button { border-radius: 0 6px 6px 0; }
.reservation-guest-results {
  position: absolute; inset: calc(100% + 6px) 0 auto; z-index: 25; max-height: 370px; overflow: auto;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  box-shadow: 0 14px 34px rgba(17, 46, 54, .18); padding: 8px;
}
.reservation-guest-results-head { padding: 4px 6px 8px; border-bottom: 1px solid var(--line); }
.reservation-guest-match {
  width: 100%; display: grid; grid-template-columns: minmax(150px, 1.2fr) minmax(110px, .8fr) minmax(180px, 1fr);
  gap: 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 11px 8px;
  background: #fff; color: var(--text); text-align: left;
}
.reservation-guest-match:hover, .reservation-guest-match:focus-visible { background: var(--brand-soft); }
.reservation-guest-match span, .reservation-search-notice { color: var(--muted); font-size: 12px; }
.reservation-search-state { display: grid; gap: 7px; margin: 0; padding: 18px 10px; color: var(--muted); }
.reservation-show-more { width: 100%; margin-top: 8px; }
.reservation-selected-guest {
  margin-top: 9px; padding: 10px 12px; border: 1px solid #9bd5c2; border-radius: 8px; background: #eef9f5;
}
.reservation-selected-guest > div:first-child { display: grid; gap: 2px; }
.reservation-selected-guest span { color: #35675a; font-size: 11px; font-weight: 700; }
.text-button { border: 0; background: transparent; color: var(--brand); font-weight: 750; padding: 5px; }
.danger-text { color: var(--danger); }
.secondary-button.compact { width: fit-content; padding: 7px 10px; }
@media (max-width: 760px) {
  .reservation-guest-results {
    position: fixed; inset: auto 0 0; z-index: 70; max-height: min(68vh, 620px);
    border-radius: 8px 8px 0 0; padding: 12px; box-shadow: 0 -12px 36px rgba(17, 46, 54, .24);
  }
  .reservation-guest-match { grid-template-columns: minmax(0, 1fr); gap: 3px; min-height: 72px; }
  .reservation-selected-guest { align-items: flex-start; }
}


.accessible-modal-card[data-accessible-modal-id="reservation-duplicate-modal"] { width: min(100%, 680px); }
.reservation-duplicate-intro { margin: 0; color: var(--muted); line-height: 1.5; }
.reservation-duplicate-list { display: grid; gap: 8px; margin: 14px 0; }
.reservation-duplicate-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: 8px; padding: 11px;
}
.reservation-duplicate-identity { display: grid; min-width: 0; gap: 3px; }
.reservation-duplicate-identity span,
.reservation-duplicate-identity small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.reservation-duplicate-blocked { margin: 0; color: var(--danger); font-size: 13px; line-height: 1.4; }
.reservation-duplicate-actions { justify-content: flex-end; }
@media (max-width: 620px) {
  .accessible-modal-backdrop { align-items: end; padding: 10px; }
  .accessible-modal-card { width: 100%; max-height: calc(100dvh - 20px); }
  .accessible-modal-card .accessible-modal-header { align-items: center; flex-direction: row; }
  .accessible-modal-card .accessible-modal-footer { align-items: stretch; }
  .reservation-duplicate-row { align-items: stretch; flex-direction: column; }
  .reservation-duplicate-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .reservation-duplicate-actions > * { width: 100%; }
}


.reservation-form-grid > .reservation-guest-search-field {
  grid-column: span 12;
  order: 0;
}


/* Persistent Stays synchronization */
.sync-center-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin-bottom: 14px; padding: 2px 0;
}
.sync-center-toolbar h2 { margin: 0; font-size: 21px; }
.sync-center-toolbar p, .panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.sync-resource-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sync-resource-panel { min-width: 0; }
.sync-resource-panel .tiny-button.danger-button {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.sync-last-success { padding: 0 18px 12px; color: var(--muted); font-size: 12px; }
.sync-status-band { border-top: 1px solid var(--line); padding: 15px 18px; background: #f8fafb; }
.sync-status-band.is-compact { margin: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sync-tone-good { background: #f2faf6; }
.sync-tone-danger { background: #fff5f3; }
.sync-tone-warning { background: #fff9ed; }
.sync-tone-active { background: #f2f8fa; }
.sync-status-heading, .sync-status-footer, .sync-progress-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.sync-status-heading > div { display: grid; gap: 3px; min-width: 0; }
.sync-status-heading span, .sync-status-footer > span, .sync-progress-meta { color: var(--muted); font-size: 12px; }
.sync-progress { height: 7px; margin-top: 13px; overflow: hidden; border-radius: 4px; background: #dce8eb; }
.sync-progress > span { display: block; height: 100%; background: #087888; transition: width .25s ease; }
.sync-progress-meta { margin-top: 5px; }
.sync-counter-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 13px; color: var(--muted); font-size: 12px; }
.sync-counter-row strong { color: var(--ink); }
.sync-error-message {
  display: flex; align-items: flex-start; gap: 10px; margin: 12px 18px; padding: 11px 12px;
  border-left: 3px solid #bd3f32; background: #fff1ef; color: #7d2d25; font-size: 12px;
}
.sync-error-message span { overflow-wrap: anywhere; }
.sync-status-footer { align-items: flex-end; flex-wrap: wrap; margin-top: 13px; padding-top: 11px; border-top: 1px solid rgba(100, 125, 132, .18); }
.sync-status-empty { padding: 16px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.sync-history-panel { margin-top: 14px; }
@media (max-width: 980px) {
  .sync-resource-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .sync-center-toolbar, .sync-status-heading, .sync-status-footer { align-items: stretch; flex-direction: column; }
  .sync-center-toolbar .secondary-button, .sync-resource-panel .primary-button { width: 100%; }
  .sync-status-band { padding: 14px; }
  .sync-error-message { margin-inline: 14px; }
}

/* Hierarchical team access */
.scope-type-option[hidden],
.hierarchical-scope-select[hidden],
.ownership-scope-selector[hidden],
.assigned-records-note[hidden],
.category-override-card[hidden],
[data-access-override-editor][hidden],
.owner-permissions-section[hidden],
.fiscal-access-section[hidden] { display:none !important; }
.access-team-panel,
.access-users-panel,
.access-diagnostics-panel { margin-bottom:14px; }

.access-profile-form { display:grid; gap:0; padding:0; }
.access-form-section { padding:18px 20px; border-bottom:1px solid var(--border); }
.access-section-heading { display:flex; align-items:flex-start; gap:10px; margin-bottom:14px; }
.access-section-heading h3 { margin:0; font-size:16px; line-height:1.25; }
.access-section-heading p { margin:3px 0 0; color:var(--muted); font-size:13px; }
.access-step {
  display:grid; place-items:center; flex:0 0 26px; width:26px; height:26px;
  border-radius:50%; background:#0b7285; color:#fff; font-size:12px; font-weight:800;
}

.access-category-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.access-category-card {
  min-height:112px; display:flex; flex-direction:column; justify-content:space-between;
  border-radius:6px; padding:12px; transition:border-color .15s ease,background .15s ease;
}
.access-category-heading span { min-width:0; }
.access-recommendation { margin-top:10px; color:#52646b; font-size:11px; line-height:1.35; }
.access-category-card:not(.selected) .access-recommendation { opacity:.72; }

.primary-scope-section { background:#f7fafb; }
.scope-type-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.scope-type-option {
  display:flex; align-items:flex-start; gap:8px; min-height:58px; padding:10px;
  border:1px solid var(--border); border-radius:6px; background:#fff; cursor:pointer;
}
.scope-type-option.selected { border-color:#0b7285; box-shadow:0 0 0 1px #0b7285; background:#effafa; }
.scope-type-option input { margin-top:3px; }
.scope-type-option span { display:grid; gap:3px; min-width:0; }
.scope-type-option strong { font-size:13px; line-height:1.3; }
.scope-type-option small { color:#0b7285; font-size:10px; font-weight:800; text-transform:uppercase; }

.access-scope-editor { display:grid; gap:12px; }
.hierarchical-scope-select,
.ownership-scope-selector,
.assigned-records-note { margin-top:2px; }
.scope-picker-trigger {
  width:100%; min-height:44px; display:flex; align-items:center; justify-content:space-between;
  gap:10px; padding:9px 12px; border:1px solid #9fb3b9; border-radius:6px;
  background:#fff; color:var(--text); font:inherit; font-weight:750; text-align:left; cursor:pointer;
}
.scope-picker-trigger:hover { border-color:#0b7285; }
.access-scope-chip-row { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; min-height:26px; }
.access-scope-chip {
  max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  padding:5px 8px; border:1px solid #b9d7db; border-radius:999px;
  background:#eef8f9; color:#174b55; font-size:12px; font-weight:700;
}
.scope-inheritance-toggle {
  display:flex; align-items:center; gap:8px; margin-top:14px; padding-top:12px;
  border-top:1px solid var(--border); font-size:13px; font-weight:750;
}

.category-scope-overrides { border:1px solid var(--border); border-radius:6px; background:#fff; }
.category-scope-overrides > summary {
  cursor:pointer; list-style:none; display:flex; align-items:center; padding:12px 14px;
}
.category-scope-overrides > summary::-webkit-details-marker { display:none; }
.category-scope-overrides > summary span { display:grid; gap:3px; }
.category-scope-overrides > summary small { color:var(--muted); font-size:12px; font-weight:500; }
.category-scope-overrides > summary::after { content:"+"; margin-left:auto; font-size:20px; }
.category-scope-overrides[open] > summary::after { content:"\2212"; }
.category-override-list { border-top:1px solid var(--border); }
.category-override-card { padding:13px; border-bottom:1px solid var(--border); }
.category-override-card:last-child { border-bottom:0; }
.category-override-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.category-override-header > span { display:grid; gap:2px; }
.category-override-header small { color:var(--muted); font-size:12px; }
.category-override-header label { display:flex; align-items:center; gap:6px; font-size:12px; font-weight:750; }
.category-override-card [data-access-override-editor] { margin-top:12px; padding-top:12px; border-top:1px dashed var(--border); }

.ownership-scope-selector { display:grid; grid-template-columns:minmax(220px,320px) 1fr; gap:14px; }
.owned-units-preview { display:grid; gap:5px; padding:10px 12px; border-left:3px solid #0b7285; background:#f4f8f9; }
.unit-display-label { display:inline; overflow-wrap:anywhere; }
.unit-display-label strong { white-space:nowrap; }
.owner-permission-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 14px; }
.owner-permission-grid label { display:flex; align-items:flex-start; gap:8px; font-size:13px; }

.effective-permissions-summary { padding:18px 20px; background:#f7fafb; border-bottom:1px solid var(--border); }
.effective-permissions-summary dl { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 24px; margin:0; }
.effective-permissions-summary dl > div { display:grid; grid-template-columns:150px 1fr; gap:10px; padding:8px 0; border-bottom:1px solid #dce7e9; }
.effective-permissions-summary dt { color:var(--muted); font-size:12px; font-weight:700; }
.effective-permissions-summary dd { margin:0; font-size:13px; font-weight:750; overflow-wrap:anywhere; }

.sticky-form-actions {
  position:sticky; bottom:0; z-index:4; display:flex; justify-content:flex-end; gap:8px;
  padding:12px 20px; border-top:1px solid var(--border); background:rgba(255,255,255,.96);
}
.access-expiration-field { margin:16px 20px; max-width:320px; }
.security-access-table th,
.security-access-table td { vertical-align:top; }
.security-access-table .action-row { min-width:250px; }
.scope-summary-text { font-weight:750; }

.scope-picker-backdrop { align-items:center; }
.scope-picker-modal { width:min(680px,calc(100vw - 28px)); max-height:min(760px,calc(100vh - 32px)); display:grid; grid-template-rows:auto auto 1fr auto; overflow:hidden; }
.scope-picker-toolbar { display:grid; grid-template-columns:1fr auto; align-items:end; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); }
.scope-picker-list { min-height:220px; overflow:auto; padding:4px 14px 12px; }
.scope-picker-group { position:sticky; top:0; z-index:1; padding:10px 4px 6px; background:#fff; color:#52646b; font-size:11px; font-weight:850; text-transform:uppercase; }
.scope-picker-item { display:flex; align-items:flex-start; gap:10px; padding:9px 6px; border-bottom:1px solid #edf1f2; cursor:pointer; }
.scope-picker-item input { margin-top:3px; }
.scope-picker-item span { display:grid; gap:2px; min-width:0; }
.scope-picker-item strong { overflow-wrap:anywhere; }
.scope-picker-item small { color:var(--muted); font-size:12px; }
.scope-picker-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; border-top:1px solid var(--border); background:#f8fafb; }
.effective-category-list { display:grid; gap:8px; padding-top:14px; }
.effective-category-card { padding:12px; border:1px solid var(--border); border-radius:6px; }
.effective-category-card > div { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.effective-category-card p { margin:8px 0 0; font-size:12px; overflow-wrap:anywhere; }

@media (max-width:1100px) {
  .access-category-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .scope-type-options { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .effective-permissions-summary dl { grid-template-columns:1fr; }
}

@media (max-width:760px) {
  .access-form-section { padding:15px 14px; }
  .access-category-grid,
  .scope-type-options,
  .owner-permission-grid,
  .ownership-scope-selector { grid-template-columns:1fr; }
  .access-category-card { min-height:0; }
  .category-override-header { align-items:flex-start; flex-direction:column; }
  .sticky-form-actions { padding:10px 14px; }
  .sticky-form-actions .primary-button,
  .sticky-form-actions .secondary-button { flex:1 1 auto; }
  .effective-permissions-summary { padding:15px 14px; }
  .effective-permissions-summary dl > div { grid-template-columns:1fr; gap:3px; }
  .access-editor-modal { width:100%; max-width:none; height:100%; max-height:none; border-radius:0; }
  .scope-picker-backdrop { align-items:flex-end; padding:0; }
  .scope-picker-modal { width:100%; max-height:88vh; border-radius:6px 6px 0 0; }
  .scope-picker-toolbar { grid-template-columns:1fr; }
  .scope-picker-footer { align-items:stretch; flex-direction:column; }
  .scope-picker-footer .action-row { width:100%; }
  .scope-picker-footer button { flex:1 1 auto; }

  .security-access-table,
  .security-access-table thead,
  .security-access-table tbody,
  .security-access-table tr,
  .security-access-table th,
  .security-access-table td { display:block; width:100%; }
  .security-access-table { min-width:0; }
  .security-access-table thead { display:none; }
  .security-access-table tbody { padding:8px; }
  .security-access-table tr { margin-bottom:10px; padding:12px; border:1px solid var(--border); border-radius:6px; background:#fff; }
  .security-access-table td { padding:5px 0; border:0; min-width:0; }
  .security-access-table td::before { display:block; color:var(--muted); font-size:10px; font-weight:800; text-transform:uppercase; }
  .security-access-table td:nth-child(1)::before { content:"Nombre"; }
  .security-access-table td:nth-child(2)::before { content:"Email"; }
  .security-access-table td:nth-child(3)::before { content:"Categorias"; }
  .security-access-table td:nth-child(4)::before { content:"Alcance"; }
  .security-access-table td:nth-child(5)::before { content:"Establecimientos"; }
  .security-access-table td:nth-child(6)::before { content:"Estado"; }
  .security-access-table td:nth-child(7)::before { content:"Ultima conexion"; }
  .security-access-table td:nth-child(8)::before { content:"Acciones"; }
  .security-access-table .action-row { display:flex; min-width:0; flex-wrap:wrap; }
}
