:root {
  --emc-primary: #6d5dfc;
  --emc-primary-hover: #5847e8;
  --emc-navy: #061b3a;
  --emc-teal: #14b8a6;
  --emc-success: #10b981;
  --emc-warning: #f59e0b;
  --emc-danger: #ef4444;
  --emc-info: #2563eb;
  --emc-surface: #ffffff;
  --emc-surface-muted: #f8fafc;
  --emc-border: #e5ebf4;
  --emc-border-strong: #cbd5e1;
  --emc-text: #101828;
  --emc-text-soft: #475569;
  --emc-muted: #94a3b8;
  --emc-radius-sm: 10px;
  --emc-radius-md: 12px;
  --emc-radius-lg: 16px;
  --emc-shadow-card: 0 16px 42px rgba(15, 23, 42, 0.07);
  --emc-shadow-dropdown: 0 18px 46px rgba(15, 23, 42, 0.16);
  --emc-shadow-modal: 0 30px 80px rgba(15, 23, 42, 0.22);
  --emc-control-h: 44px;
  --emc-transition: 180ms ease;
}

body {
  color: var(--emc-text);
  font-family: Inter, "Plus Jakarta Sans", Manrope, system-ui, sans-serif;
  letter-spacing: 0;
}

.content {
  background:
    radial-gradient(circle at top right, rgba(20, 184, 166, 0.08), transparent 32vw),
    linear-gradient(180deg, #fbfdff 0%, #f7f9fc 100%);
}

.panel,
.module-panel,
.bookings-card,
.table-shell,
.stat-card,
.settings-shell,
.modal-content,
.email-workspace {
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-lg);
  background: var(--emc-surface);
  box-shadow: var(--emc-shadow-card);
}

.panel,
.module-panel {
  padding: 24px;
}

.module-action,
.view-btn,
.outline-full,
.date-select,
button,
.btn {
  min-height: var(--emc-control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  background: var(--emc-surface);
  color: var(--emc-text);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: transform var(--emc-transition), box-shadow var(--emc-transition), background var(--emc-transition), border-color var(--emc-transition);
}

.module-action:hover,
.view-btn:hover,
.outline-full:hover,
.date-select:hover,
button:hover,
.btn:hover {
  transform: translateY(-1px);
  border-color: var(--emc-border-strong);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.module-action.primary,
.btn-primary,
button.primary {
  border-color: var(--emc-primary);
  background: var(--emc-primary);
  color: #fff;
}

.module-action.primary:hover,
.btn-primary:hover,
button.primary:hover {
  background: var(--emc-primary-hover);
}

.module-action.danger,
.btn-danger {
  border-color: rgba(239, 68, 68, 0.2);
  background: #fff1f2;
  color: #dc2626;
}

.module-action.success,
.btn-success {
  border-color: rgba(16, 185, 129, 0.2);
  background: #ecfdf5;
  color: #047857;
}

button:disabled,
.module-action.disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

label {
  color: var(--emc-text-soft);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select,
.mini-input {
  min-height: var(--emc-control-h);
  width: 100%;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  background: #fff;
  color: var(--emc-text);
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--emc-transition), box-shadow var(--emc-transition), background var(--emc-transition);
}

textarea {
  min-height: 112px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus,
.mini-input:focus,
.emc-select.is-open .emc-select-trigger {
  border-color: rgba(109, 93, 252, 0.72);
  box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.12);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.emc-native-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.emc-select {
  position: relative;
  width: 100%;
}

.emc-select-trigger {
  width: 100%;
  min-height: var(--emc-control-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  background: #fff;
  color: var(--emc-text);
  font-weight: 700;
}

.emc-select-panel {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  padding: 8px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-lg);
  background: #fff;
  box-shadow: var(--emc-shadow-dropdown);
  animation: emcFadeUp var(--emc-transition);
}

.emc-select.is-open .emc-select-panel {
  display: block;
}

.emc-select-search {
  margin-bottom: 8px;
}

.emc-select-options {
  max-height: 240px;
  overflow: auto;
}

.emc-select-option {
  width: 100%;
  justify-content: flex-start;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--emc-text-soft);
  box-shadow: none;
}

.emc-select-option:hover,
.emc-select-option.is-selected,
.emc-select-option.is-active {
  background: #f0edff;
  color: var(--emc-primary);
  transform: none;
}

.emc-select-empty {
  padding: 12px;
  color: var(--emc-muted);
  text-align: center;
}

.status-pill,
.badge,
.match-score {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.module-table,
.bookings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.module-table th,
.bookings-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-transform: none;
}

.module-table td,
.module-table th,
.bookings-table td,
.bookings-table th {
  padding: 14px 16px;
  border-bottom: 1px solid var(--emc-border);
}

.module-table tbody tr,
.bookings-table tbody tr {
  transition: background var(--emc-transition);
}

.module-table tbody tr:hover,
.bookings-table tbody tr:hover {
  background: #fbfdff;
}

.empty-state {
  padding: 32px;
  border: 1px dashed var(--emc-border-strong);
  border-radius: var(--emc-radius-lg);
  background: #fbfdff;
  color: var(--emc-text-soft);
  text-align: center;
}

.empty-state i,
.empty-state svg {
  color: var(--emc-primary);
}

.modal-backdrop {
  backdrop-filter: blur(8px);
}

.modal-content {
  border: 1px solid var(--emc-border);
  box-shadow: var(--emc-shadow-modal);
}

@keyframes emcFadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.emc-page-heading {
  margin-bottom: 16px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--emc-primary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.emc-tabs {
  margin-bottom: 20px;
}

.crm-email-shell {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr) 300px;
  min-height: calc(100vh - 230px);
  border: 1px solid var(--emc-border);
  border-radius: 22px;
  background: var(--emc-surface);
  box-shadow: var(--emc-shadow-card);
  overflow: hidden;
}

.crm-email-left,
.crm-email-context {
  background: #fbfdff;
}

.crm-email-left {
  border-right: 1px solid var(--emc-border);
}

.crm-email-context {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
  border-left: 1px solid var(--emc-border);
}

.crm-email-left-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--emc-border);
}

.crm-email-left-head small,
.crm-email-header p,
.context-pair span,
.locked-recipient small {
  display: block;
  color: var(--emc-muted);
  font-size: 12px;
  font-weight: 700;
}

.crm-email-folders {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
}

.crm-email-folders a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--emc-radius-md);
  color: var(--emc-text-soft);
  font-size: 13px;
  font-weight: 800;
}

.crm-email-folders a.active,
.crm-email-folders a:hover {
  color: var(--emc-primary);
  background: #f0edff;
}

