:root {
  --crm-bg: #f5f6f8;
  --crm-surface: #ffffff;
  --crm-surface-soft: #fafafb;
  --crm-border: #e6e7eb;
  --crm-border-strong: #d9dbe2;
  --crm-text: #191b24;
  --crm-muted: #727582;
  --crm-subtle: #9a9daa;
  --crm-primary: #635bff;
  --crm-primary-dark: #5149e8;
  --crm-primary-soft: #eeecff;
  --crm-success: #12805c;
  --crm-success-soft: #e7f7f0;
  --crm-warning: #a86512;
  --crm-warning-soft: #fff5df;
  --crm-danger: #bf3d57;
  --crm-danger-soft: #ffedf1;
  --crm-sidebar: #11131f;
  --crm-sidebar-soft: #191c2b;
  --crm-radius-sm: 10px;
  --crm-radius: 16px;
  --crm-radius-lg: 22px;
  --crm-shadow-sm: 0 1px 2px rgba(20, 22, 31, .04), 0 5px 18px rgba(20, 22, 31, .035);
  --crm-shadow: 0 1px 2px rgba(20, 22, 31, .03), 0 14px 36px rgba(20, 22, 31, .06);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--crm-text);
  background: var(--crm-bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .92rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--crm-primary); }
a:hover { color: var(--crm-primary-dark); }
code { color: #5f48b8; background: #f2efff; border-radius: 7px; padding: .14rem .4rem; font-size: .82em; }

/* Application shell */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 276px;
  min-width: 276px;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 1035;
  color: #fff;
  background:
    radial-gradient(circle at 20% -10%, rgba(99, 91, 255, .25), transparent 28%),
    linear-gradient(180deg, #151725 0%, #10121c 100%);
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar-inner { display: flex; flex-direction: column; width: 100%; height: 100%; padding: 22px 16px 16px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 20px; }
.brand-link { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-link:hover { color: #fff; }
.brand-mark { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #817aff, #5850e8); box-shadow: 0 10px 28px rgba(99,91,255,.35); font-size: 1.1rem; flex: 0 0 auto; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 1.06rem; letter-spacing: -.02em; }
.brand-copy small { color: #7f849e; font-size: .66rem; margin-top: 1px; letter-spacing: .03em; }
.sidebar-close { width: 34px; height: 34px; border: 0; border-radius: 9px; color: #9297af; background: rgba(255,255,255,.05); }

.workspace-card { display: flex; align-items: center; gap: 10px; min-height: 64px; margin: 0 2px 22px; padding: 10px 11px; border: 1px solid rgba(255,255,255,.075); border-radius: 15px; background: rgba(255,255,255,.045); }
.workspace-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: #dedcff; background: rgba(99,91,255,.2); font-weight: 750; flex: 0 0 auto; }
.workspace-copy { min-width: 0; flex: 1; }
.workspace-copy strong, .workspace-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-copy small { color: #747a94; font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; }
.workspace-copy strong { color: #f2f3f8; font-size: .78rem; margin-top: 3px; }
.workspace-status { width: 7px; height: 7px; border-radius: 50%; background: #40d09c; box-shadow: 0 0 0 4px rgba(64,208,156,.1); }

.sidebar-nav { overflow-y: auto; padding: 0 3px 12px; scrollbar-width: thin; scrollbar-color: #34384e transparent; }
.nav-caption { color: #5f647c; text-transform: uppercase; font-size: .59rem; font-weight: 800; letter-spacing: .13em; padding: 0 12px 8px; }
.sidebar-link { position: relative; display: flex; align-items: center; gap: 11px; min-height: 42px; margin: 2px 0; padding: 9px 11px; color: #9ca1b8; text-decoration: none; border-radius: 11px; font-size: .83rem; font-weight: 570; transition: color .16s ease, background .16s ease, transform .16s ease; }
.sidebar-link > i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.055); transform: translateX(1px); }
.sidebar-link.active { color: #fff; background: linear-gradient(100deg, rgba(99,91,255,.92), rgba(86,78,224,.72)); box-shadow: 0 8px 20px rgba(38,34,113,.26); }
.sidebar-link.active::before { content: ""; position: absolute; left: -3px; width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: #b8b4ff; }
.nav-badge { margin-left: auto; padding: 2px 6px; border-radius: 6px; color: #777d96; background: rgba(255,255,255,.055); font-size: .56rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.nav-badge.accent { color: #bbb7ff; background: rgba(99,91,255,.15); }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.055); }
.profile-card { display: flex; align-items: center; gap: 10px; padding: 6px; }
.profile-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #d8dbe8; background: #292d41; font-size: .76rem; font-weight: 750; flex: 0 0 auto; }
.profile-copy { min-width: 0; flex: 1; }
.profile-copy strong, .profile-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy strong { color: #e9eaf1; font-size: .73rem; }
.profile-copy small { color: #6f748d; font-size: .64rem; margin-top: 2px; }
.profile-action { width: 32px; height: 32px; border: 0; border-radius: 9px; color: #777d95; background: transparent; }
.profile-action:hover { color: #fff; background: rgba(255,255,255,.07); }

.app-main { min-width: 0; flex: 1; }
.app-topbar { height: 72px; padding: 0 30px; position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(255,255,255,.88); border-bottom: 1px solid rgba(225,226,231,.9); backdrop-filter: blur(18px); }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-title span, .topbar-title small { display: block; }
.topbar-title span { font-size: .82rem; font-weight: 750; letter-spacing: -.01em; }
.topbar-title small { color: var(--crm-subtle); font-size: .65rem; margin-top: 1px; }
.system-health { height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--crm-muted); border: 1px solid var(--crm-border); border-radius: 10px; background: #fff; font-size: .7rem; font-weight: 650; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #a1a4af; box-shadow: 0 0 0 4px rgba(161,164,175,.11); }
.system-health.is-online .status-dot, .topbar-context.is-online .status-dot { background: #20a879; box-shadow: 0 0 0 4px rgba(32,168,121,.1); }
.system-health.is-offline, .topbar-context.is-offline { color: var(--crm-danger); }
.system-health.is-offline .status-dot, .topbar-context.is-offline .status-dot { background: var(--crm-danger); box-shadow: 0 0 0 4px rgba(191,61,87,.1); }
.tenant-switcher { min-width: 210px; max-width: 330px; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; color: #5c6070; background: #fff; border: 1px solid var(--crm-border); border-radius: 11px; box-shadow: 0 2px 10px rgba(25,27,36,.025); }
.tenant-switcher > i:first-of-type { color: var(--crm-primary); }
.tenant-switcher select { min-width: 0; width: 100%; border: 0; outline: 0; appearance: none; color: #414553; background: transparent; font-size: .77rem; font-weight: 680; cursor: pointer; text-overflow: ellipsis; }
.tenant-chevron { color: var(--crm-subtle); font-size: .75rem; pointer-events: none; }
.tenant-pill { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; color: #535765; background: #fff; border: 1px solid var(--crm-border); border-radius: 10px; font-size: .75rem; font-weight: 650; }
.icon-button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; color: #555968; background: #fff; border: 1px solid var(--crm-border); border-radius: 10px; font-size: 1.05rem; }
.icon-button:hover { color: var(--crm-primary); border-color: #d5d1ff; background: var(--crm-primary-soft); }
.app-content { width: 100%; max-width: 1580px; margin: 0 auto; padding: 30px 32px 48px; }

/* Page elements */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; color: #171923; font-size: clamp(1.55rem, 2.4vw, 2rem); line-height: 1.15; letter-spacing: -.045em; font-weight: 760; }
.page-heading p { max-width: 720px; margin: 8px 0 0; color: var(--crm-muted); font-size: .86rem; line-height: 1.55; }
.eyebrow, .section-kicker { display: block; margin-bottom: 7px; color: var(--crm-primary); font-size: .62rem; font-weight: 820; text-transform: uppercase; letter-spacing: .13em; }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--crm-muted); text-decoration: none; font-size: .77rem; font-weight: 620; }
.back-link:hover { color: var(--crm-primary); }

.card, .surface-card { background: var(--crm-surface); border: 1px solid var(--crm-border) !important; border-radius: var(--crm-radius); box-shadow: var(--crm-shadow-sm) !important; }
.card { overflow: hidden; }
.card-header { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; background: var(--crm-surface) !important; border-bottom: 1px solid #ececef; }
.card-body { padding: 20px; }
.form-panel { padding: 22px; background: var(--crm-surface); border: 1px solid var(--crm-border); border-radius: var(--crm-radius); box-shadow: var(--crm-shadow); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-size: 1.08rem; letter-spacing: -.025em; font-weight: 740; }
.section-heading p { margin: 6px 0 0; color: var(--crm-muted); font-size: .78rem; }
.section-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--crm-primary); background: var(--crm-primary-soft); font-size: 1.05rem; flex: 0 0 auto; }

.btn { border-radius: 10px; font-size: .8rem; font-weight: 680; padding: .58rem .9rem; }
.btn-sm { padding: .38rem .62rem; border-radius: 8px; font-size: .72rem; }
.btn-primary { --bs-btn-bg: var(--crm-primary); --bs-btn-border-color: var(--crm-primary); --bs-btn-hover-bg: var(--crm-primary-dark); --bs-btn-hover-border-color: var(--crm-primary-dark); --bs-btn-active-bg: var(--crm-primary-dark); box-shadow: 0 7px 18px rgba(99,91,255,.2); }
.btn-outline-primary { --bs-btn-color: var(--crm-primary); --bs-btn-border-color: #d6d2ff; --bs-btn-hover-bg: var(--crm-primary); --bs-btn-hover-border-color: var(--crm-primary); }
.btn-ghost { color: #666a78; background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { color: var(--crm-primary); background: var(--crm-primary-soft); }
.form-label { margin-bottom: .42rem; color: #555968; font-size: .72rem; font-weight: 720; }
.form-hint, .form-text { color: var(--crm-subtle); font-size: .66rem; }
.form-control, .form-select { min-height: 43px; color: var(--crm-text); background-color: #fff; border: 1px solid #dde0e6; border-radius: 10px; font-size: .83rem; }
.form-control::placeholder { color: #b2b4bd; }
.form-control:focus, .form-select:focus { border-color: #aaa5ff; box-shadow: 0 0 0 .22rem rgba(99,91,255,.1); }
.form-control-sm, .form-select-sm { min-height: 34px; border-radius: 8px; font-size: .75rem; }
.filter-bar { display: flex; align-items: center; gap: 8px; padding: 9px; background: #fff; border: 1px solid var(--crm-border); border-radius: 14px; box-shadow: var(--crm-shadow-sm); }
.filter-bar .form-select { width: auto; min-width: 170px; }
.search-field { min-width: 220px; height: 42px; display: flex; align-items: center; gap: 9px; flex: 1; padding: 0 12px; background: #fff; border: 1px solid #dde0e6; border-radius: 10px; }
.search-field:focus-within { border-color: #aaa5ff; box-shadow: 0 0 0 .22rem rgba(99,91,255,.1); }
.search-field i { color: #a1a4af; }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--crm-text); background: transparent; }

/* Tables and lists */
.table { --bs-table-bg: transparent; margin: 0; color: var(--crm-text); }
.table > :not(caption) > * > * { padding: .9rem 1rem; border-bottom-color: #eeeff2; vertical-align: middle; }
.table thead th { padding-top: .72rem; padding-bottom: .72rem; color: #898c98; background: #fafafb; font-size: .61rem; font-weight: 820; text-transform: uppercase; letter-spacing: .085em; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #fafaff; }
.list-group-item { padding: 14px 18px; border-color: #eeeff2; }
.list-group-item-action:hover { background: #fafaff; }
.min-w-0 { min-width: 0; }
.avatar { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 11px; color: var(--crm-primary-dark); background: var(--crm-primary-soft); font-size: .82rem; font-weight: 780; flex: 0 0 auto; }
.customer-list-link { min-width: 210px; display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.customer-list-link:hover { color: var(--crm-primary); }
.customer-list-link strong, .customer-list-link small { display: block; }
.customer-list-link small { margin-top: 2px; color: var(--crm-subtle); font-size: .63rem; font-weight: 560; }
.customer-hero-avatar { width: 58px; height: 58px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: linear-gradient(145deg, #756dff, #5048d6); border-radius: 18px; box-shadow: 0 12px 28px rgba(80,72,214,.24); font-size: 1.2rem; font-weight: 820; }
.customer-metric { min-height: 90px; display: flex; align-items: center; gap: 13px; padding: 16px; background: #fff; border: 1px solid var(--crm-border); border-radius: var(--crm-radius); box-shadow: var(--crm-shadow-sm); }
.customer-metric strong, .customer-metric small { display: block; }
.customer-metric strong { color: #20232d; font-size: 1.35rem; line-height: 1; letter-spacing: -.035em; }
.customer-metric small { margin-top: 5px; color: var(--crm-muted); font-size: .67rem; font-weight: 650; }
.customer-timeline { max-height: 820px; overflow-y: auto; padding: 8px 20px 18px; }
.customer-timeline-entry { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 15px 0; }
.customer-timeline-entry:not(:last-child)::before { content: ""; position: absolute; left: 19px; top: 48px; bottom: -8px; width: 1px; background: #e7e8ec; }
.customer-timeline-icon { position: relative; z-index: 1; width: 40px; height: 40px; display: grid; place-items: center; border: 4px solid #fff; border-radius: 13px; box-shadow: 0 0 0 1px #e5e6ea; }
.customer-timeline-icon.indigo { color: #554dd9; background: #eeecff; }
.customer-timeline-icon.green { color: #11795b; background: #e7f7f0; }
.customer-timeline-icon.amber { color: #9f6111; background: #fff4df; }
.customer-timeline-icon.purple { color: #7044b3; background: #f3ecff; }
.customer-timeline-content { min-width: 0; padding: 3px 0; }
.customer-timeline-content a { color: #292c36; text-decoration: none; }
.customer-timeline-content a:hover { color: var(--crm-primary); }
.customer-timeline-content time { flex: 0 0 auto; color: var(--crm-subtle); font-size: .62rem; white-space: nowrap; }
.customer-timeline-content p { margin: 5px 0 0; color: var(--crm-muted); font-size: .73rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.customer-profile-list { display: grid; grid-template-columns: 92px minmax(0, 1fr); row-gap: 12px; }
.customer-profile-list dt { color: var(--crm-subtle); font-size: .68rem; font-weight: 650; }
.customer-profile-list dd { margin: 0; color: #3f4350; font-size: .75rem; overflow-wrap: anywhere; }
.customer-hero-actions { flex-wrap: wrap; }
.customer-filter-bar .search-field { flex: 1 1 320px; }
.customer-filter-bar .form-select { min-width: 145px; }
.customer-labels { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.customer-tag, .language-chip, .consent-chip { display: inline-flex; align-items: center; gap: 5px; width: max-content; padding: 5px 9px; border-radius: 999px; font-size: .64rem; line-height: 1; font-weight: 720; white-space: nowrap; }
.customer-tag { color: #525665; background: #f0f1f4; border: 1px solid #e4e5e9; }
.language-chip { color: #5148ca; background: #eeecff; border: 1px solid #dfdcff; }
.consent-chip.opted_in { color: #11795b; background: #e7f7f0; border: 1px solid #d2eee3; }
.consent-chip.opted_out { color: #ad3851; background: #ffedf1; border: 1px solid #f9dbe2; }
.consent-chip.unknown { color: #6d707b; background: #eff0f3; border: 1px solid #e2e3e7; }
.profile-preferences { white-space: pre-wrap; }
.profile-edit-panel { background: linear-gradient(180deg, #fbfbff, #fff); }
.profile-edit-panel .form-label { font-size: .69rem; }
.consent-warning { display: flex; align-items: flex-start; gap: 9px; padding: 11px 12px; color: #665019; background: #fff8e8; border: 1px solid #f5e5b8; border-radius: 11px; font-size: .69rem; line-height: 1.5; }
.consent-warning i { color: #a97713; font-size: 1rem; }
.customer-notes-list { max-height: 330px; overflow-y: auto; padding: 4px 18px; }
.customer-note { padding: 13px 0; }
.customer-note:not(:last-child) { border-bottom: 1px solid #eff0f2; }
.customer-note p { margin: 0; color: #414551; font-size: .74rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.customer-note small { display: block; margin-top: 5px; color: var(--crm-subtle); font-size: .62rem; }
.customer-conversation-link { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 11px; }
.customer-conversation-link strong, .customer-conversation-link small { display: block; }
.customer-conversation-link small { margin-top: 3px; color: var(--crm-subtle); font-size: .63rem; }
.assignee-cell { min-width: 270px; }
.assignment-inline-form { display: grid; grid-template-columns: 30px minmax(155px, 1fr) 34px; align-items: center; gap: 7px; }
.assignee-avatar { width: 30px; height: 30px; display: inline-grid; place-items: center; flex: 0 0 auto; color: #5048d6; background: #eeecff; border: 1px solid #dfdcff; border-radius: 9px; font-size: .68rem; font-weight: 800; }
.assignee-avatar.is-empty { color: #8b8e99; background: #f1f2f4; border-color: #e2e3e7; }
.assignee-display { min-width: 0; display: inline-flex; align-items: center; gap: 8px; color: #484c59; font-size: .75rem; font-weight: 680; white-space: nowrap; }
.assignee-display.surface-inline { min-height: 40px; padding: 4px 10px 4px 5px; background: #fff; border: 1px solid var(--crm-border); border-radius: 11px; box-shadow: var(--crm-shadow-sm); }
.assignment-save { width: 34px; height: 34px; padding: 0; }
.assignment-history { max-height: 310px; overflow-y: auto; padding: 5px 18px; }
.assignment-event { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 13px 0; color: #555967; font-size: .75rem; line-height: 1.45; }
.assignment-event:not(:last-child) { border-bottom: 1px solid #eff0f2; }
.assignment-event-icon { width: 30px; height: 30px; display: grid; place-items: center; color: var(--crm-primary); background: var(--crm-primary-soft); border-radius: 9px; }
.assignment-event strong { color: #272a34; font-weight: 720; }
.assignment-event small { display: block; margin-top: 3px; color: var(--crm-subtle); font-size: .64rem; }
.empty-inline { min-height: 86px; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--crm-subtle); font-size: .72rem; }
.empty-state { padding: 46px 20px; color: var(--crm-muted); text-align: center; }
.empty-state.compact { padding: 30px 18px; }
.empty-state i { display: block; margin-bottom: 10px; color: #b6b8c1; font-size: 1.8rem; }

/* Status and metrics */
.badge { padding: .42em .68em; border-radius: 7px; font-size: .64rem; font-weight: 750; }
.text-bg-primary { color: var(--crm-primary-dark) !important; background: var(--crm-primary-soft) !important; }
.text-bg-success { color: var(--crm-success) !important; background: var(--crm-success-soft) !important; }
.text-bg-warning { color: var(--crm-warning) !important; background: var(--crm-warning-soft) !important; }
.text-bg-danger { color: var(--crm-danger) !important; background: var(--crm-danger-soft) !important; }
.text-bg-secondary { color: #656976 !important; background: #eff0f3 !important; }
.status-chip, .role-chip { display: inline-flex; align-items: center; gap: 7px; width: max-content; padding: 5px 9px; border-radius: 999px; font-size: .65rem; line-height: 1; font-weight: 740; white-space: nowrap; }
.status-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 11%, transparent); }
.status-chip.success { color: var(--crm-success); background: var(--crm-success-soft); }
.status-chip.primary { color: var(--crm-primary-dark); background: var(--crm-primary-soft); }
.status-chip.warning { color: var(--crm-warning); background: var(--crm-warning-soft); }
.status-chip.danger { color: var(--crm-danger); background: var(--crm-danger-soft); }
.status-chip.neutral { color: #707480; background: #eff0f3; }
.role-chip { color: #555968; background: #f0f1f4; }
.role-chip.role-owner { color: #7044b3; background: #f3ecff; }
.role-chip.role-admin { color: #4054aa; background: #ebefff; }
.role-chip.role-operator { color: #11795b; background: #e7f7f0; }
.metric-card { display: block; height: 100%; padding: 19px; color: inherit; text-decoration: none; background: #fff; border: 1px solid var(--crm-border); border-radius: var(--crm-radius); box-shadow: var(--crm-shadow-sm); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.metric-card:hover { color: inherit; transform: translateY(-2px); border-color: #d8d5ff; box-shadow: var(--crm-shadow); }
.metric-card.static-card:hover { transform: none; border-color: var(--crm-border); box-shadow: var(--crm-shadow-sm); }
.metric-top { display: flex; align-items: center; justify-content: space-between; }
.metric-label { color: var(--crm-muted); font-size: .74rem; font-weight: 650; }
.metric-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; font-size: 1rem; }
.metric-icon.indigo { color: #5850d5; background: #eeecff; }
.metric-icon.green { color: #11795b; background: #e7f7f0; }
.metric-icon.amber { color: #9f6111; background: #fff4df; }
.metric-icon.rose { color: #ad3851; background: #ffedf1; }
.metric-value { margin-top: 16px; color: #161821; font-size: 1.82rem; line-height: 1; letter-spacing: -.045em; font-weight: 770; }
.metric-foot { margin-top: 8px; color: #a0a3ad; font-size: .65rem; }
.hero-panel { position: relative; overflow: hidden; padding: 28px; color: #fff; border-radius: var(--crm-radius-lg); background: linear-gradient(125deg, #4d47c8, #726bff); box-shadow: 0 18px 42px rgba(77,71,200,.2); }
.hero-panel::after { content: ""; position: absolute; width: 260px; height: 260px; right: -65px; top: -125px; border-radius: 50%; border: 48px solid rgba(255,255,255,.075); }
.hero-panel h1 { position: relative; z-index: 1; margin: 0; font-size: 1.65rem; letter-spacing: -.035em; font-weight: 740; }
.hero-panel p { position: relative; z-index: 1; max-width: 620px; margin: 10px 0 0; color: rgba(255,255,255,.74); }
.quick-link { display: flex; align-items: center; gap: 12px; padding: 12px; color: var(--crm-text); text-decoration: none; border: 1px solid var(--crm-border); border-radius: 12px; transition: .16s; }
.quick-link:hover { color: var(--crm-primary); border-color: #d8d5ff; background: #fafaff; transform: translateX(2px); }
.quick-link i { width: 34px; height: 34px; display: grid; place-items: center; color: var(--crm-primary); background: var(--crm-primary-soft); border-radius: 9px; }

/* Operations center */
.operations-actions form { margin: 0; }
.operations-metric { min-height: 108px; height: 100%; display: flex; align-items: center; gap: 14px; padding: 17px; background: #fff; border: 1px solid var(--crm-border); border-radius: var(--crm-radius); box-shadow: var(--crm-shadow-sm); }
.operations-metric > div { min-width: 0; }
.operations-metric small, .operations-metric strong, .operations-metric em { display: block; }
.operations-metric small { color: var(--crm-muted); font-size: .65rem; font-weight: 680; }
.operations-metric strong { margin-top: 4px; color: #242731; font-size: 1.18rem; line-height: 1.15; letter-spacing: -.025em; }
.operations-metric em { margin-top: 5px; color: var(--crm-subtle); font-size: .6rem; font-style: normal; }
.operations-policy { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; background: var(--crm-border); border: 1px solid var(--crm-border); border-radius: 14px; box-shadow: var(--crm-shadow-sm); }
.operations-policy > div { display: flex; align-items: flex-start; gap: 11px; padding: 15px; background: #fff; }
.operations-policy > div > i { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; color: var(--crm-primary); background: var(--crm-primary-soft); border-radius: 9px; }
.operations-policy strong, .operations-policy small { display: block; }
.operations-policy strong { color: #343741; font-size: .7rem; }
.operations-policy small { margin-top: 4px; color: var(--crm-muted); font-size: .62rem; line-height: 1.4; }
.operations-table td:first-child { min-width: 180px; }
.operations-table code { color: #4f48c6; font-size: .67rem; }
.operations-table td small { display: block; max-width: 360px; margin-top: 4px; color: var(--crm-subtle); font-size: .6rem; white-space: normal; overflow-wrap: anywhere; }
.icon-button.compact { width: 32px; height: 32px; border-radius: 9px; }
.operations-log { max-height: 540px; overflow-y: auto; padding: 4px 20px; }
.operations-log-entry { position: relative; display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; padding: 14px 0; }
.operations-log-entry:not(:last-child) { border-bottom: 1px solid #eff0f2; }
.operations-log-entry .timeline-dot { margin-top: 6px; }
.operations-log-entry strong { color: #30333d; font-size: .73rem; }
.operations-log-entry small { display: block; margin-top: 5px; color: var(--crm-subtle); font-size: .61rem; }
.operations-log-entry p { margin: 6px 0 0; color: var(--crm-danger); font-size: .67rem; line-height: 1.5; overflow-wrap: anywhere; }

/* Conversations and simulator */
.conversation-thread { min-height: 420px; background: linear-gradient(180deg, #f8f8fa, #f3f4f7); }
.message-bubble { max-width: 75%; padding: .8rem 1rem; background: #fff; border: 1px solid #e7e8ec; border-radius: 6px 16px 16px 16px; box-shadow: 0 4px 14px rgba(20,22,31,.045); }
.message-bubble.outbound { background: #edebff; border-color: #ddd9ff; border-radius: 16px 6px 16px 16px; }
.simulator-panel { padding: 22px; }
.integration-timeline { max-height: 500px; overflow-y: auto; padding: 18px; }
.timeline-entry { position: relative; display: grid; grid-template-columns: 12px 1fr; gap: 12px; padding: 0 0 20px; }
.timeline-entry:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 11px; bottom: 0; width: 1px; background: #e4e5e9; }
.timeline-dot { position: relative; z-index: 1; width: 10px; height: 10px; margin-top: 5px; border: 2px solid #fff; border-radius: 50%; background: #999daa; box-shadow: 0 0 0 2px #e6e7eb; }
.timeline-dot.success { background: #20a879; box-shadow: 0 0 0 2px #d7f1e7; }
.timeline-dot.danger { background: #d34a63; box-shadow: 0 0 0 2px #f8dce2; }
.timeline-entry strong { font-size: .77rem; }
.timeline-entry small { display: block; margin-top: 4px; color: var(--crm-subtle); font-size: .64rem; }
.timeline-entry p { font-size: .7rem; }

/* Alerts and toast */
.alert { border: 0; border-radius: 12px; font-size: .82rem; }
.alert-info { color: #41469c; background: #eeeeff; }
.alert-warning { color: #805115; background: #fff4dd; }
.alert-secondary { color: #5f6372; background: #eceef2; }
.toast-container { z-index: 1090; margin-top: 64px; }
.crm-toast { min-width: 320px; color: var(--crm-text); background: rgba(255,255,255,.97); border: 1px solid var(--crm-border); border-radius: 14px; box-shadow: 0 18px 55px rgba(20,22,31,.16); backdrop-filter: blur(14px); }
.crm-toast .toast-body { display: flex; align-items: center; gap: 10px; padding: 12px; }
.toast-icon { width: 30px; height: 30px; display: grid; place-items: center; color: var(--crm-success); background: var(--crm-success-soft); border-radius: 9px; flex: 0 0 auto; }

/* Authentication */
.auth-body { min-height: 100vh; color: #171923; background: #f4f4f6; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(520px, 1.15fr) minmax(440px, .85fr); }
.auth-stage { position: relative; overflow: hidden; min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; padding: 42px clamp(42px, 6vw, 86px); color: #fff; background: radial-gradient(circle at 76% 16%, rgba(105,96,255,.32), transparent 27%), radial-gradient(circle at 12% 88%, rgba(31,185,138,.1), transparent 24%), linear-gradient(150deg, #151725, #0e1019 74%); }
.auth-stage::before { content: ""; position: absolute; inset: 0; opacity: .2; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(to bottom, black, transparent 82%); }
.auth-brand, .auth-mobile-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font-size: 1.04rem; }
.auth-brand small { color: #7f849e; font-size: .66rem; margin-top: 1px; }
.auth-copy { position: relative; z-index: 1; max-width: 690px; margin: 72px 0 46px; }
.auth-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; color: #bbb8ff; background: rgba(99,91,255,.11); border: 1px solid rgba(141,134,255,.18); border-radius: 999px; font-size: .68rem; font-weight: 680; }
.auth-copy h1 { margin: 24px 0 0; font-size: clamp(2.5rem, 4.8vw, 5rem); line-height: .98; letter-spacing: -.065em; font-weight: 750; }
.auth-copy h1 span { color: #8e93a8; }
.auth-copy > p { max-width: 620px; margin: 26px 0 0; color: #a6aabb; font-size: .98rem; line-height: 1.7; }
.auth-benefits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 38px; }
.auth-benefits > div { display: flex; align-items: flex-start; gap: 10px; }
.auth-benefits > div > span { width: 32px; height: 32px; display: grid; place-items: center; color: #b9b6ff; background: rgba(99,91,255,.12); border-radius: 9px; flex: 0 0 auto; }
.auth-benefits p { margin: 0; }
.auth-benefits strong, .auth-benefits small { display: block; }
.auth-benefits strong { color: #e7e8ee; font-size: .72rem; }
.auth-benefits small { margin-top: 5px; color: #777d92; font-size: .62rem; line-height: 1.45; }
.auth-preview { position: relative; z-index: 1; max-width: 680px; padding: 16px; border: 1px solid rgba(255,255,255,.08); border-radius: 17px; background: rgba(255,255,255,.045); backdrop-filter: blur(12px); }
.preview-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
.preview-head span { display: flex; gap: 5px; }
.preview-head i { color: #4d5063; font-size: .42rem; }
.preview-head small { color: #747a90; font-size: .62rem; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 12px; }
.preview-grid > div { display: flex; align-items: center; gap: 10px; padding: 11px; background: rgba(255,255,255,.035); border-radius: 11px; }
.preview-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; }
.preview-icon.violet { color: #bbb7ff; background: rgba(99,91,255,.15); }
.preview-icon.mint { color: #75d8b7; background: rgba(31,185,138,.12); }
.preview-grid p { margin: 0; flex: 1; }
.preview-grid small, .preview-grid strong { display: block; }
.preview-grid small { color: #777d91; font-size: .59rem; }
.preview-grid strong { margin-top: 2px; color: #eff0f5; font-size: .82rem; }
.preview-grid em { color: #74d5b5; font-size: .58rem; font-style: normal; }
.auth-panel { display: grid; place-items: center; min-height: 100vh; padding: 44px clamp(30px, 5vw, 74px); background: #f6f6f8; }
.auth-card { width: 100%; max-width: 430px; }
.auth-mobile-brand { display: none; margin-bottom: 40px; }
.auth-card-heading .eyebrow { margin-bottom: 10px; }
.auth-card-heading h2 { margin: 0; font-size: 2rem; letter-spacing: -.05em; font-weight: 760; }
.auth-card-heading p { margin: 10px 0 0; color: var(--crm-muted); font-size: .84rem; }
.auth-alert { display: flex; align-items: center; gap: 9px; margin: 24px 0 0; }
.auth-form { display: grid; gap: 20px; margin-top: 30px; }
.field-with-icon { position: relative; }
.field-with-icon > i { position: absolute; left: 14px; top: 50%; z-index: 2; color: #a2a5af; transform: translateY(-50%); }
.field-with-icon .form-control { min-height: 50px; padding-left: 42px; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(20,22,31,.025); }
.auth-submit { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-radius: 12px; }
.auth-demo { display: flex; align-items: center; gap: 11px; margin-top: 24px; padding: 12px; background: #fff; border: 1px solid var(--crm-border); border-radius: 12px; }
.auth-demo > span { width: 32px; height: 32px; display: grid; place-items: center; color: var(--crm-primary); background: var(--crm-primary-soft); border-radius: 9px; }
.auth-demo p { margin: 0; }
.auth-demo strong, .auth-demo small { display: block; }
.auth-demo strong { font-size: .7rem; }
.auth-demo small { margin-top: 3px; color: var(--crm-muted); font-size: .65rem; }
.auth-security { margin-top: 22px; color: #a0a3ad; text-align: center; font-size: .61rem; }
.auth-security i { margin-right: 4px; }

@media (max-width: 1199.98px) {
  .auth-shell { grid-template-columns: 1fr 460px; }
  .auth-stage { padding: 40px; }
  .auth-benefits { grid-template-columns: 1fr; max-width: 440px; }
  .auth-benefits small { display: none; }
}

@media (max-width: 991.98px) {
  .app-sidebar { position: fixed; left: 0; top: 0; box-shadow: 24px 0 60px rgba(5,6,12,.28); }
  .app-sidebar.show { display: flex !important; }
  .app-topbar { padding: 0 18px; }
  .app-content { padding: 24px 18px 40px; }
  .auth-shell { display: block; }
  .auth-stage { display: none; }
  .auth-panel { min-height: 100vh; }
  .auth-mobile-brand { display: flex; }
  .operations-policy { grid-template-columns: 1fr; }
}

@media (max-width: 575.98px) {
  .app-topbar { height: 66px; }
  .topbar-title, .system-health { display: none; }
  .tenant-switcher { min-width: 0; max-width: 215px; }
  .tenant-pill { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-content { padding: 20px 12px 34px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-actions, .page-actions .btn { width: 100%; }
  .card-body { padding: 16px; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar .form-select, .filter-bar .btn, .search-field { width: 100%; }
  .message-bubble { max-width: 92%; }
  .auth-panel { padding: 30px 20px; }
  .auth-card-heading h2 { font-size: 1.7rem; }
  .preview-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* Fast navigation feedback. The UI assets are self-hosted, so this line normally
   flashes only on slower network hops such as a public tunnel. */
.navigation-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 2000;
  height: 3px;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  background: rgba(103, 82, 245, 0.16);
  transition: opacity 120ms ease;
}

.navigation-progress::after {
  content: "";
  display: block;
  width: 38%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6752f5, #8a7bff);
  box-shadow: 0 0 12px rgba(103, 82, 245, 0.5);
  animation: navigation-progress 900ms ease-in-out infinite;
}

.navigation-progress.htmx-request {
  opacity: 1;
}

body.htmx-request .app-content {
  opacity: 0.76;
  transition: opacity 120ms ease;
}

@keyframes navigation-progress {
  from { transform: translateX(-110%); }
  to { transform: translateX(360%); }
}

@media (prefers-reduced-motion: reduce) {
  .navigation-progress::after { animation: none; width: 100%; }
  body.htmx-request .app-content { transition: none; }
}
