:root {
  color-scheme: dark;
  --bg: #070a12;
  --bg-deep: #05070d;
  --surface: rgba(14, 19, 32, .86);
  --surface-strong: #121827;
  --surface-soft: rgba(22, 29, 47, .6);
  --surface-hover: rgba(42, 50, 77, .56);
  --line: rgba(156, 171, 211, .15);
  --line-strong: rgba(160, 177, 221, .25);
  --text: #f4f6ff;
  --muted: #97a0b8;
  --subtle: #69738d;
  --purple: #7b4dff;
  --purple-light: #a78bff;
  --blue: #2287ff;
  --cyan: #31bcff;
  --green: #25d884;
  --orange: #ff9b36;
  --red: #ff5d6d;
  --shadow: 0 22px 60px rgba(0, 0, 0, .33);
  --radius: 16px;
  --radius-sm: 11px;
  --sidebar: 244px;
  font-family: 'DM Sans', Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:not(:disabled), a { -webkit-tap-highlight-color: transparent; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .56; }
input, select, textarea { color: var(--text); }
input::placeholder, textarea::placeholder { color: #69738d; opacity: 1; }
::selection { background: rgba(123, 77, 255, .45); color: #fff; }
[hidden] { display: none !important; }

.crm-body {
  background:
    radial-gradient(circle at 72% -18%, rgba(48, 92, 204, .19), transparent 31rem),
    radial-gradient(circle at 3% 78%, rgba(92, 35, 192, .10), transparent 35rem),
    linear-gradient(135deg, #080b13 0%, #070a12 44%, #060912 100%);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

/* Authentication */
.auth-screen {
  min-height: 100vh;
  padding: 36px 22px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.auth-screen::before, .auth-screen::after {
  content: '';
  position: absolute;
  width: 33rem;
  height: 33rem;
  border-radius: 999px;
  filter: blur(6px);
  opacity: .34;
  pointer-events: none;
}
.auth-screen::before { left: -21rem; bottom: -20rem; background: radial-gradient(circle, #6636df, transparent 67%); }
.auth-screen::after { right: -18rem; top: -18rem; background: radial-gradient(circle, #126ecf, transparent 67%); }
.auth-card {
  width: min(100%, 430px);
  padding: 36px;
  border: 1px solid rgba(173, 190, 238, .17);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(19, 25, 41, .93), rgba(10, 14, 25, .94));
  box-shadow: 0 32px 80px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255,255,255,.05);
  position: relative;
  z-index: 1;
}
.auth-brand { display: inline-flex; align-items: center; margin-bottom: 42px; }
.auth-brand img { width: 152px; height: auto; display: block; }
.auth-loading { color: var(--muted); display: flex; align-items: center; gap: 11px; min-height: 100px; }
.auth-loading i, .loading-dot {
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 2px solid rgba(150, 129, 255, .2);
  border-top-color: var(--purple-light);
  border-radius: 50%;
  animation: crm-spin .75s linear infinite;
}
@keyframes crm-spin { to { transform: rotate(360deg); } }
.eyebrow { display: block; color: var(--purple-light); font: 700 10px/1 'Manrope', sans-serif; letter-spacing: .13em; }
.auth-form h1, .page-heading h1 {
  font-family: 'Manrope', sans-serif;
  color: #fbfcff;
  letter-spacing: -.055em;
}
.auth-form h1 { font-size: clamp(28px, 7vw, 36px); line-height: 1.08; margin: 11px 0 10px; }
.auth-form > p:not(.form-error) { color: var(--muted); margin: 0 0 28px; line-height: 1.55; font-size: 14px; }
.auth-form label, .form-field { display: grid; gap: 8px; margin: 0 0 17px; }
.auth-form label > span, .form-field > span, .modal label > span {
  color: var(--subtle);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
}
.auth-form input, .form-field input, .form-field select, .form-field textarea, .search input {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  background: rgba(4, 7, 14, .46);
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 13px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.form-field textarea { min-height: 85px; resize: vertical; }
.auth-form input:focus, .form-field input:focus, .form-field select:focus, .form-field textarea:focus, .search:focus-within {
  border-color: rgba(137, 102, 255, .82);
  box-shadow: 0 0 0 3px rgba(112, 75, 255, .15);
  background: rgba(7, 10, 20, .74);
}
.primary-button, .secondary-button, .quiet-button, .danger-button, .mini-button {
  border: 0;
  border-radius: 10px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .16s ease, filter .16s ease, background .16s ease, border-color .16s ease;
}
.primary-button { color: #fff; background: linear-gradient(115deg, #7944ed, #3e72fb); box-shadow: 0 9px 24px rgba(86, 71, 227, .24); }
.primary-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.primary-button b { font-size: 18px; line-height: 1; font-weight: 500; }
.secondary-button { background: rgba(43, 51, 81, .52); border: 1px solid var(--line); color: #e6e9f7; }
.secondary-button:hover, .quiet-button:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.quiet-button { background: transparent; border: 1px solid transparent; color: #b6bdd4; }
.danger-button { color: #ffdce0; background: rgba(186, 45, 66, .18); border: 1px solid rgba(255, 93, 109, .27); }
.mini-button { min-height: 32px; padding: 0 10px; font-size: 11px; background: rgba(39, 47, 75, .52); border: 1px solid var(--line); color: #dbe1f7; }
.mini-button:hover { background: var(--surface-hover); }
.form-error { color: #ffacb6 !important; background: rgba(187, 45, 67, .14); border: 1px solid rgba(255, 93, 109, .22); border-radius: 9px; padding: 10px 12px; margin: 16px 0 0 !important; font-size: 12px !important; }
.auth-note { color: var(--subtle); font-size: 11px; text-align: center; margin: 29px 0 0; }

/* Application shell */
.crm-app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  min-height: 100vh;
  width: var(--sidebar);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  overflow-y: auto;
  padding: 23px 16px 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(159, 177, 221, .12);
  background: linear-gradient(180deg, rgba(9, 13, 23, .95), rgba(8, 12, 21, .99));
  backdrop-filter: blur(18px);
}
.sidebar-brand { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; margin-bottom: 27px; text-decoration: none; }
.sidebar-brand img { width: 136px; height: auto; }
.sidebar-brand span { color: #a792ff; border: 1px solid rgba(127, 92, 255, .32); background: rgba(91, 59, 194, .18); border-radius: 5px; padding: 3px 5px; font: 700 9px/1 'Manrope', sans-serif; letter-spacing: .07em; }
.sidebar-nav { display: grid; gap: 3px; }
.nav-label { color: #737e9b; font: 700 10px/1 'Manrope', sans-serif; letter-spacing: .11em; padding: 20px 12px 8px; }
.nav-label:first-child { padding-top: 0; }
.nav-link { min-height: 42px; padding: 0 12px; width: 100%; border: 1px solid transparent; background: transparent; color: #b7bfd4; border-radius: 8px; text-align: left; display: flex; align-items: center; gap: 12px; font-size: 14px; }
.nav-link i, .icon-button i, .search i, .user-menu i, .icon-title i, .action-list i { width: 18px; height: 18px; display: grid; place-items: center; color: #aeb7d1; flex: 0 0 auto; }
.nav-link svg, .icon-button svg, .search svg, .user-menu svg, .icon-title svg, .action-list svg { width: 100%; height: 100%; stroke: currentColor; }
.nav-link:hover { color: #ecedff; background: rgba(41, 48, 77, .38); }
.nav-link.is-active { color: #e8e1ff; border-color: rgba(122, 78, 255, .20); background: linear-gradient(100deg, rgba(76, 39, 177, .46), rgba(43, 36, 117, .23)); box-shadow: inset 2px 0 0 #7a56ff; }
.nav-link.is-active i { color: #9c7bff; }
.cloud-health { margin-top: auto; padding: 13px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(19, 25, 41, .72); display: flex; align-items: center; justify-content: space-between; color: #cad1e8; font-size: 12px; }
.cloud-health span { display: inline-flex; align-items: center; gap: 8px; }
.cloud-health i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 11px rgba(37, 216, 132, .7); }
.cloud-health b { color: var(--green); font-size: 11px; }
.sidebar-version { color: #59627c; margin: 13px 12px 1px; font: 700 9px/1.2 'Manrope', sans-serif; letter-spacing: .08em; }
.app-main { min-width: 0; grid-column: 2; padding: 0 28px 38px; }
.topbar { height: 79px; display: flex; align-items: center; justify-content: flex-end; gap: 16px; position: sticky; z-index: 12; top: 0; background: linear-gradient(to bottom, rgba(7,10,18,.98) 55%, rgba(7,10,18,.78) 78%, transparent); backdrop-filter: blur(10px); }
.search { width: min(100%, 335px); height: 42px; position: relative; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: rgba(14, 18, 31, .56); transition: border-color .18s ease, box-shadow .18s ease; }
.search i { margin-left: 12px; color: #939dbb; }
.search input { min-height: 40px; background: transparent; border: 0; box-shadow: none !important; padding: 0 12px 0 10px; font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; position: relative; }
.icon-button { width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: rgba(16, 21, 36, .7); display: grid; place-items: center; color: #cdd4e9; }
.icon-button:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.icon-button i { width: 17px; height: 17px; }
.mobile-toggle { display: none; border-radius: 10px; }
.user-button { min-height: 42px; padding: 0 8px 0 3px; display: flex; align-items: center; gap: 9px; border: 0; border-radius: 11px; background: transparent; color: #f4f5ff; }
.user-button:hover { background: rgba(38, 45, 70, .56); }
.user-button > span { width: 37px; height: 37px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #2e3857, #15192c); border: 1px solid rgba(180, 194, 232, .15); font-size: 12px; font-weight: 700; }
.user-button b { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.user-button i { display: grid; width: 14px; height: 14px; color: #8994af; }
.user-menu { position: absolute; top: 49px; right: 0; width: 160px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: #151b2c; box-shadow: var(--shadow); }
.user-menu button { border: 0; background: transparent; color: #d6dcef; width: 100%; min-height: 35px; padding: 0 9px; text-align: left; border-radius: 7px; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.user-menu button:hover { background: var(--surface-hover); }
.user-menu i { width: 15px; height: 15px; }
.view-root { max-width: 1440px; margin: 0 auto; min-height: 650px; }

/* Generic CRM content */
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 5px 0 23px; }
.page-heading .eyebrow { margin-bottom: 7px; }
.page-heading h1 { font-size: clamp(27px, 3vw, 36px); line-height: 1.1; margin: 0; }
.page-description { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.heading-actions, .toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.heading-actions { padding-top: 8px; justify-content: flex-end; }
.toolbar { justify-content: space-between; margin: 0 0 15px; }
.toolbar .search-small { min-width: min(100%, 260px); }
.toolbar .search-small input { background: rgba(7, 10, 18, .55); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 17px; }
.metric-card, .panel, .module-card, .stat-card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(18, 24, 40, .83), rgba(11, 15, 27, .76)); box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.metric-card { min-height: 138px; padding: 18px; position: relative; overflow: hidden; }
.metric-card::after { content: ''; position: absolute; width: 100px; height: 70px; right: -22px; bottom: -28px; background: radial-gradient(ellipse, var(--metric-glow, rgba(87, 94, 255, .25)), transparent 67%); }
.metric-card .metric-label { display: block; color: #9da7c0; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.metric-number { display: flex; align-items: baseline; gap: 9px; margin-top: 9px; }
.metric-number strong { color: #f8f9ff; font: 700 27px/1 'Manrope', sans-serif; letter-spacing: -.055em; }
.metric-number b { color: var(--green); font-size: 12px; }
.metric-sub { color: var(--muted); margin: 9px 0 0; font-size: 12px; }
.metric-icon { width: 39px; height: 39px; display: grid; place-items: center; position: absolute; top: 16px; right: 16px; border-radius: 50%; background: var(--metric-bg, rgba(72, 59, 190, .22)); color: var(--metric-color, var(--purple-light)); }
.metric-icon i { width: 20px; height: 20px; }
.metric-icon svg { width: 100%; height: 100%; stroke: currentColor; }
.sparkline { position: absolute; left: 18px; right: 18px; bottom: 13px; height: 25px; opacity: .95; }
.sparkline svg { width: 100%; height: 100%; overflow: visible; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.46fr) minmax(295px, .9fr); gap: 17px; }
.dashboard-grid .wide { grid-column: 1; }
.dashboard-grid .side { grid-column: 2; }
.dashboard-bottom { display: grid; grid-template-columns: 1.1fr .9fr; gap: 17px; margin-top: 17px; }
.panel { padding: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.panel-head h2 { margin: 0; font: 700 16px/1.2 'Manrope', sans-serif; letter-spacing: -.035em; }
.panel-head p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
.panel-link { border: 0; padding: 2px 0; background: transparent; color: #a88cff; font-size: 12px; white-space: nowrap; }
.panel-link:hover { color: #c5b6ff; }
.chart-shell { height: 205px; position: relative; padding: 18px 0 0; }
.chart-shell::before { content: ''; position: absolute; inset: 12px 0 28px; background: repeating-linear-gradient(to bottom, transparent 0, transparent 43px, rgba(146, 162, 203, .08) 44px); pointer-events: none; }
.chart-shell svg { width: 100%; height: 170px; overflow: visible; position: relative; }
.chart-labels { display: flex; justify-content: space-between; color: var(--subtle); font-size: 10px; padding: 2px 3px 0; }
.chart-legend { display: flex; gap: 18px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 3px; border-radius: 2px; background: var(--blue); }
.chart-legend i.purple { background: var(--purple); }
.module-distribution { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 18px; min-height: 205px; }
.donut { width: 128px; height: 128px; margin: auto; position: relative; border-radius: 50%; background: conic-gradient(#2b84ff 0 45%, #7745fa 45% 76%, #ff9e22 76% 89%, #2abf69 89% 100%); }
.donut::after { content: ''; position: absolute; inset: 25px; border-radius: inherit; background: #121827; box-shadow: inset 0 0 0 1px rgba(160,177,221,.08); }
.donut > b { position: absolute; z-index: 1; inset: 0; display: grid; place-items: center; font: 700 16px 'Manrope', sans-serif; }
.distribution-list { display: grid; gap: 12px; min-width: 0; }
.distribution-item { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12px; }
.distribution-item i { width: 8px; height: 8px; border-radius: 3px; background: var(--colour, var(--blue)); }
.distribution-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cdd4e9; }
.distribution-item b { color: #f1f3fc; font-size: 11px; }
.action-list { display: grid; gap: 7px; }
.action-list button { min-height: 39px; border: 1px solid rgba(142, 158, 204, .09); background: rgba(28, 35, 57, .52); color: #dce1f2; border-radius: 8px; padding: 0 11px; display: flex; align-items: center; gap: 10px; text-align: left; font-size: 12px; }
.action-list button:hover { background: var(--surface-hover); border-color: var(--line); }
.action-list i { width: 18px; height: 18px; color: #a17aff; }
.system-list { display: grid; gap: 10px; }
.system-list > div { display: flex; align-items: center; justify-content: space-between; color: #c4cbe0; font-size: 12px; }
.system-list span { display: inline-flex; align-items: center; gap: 8px; }
.system-list i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(37,216,132,.6); }
.system-list b { color: var(--green); font-size: 11px; }
.dashboard-aside { display: grid; gap: 17px; align-content: start; }
.secondary-dashboard-row { margin-top: 17px; }
.status-bars { display: grid; gap: 17px; padding: 11px 2px 4px; min-height: 202px; align-content: center; }
.status-bar { display: grid; grid-template-columns: 76px minmax(50px, 1fr) 30px; align-items: center; gap: 10px; color: #bac3db; font-size: 11px; }
.status-bar > div { height: 9px; overflow: hidden; border-radius: 99px; background: rgba(126, 144, 189, .12); }
.status-bar i { height: 100%; min-width: 5px; display: block; border-radius: inherit; box-shadow: 0 0 12px color-mix(in srgb, currentColor 38%, transparent); }
.status-bar b { color: #eff2fb; font-size: 11px; text-align: right; }
.empty-inline, .empty-compact { color: var(--muted); font-size: 12px; padding: 22px 2px; line-height: 1.5; }
.empty-compact { padding: 20px 18px; }
.activity-feed { display: grid; gap: 3px; }
.activity-item { min-height: 52px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid rgba(152,170,215,.09); padding: 8px 0; }
.activity-item:last-child { border-bottom: 0; }
.activity-dot { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; color: #ad91ff; background: rgba(100, 65, 211, .15); border-radius: 9px; }
.activity-dot i { width: 15px; height: 15px; }
.activity-dot svg { width: 100%; height: 100%; stroke: currentColor; }
.activity-item b { color: #dee4f4; display: block; font-size: 12px; font-weight: 600; }
.activity-item small { color: var(--subtle); display: block; margin-top: 4px; font-size: 10px; }
.search-results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.steps-list { list-style: none; display: grid; gap: 14px; padding: 0; margin: 7px 0 0; }
.steps-list li { display: flex; align-items: center; gap: 12px; color: #c9d1e7; font-size: 13px; }
.steps-list b { width: 25px; height: 25px; border-radius: 8px; display: grid; place-items: center; color: #cbbdff; background: rgba(103, 67, 215, .19); border: 1px solid rgba(146, 111, 255, .18); font-size: 11px; }
.steps-list code { color: #beabff; font-size: 11px; }
.license-mini-list { display: grid; gap: 6px; }
.license-mini-list button { min-height: 49px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 9px; color: #dce2f4; text-align: left; border: 1px solid rgba(144,160,205,.10); border-radius: 9px; background: rgba(28, 35, 57, .42); }
.license-mini-list button:hover { border-color: var(--line-strong); background: var(--surface-hover); }
.license-mini-list button > span { min-width: 0; display: grid; grid-template-columns: 18px minmax(0,1fr); column-gap: 8px; align-items: center; }
.license-mini-list button > span > i { grid-row: 1 / span 2; width: 17px; height: 17px; color: #a78cff; }
.license-mini-list button b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.license-mini-list button small { grid-column: 2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 10px; }
.license-mini-list > button > i { width: 17px; height: 17px; flex: 0 0 auto; color: #bba6ff; }
.license-mini-list svg { width: 100%; height: 100%; stroke: currentColor; }
.confirmation-copy { color: #c9d1e6; font-size: 13px; line-height: 1.55; margin: 0; }

/* Rows and tables */
.table-panel { padding: 0; }
.table-panel .panel-head { padding: 18px 18px 0; }
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.data-table th { color: var(--subtle); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: left; padding: 0 18px 11px; white-space: nowrap; }
.data-table td { padding: 12px 18px; border-top: 1px solid rgba(152, 170, 215, .09); color: #c9d0e3; font-size: 12px; vertical-align: middle; }
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:hover { background: rgba(37, 44, 70, .36); }
.data-table .entity-title { color: #eff1fa; font-weight: 700; display: block; }
.data-table .entity-sub { color: var(--muted); font-size: 11px; margin-top: 3px; display: block; }
.data-table .table-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-actions { border: 0; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 7px; color: #aeb8d3; background: transparent; }
.row-actions:hover { background: rgba(76, 84, 117, .48); color: #f5f6ff; }
.row-actions i { width: 16px; height: 16px; }
.row-actions svg { width: 100%; height: 100%; stroke: currentColor; }
.status, .module-pill, .code-prefix, .role-pill { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 22px; padding: 0 8px; border-radius: 6px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.active, .status.paid, .status.issued { color: #35da8c; background: rgba(25, 166, 88, .14); }
.status.suspended, .status.due, .status.draft { color: #ffb24b; background: rgba(213, 128, 16, .15); }
.status.revoked, .status.overdue, .status.cancelled, .status.expired, .status.archived { color: #ff7583; background: rgba(195, 51, 68, .14); }
.status.paused { color: #bc9cff; background: rgba(112, 71, 222, .16); }
.status.scheduled { color: #8cb4ff; background: rgba(48, 114, 228, .14); }
.status.not-applicable { color: #abb4cb; background: rgba(120, 133, 164, .14); }
.status.read-only { color: #9fafff; background: rgba(75, 113, 220, .15); }
.module-pill { color: #aa90ff; background: rgba(104, 67, 218, .16); margin: 1px 3px 1px 0; }
.module-pill.core { color: #75aaff; background: rgba(41, 124, 237, .14); }
.code-prefix { color: #a994ff; background: rgba(88, 62, 187, .22); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.role-pill { color: #c1cae5; background: rgba(101, 114, 150, .16); text-transform: capitalize; }
.empty-state { min-height: 260px; padding: 36px 24px; display: grid; place-items: center; text-align: center; }
.empty-state > div { max-width: 340px; }
.empty-state i { width: 47px; height: 47px; display: grid; place-items: center; margin: 0 auto 15px; border-radius: 14px; color: #a488ff; background: rgba(96, 61, 203, .14); border: 1px solid rgba(140, 110, 255, .2); }
.empty-state i svg { width: 23px; height: 23px; stroke: currentColor; }
.empty-state h2 { margin: 0; font: 700 18px 'Manrope', sans-serif; letter-spacing: -.04em; }
.empty-state p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 8px 0 18px; }
.list-count { color: var(--muted); font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat-card { padding: 15px; }
.stat-card span { color: var(--muted); display: block; font-size: 11px; }
.stat-card b { display: block; font: 700 18px 'Manrope', sans-serif; letter-spacing: -.04em; margin-top: 6px; }

/* Customer dossier */
.back-link { display: inline-flex; align-items: center; margin: 0 0 12px; padding: 0; border: 0; background: transparent; color: #ab91ff; font-size: 12px; }
.back-link:hover { color: #d1c4ff; }
.customer-profile-grid { display: grid; grid-template-columns: 1.1fr 1fr .88fr; gap: 14px; margin-bottom: 14px; }
.customer-facts { min-height: 176px; }
.customer-facts dl { display: grid; gap: 10px; margin: 0; }
.customer-facts dl div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; font-size: 12px; }
.customer-facts dt { color: var(--muted); }
.customer-facts dd { min-width: 0; margin: 0; color: #dce3f6; overflow-wrap: anywhere; }
.customer-contact-list, .customer-code-list, .customer-node-list, .customer-license-list { display: grid; gap: 8px; }
.customer-contact-list > div, .customer-code-list > div, .customer-node-list > div { min-width: 0; padding: 9px 0; border-bottom: 1px solid rgba(159,177,221,.10); }
.customer-contact-list > div:last-child, .customer-code-list > div:last-child, .customer-node-list > div:last-child { border-bottom: 0; }
.customer-contact-list b, .customer-code-list b, .customer-node-list b { display: block; color: #edf0fa; font-size: 12px; }
.customer-contact-list span, .customer-contact-list small, .customer-code-list small, .customer-node-list small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.customer-license-summary { display: grid; gap: 9px; padding-top: 6px; }
.customer-license-summary b { color: #44de97; font: 700 26px/1 'Manrope', sans-serif; letter-spacing: -.055em; }
.customer-license-summary span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.customer-detail-layout { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(285px, .72fr); gap: 14px; align-items: start; }
.customer-detail-side { display: grid; gap: 14px; }
.customer-license-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 84px; padding: 13px 0; border-bottom: 1px solid rgba(159,177,221,.11); }
.customer-license-row:first-child { padding-top: 2px; }
.customer-license-row:last-child { padding-bottom: 2px; border-bottom: 0; }
.customer-license-row > div:first-child { min-width: 0; display: grid; gap: 5px; }
.customer-license-row b { color: #f2f4fc; font: 700 14px 'Manrope', sans-serif; }
.customer-license-row span, .customer-license-row small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.customer-license-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.customer-node-list > div, .customer-code-list > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.customer-node-list > div > span:first-child, .customer-code-list > div > span:first-child { min-width: 0; }
.customer-node-list > div > span:last-child { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; }

/* Modals, layouts and interaction */
.modal-backdrop { position: fixed; z-index: 80; inset: 0; padding: 18px; display: grid; place-items: center; overflow-y: auto; background: rgba(3, 5, 11, .66); backdrop-filter: blur(5px); animation: fade-in .16s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(100%, 730px); max-height: min(880px, calc(100vh - 36px)); overflow: auto; border: 1px solid rgba(169, 185, 230, .19); border-radius: 17px; background: linear-gradient(150deg, #151c2e, #0e1321); box-shadow: 0 30px 90px rgba(0,0,0,.58); animation: modal-in .18s cubic-bezier(.2,.8,.2,1); }
.modal.modal-small { width: min(100%, 450px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { min-height: 66px; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 18px 19px 12px; border-bottom: 1px solid rgba(159, 177, 221, .12); }
.modal-header h2 { margin: 0; font: 700 19px/1.2 'Manrope', sans-serif; letter-spacing: -.045em; }
.modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.modal-close { width: 29px; height: 29px; margin-top: -2px; border: 0; background: transparent; color: #a8b1c9; border-radius: 7px; font-size: 21px; line-height: 1; }
.modal-close:hover { color: #fff; background: rgba(65, 75, 108, .5); }
.modal-content { padding: 19px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 19px 18px; border-top: 1px solid rgba(159, 177, 221, .12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .form-field.full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; color: #dfe5f7; font: 700 12px 'Manrope', sans-serif; padding: 16px 0 11px; margin-top: 2px; border-top: 1px solid rgba(159,177,221,.10); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section::after { content: ''; height: 1px; flex: 1; background: rgba(159,177,221,.1); }
.form-help { margin: -7px 0 14px; color: var(--subtle); font-size: 11px; line-height: 1.45; }
.form-grid .form-help { grid-column: 1 / -1; }
.checkbox-grid { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 18px; }
.check-pill { position: relative; display: inline-flex; }
.check-pill input { position: absolute; opacity: 0; pointer-events: none; }
.check-pill span { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; display: inline-flex; align-items: center; color: #adb7d1; font-size: 12px; transition: .15s ease; }
.check-pill input:checked + span { color: #e6ddff; background: rgba(101, 63, 211, .25); border-color: rgba(147, 113, 255, .48); }
.inline-notice { border: 1px solid rgba(117, 96, 232, .28); background: rgba(74, 48, 165, .14); color: #c9bcff; padding: 11px 12px; border-radius: 9px; font-size: 12px; line-height: 1.45; margin: 0 0 16px; }
.secret-code { display: flex; align-items: center; gap: 8px; padding: 14px; border-radius: 10px; background: rgba(5, 8, 15, .6); border: 1px solid var(--line); margin: 14px 0 4px; }
.secret-code code { min-width: 0; flex: 1; color: #c7b6ff; font: 700 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.secret-code button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: rgba(44, 52, 81, .6); color: #e6eaff; }
.secret-code button:hover { background: var(--surface-hover); }
.secret-code i { width: 16px; height: 16px; }
.secret-code svg { width: 100%; height: 100%; stroke: currentColor; }
.modal-loading { display: flex; justify-content: center; padding: 30px; color: var(--muted); }

.toast { max-width: min(420px, calc(100vw - 32px)); min-height: 48px; position: fixed; right: 19px; bottom: 18px; z-index: 100; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; color: #e9edf9; border: 1px solid rgba(126, 145, 193, .24); border-radius: 11px; background: rgba(20, 27, 45, .95); box-shadow: 0 19px 44px rgba(0,0,0,.38); transform: translateY(12px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast > i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(37,216,132,.65); }
.toast.is-error > i { background: var(--red); box-shadow: 0 0 10px rgba(255,93,109,.65); }
.toast span { min-width: 0; flex: 1; font-size: 12px; line-height: 1.35; }
.toast button { width: 27px; height: 27px; border: 0; color: #9da7c1; background: transparent; border-radius: 7px; font-size: 19px; line-height: 1; }
.toast button:hover { background: rgba(63,73,105,.6); color: #fff; }
.screen-error { display: grid; place-items: center; min-height: 55vh; }
.screen-error > div { max-width: 460px; padding: 24px; border: 1px solid rgba(255,93,109,.22); border-radius: 14px; background: rgba(112, 27, 44, .14); text-align: center; }
.screen-error h2 { font: 700 20px 'Manrope', sans-serif; margin: 0; }
.screen-error p { color: #d9bdc4; font-size: 13px; line-height: 1.5; }

/* Light setting remains discreet for users who choose it. */
.is-light {
  color-scheme: light;
  --bg: #edf0f8;
  --bg-deep: #e9edf7;
  --surface: rgba(255,255,255,.84);
  --surface-strong: #fff;
  --surface-soft: rgba(232, 236, 248, .8);
  --surface-hover: rgba(221, 226, 244, .9);
  --line: rgba(49, 61, 95, .14);
  --line-strong: rgba(49, 61, 95, .25);
  --text: #171b28;
  --muted: #64708b;
  --subtle: #75819a;
  --shadow: 0 22px 60px rgba(30, 38, 71, .14);
  background: #edf0f8;
}
.is-light .crm-body, .is-light.crm-body { background: radial-gradient(circle at 72% -18%, rgba(66, 100, 218, .15), transparent 31rem), #edf0f8; }
.is-light .sidebar { background: rgba(248,250,255,.91); }
.is-light .topbar { background: linear-gradient(to bottom, rgba(237,240,248,.97) 55%, rgba(237,240,248,.74) 78%, transparent); }
.is-light .metric-card, .is-light .panel, .is-light .stat-card, .is-light .modal { background: linear-gradient(145deg, rgba(255,255,255,.93), rgba(246,248,254,.92)); }
.is-light .auth-card { background: linear-gradient(145deg, rgba(255,255,255,.95), rgba(246,248,255,.95)); }
.is-light .auth-form h1, .is-light .page-heading h1, .is-light .metric-number strong, .is-light .panel-head h2, .is-light .data-table .entity-title { color: #1b2130; }
.is-light .donut::after { background: #fff; }

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-grid .wide, .dashboard-grid .side { grid-column: auto; }
}
@media (max-width: 920px) {
  :root { --sidebar: 0px; }
  .crm-app { display: block; }
  .sidebar { width: 266px; transform: translateX(-104%); transition: transform .22s ease; box-shadow: 18px 0 50px rgba(0,0,0,.38); }
  .crm-app.nav-open .sidebar { transform: translateX(0); }
  .crm-app.nav-open::after { content: ''; position: fixed; z-index: 15; inset: 0; background: rgba(2,4,9,.52); }
  .app-main { padding: 0 20px 30px; }
  .topbar { height: 70px; justify-content: space-between; gap: 10px; }
  .mobile-toggle { display: grid; flex: 0 0 auto; }
  .search { width: min(100%, 355px); margin-left: auto; }
  .user-button b { display: none; }
  .user-button { padding-right: 2px; }
  .dashboard-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 660px) {
  .auth-screen { padding: 17px; place-items: stretch; }
  .auth-card { margin: auto 0; padding: 27px 23px; }
  .auth-brand { margin-bottom: 31px; }
  .app-main { padding: 0 14px 24px; }
  .topbar { height: 63px; }
  .search { width: auto; flex: 1; min-width: 0; }
  .search input { font-size: 12px; }
  .top-actions { gap: 5px; }
  .top-actions > .icon-button { display: none; }
  .user-button > span { width: 34px; height: 34px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 11px; margin: 7px 0 19px; }
  .heading-actions { width: 100%; padding-top: 0; justify-content: flex-start; }
  .heading-actions .primary-button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 10px; }
  .metric-card { min-height: 128px; padding: 14px; }
  .metric-number strong { font-size: 22px; }
  .metric-icon { width: 33px; height: 33px; top: 12px; right: 12px; }
  .metric-sub { margin-top: 6px; font-size: 10px; padding-right: 3px; }
  .panel { padding: 14px; border-radius: 13px; }
  .dashboard-grid, .dashboard-bottom { gap: 10px; margin-top: 10px; }
  .module-distribution { grid-template-columns: 108px minmax(0, 1fr); gap: 11px; min-height: 165px; }
  .donut { width: 102px; height: 102px; }
  .donut::after { inset: 20px; }
  .chart-shell { height: 180px; }
  .chart-shell svg { height: 145px; }
  .chart-legend { gap: 10px; font-size: 10px; }
  .toolbar { align-items: stretch; }
  .toolbar .search-small { min-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .form-field.full { grid-column: auto; }
  .modal-backdrop { padding: 8px; align-items: end; }
  .modal { max-height: calc(100vh - 16px); border-radius: 16px 16px 10px 10px; }
  .modal-content { padding: 16px; }
  .modal-footer { padding: 12px 16px 15px; }
  .modal-footer .primary-button, .modal-footer .secondary-button { flex: 1; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .customer-profile-grid, .customer-detail-layout { grid-template-columns: 1fr; gap: 10px; }
  .customer-facts { min-height: auto; }
  .customer-license-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .customer-license-actions { width: 100%; justify-content: flex-start; }
  .search-results-grid { grid-template-columns: 1fr; gap: 10px; }
  .dashboard-aside { gap: 10px; }
  .secondary-dashboard-row { margin-top: 10px; }
  .toast { right: 12px; bottom: 12px; }
}
@media (max-width: 390px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 115px; }
  .search input::placeholder { color: transparent; }
  .search { flex: 0 1 92px; }
}