.crm-thread-list {
  display: grid;
  gap: 10px;
  padding: 14px;
  max-height: calc(100vh - 355px);
  overflow: auto;
}

.crm-thread-card {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-lg);
  background: var(--emc-surface);
  color: var(--emc-text);
  transition: transform var(--emc-transition), box-shadow var(--emc-transition), border-color var(--emc-transition);
}

.crm-thread-card:hover,
.crm-thread-card.active {
  transform: translateY(-1px);
  border-color: rgba(109, 93, 252, 0.35);
  box-shadow: 0 14px 32px rgba(109, 93, 252, 0.12);
}

.crm-thread-card strong,
.crm-email-header h2,
.context-card h3 {
  margin: 0;
  color: var(--emc-text);
}

.crm-thread-card small {
  display: -webkit-box;
  margin-top: 4px;
  color: var(--emc-text-soft);
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.crm-thread-card time {
  color: var(--emc-muted);
  font-size: 11px;
  white-space: nowrap;
}

.crm-thread-card b,
.crm-thread-card em {
  grid-column: 2;
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  color: #0369a1;
  background: #e0f2fe;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.crm-thread-card b {
  position: absolute;
  top: 8px;
  left: 8px;
  color: #fff;
  background: var(--emc-primary);
}

.crm-email-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}

.crm-email-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--emc-border);
}

.crm-email-header h2 {
  font-size: 22px;
}

.crm-email-thread {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 24px;
  overflow: auto;
}

.crm-email-message {
  display: grid;
  grid-template-columns: 42px minmax(0, 760px);
  gap: 12px;
  align-items: start;
}

.crm-email-message.outgoing {
  justify-content: end;
  grid-template-columns: minmax(0, 760px) 42px;
}

.crm-email-message.outgoing .avatar-sm {
  grid-column: 2;
  grid-row: 1;
}

.crm-email-message.outgoing .crm-email-bubble {
  grid-column: 1;
  grid-row: 1;
  background: #f8f7ff;
}

.crm-email-bubble {
  padding: 16px;
  border: 1px solid var(--emc-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.crm-email-bubble header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.crm-email-bubble h3 {
  margin: 12px 0 8px;
  font-size: 15px;
}

.crm-email-bubble p {
  margin: 0;
  color: var(--emc-text-soft);
  line-height: 1.6;
}

.crm-email-bubble time,
.crm-email-bubble small {
  color: var(--emc-muted);
  font-size: 12px;
}

.crm-email-composer {
  display: grid;
  gap: 14px;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--emc-border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.composer-top {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(260px, 1fr);
  gap: 14px;
}

.locked-recipient {
  min-height: var(--emc-control-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  background: #f8fafc;
}

.locked-recipient span {
  flex: 1;
}

.locked-recipient em {
  padding: 4px 8px;
  border-radius: 999px;
  color: #047857;
  background: #ecfdf5;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.crm-email-composer footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.crm-email-composer footer span {
  flex: 1;
  min-width: 220px;
  color: var(--emc-muted);
  font-size: 12px;
  font-weight: 700;
}

.context-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-lg);
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.context-pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}

.context-pair:last-of-type {
  border-bottom: 0;
}

.crm-email-empty {
  align-self: center;
  justify-self: center;
  max-width: 420px;
}

.mailbox-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.42fr) minmax(0, 1fr);
  gap: 20px;
}

.mailbox-status-card,
.mailbox-config-card {
  display: grid;
  align-content: start;
  gap: 16px;
}

.mailbox-status-card h2 {
  margin: 0;
  font-size: 22px;
}

.mailbox-status-card p,
.mailbox-status-card small {
  color: var(--emc-text-soft);
}

.advanced-mailbox {
  padding: 14px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-lg);
  background: #fbfdff;
}

.advanced-mailbox summary {
  cursor: pointer;
  color: var(--emc-primary);
  font-weight: 800;
}

.advanced-mailbox .form-grid {
  margin-top: 14px;
}

.mailbox-help-callout {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: var(--emc-radius-lg);
  background: #f0fdfa;
}

.mailbox-help-callout i,
.mailbox-help-callout svg {
  color: var(--emc-teal);
}

.mailbox-help-callout p {
  margin: 4px 0 0;
  color: var(--emc-text-soft);
}

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

.guide-card {
  display: grid;
  gap: 14px;
}

.guide-steps {
  display: grid;
  gap: 12px;
  padding-left: 20px;
}

.guide-steps p,
.guide-card p {
  margin: 4px 0 0;
  color: var(--emc-text-soft);
  line-height: 1.55;
}

.mailbox-screenshot-placeholder {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 1px dashed var(--emc-border-strong);
  border-radius: var(--emc-radius-lg);
  background: #f8fafc;
  color: var(--emc-muted);
  font-weight: 800;
}

@media (max-width: 860px) {
  .panel,
  .module-panel {
    padding: 16px;
  }

  .module-table td,
  .module-table th,
  .bookings-table td,
  .bookings-table th {
    padding: 12px;
  }

  .crm-email-shell {
    grid-template-columns: 1fr;
  }

  .crm-email-left,
  .crm-email-context {
    border: 0;
    border-bottom: 1px solid var(--emc-border);
  }

  .crm-thread-list {
    max-height: 340px;
  }

  .composer-top {
    grid-template-columns: 1fr;
  }

  .crm-email-header,
  .crm-email-composer footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .mailbox-grid,
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

/* Email workspace polish */
.email-channel-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.email-channel-tabs a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.email-channel-tabs svg,
.email-channel-tabs i[data-lucide] {
  width: 16px;
  height: 16px;
}

.crm-email-shell {
  grid-template-columns: minmax(280px, 360px) minmax(520px, 1fr) minmax(260px, 320px);
  min-height: calc(100vh - 210px);
  border-radius: 18px;
}

.crm-email-left,
.crm-email-context {
  background: #f8fafc;
}

.crm-email-left-head {
  min-height: 82px;
  padding: 20px;
  background: #fff;
}

.crm-email-left-head strong {
  display: block;
  font-size: 15px;
}

.crm-email-folders {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--emc-border);
}

.crm-email-folders a {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
}

.crm-email-folders a.active,
.crm-email-folders a:hover {
  border-color: rgba(109, 93, 252, 0.18);
}

.crm-thread-list {
  gap: 12px;
  padding: 16px;
  max-height: calc(100vh - 360px);
}

.crm-thread-card {
  grid-template-columns: 40px minmax(0, 1fr);
  padding: 14px;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.035);
}

.crm-thread-card:hover,
.crm-thread-card.active {
  transform: none;
  background: #fff;
}

.thread-card-content {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.thread-card-meta,
.thread-card-tags {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.thread-card-meta strong,
.thread-card-subject {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-card-meta strong {
  font-size: 13px;
}

.thread-card-subject {
  color: var(--emc-text);
  font-size: 14px;
  font-weight: 800;
}

.thread-card-tags {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.crm-thread-card b,
.crm-thread-card em {
  position: static;
  grid-column: auto;
  justify-self: auto;
}

.crm-thread-card b {
  min-width: 22px;
  text-align: center;
}

.crm-email-main {
  grid-template-rows: auto minmax(320px, 1fr) auto;
  background: #fff;
}

.crm-email-header {
  min-height: 82px;
  padding: 20px 24px;
  background: #fff;
}

.crm-email-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.25;
}

.crm-email-thread {
  gap: 16px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.72), rgba(255, 255, 255, 0.88)),
    radial-gradient(circle at top left, rgba(109, 93, 252, 0.07), transparent 28rem);
}

.crm-email-message {
  grid-template-columns: 40px minmax(0, 720px);
}

.crm-email-message.outgoing {
  grid-template-columns: minmax(0, 720px) 40px;
}

.crm-email-bubble {
  border-radius: 16px;
}

.crm-email-bubble header {
  justify-content: space-between;
  gap: 12px;
}

.crm-email-bubble header > span:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.crm-email-bubble header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-email-bubble h3 {
  margin: 14px 0 8px;
  font-size: 14px;
  line-height: 1.35;
}

.crm-email-bubble p {
  color: var(--emc-text);
  font-size: 14px;
}

.email-attachments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.email-attachments a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--emc-border);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 800;
}

.crm-email-composer {
  gap: 12px;
  padding: 18px 24px;
  background: #fff;
}

.composer-top {
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
}

.crm-email-composer textarea {
  min-height: 124px;
  resize: vertical;
}

.crm-email-composer footer {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
}

.crm-email-context {
  padding: 18px;
}

.context-card {
  border-radius: 14px;
}

.context-card .module-action {
  width: 100%;
}

@media (max-width: 1280px) {
  .crm-email-shell {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }

  .crm-email-context {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--emc-border);
    border-left: 0;
  }
}

@media (max-width: 920px) {
  .crm-email-shell {
    grid-template-columns: 1fr;
  }

  .crm-email-left,
  .crm-email-context {
    border-right: 0;
    border-left: 0;
  }

  .crm-email-context {
    grid-template-columns: 1fr;
  }

  .crm-thread-list {
    max-height: 360px;
  }

  .crm-email-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .crm-email-composer footer {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .crm-email-composer footer .module-action {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .crm-email-shell {
    border-radius: 14px;
  }

  .crm-email-left-head,
  .crm-email-header,
  .crm-email-thread,
  .crm-email-composer,
  .crm-email-context {
    padding: 16px;
  }

  .crm-email-folders {
    grid-template-columns: 1fr;
  }

  .crm-email-message,
  .crm-email-message.outgoing {
    grid-template-columns: 1fr;
  }

  .crm-email-message > .avatar-sm {
    display: none;
  }

  .composer-top {
    grid-template-columns: 1fr;
  }
}

.media-manager .module-panel {
  overflow: visible;
}

.media-filter {
  grid-template-columns: minmax(220px, 1fr) 160px 160px 140px auto auto;
}

.media-view-toggle,
.media-preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.media-view-toggle .view-btn.active {
  border-color: var(--emc-primary);
  color: var(--emc-primary);
  background: rgba(37, 99, 235, 0.08);
}

.media-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.media-results {
  min-width: 0;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 14px;
}

.media-card,
.media-file-line {
  border: 1px solid var(--emc-border);
  background: #fff;
  color: var(--emc-text);
  text-align: left;
  cursor: pointer;
}

.media-card {
  display: grid;
  gap: 10px;
  min-height: 206px;
  padding: 10px;
  border-radius: 8px;
}

.media-card:hover,
.media-card.selected,
.media-file-line:hover,
.media-file-line.selected {
  border-color: var(--emc-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.10);
}

.media-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 7px;
  background: #f1f5f9;
  color: var(--emc-primary);
}

.media-thumb.small {
  width: 42px;
  height: 42px;
  aspect-ratio: auto;
  border-radius: 6px;
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb svg {
  width: 34px;
  height: 34px;
}

.media-card-body,
.media-file-line span:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.media-card-body strong,
.media-file-line strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-card-body small,
.media-file-line small {
  color: var(--emc-text-soft);
  font-size: 11px;
  font-weight: 700;
}

.media-file-line {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 6px;
  border-radius: 7px;
}

.media-preview-panel {
  position: sticky;
  top: 16px;
  min-height: 420px;
  padding: 14px;
  border: 1px solid var(--emc-border);
  border-radius: 8px;
  background: #fff;
}

.media-preview-empty {
  display: grid;
  place-items: center;
  min-height: 390px;
  color: var(--emc-text-soft);
  text-align: center;
}

.media-preview-empty svg {
  width: 34px;
  height: 34px;
  color: var(--emc-primary);
}

.media-preview-empty strong {
  color: var(--emc-text);
  font-size: 15px;
}

.media-preview-content {
  display: grid;
  gap: 14px;
}

.media-preview-frame {
  display: grid;
  place-items: center;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--emc-border);
  border-radius: 7px;
  background: #f8fafc;
}

.media-preview-frame img,
.media-preview-frame iframe {
  width: 100%;
  height: 280px;
  border: 0;
  object-fit: contain;
}

.media-document-preview {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 220px;
  color: var(--emc-text-soft);
  text-align: center;
}

.media-document-preview svg {
  width: 44px;
  height: 44px;
  color: var(--emc-primary);
}

.media-document-preview strong {
  color: var(--emc-text);
}

.media-preview-content h2 {
  margin: 0;
  color: var(--emc-text);
  font-size: 17px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.media-preview-content dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.media-preview-content dl div {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
}

.media-preview-content dt {
  color: var(--emc-text-soft);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.media-preview-content dd {
  margin: 0;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.media-preview-actions .module-action {
  flex: 1;
  justify-content: center;
}

.media-attach-form {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--emc-border);
}

.media-attach-form h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
}

.media-attach-form input,
.media-attach-form select,
.media-modal-card input,
.media-modal-card select,
.media-modal-card textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--emc-border);
  border-radius: 7px;
  background: #fff;
}

.media-delete-wide {
  justify-content: center;
  width: 100%;
}

.media-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
}

.media-modal-card {
  display: grid;
  gap: 12px;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.media-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.media-modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.media-modal-card label {
  display: grid;
  gap: 6px;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 900;
}

.media-manager .hidden {
  display: none !important;
}

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

  .media-preview-panel {
    position: static;
  }

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

@media (max-width: 720px) {
  .media-filter {
    grid-template-columns: 1fr;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  }
}

.trash-filter {
  grid-template-columns: minmax(240px, 1fr) 220px auto;
}

.trash-recovery .view-btn.danger {
  color: var(--emc-danger);
}

@media (max-width: 720px) {
  .trash-filter {
    grid-template-columns: 1fr;
  }
}

/* Final design-system consistency layer */
:where(a, button, input, textarea, select, [role="button"]):focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.16);
}

:where(.module-action, .view-btn, .btn, .outline-full, .date-select, .modal-close, .menu-btn, .dropdown-trigger) {
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

:where(.module-action, .btn, .outline-full, .date-select) {
  min-height: var(--emc-control-h);
  border-radius: var(--emc-radius-md);
  font-size: 13px;
}

:where(.module-action, .view-btn, .btn, .modal-close, .menu-btn, .dropdown-trigger) :where(svg, i[data-lucide]) {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

:where(.module-action.primary, .btn-primary) {
  border-color: var(--emc-primary);
  background: var(--emc-primary);
  color: #fff;
}

:where(.module-action.success, .btn-success) {
  border-color: rgba(16, 185, 129, 0.28);
  background: #ecfdf5;
  color: #047857;
}

:where(.module-action.warning, .btn-warning) {
  border-color: rgba(245, 158, 11, 0.28);
  background: #fffbeb;
  color: #b45309;
}

:where(.module-action.danger, .btn-danger) {
  border-color: rgba(239, 68, 68, 0.25);
  background: #fff1f2;
  color: #dc2626;
}

:where(.module-action.ghost, .btn-ghost) {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

:where(.module-action:disabled, .module-action.disabled, .view-btn:disabled, .btn:disabled, button[disabled]) {
  pointer-events: none;
  opacity: 0.56;
  filter: grayscale(0.12);
}

:where(.view-btn, .icon-btn, .icon-tool, .modal-close, .menu-btn, .dropdown-trigger) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--emc-radius-md);
  line-height: 1;
}

:where(.row-actions, .inline-actions, .panel-title, .page-heading, .filter-bar, .pagination-row) {
  min-width: 0;
}

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

.row-actions form,
.inline-actions form {
  display: inline-flex;
  margin: 0;
}

:where(.care-form, .settings-form, .translation-row, .crm-email-composer, .message-compose) label {
  color: var(--emc-text-soft);
  font-size: 13px;
  font-weight: 800;
}

:where(input, textarea, select, .mini-input, .filter-select, .emc-select-trigger) {
  border-color: var(--emc-border);
  border-radius: var(--emc-radius-md);
  color: var(--emc-text);
}

:where(input, textarea, select, .mini-input)::placeholder {
  color: var(--emc-muted);
  opacity: 1;
}

input[type="file"] {
  min-height: var(--emc-control-h);
  padding: 9px 12px;
}

input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 12px;
  padding: 0 12px;
  border: 1px solid var(--emc-border);
  border-radius: 9px;
  background: var(--emc-surface-muted);
  color: var(--emc-text-soft);
  font-weight: 800;
}

:where(input[type="checkbox"], input[type="radio"]) {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--emc-primary);
  vertical-align: middle;
}

:where(.compact-check, .settings-toggle, .dynamic-option, .slot-option) {
  align-items: center;
  gap: 10px;
}

:where(.dynamic-options label, .compact-check, .settings-toggle, .slot-option) {
  line-height: 1.35;
}

:where(.alert, .alert-success, .alert-danger, .alert-warning, .alert-info) {
  margin: 0 0 16px;
  padding: 13px 15px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.alert-success {
  border-color: rgba(16, 185, 129, 0.25);
  background: #ecfdf5;
  color: #047857;
}

.alert-danger {
  border-color: rgba(239, 68, 68, 0.25);
  background: #fff1f2;
  color: #dc2626;
}

.alert-warning {
  border-color: rgba(245, 158, 11, 0.28);
  background: #fffbeb;
  color: #b45309;
}

.alert-info {
  border-color: rgba(37, 99, 235, 0.22);
  background: #eff6ff;
  color: #1d4ed8;
}

:where(.panel, .module-panel, .bookings-card, .table-shell, .settings-shell, .context-card) {
  min-width: 0;
}

:where(.panel-title, .page-heading) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

:where(.panel-title h2, .page-heading h1) {
  letter-spacing: 0;
}

:where(.panel-title span, .mini-label, .page-heading p) {
  color: var(--emc-muted);
  font-weight: 700;
}

.table-wrap {
  border-radius: var(--emc-radius-lg);
}

:where(.data-table, .module-table, .bookings-table) {
  border-collapse: separate;
  border-spacing: 0;
}

:where(.data-table th, .module-table th, .bookings-table th) {
  color: #64748b;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

:where(.data-table td, .module-table td, .bookings-table td) {
  color: var(--emc-text);
  vertical-align: middle;
}

:where(.data-table td small, .module-table td small, .bookings-table td small) {
  display: block;
  margin-top: 4px;
  color: var(--emc-muted);
  line-height: 1.35;
}

:where(.data-table td, .module-table td, .bookings-table td, .person span, .crm-thread-card span) {
  min-width: 0;
}

:where(.status-pill, .badge, .match-score) {
  border-radius: 999px;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.confirmed,
.status-pill.completed,
.status-pill.active {
  background: #dcfce7;
  color: #047857;
}

.status-pill.pending,
.status-pill.pending-payment {
  background: #fffbeb;
  color: #b45309;
}

.status-pill.submitted,
.status-pill.payment-submitted,
.status-pill.info {
  background: #eff6ff;
  color: #1d4ed8;
}

.status-pill.cancelled,
.status-pill.rejected,
.status-pill.failed,
.status-pill.inactive {
  background: #fff1f2;
  color: #dc2626;
}

:where(.empty-state, .builder-empty-state, .field-settings-empty, .crm-email-empty) {
  border-color: var(--emc-border-strong);
  border-radius: var(--emc-radius-lg);
  color: var(--emc-text-soft);
}

:where(.empty-state strong, .builder-empty-state strong) {
  color: var(--emc-text);
}

:where(.empty-state p, .builder-empty-state p) {
  max-width: 52ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.55;
}

.rich-copy {
  color: var(--emc-text);
  line-height: 1.7;
}

.rich-copy :where(h1, h2, h3, h4) {
  margin-top: 0;
  color: var(--emc-text);
}

.rich-copy :where(ul, ol) {
  padding-left: 1.25rem;
}

.consent-copy {
  max-height: 260px;
  overflow: auto;
  margin: .75rem 0;
  padding: 1rem;
  border: 1px solid var(--emc-border-strong);
  border-radius: var(--emc-radius-sm);
  background: var(--emc-surface-muted);
}

.legal-editor-panel {
  max-width: 100%;
  overflow: visible;
}

.legal-editor-field {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.legal-editor-label {
  font-weight: 800;
  color: var(--emc-text);
}

.legal-editor-shell {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--emc-border-strong);
  border-radius: var(--emc-radius-md);
  background: var(--emc-surface);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.05);
}

.legal-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  min-height: auto;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--emc-border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.legal-editor-toolbar .ql-formats {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0 4px 0 0;
  padding-right: 6px;
  border-right: 1px solid var(--emc-border);
}

.legal-editor-toolbar button,
.legal-editor-toolbar .ql-picker {
  min-width: 34px;
  min-height: 34px;
  border-radius: 8px;
}

.legal-editor-toolbar button:hover,
.legal-editor-toolbar .ql-picker:hover {
  background: #eef2ff;
}

.legal-media-button {
  width: auto !important;
  min-width: 92px !important;
  padding: 0 12px !important;
  border: 1px solid var(--emc-navy) !important;
  background: var(--emc-navy) !important;
  color: #fff !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  text-transform: uppercase;
}

.legal-editor-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--emc-border);
  border-radius: 10px;
  background: #f8fafc;
}

.legal-editor-mode button {
  width: auto;
  min-width: 58px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--emc-text-soft);
  font-weight: 700;
}

.legal-editor-mode button.active {
  background: #fff;
  color: var(--emc-primary);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.legal-document-editor {
  min-height: 420px;
}

.legal-editor-shell .ql-container {
  border: 0;
  font-family: inherit;
  font-size: 15px;
}

.legal-editor-shell .ql-editor {
  min-height: 420px;
  padding: 24px;
  line-height: 1.7;
}

.legal-html-editor {
  display: block;
  width: 100%;
  min-height: 420px;
  padding: 24px;
  border: 0;
  outline: 0;
  resize: vertical;
  font: 500 14px/1.7 Consolas, "Courier New", monospace;
  color: var(--emc-text);
  background: #0f172a;
  color: #e2e8f0;
}

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

.pdf-document-editor .ql-editor table,
.legal-editor-shell .ql-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.pdf-document-editor .ql-editor th,
.pdf-document-editor .ql-editor td,
.legal-editor-shell .ql-editor th,
.legal-editor-shell .ql-editor td {
  padding: 10px 12px;
  border: 1px solid var(--emc-border-strong);
  vertical-align: top;
}

.pdf-document-editor .ql-editor th,
.legal-editor-shell .ql-editor th {
  background: var(--emc-surface-muted);
  font-weight: 800;
}

.color-dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border: 1px solid var(--emc-border-strong);
  border-radius: 999px;
  vertical-align: middle;
}

.pdf-builder {
  padding: 0 24px 28px;
}

.pdf-builder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 16px;
}

.pdf-crumb {
  color: var(--emc-primary);
  font-size: 12px;
  font-weight: 800;
}

.pdf-builder-head h1 {
  margin: 2px 0 4px;
  color: var(--emc-text);
  font-size: 28px;
  font-weight: 900;
}

.pdf-builder-head p,
.pdf-panel-section p {
  margin: 0;
  color: var(--emc-text-soft);
  font-size: 13px;
}

.pdf-builder-grid {
  display: grid;
  grid-template-columns: 260px minmax(520px, 1fr) 292px;
  gap: 20px;
  align-items: start;
}

.pdf-side-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  background: #fff;
}

.pdf-panel-section {
  display: grid;
  gap: 10px;
}

.pdf-panel-section + .pdf-panel-section {
  padding-top: 14px;
  border-top: 1px solid var(--emc-border);
}

.pdf-panel-section h2 {
  margin: 0;
  color: var(--emc-text);
  font-size: 14px;
  font-weight: 900;
}

.pdf-panel-section h3,
.pdf-setting-label {
  margin: 8px 0 0;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 900;
}

.pdf-panel-section label {
  display: grid;
  gap: 6px;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 800;
}

.pdf-panel-section input,
.pdf-panel-section select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--emc-border);
  border-radius: 7px;
  background: #fff;
}

.pdf-tool,
.pdf-field-token {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--emc-border);
  border-radius: 7px;
  background: #fff;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 800;
  cursor: grab;
}

.pdf-tool span,
.pdf-field-token span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.pdf-tool svg,
.pdf-field-token svg {
  width: 15px;
  height: 15px;
  color: var(--emc-primary);
}

.pdf-field-token code {
  color: var(--emc-text-soft);
  font-size: 10px;
}

.pdf-canvas-wrap {
  min-width: 0;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  background: #f8fafc;
  overflow: hidden;
}

.pdf-canvas-scroll {
  display: grid;
  place-items: start center;
  padding: 28px;
  overflow: auto;
}

.pdf-page {
  position: relative;
  width: min(100%, 210mm);
  aspect-ratio: 210 / 297;
  background: #fff;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.11);
  transform-origin: top center;
}

.pdf-element {
  position: absolute;
  min-width: 8mm;
  min-height: 4mm;
  padding: 2mm;
  border: 1px dashed rgba(37, 99, 235, 0.38);
  outline: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.64);
  color: #111827;
  cursor: move;
  white-space: pre-wrap;
}

.pdf-element.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.pdf-el-table {
  padding: 0;
}

.pdf-el-table table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  font-size: inherit;
}

.pdf-el-table th {
  background: #0f5eea;
  color: #fff;
  font-weight: 900;
}

.pdf-el-table th,
.pdf-el-table td {
  padding: 5px;
  border: 1px dashed rgba(37, 99, 235, 0.35);
  vertical-align: top;
}

.pdf-el-line {
  min-height: 2mm;
  padding: 0;
  border: 0;
  background: transparent;
}

.pdf-el-line span {
  display: block;
  height: 2px;
  margin-top: 1mm;
  background: #2563eb;
}

.pdf-image-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  border: 1px dashed rgba(37, 99, 235, 0.38);
  color: #0f5eea;
  font-weight: 900;
  text-align: center;
}

.pdf-resize {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 3px 0 0;
  background: #2563eb;
  cursor: nwse-resize;
}

.pdf-canvas-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px;
  border-top: 1px solid var(--emc-border);
  background: #fff;
}

.pdf-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pdf-segment label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--emc-border);
  border-radius: 7px;
}

.pdf-margin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pdf-delete-template {
  width: 100%;
  margin-top: 14px;
  justify-content: center;
}

@media (max-width: 1200px) {
  .pdf-builder-grid {
    grid-template-columns: 220px minmax(460px, 1fr);
  }

  .pdf-builder-grid > .pdf-side-panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .pdf-builder-head,
  .pdf-canvas-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .pdf-builder-grid {
    grid-template-columns: 1fr;
  }

  .pdf-canvas-scroll {
    padding: 16px;
  }
}

.template-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 18px;
  align-items: start;
  width: 100%;
}

.pdf-builder-v2 {
  --pdf-blue: #2563eb;
  --pdf-border: #dce4f2;
  --pdf-muted: #64748b;
  padding: 14px 14px 26px;
  background: #f4f7fb;
}

.pdf-builder-v2 .pdf-builder-head {
  align-items: center;
  margin-bottom: 14px;
}

.pdf-builder-v2 .pdf-builder-head h1 {
  font-size: 22px;
  line-height: 1.1;
}

.pdf-head-actions {
  align-items: center;
}

.pdf-builder-v2 .pdf-builder-grid {
  grid-template-columns: 286px minmax(560px, 1fr) 318px;
  gap: 16px;
}

.pdf-builder-v2 .pdf-side-panel,
.pdf-builder-v2 .pdf-canvas-wrap {
  border-color: var(--pdf-border);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.04);
}

.pdf-builder-v2 .pdf-side-panel {
  align-content: start;
  max-height: calc(100vh - 132px);
  overflow: auto;
  padding: 16px;
}

.pdf-panel-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.pdf-panel-title > svg {
  width: 16px;
  color: var(--pdf-muted);
}

.pdf-builder-v2 .pdf-tool,
.pdf-builder-v2 .pdf-field-token {
  min-height: 36px;
  border-radius: 6px;
  background: #fff;
}

.pdf-builder-v2 .pdf-field-token {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.pdf-builder-v2 .pdf-field-token code {
  justify-self: end;
}

.pdf-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--pdf-border);
  background: #fff;
}

.pdf-tool-group,
.pdf-zoom,
.pdf-element-actions,
.pdf-color-pair {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-status {
  color: var(--pdf-muted);
  font-size: 12px;
  font-weight: 800;
}

.pdf-builder-v2 .pdf-canvas-scroll {
  min-height: 674px;
  padding: 18px;
  background: #f8fafc;
}

.pdf-page-shell {
  transform-origin: top center;
}

.pdf-builder-v2 .pdf-page {
  width: 210mm;
  max-width: none;
  transition: width .16s ease, aspect-ratio .16s ease, background .16s ease;
}

.pdf-page.has-border::before {
  position: absolute;
  inset: 8mm;
  z-index: 0;
  border: 1px solid #cbd5e1;
  content: "";
  pointer-events: none;
}

.pdf-page.has-watermark::after {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  color: rgba(148, 163, 184, 0.24);
  content: attr(data-watermark);
  font-size: 42px;
  font-weight: 900;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-28deg);
  white-space: nowrap;
}

.pdf-builder-v2 .pdf-element {
  z-index: 1;
  border-color: rgba(37, 99, 235, 0.22);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.68);
}

.pdf-builder-v2 .pdf-element:hover {
  border-color: rgba(37, 99, 235, 0.55);
}

.pdf-builder-v2 .pdf-element.selected {
  border-style: solid;
  border-color: var(--pdf-blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.pdf-builder-v2 .pdf-el-table th {
  background: var(--pdf-blue);
}

.pdf-builder-v2 .pdf-image-placeholder small {
  display: block;
  margin-top: 4px;
  color: var(--pdf-muted);
  font-size: 10px;
  font-weight: 700;
}

.pdf-builder-v2 .pdf-canvas-footer {
  min-height: 50px;
  border-color: var(--pdf-border);
}

.pdf-builder-v2 .view-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--pdf-border);
  border-radius: 6px;
  background: #fff;
  color: #334155;
}

.pdf-builder-v2 .view-btn:disabled,
.pdf-builder-v2 .module-action:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.pdf-builder-v2 .view-btn svg {
  width: 15px;
  height: 15px;
}

.pdf-zoom select {
  width: 74px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--pdf-border);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.pdf-actions-menu {
  position: relative;
}

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

.pdf-actions-menu .date-select svg {
  width: 14px;
  height: 14px;
}

.pdf-actions-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  display: none;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--pdf-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
}

.pdf-actions-list.open {
  display: grid;
}

.pdf-actions-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.pdf-actions-list button:hover {
  background: #f1f5f9;
}

.pdf-actions-list svg {
  width: 15px;
  height: 15px;
  color: var(--pdf-blue);
}

.pdf-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--pdf-border);
  border-radius: 7px;
  background: #f8fafc;
}

.pdf-tabs button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--pdf-muted);
  font-size: 12px;
  font-weight: 900;
}

.pdf-tabs button.active {
  background: #fff;
  color: var(--pdf-blue);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.08);
}

.pdf-tab-panel {
  display: none;
}

.pdf-tab-panel.active {
  display: grid;
  gap: 14px;
}

.pdf-builder-v2 textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--pdf-border);
  border-radius: 7px;
  resize: vertical;
  font: 700 12px/1.5 Consolas, "Courier New", monospace;
}

.pdf-builder-v2 input[readonly] {
  background: #f8fafc;
  color: var(--pdf-muted);
}

.pdf-color-pair > label {
  flex: 1;
}

.pdf-element-actions {
  flex-wrap: wrap;
}

.pdf-element-actions .module-action {
  flex: 1;
  justify-content: center;
  min-width: 92px;
}

.pdf-element-actions .module-action.active {
  border-color: var(--pdf-blue);
  color: var(--pdf-blue);
  background: rgba(37, 99, 235, 0.08);
}

.pdf-builder-v2 .settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pdf-builder-v2 .settings-toggle input {
  width: 38px;
  min-height: 20px;
  accent-color: var(--pdf-blue);
}

.pdf-builder-v2 .pdf-segment label {
  gap: 6px;
  font-size: 12px;
}

.pdf-builder-v2 .pdf-segment label:has(input:checked) {
  border-color: var(--pdf-blue);
  color: var(--pdf-blue);
  background: rgba(37, 99, 235, 0.07);
}

.pdf-builder-v2 .pdf-segment svg {
  width: 15px;
  height: 15px;
}

.pdf-builder-v2 .hidden {
  display: none !important;
}

@media (max-width: 1360px) {
  .pdf-builder-v2 .pdf-builder-grid {
    grid-template-columns: 250px minmax(500px, 1fr) 300px;
  }
}

@media (max-width: 1120px) {
  .pdf-builder-v2 .pdf-builder-grid {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .pdf-builder-v2 .pdf-right-panel {
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .pdf-builder-v2 .pdf-builder-grid {
    grid-template-columns: 1fr;
  }

  .pdf-builder-v2 .pdf-side-panel {
    max-height: none;
  }

  .pdf-head-actions,
  .pdf-canvas-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .pdf-tool-group,
  .pdf-zoom {
    justify-content: center;
  }
}

.placeholder-picker {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--emc-border-strong);
  border-radius: var(--emc-radius-md);
  background: var(--emc-surface-muted);
}

.placeholder-picker .module-action.full {
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.care-form label.settings-toggle,
.settings-form label.settings-toggle,
label.settings-toggle,
.compact-check {
  display: inline-grid !important;
  grid-template-columns: 22px minmax(0, 1fr);
  justify-content: start;
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
  width: fit-content;
  max-width: 100%;
  min-height: 36px;
  line-height: 1.35;
}

.care-form label.settings-toggle.wide,
.settings-form label.settings-toggle.wide,
label.settings-toggle.wide {
  width: 100%;
  grid-template-columns: 22px minmax(0, 1fr);
}

.care-form label.settings-toggle input,
.settings-form label.settings-toggle input,
label.settings-toggle input,
.compact-check input {
  width: 18px !important;
  min-width: 18px;
  height: 18px !important;
  min-height: 18px;
  margin: 0;
  justify-self: start;
}

@media (max-width: 980px) {
  .template-editor-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .legal-editor-mode {
    width: 100%;
    margin-left: 0;
  }

  .legal-editor-mode button {
    flex: 1;
  }
}

:where(.care-modal-card, .builder-modal-card, .modal-content) {
  width: min(720px, calc(100vw - 32px));
  border-radius: var(--emc-radius-lg);
}

:where(.modal-close) {
  color: var(--emc-text-soft);
  background: #fff;
}

:where(.communication-tabs, .settings-tabs, .workspace-tabs, .inspector-tabs, .emc-tabs) {
  gap: 8px;
}

:where(.communication-tabs a, .settings-tabs a, .workspace-tabs button, .inspector-tabs button) {
  min-height: 40px;
  border-radius: var(--emc-radius-md);
  font-weight: 800;
}

:where(.dropdown-panel, .global-search-panel, .emc-select-panel) {
  border-color: var(--emc-border);
  border-radius: var(--emc-radius-lg);
  box-shadow: var(--emc-shadow-dropdown);
}

img.avatar,
.avatar {
  flex: 0 0 auto;
  object-fit: cover;
}

.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--emc-text);
  font-weight: 900;
}

.realtime-toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  display: grid;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.realtime-toast {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--emc-border);
  border-left: 4px solid var(--emc-info);
  border-radius: var(--emc-radius-lg);
  background: #fff;
  box-shadow: var(--emc-shadow-dropdown);
  pointer-events: auto;
  animation: emcFadeUp var(--emc-transition);
}

.realtime-toast.success {
  border-left-color: var(--emc-success);
}

.realtime-toast.warning {
  border-left-color: var(--emc-warning);
}

.realtime-toast.danger {
  border-left-color: var(--emc-danger);
}

.realtime-toast-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--emc-radius-md);
  background: #eff6ff;
  color: var(--emc-info);
}

.realtime-toast.success .realtime-toast-icon {
  background: #ecfdf5;
  color: var(--emc-success);
}

.realtime-toast.warning .realtime-toast-icon {
  background: #fff7ed;
  color: var(--emc-warning);
}

.realtime-toast.danger .realtime-toast-icon {
  background: #fff1f2;
  color: var(--emc-danger);
}

.realtime-toast-body,
.realtime-toast-close {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.realtime-toast-body {
  display: grid;
  justify-items: start;
  gap: 4px;
  color: var(--emc-text);
  text-align: left;
}

.realtime-toast-body:hover,
.realtime-toast-close:hover {
  transform: none;
  border-color: transparent;
  box-shadow: none;
}

.realtime-toast-body strong {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.35;
}

.realtime-toast-body small {
  display: -webkit-box;
  color: var(--emc-text-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.realtime-toast-close {
  width: 30px;
  height: 30px;
  color: var(--emc-muted);
}

.realtime-toast-close svg,
.realtime-toast-icon svg {
  width: 17px;
  height: 17px;
}

@media (max-width: 640px) {
  :where(.panel-title, .page-heading) {
    align-items: flex-start;
    flex-direction: column;
  }

  :where(.panel-title .module-action, .page-heading .module-action, .filter-bar .module-action) {
    width: 100%;
  }

  :where(.form-grid, .settings-row, .selection-grid, .composer-top) {
    grid-template-columns: 1fr;
  }

  :where(.data-table, .module-table, .bookings-table) {
    min-width: 760px;
  }

  .realtime-toast-stack {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }
}

.session-notes-section {
  align-items: start;
}

.session-note-list {
  display: grid;
  gap: 14px;
}

.session-note-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-lg);
  background: #fff;
}

.session-note-card.pinned {
  border-color: rgba(109, 93, 252, 0.34);
  background: #fbfaff;
}

.session-note-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.session-note-card header strong {
  display: block;
  color: var(--emc-text);
  font-size: 15px;
  font-weight: 900;
}

.session-note-card header small {
  color: var(--emc-muted);
  font-size: 12px;
  font-weight: 700;
}

.session-note-body {
  color: var(--emc-text-soft);
  font-size: 14px;
  line-height: 1.65;
}

.session-note-body :where(p, ul, ol, blockquote) {
  margin: 0 0 10px;
}

.session-note-body :where(ul, ol) {
  padding-left: 20px;
}

.session-note-edit {
  display: grid;
  gap: 12px;
}

.session-note-edit summary {
  width: fit-content;
  cursor: pointer;
  color: var(--emc-primary);
  font-size: 13px;
  font-weight: 900;
}

.session-note-editor {
  min-height: 180px;
  border-radius: var(--emc-radius-md);
  background: #fff;
}

.session-note-editor .ql-container {
  min-height: 130px;
  font-family: inherit;
  font-size: 14px;
}

.session-note-editor .ql-toolbar,
.session-note-editor .ql-container {
  border-color: var(--emc-border);
}

.permissions-heading {
  align-items: flex-start;
}

.permissions-alert,
.permission-stat-grid,
.permission-role-panel,
.permission-workspace {
  margin-left: 41px;
  margin-right: 41px;
}

.permission-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.permission-stat-card,
.permission-role-panel,
.permission-summary-panel .panel {
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-lg);
  background: var(--emc-surface);
  box-shadow: var(--emc-shadow-card);
}

.permission-stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 106px;
  padding: 18px;
}

.permission-stat-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 14px;
  background: #eff6ff;
  color: var(--emc-info);
}

.permission-stat-icon.purple {
  background: #f0edff;
  color: var(--emc-primary);
}

.permission-stat-icon.green {
  background: #ecfdf5;
  color: var(--emc-success);
}

.permission-stat-icon.orange {
  background: #fff7ed;
  color: #ea580c;
}

.permission-stat-card p,
.permission-stat-card small,
.permission-role-copy p,
.permission-matrix-header p,
.permission-save-bar span,
.permission-summary-panel p,
.permission-legend small {
  margin: 0;
  color: var(--emc-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.permission-stat-card strong {
  display: block;
  margin: 3px 0;
  color: var(--emc-text);
  font-size: 24px;
  font-weight: 900;
}

.permission-role-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.permission-role-copy h2,
.permission-summary-panel h2,
.permission-summary-panel h3,
.permission-matrix-header h2 {
  margin: 0;
  color: var(--emc-text);
  letter-spacing: 0;
}

.permission-role-copy h2 {
  margin: 4px 0;
  font-size: 18px;
}

.permission-role-controls {
  display: flex;
  align-items: end;
  gap: 12px;
  min-width: min(480px, 100%);
}

.permission-role-controls label {
  flex: 1;
  display: grid;
  gap: 7px;
}

.permission-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 18px;
  margin-bottom: 36px;
}

.permission-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--emc-border);
}

.permission-tab {
  min-height: 48px;
  justify-content: flex-start;
  flex: 0 0 auto;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.permission-tab:hover {
  transform: none;
  box-shadow: none;
}

.permission-tab.active {
  border-bottom-color: var(--emc-primary);
  color: var(--emc-primary);
}

.permission-tab span {
  color: var(--emc-muted);
  font-size: 11px;
  font-weight: 800;
}

.permission-role-form {
  display: none;
}

.permission-role-form.active {
  display: block;
}

.permission-matrix-panel {
  padding: 0;
  overflow: hidden;
}

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

.permission-matrix-header h2 {
  font-size: 17px;
}

.permission-search {
  position: relative;
  width: min(320px, 100%);
}

.permission-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--emc-muted);
}

.permission-search input {
  padding-left: 38px;
}

.permission-matrix {
  overflow-x: auto;
}

.permission-matrix-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) repeat(5, 82px);
  align-items: center;
  min-width: 720px;
}

.permission-matrix-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 48px;
  padding: 0 18px;
  color: #64748b;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.permission-section {
  border-top: 1px solid var(--emc-border);
}

.permission-section:first-of-type {
  border-top: 0;
}

.permission-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 720px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  background: #fbfdff;
}

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

.permission-section summary > span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.permission-section summary svg {
  width: 17px;
  height: 17px;
  color: var(--emc-primary);
  transition: transform var(--emc-transition);
}

.permission-section:not([open]) summary svg {
  transform: rotate(-90deg);
}

.permission-section summary strong {
  display: block;
  color: var(--emc-text);
  font-size: 13px;
  font-weight: 900;
}

.permission-section summary small,
.permission-section summary em {
  color: var(--emc-muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.permission-item {
  padding: 12px 18px;
  border-top: 1px solid #edf2f7;
  background: #fff;
}

.permission-item:hover {
  background: #fbfdff;
}

.permission-name-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.permission-name-cell strong {
  color: var(--emc-text);
  font-size: 13px;
  font-weight: 900;
}

.permission-name-cell small {
  color: var(--emc-text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.permission-name-cell code {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.permission-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  cursor: pointer;
}

.permission-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.permission-check span {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--emc-border-strong);
  border-radius: 5px;
  background: #fff;
  transition: background var(--emc-transition), border-color var(--emc-transition), box-shadow var(--emc-transition);
}

.permission-check.enabled input:focus-visible + span {
  box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.13);
}

.permission-check.enabled input:checked + span {
  border-color: var(--emc-primary);
  background: var(--emc-primary);
}

.permission-check.enabled input:checked + span::after {
  content: "";
  width: 8px;
  height: 5px;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.permission-check.muted {
  cursor: default;
  opacity: 0.45;
}

.permission-check.muted span {
  background: #f8fafc;
}

.permission-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--emc-border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.permission-save-bar > div {
  display: grid;
  gap: 3px;
}

.permission-save-bar .module-action {
  min-height: 38px;
}

.permission-summary-panel {
  position: sticky;
  top: 88px;
}

.permission-summary-panel .panel {
  display: grid;
  gap: 16px;
}

.permission-progress {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  margin: 2px auto 0;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, #fff 72%, transparent 73%),
    conic-gradient(var(--emc-primary) var(--permission-progress), #edf2f7 0);
}

.permission-progress strong {
  color: var(--emc-text);
  font-size: 24px;
  font-weight: 900;
}

.permission-summary-panel h3 {
  font-size: 15px;
}

.permission-summary-actions {
  display: grid;
  gap: 8px;
}

.permission-preview-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--emc-border);
  border-radius: var(--emc-radius-md);
  background: #fbfdff;
}

.permission-preview-box[hidden] {
  display: none;
}

.permission-preview-box strong {
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 900;
}

.permission-preview-box p {
  color: var(--emc-text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.permission-legend {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--emc-border);
}

.permission-legend span {
  display: grid;
  grid-template-columns: 10px 1fr;
  column-gap: 8px;
  color: var(--emc-text);
  font-size: 12px;
  font-weight: 900;
}

.permission-legend small {
  grid-column: 2;
}

.legend-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
}

.legend-dot.allowed {
  background: var(--emc-primary);
}

.legend-dot.denied {
  background: var(--emc-border-strong);
}

.legend-dot.inherited {
  background: var(--emc-info);
}

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

@media (max-width: 1200px) {
  .permission-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .permission-workspace {
    grid-template-columns: 1fr;
  }

  .permission-summary-panel {
    position: static;
  }
}

@media (max-width: 900px) {
  .permissions-alert,
  .permission-stat-grid,
  .permission-role-panel,
  .permission-workspace {
    margin-left: 18px;
    margin-right: 18px;
  }

  .permission-role-panel,
  .permission-matrix-header {
    align-items: stretch;
    flex-direction: column;
  }

  .permission-role-controls {
    width: 100%;
  }

  .permission-search {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .permissions-alert,
  .permission-stat-grid,
  .permission-role-panel,
  .permission-workspace {
    margin-left: 12px;
    margin-right: 12px;
  }

  .permission-stat-grid {
    grid-template-columns: 1fr;
  }

  .permission-role-controls,
  .permission-save-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .permission-role-controls .module-action,
  .permission-save-bar .module-action {
    width: 100%;
  }
}
