@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800;900&display=swap');
:root {
  --bg: #080d0b;
  --surface: #0f1713;
  --surface-2: #121e18;
  --panel: #16231c;
  --panel-2: #101915;
  --line: #254035;
  --line-soft: rgba(255,255,255,0.08);
  --text: #eef8f2;
  --muted: #8ba99a;
  --soft: #c6d8cf;
  --green: #25d366;
  --green-2: #13a86b;
  --cyan: #4cc9f0;
  --amber: #f8b84e;
  --rose: #ff6b6b;
  --shadow: 0 18px 52px rgba(0,0,0,0.28);
}
html[data-theme="normal"] {
  --bg: #f4f8f6;
  --surface: #ffffff;
  --surface-2: #eef6f1;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --line: #cfe0d7;
  --line-soft: rgba(14,48,32,0.10);
  --text: #102118;
  --muted: #64786d;
  --soft: #243b2f;
  --green: #17b65e;
  --green-2: #0e8d68;
  --cyan: #168aad;
  --amber: #b7791f;
  --rose: #d64545;
  --shadow: 0 18px 42px rgba(18,55,37,0.12);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.app {
  height: 100vh;
  width: 100vw;
  max-width: 100vw;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.topbar {
  grid-column: 2;
  grid-row: 1;
  min-height: 68px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  background: linear-gradient(180deg, #111d17, #0d1511);
  border-bottom: 1px solid var(--line);
}
html[data-theme="normal"] .topbar {
  background: linear-gradient(180deg, #ffffff, #edf7f1);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 190px;
  flex: 0 1 300px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #041108;
  font-weight: 900;
  box-shadow: 0 0 0 5px rgba(37,211,102,0.09);
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}
.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 10px;
  width: min(520px, 44vw);
  min-width: 0;
}
.stat {
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
}
.stat strong {
  display: block;
  font-size: 19px;
  color: var(--text);
}
.stat span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}
.health {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.theme-switch,
.layout-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}
.layout-switch {
  border-color: rgba(37,211,102,0.42);
  background: rgba(37,211,102,0.10);
  box-shadow: 0 10px 24px rgba(37,211,102,0.10);
}
.theme-option,
.layout-option {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.theme-option.active,
.layout-option.active {
  background: var(--green);
  color: #041108;
}
.layout-option {
  min-width: 74px;
}
.health-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 14px rgba(248,184,78,0.45);
}
.health.ok .health-dot {
  background: var(--green);
  box-shadow: 0 0 14px rgba(37,211,102,0.55);
}
.health.err .health-dot {
  background: var(--rose);
  box-shadow: 0 0 14px rgba(255,107,107,0.55);
}
.tabs {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(180deg, rgba(37,211,102,0.12), transparent 180px),
    linear-gradient(180deg, #0d1712, #07100c);
  border-right: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.03);
}
.tabs::before,
.tabs::after {
  content: none;
  display: none;
}
.side-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 6px 14px;
  padding: 10px 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.side-logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #041108;
  font-weight: 900;
  box-shadow: 0 0 0 6px rgba(37,211,102,0.10);
}
.side-logo strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0;
}
.side-logo span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.nav-section {
  margin: 12px 10px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.nav-footnote {
  margin: auto 8px 0;
  padding: 12px;
  border: 1px solid rgba(37,211,102,0.22);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  background: rgba(37,211,102,0.07);
}
.nav-footnote strong {
  display: block;
  color: var(--text);
  margin-bottom: 3px;
}
html[data-theme="normal"] .tabs {
  background:
    linear-gradient(180deg, rgba(23,182,94,0.10), transparent 180px),
    #ffffff;
}
html[data-theme="normal"] .side-logo {
  border-bottom-color: rgba(14,48,32,0.10);
}
.tab {
  position: relative;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: calc(100% - 4px);
  margin: 1px 2px;
}
.tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border-color: var(--line-soft);
}
.tab.active {
  color: var(--text);
  border-color: rgba(37,211,102,0.36);
  background: linear-gradient(135deg, rgba(37,211,102,0.16), rgba(76,201,240,0.08));
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}
.tab.active::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--green);
}
.nav-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #06110b;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  flex: 0 0 auto;
}
.nav-ico svg {
  width: 16px;
  height: 16px;
}
.badge {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  font-size: 11px;
}
.main {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(76,201,240,0.04), transparent 32%),
    linear-gradient(180deg, rgba(37,211,102,0.05), transparent 300px),
    var(--bg);
}
html[data-theme="normal"] .main {
  background:
    linear-gradient(90deg, rgba(22,138,173,0.08), transparent 32%),
    linear-gradient(180deg, rgba(23,182,94,0.08), transparent 300px),
    var(--bg);
}
.view { display: none; height: 100%; min-height: 0; }
.view.active { display: block; }
.sender-layout, .inbox-layout {
  height: 100%;
  min-height: 0;
  display: grid;
}
.sender-layout { grid-template-columns: 360px minmax(0, 1fr); }
.inbox-layout { grid-template-columns: 340px minmax(0, 1fr); }
.sidebar {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  border-right: 1px solid var(--line);
  background: rgba(15,23,19,0.92);
}
html[data-theme="normal"] .sidebar {
  background: rgba(255,255,255,0.94);
}
.side-head {
  padding: 15px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.section-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.filters {
  padding: 13px 16px;
  display: grid;
  gap: 9px;
  border-bottom: 1px solid var(--line);
}
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
select, input, textarea {
  width: 100%;
  color: var(--text);
  background: #07100c;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
html[data-theme="normal"] select,
html[data-theme="normal"] input,
html[data-theme="normal"] textarea {
  background: #ffffff;
}
select, input { min-height: 38px; padding: 0 10px; }
textarea {
  min-height: 126px;
  padding: 12px;
  line-height: 1.55;
  resize: vertical;
}
select:focus, input:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.10);
}
.selectbar {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.selectbar input { width: 15px; min-height: 15px; accent-color: var(--green); }
.list {
  min-height: 0;
  overflow: auto;
}
.student {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  text-align: left;
}
.student:hover, .student.selected { background: rgba(37,211,102,0.08); }
.student input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--green);
}
.student-name, .conv-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.student-meta, .conv-preview, .tiny {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.priority {
  width: 8px;
  height: 32px;
  border-radius: 99px;
  background: var(--green);
}
.priority.high { background: var(--rose); }
.priority.medium { background: var(--amber); }
.content {
  min-width: 0;
  min-height: 0;
  padding: 18px;
  overflow: auto;
}
.workspace-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  max-width: 1240px;
  margin-bottom: 16px;
}
.overview-card {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(37,211,102,0.12), transparent 64%),
    linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.overview-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -34px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(76,201,240,0.16);
}
html[data-theme="normal"] .overview-card {
  background:
    linear-gradient(135deg, rgba(23,182,94,0.12), transparent 64%),
    #ffffff;
}
.overview-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.overview-card strong {
  display: block;
  margin-top: 9px;
  font-size: 24px;
  letter-spacing: 0;
}
.overview-card small {
  display: block;
  margin-top: 5px;
  color: var(--soft);
  font-size: 12px;
}
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  max-width: 1240px;
}
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
}
html[data-theme="normal"] .card {
  background: linear-gradient(180deg, #ffffff, #f7fbf8);
}
.card + .card { margin-top: 16px; }
.card-title {
  margin: 0 0 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.mode-tab {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.035);
  color: var(--muted);
  font-weight: 800;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  text-align: left;
}
.mode-tab.active {
  color: var(--text);
  border-color: var(--green);
  background: rgba(37,211,102,0.12);
}
.mode-tab span { display: block; }
.mode-tab small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.mode-icon, .svg-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #05110b;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 10px 24px rgba(37,211,102,0.18);
}
.mode-icon svg, .svg-badge svg { width: 18px; height: 18px; }
.composer-mode[hidden] { display: none; }
.composer-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: -4px 0 12px;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}
.tpl {
  min-height: 68px;
  text-align: left;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #09120e;
  color: var(--muted);
}
html[data-theme="normal"] .tpl {
  background: #ffffff;
}
.tpl strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 13px;
}
.tpl span {
  font-size: 11px;
  color: var(--muted);
}
.tpl.active, .tpl:hover {
  border-color: var(--green);
  background: rgba(37,211,102,0.09);
}
.meta-toolbar {
  display: grid;
  grid-template-columns: 1fr 150px auto;
  gap: 9px;
  margin-bottom: 12px;
}
.meta-picker {
  display: grid;
  gap: 9px;
  max-height: 360px;
  overflow: auto;
}
.meta-pick {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
  padding: 12px;
  display: grid;
  gap: 8px;
  text-align: left;
  color: var(--text);
}
html[data-theme="normal"] .meta-pick { background: #ffffff; }
.meta-pick:hover, .meta-pick.active {
  border-color: var(--green);
  background: rgba(37,211,102,0.08);
}
.meta-pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.meta-pick-name {
  font-weight: 900;
  font-size: 13px;
}
.meta-pick-meta {
  color: var(--muted);
  font-size: 11px;
}
.meta-pick-body {
  color: var(--soft);
  font-size: 12px;
  line-height: 1.5;
  max-height: 54px;
  overflow: hidden;
}
.meta-selected {
  border: 1px solid rgba(37,211,102,0.25);
  background:
    linear-gradient(135deg, rgba(37,211,102,0.10), rgba(76,201,240,0.06)),
    rgba(37,211,102,0.04);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
}
.meta-selected[hidden] { display: none; }
.meta-selected strong {
  display: block;
  margin-bottom: 5px;
}
.meta-selected span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.meta-selected .import-row {
  grid-template-columns: 150px 1fr auto auto;
}
.selected-template-head {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}
.header-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed rgba(76,201,240,0.35);
  border-radius: 8px;
  background: rgba(76,201,240,0.06);
}
.header-box-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.pill.ok { color: var(--green); border-color: rgba(37,211,102,0.35); background: rgba(37,211,102,0.08); }
.pill.warn { color: var(--amber); border-color: rgba(255,184,77,0.35); background: rgba(255,184,77,0.08); }
.media-preview {
  display: none;
  margin-top: 9px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
}
.media-preview.show { display: block; }
.media-preview img, .media-preview video {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
}
.media-doc {
  padding: 12px;
  color: var(--soft);
  font-size: 12px;
}
.mapper-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(248,184,78,0.32);
  border-radius: 8px;
  background: rgba(248,184,78,0.07);
}
.mapper-box[hidden] { display: none; }
.mapper-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mapper-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.mapper-token {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--amber);
  background: rgba(0,0,0,0.16);
  font-weight: 900;
}
.mapper-controls {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(180px, 1fr);
  gap: 8px;
}
.mapper-static-input[hidden] {
  display: none;
}
.media-library {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  margin-top: 10px;
}
.media-tile {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
  color: var(--soft);
  display: grid;
  gap: 5px;
  padding: 8px;
  text-align: left;
  overflow: hidden;
}
.media-tile:hover {
  border-color: var(--green);
  background: rgba(37,211,102,0.08);
}
.media-thumb {
  height: 48px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
}
.media-thumb img, .media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-name {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview {
  min-height: 210px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(18,140,126,0.18), rgba(37,211,102,0.06)),
    #07100c;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.6;
}
html[data-theme="normal"] .preview {
  background:
    linear-gradient(135deg, rgba(18,140,126,0.08), rgba(37,211,102,0.06)),
    #ffffff;
}
.preview-phone {
  max-width: 390px;
  margin: 0 auto;
  border: 10px solid #111;
  border-radius: 30px;
  padding: 12px;
  background:
    radial-gradient(circle at 24px 24px, rgba(255,255,255,0.10) 1px, transparent 1px) 0 0 / 18px 18px,
    #e5ddd5;
}
.preview-phone::before {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin: -3px auto 10px;
  border-radius: 99px;
  background: #222;
}
.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.preview-bubble {
  margin-left: auto;
  max-width: 92%;
  background: #dcf8c6;
  color: #07120d;
  border-radius: 8px 8px 2px 8px;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0,0,0,0.20);
}
.preview-body {
  padding: 12px 13px;
  white-space: pre-wrap;
}
.preview-footer {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  padding: 0 10px 7px;
  color: rgba(7,18,13,0.55);
  font-size: 10px;
}
.preview-media { background: #a8c7b0; }
.preview-media img, .preview-media video {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
}
.preview-doc {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: rgba(255,255,255,0.7);
  font-weight: 800;
  font-size: 12px;
}
.crm-template-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 12px;
  display: grid;
  gap: 10px;
}
.crm-template-preview[hidden] { display: none; }
.crm-template-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .35px;
}
.crm-template-preview-phone {
  background: #efe7dc;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 12px;
}
.crm-template-preview-bubble {
  max-width: 420px;
  background: #d9ffd0;
  border-radius: 12px;
  padding: 10px;
  color: #07120d;
  box-shadow: 0 8px 20px rgba(0,0,0,0.10);
}
.crm-template-preview-media {
  display: grid;
  place-items: center;
  min-height: 110px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(37,211,102,0.22), rgba(76,201,240,0.22));
  color: #0d2018;
  font-weight: 900;
}
.crm-template-preview-body {
  white-space: pre-wrap;
  line-height: 1.5;
}
.crm-template-preview .template-buttons {
  margin-top: 10px;
}
.var {
  color: var(--cyan);
  font-weight: 800;
}
.actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}
.btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.btn:hover { border-color: var(--green); }
.btn-primary {
  background: var(--green);
  color: #041108;
}
.btn-primary:hover { background: #35ea78; border-color: #35ea78; }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--soft);
}
.btn-danger {
  background: rgba(255,107,107,0.12);
  border-color: rgba(255,107,107,0.34);
  color: var(--rose);
}
.btn-danger:hover {
  background: rgba(255,107,107,0.18);
  border-color: var(--rose);
}

/* Phase 2 premium CRM UX layer */
.premium-empty-state {
  min-height: 168px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 26px;
  background:
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,0.92), rgba(242,248,250,0.82));
  border: 1px solid rgba(148, 163, 184, 0.26);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.06);
}

html.dark .premium-empty-state,
html[data-theme="dark"] .premium-empty-state {
  background:
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 36%),
    linear-gradient(145deg, rgba(10, 18, 15, 0.96), rgba(7, 16, 14, 0.92));
}

.search-clear-btn {
  min-height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: rgba(255,255,255,0.78);
  color: var(--muted);
  padding: 0 14px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.search-clear-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(16, 185, 129, 0.46);
  background: rgba(236, 253, 245, 0.86);
  color: var(--text);
}

.premium-crm-card {
  position: relative;
  display: grid;
  gap: 12px;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(125, 170, 184, 0.34);
  background:
    radial-gradient(circle at 100% 0%, rgba(56, 189, 248, 0.12), transparent 32%),
    radial-gradient(circle at 0% 10%, rgba(34, 197, 94, 0.13), transparent 28%),
    linear-gradient(160deg, rgba(255,255,255,0.96), rgba(244,252,248,0.92));
  box-shadow: 0 22px 56px rgba(15, 23, 42, 0.08);
}

.premium-crm-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, #10b981, #2563eb);
}

.crm-card-top {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.crm-card-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #34d399, #22d3ee);
  color: #06120f;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.22);
}

.crm-card-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.crm-card-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 16px;
}

.crm-card-title span,
.crm-card-remark,
.crm-card-meta-grid span {
  color: var(--muted);
}

.crm-card-course {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(59, 130, 246, 0.26);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(219, 234, 254, 0.72), rgba(240, 253, 250, 0.82));
}

.crm-card-course span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
  color: var(--text);
}

.crm-card-course small,
.crm-card-meta-grid b {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #64748b;
}

.crm-card-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.crm-card-meta-grid span {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid rgba(148, 163, 184, 0.20);
  border-radius: 14px;
  background: rgba(255,255,255,0.62);
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-card-score-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.crm-card-counts,
.lead-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crm-card-counts span,
.lead-count-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.10);
  color: #0f766e;
  font-size: 11px;
  font-weight: 850;
}

.crm-card-remark {
  margin: 0;
  min-height: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}

.crm-card-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-card-actions .btn,
.row-actions .btn,
.lead-more-select {
  min-height: 38px;
}

.lead-more-select {
  max-width: 132px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.30);
  background: rgba(255,255,255,0.82);
  color: var(--text);
  font-weight: 800;
  padding: 0 10px;
}

.mobile-action-trigger {
  display: none !important;
}

.followup-folder-card[data-followup-card-filter] {
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.followup-folder-card[data-followup-card-filter]:hover,
.followup-folder-card[data-followup-card-filter]:focus-visible,
.followup-folder-card[data-followup-card-filter].active {
  transform: translateY(-2px);
  border-color: rgba(16, 185, 129, 0.52);
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.10);
  outline: none;
}

.followup-lead-card {
  position: relative;
  overflow: hidden;
}

.followup-lead-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, #22c55e, #38bdf8);
}

.calling-row,
.calling-tiny-lead,
.calling-bucket,
.calling-admin-suite,
.calling-chart-card {
  border-color: rgba(125, 170, 184, 0.28) !important;
  background:
    radial-gradient(circle at 100% 0%, rgba(34, 197, 94, 0.08), transparent 30%),
    linear-gradient(145deg, rgba(255,255,255,0.95), rgba(248,250,252,0.88)) !important;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.07);
}

.calling-row {
  position: relative;
  overflow: hidden;
  border-radius: 20px !important;
}

.calling-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, #0ea5e9, #22c55e);
}

.calling-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.calling-actions .btn {
  min-height: 36px;
  border-radius: 999px;
}

.calling-bucket-head,
.calling-panel-head {
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  margin-bottom: 10px;
}

.mobile-action-sheet {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.mobile-action-sheet.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-action-scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.48);
  backdrop-filter: blur(5px);
}

.mobile-action-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(72vh, 620px);
  overflow: auto;
  padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: var(--surface);
  box-shadow: 0 -24px 70px rgba(2, 6, 23, 0.24);
  transform: translateY(24px);
  transition: transform .22s ease;
}

.mobile-action-sheet.open .mobile-action-panel {
  transform: translateY(0);
}

.mobile-action-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  margin: 3px auto 12px;
  background: rgba(148, 163, 184, 0.58);
}

.mobile-action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 12px;
}

.mobile-action-list {
  display: grid;
  gap: 9px;
}

.mobile-action-list button {
  width: 100%;
  display: grid;
  gap: 3px;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  padding: 13px 14px;
  background: rgba(255,255,255,0.70);
  color: var(--text);
  cursor: pointer;
}

.mobile-action-list button span {
  font-weight: 900;
}

.mobile-action-list button small {
  color: var(--muted);
  font-weight: 650;
}

html.dark .premium-crm-card,
html[data-theme="dark"] .premium-crm-card,
html.dark .calling-row,
html.dark .calling-tiny-lead,
html.dark .calling-bucket,
html.dark .calling-admin-suite,
html.dark .calling-chart-card,
html[data-theme="dark"] .calling-row,
html[data-theme="dark"] .calling-tiny-lead,
html[data-theme="dark"] .calling-bucket,
html[data-theme="dark"] .calling-admin-suite,
html[data-theme="dark"] .calling-chart-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(34, 197, 94, 0.10), transparent 30%),
    linear-gradient(145deg, rgba(10,18,15,0.96), rgba(7,15,14,0.92)) !important;
}

html.dark .crm-card-meta-grid span,
html[data-theme="dark"] .crm-card-meta-grid span,
html.dark .mobile-action-list button,
html[data-theme="dark"] .mobile-action-list button,
html.dark .lead-more-select,
html[data-theme="dark"] .lead-more-select {
  background: rgba(15, 23, 42, 0.68);
  border-color: rgba(148, 163, 184, 0.18);
}

@media (max-width: 760px) {
  .mobile-action-trigger {
    display: inline-flex !important;
  }

  .row-actions .lead-more-select,
  .crm-card-actions .lead-more-select {
    display: none !important;
  }

  .premium-crm-card {
    border-radius: 20px;
    padding: 14px !important;
  }

  .crm-card-top {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .crm-card-top .status-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .crm-card-meta-grid {
    grid-template-columns: 1fr;
  }

  .crm-card-score-row {
    grid-template-columns: 1fr;
  }

  .crm-card-actions .btn,
  .row-actions .btn {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .search-clear-btn {
    width: 100%;
  }
}
.btn-call {
  background: rgba(32, 201, 151, 0.13);
  border-color: rgba(32, 201, 151, 0.28);
  color: var(--green);
}
.btn-call:hover {
  background: var(--green);
  border-color: var(--green);
  color: #041108;
}
.btn-wa {
  background: rgba(18, 140, 126, 0.12);
  border-color: rgba(18, 140, 126, 0.28);
  color: #0c8f7f;
}
.btn-wa:hover {
  background: #0c8f7f;
  border-color: #0c8f7f;
  color: #fff;
}
.btn-small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}
.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
.chat-back {
  display: none;
}
.progress-wrap { display: none; margin-top: 13px; }
.progress-text {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}
.progress-outer {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.progress-inner {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transition: width 0.2s;
}
.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.mini {
  padding: 12px;
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}
.mini strong {
  display: block;
  font-size: 20px;
}
.mini span {
  color: var(--muted);
  font-size: 11px;
}
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
  max-width: 100%;
}
.chart-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.14);
  min-width: 0;
  overflow: hidden;
}
html[data-theme="normal"] .chart-card { background: #ffffff; }
.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--soft);
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 13px;
}
.bar-list {
  display: grid;
  gap: 11px;
}
.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 50px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.bar-track {
  height: 10px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}
.donut-wrap {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
}
.donut {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0deg, var(--green) 0deg, rgba(255,255,255,0.08) 0deg 360deg);
  position: relative;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: var(--panel);
}
.donut-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1;
  font-size: 24px;
  font-weight: 900;
}
.legend {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.tick {
  display: inline-flex;
  gap: 1px;
  color: var(--muted);
  font-weight: 900;
}
.tick.read { color: #4cc9f0; }
.tick.failed { color: var(--rose); }
.import-grid {
  display: grid;
  gap: 10px;
}
.import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(2, auto);
  gap: 10px;
  align-items: center;
}
.import-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-line;
}
.meta-form {
  display: grid;
  gap: 9px;
}
.meta-form-row {
  display: grid;
  grid-template-columns: 1fr 150px 120px;
  gap: 9px;
}
.billing-rate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.billing-rate-field {
  display: grid;
  gap: 6px;
}
.billing-rate-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .35px;
  text-transform: uppercase;
}
.billing-rate-field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.meta-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  margin-top: 12px;
}
.meta-template {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.13);
}
html[data-theme="normal"] .meta-template {
  background: #ffffff;
}
.meta-template strong {
  display: block;
  font-size: 13px;
}
.meta-template span {
  color: var(--muted);
  font-size: 11px;
}
.meta-status {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  background: rgba(255,255,255,0.08);
}
.meta-status.approved { color: var(--green); }
.meta-status.pending { color: var(--amber); }
.meta-status.rejected { color: var(--rose); }
.conv-sidebar {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.inbox-bulk-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(37,211,102,0.06);
}
.inbox-bulk-bar.show {
  display: flex;
}
.inbox-select-all {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}
.inbox-bulk-count {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.inbox-bulk-bar .btn {
  padding: 8px 10px;
  min-height: 34px;
}
.conversation {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: 22px 42px 1fr auto;
  gap: 11px;
  align-items: start;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
}
.conversation-check-wrap {
  width: 18px;
  height: 40px;
  display: grid;
  place-items: center;
}
.conversation-check {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}
.conversation > span:nth-child(3) {
  min-width: 0;
  overflow: hidden;
}
.conversation:hover, .conversation.active {
  background: rgba(37,211,102,0.08);
}
.conversation.active {
  border-left: 3px solid var(--green);
  padding-left: 13px;
}
.conversation.checked {
  background: rgba(37,211,102,0.12);
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #06100b;
  font-weight: 900;
}
.conv-right {
  text-align: right;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}
.conv-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  max-height: 34px;
  white-space: normal;
}
.conv-more {
  display: inline-block;
  margin-top: 4px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
}
.unread {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  margin-top: 5px;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #06100b;
  background: var(--green);
  font-weight: 900;
}
.chat {
  height: 100%;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 160px),
    var(--surface-2);
}
html[data-theme="normal"] .chat {
  background:
    linear-gradient(180deg, rgba(23,182,94,0.05), transparent 160px),
    var(--surface-2);
}
.chat-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(9,18,14,0.86);
}
html[data-theme="normal"] .chat-head {
  background: rgba(255,255,255,0.92);
}
.chat-title {
  flex: 1;
  min-width: 0;
}
.chat-title strong {
  display: block;
  font-size: 15px;
}
.lead-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 560px;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  background: rgba(0,0,0,0.16);
}
.messages {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: min(720px, 82%);
}
.message-row.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message-row.received {
  align-self: flex-start;
}
.message-row.grouped {
  margin-top: -6px;
}
.message-row.grouped .msg-avatar {
  visibility: hidden;
}
.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #06100b;
  font-size: 10px;
  font-weight: 900;
}
.bubble {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: #101a15;
  line-height: 1.5;
  font-size: 13px;
  white-space: pre-wrap;
}
html[data-theme="normal"] .bubble {
  background: #ffffff;
}
.bubble.sent {
  background: #1b3e2b;
  border-color: rgba(37,211,102,0.24);
  border-bottom-right-radius: 3px;
}
html[data-theme="normal"] .bubble.sent {
  background: #d9fdd3;
  color: #102118;
}
.bubble.received {
  background: #101a15;
  border-bottom-left-radius: 3px;
}
html[data-theme="normal"] .bubble.received {
  background: #ffffff;
  color: #102118;
}
.bubble time {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}
.load-more-wrap {
  padding: 10px 14px 14px;
}
.load-more-wrap .btn {
  width: 100%;
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--green);
  animation: spin .75s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-stack {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
}
.skeleton-line,
.skeleton-card {
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.16), rgba(255,255,255,0.06));
  background-size: 240% 100%;
  animation: shimmer 1.15s ease-in-out infinite;
}
html[data-theme="normal"] .skeleton-line,
html[data-theme="normal"] .skeleton-card {
  background: linear-gradient(90deg, rgba(18,70,44,0.06), rgba(18,70,44,0.15), rgba(18,70,44,0.06));
  background-size: 240% 100%;
}
.skeleton-line { height: 14px; }
.skeleton-card { height: 64px; }
.skeleton-card.tall { height: 130px; }
@keyframes shimmer { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
.message-text-muted {
  color: var(--muted);
  font-style: italic;
}
.template-buttons {
  display: grid;
  gap: 6px;
  margin-top: 9px;
}
.template-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(76,201,240,0.32);
  background: rgba(76,201,240,0.08);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}
html[data-theme="normal"] .template-button {
  background: rgba(22,138,173,0.08);
}
.presence-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(248,184,78,0.36);
  color: var(--amber);
  background: rgba(248,184,78,0.08);
  font-size: 11px;
  font-weight: 800;
}
.presence-indicator.show { display: inline-flex; }
.tick.pending {
  color: var(--muted);
  letter-spacing: 0;
}
.tick.failed {
  color: var(--rose);
  letter-spacing: 0;
}
.chat-media {
  display: block;
  overflow: hidden;
  border-radius: 10px;
  margin: 0 0 7px;
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--line-soft);
}
.chat-media img,
.chat-media video {
  display: block;
  max-width: min(360px, 66vw);
  max-height: 340px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.chat-media video {
  width: min(360px, 66vw);
}
.chat-media-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-weight: 800;
}
.chat-media-file:hover {
  border-color: var(--green);
  color: var(--green);
}
.quick-dock {
  position: relative;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: rgba(9,18,14,0.88);
  display: flex;
  align-items: center;
  gap: 8px;
}
html[data-theme="normal"] .quick-dock {
  background: rgba(255,255,255,0.90);
}
.quick-tab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--green);
  color: #041108;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 900;
}
.quick-tab:hover,
.quick-tab.active {
  background: var(--green-2);
  color: #fff;
}
.crm-tab {
  background: rgba(255,255,255,0.06);
  color: var(--soft);
}
.crm-tab.active,
.crm-tab:hover {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #041108;
}
.quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
}
.quick-floating {
  display: none;
  position: absolute;
  right: 18px;
  bottom: 52px;
  width: min(680px, calc(100vw - 430px));
  max-height: 230px;
  overflow: auto;
  z-index: 35;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.quick-floating.open {
  display: flex;
}
.quick-floating.open {
  flex-direction: column;
}
.quick-section {
  display: grid;
  gap: 8px;
  width: 100%;
}
.quick-section + .quick-section {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.quick-section-title {
  color: var(--soft);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.quick-empty {
  color: var(--muted);
  font-size: 12px;
}
.quick button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #07100c;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 12px;
  white-space: normal;
  text-align: left;
}
.quick button.chat-meta-template {
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(37,211,102,.15), rgba(43,168,255,.08));
  color: var(--text);
  display: grid;
  gap: 3px;
  align-content: start;
}
.quick button.chat-meta-template strong {
  font-size: 12px;
  line-height: 1.2;
}
.quick button.chat-meta-template span {
  color: var(--soft);
  font-size: 11px;
  line-height: 1.25;
}
html[data-theme="normal"] .quick button {
  background: #ffffff;
}
.quick button:hover {
  border-color: var(--green);
  color: var(--green);
}
.reply {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: rgba(9,18,14,0.92);
}
html[data-theme="normal"] .reply {
  background: rgba(255,255,255,0.94);
}
.reply-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px 0;
  border-top: 1px solid var(--line);
  background: rgba(9,18,14,0.92);
}
html[data-theme="normal"] .reply-tools {
  background: rgba(255,255,255,0.94);
}
.attach-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  font-size: 11px;
  font-weight: 900;
}
.attach-btn:hover,
.attach-btn.active {
  border-color: var(--green);
  color: #041108;
  background: var(--green);
}
.attachment-preview {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--soft);
  font-size: 12px;
  margin-left: auto;
}
.attachment-preview.show {
  display: flex;
}
.attachment-preview span {
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attachment-preview button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--rose);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 900;
}
.chat-crm {
  display: none;
  position: absolute;
  right: 18px;
  bottom: 104px;
  width: min(560px, calc(100vw - 430px));
  max-height: min(360px, 52vh);
  overflow: auto;
  z-index: 42;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.chat-crm.open {
  display: grid;
}
html[data-theme="normal"] .chat-crm {
  background: #ffffff;
}
.chat-crm-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.tag-list, .note-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.reply textarea {
  min-height: 46px;
  max-height: 120px;
  resize: none;
}
.workspace-overview .overview-card:nth-child(2)::after { background: rgba(248,184,78,0.17); }
.workspace-overview .overview-card:nth-child(3)::after { background: rgba(37,211,102,0.18); }
.workspace-overview .overview-card:nth-child(4)::after { background: rgba(255,107,107,0.13); }
.inbox-tools {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.inbox-filter {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.035);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
.inbox-filter.active {
  color: #041108;
  border-color: var(--green);
  background: var(--green);
}
.conversation {
  border-left: 3px solid transparent;
}
.conversation.active {
  border-left-color: var(--green);
}
.chat {
  background:
    radial-gradient(circle at 18px 18px, rgba(255,255,255,0.045) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 160px),
    var(--surface-2);
}
.floating-chat-search {
  position: sticky;
  top: 0;
  z-index: 22;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(9,18,14,0.78);
  backdrop-filter: blur(12px);
}
html[data-theme="normal"] .floating-chat-search {
  background: rgba(255,255,255,0.84);
}
.floating-chat-search input {
  min-height: 34px;
  border-radius: 999px;
}
.message-row.chat-search-hit .bubble {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(76,201,240,0.16), 0 10px 24px rgba(0,0,0,0.16);
}
.chat-head,
.reply {
  backdrop-filter: blur(12px);
}
.chat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: var(--soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  border-color: var(--green);
  color: var(--green);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
}
.human-toggle {
  width: auto;
  min-width: 76px;
  padding: 0 10px;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
}
.human-toggle.active {
  border-color: rgba(248,184,78,.55);
  background: rgba(248,184,78,.14);
  color: var(--amber);
}
.human-toggle .bot-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(37,211,102,.12);
}
.human-toggle.active .bot-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(248,184,78,.14);
}
.inbox-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.inbox-head-actions .human-toggle {
  min-height: 32px;
  border-radius: 999px;
}
.global-bot-toggle {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 850;
  transition: .16s ease;
}
.global-bot-toggle.bot-on {
  border-color: rgba(37,211,102,.36);
  background: rgba(37,211,102,.12);
  color: var(--green);
}
.global-bot-toggle.bot-off {
  border-color: rgba(255,107,107,.38);
  background: rgba(255,107,107,.10);
  color: var(--rose);
}
.global-bot-toggle .toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}
.messages {
  padding: 22px;
  gap: 8px;
}
.bubble {
  padding: 8px 10px 6px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.16);
}
.bubble.sent {
  background: #1f4a31;
  border-bottom-right-radius: 4px;
}
.bubble.received {
  border-bottom-left-radius: 4px;
}
.message-text {
  display: block;
}
.bubble time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}
.tick {
  letter-spacing: -2px;
  min-width: 16px;
  justify-content: flex-end;
}
.tick.read { color: #34b7f1; }
.tick.failed {
  color: var(--rose);
  letter-spacing: 0;
}
.status-caption {
  color: var(--muted);
  font-size: 10px;
}
.empty {
  height: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 30px;
}
.logs {
  height: 100%;
  overflow: auto;
  padding: 18px;
}
.table-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--panel-2);
  box-shadow: var(--shadow);
}
html[data-theme="normal"] .table-card {
  background: #ffffff;
}
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  text-align: left;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface);
}
html[data-theme="normal"] th {
  background: #eef6f1;
}
tr:hover td { background: rgba(255,255,255,0.025); }
.status-sent { color: var(--green); font-weight: 800; }
.status-delivered { color: var(--cyan); font-weight: 800; }
.status-read { color: var(--accent); font-weight: 800; }
.status-failed { color: var(--rose); font-weight: 800; }
.truncate {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: min(360px, calc(100vw - 40px));
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #07120d;
  box-shadow: var(--shadow);
  color: #f2fff7;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}
html[data-theme="normal"] .toast {
  background: #ffffff;
  color: #0b2116;
  border-color: rgba(14,48,32,0.24);
  box-shadow: 0 18px 44px rgba(10,60,30,0.18);
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast.success {
  border-color: var(--green);
  box-shadow: 0 18px 44px rgba(37,211,102,0.20);
}
.toast.error {
  border-color: var(--rose);
  color: #fff5f5;
  background: #251010;
  box-shadow: 0 18px 44px rgba(255,107,107,0.20);
}
html[data-theme="normal"] .toast.error {
  color: #7f1d1d;
  background: #fff5f5;
}
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(37,211,102,0.16), transparent 34%),
    radial-gradient(circle at 80% 30%, rgba(76,201,240,0.12), transparent 30%),
    var(--bg);
}
.login-card {
  width: min(430px, 100%);
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
}
html[data-theme="normal"] .login-card {
  background: #fff;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
}
.login-brand h1 {
  margin: 0;
  font-size: 22px;
}
.login-brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.login-field {
  display: block;
  margin-bottom: 14px;
}
.login-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.login-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 4px;
}
.login-alert {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #fff5f5;
  background: #251010;
  border: 1px solid var(--rose);
  font-size: 13px;
  font-weight: 800;
}
.login-alert.show {
  display: block;
}
.login-help {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
@media (max-width: 480px) {
  .login-screen {
    padding: 16px;
    justify-items: center;
    overflow-x: hidden;
  }
  .login-card {
    width: 100%;
    max-width: 100%;
    padding: 22px 18px;
    border-radius: 14px;
  }
  .login-brand {
    gap: 10px;
    align-items: flex-start;
  }
  .login-brand h1 {
    font-size: 20px;
    line-height: 1.15;
  }
}

/* Reassign menu: admin-only reassignment actions stay grouped instead of crowding the CRM toolbar. */
.shuffle-folder {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  z-index: 120;
}

.shuffle-folder summary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, var(--accent) 8%), var(--surface));
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.shuffle-folder summary::-webkit-details-marker {
  display: none;
}

.shuffle-folder summary::after {
  content: "v";
  font-size: 11px;
  color: var(--muted);
  transition: transform 160ms ease;
}

.shuffle-folder[open] summary {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
}

.shuffle-folder[open] {
  z-index: 10020;
}

.shuffle-folder[open] summary::after {
  transform: rotate(180deg);
}

.shuffle-folder-body {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 10030;
  width: min(420px, calc(100vw - 32px));
  padding: 14px;
  display: grid;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 12%, transparent), transparent 38%),
    color-mix(in srgb, var(--surface) 96%, white 4%);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(16px);
}

.shuffle-folder.compact .shuffle-folder-body {
  left: auto;
  right: 0;
}

.shuffleSourceCounsellor,
.reassignTargetCounsellor,
.reassignMode,
.reassignTransferNote {
  width: 100%;
  min-height: 40px;
  border-radius: 12px;
}

.shuffle-folder-body .btn {
  width: 100%;
  justify-content: center;
}

.reassign-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 2px;
}

.reassign-panel-head strong {
  font-size: 14px;
  color: var(--text);
}

.reassign-panel-head span {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.reassign-field {
  display: grid;
  gap: 6px;
  margin: 0;
}

.reassign-field span,
.reassign-divider {
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.reassign-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.reassign-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.calling-toolbar,
.calling-ops,
.super-crm-actions,
.lead-toolbar,
.saas-card:has(.shuffle-folder) {
  overflow: visible;
}

.calling-toolbar,
.super-crm-actions {
  position: relative;
  z-index: 140;
}

.crm-leads-grid,
.calling-chart-grid,
.calling-mini-kpis {
  position: relative;
  z-index: 1;
}

@media (max-width: 760px) {
  .shuffle-folder {
    width: 100%;
  }

  .shuffle-folder summary {
    width: 100%;
  }

  .shuffle-folder-body {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
    backdrop-filter: none;
  }
}
.top-search {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}
.top-search input {
  min-height: 38px;
  padding-left: 40px;
  border-radius: 10px;
}
.top-search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--muted);
}
.top-icon {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255,255,255,0.035);
  transition: .16s ease;
}
.top-icon:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(37,211,102,0.08);
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
  color: var(--text);
}
.user-profile strong { display: block; font-size: 12px; }
.user-profile span { display: block; color: var(--muted); font-size: 10px; }
.user-avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #041108;
  font-weight: 900;
}
@media (max-width: 1600px) {
  .topbar {
    gap: 10px;
    padding: 12px 14px;
    overflow: hidden;
  }
  .brand {
    min-width: 170px;
    flex-basis: 260px;
  }
  .brand p {
    display: none;
  }
  .stats {
    width: auto;
    grid-template-columns: repeat(4, minmax(72px, 92px));
    gap: 8px;
  }
  .stat {
    padding: 8px 10px;
  }
  .top-actions {
    gap: 8px;
  }
  .top-search {
    flex: 0 1 150px;
    max-width: 170px;
  }
  .layout-option {
    min-width: 58px;
  }
  .theme-option,
  .layout-option {
    padding: 0 8px;
  }
  .health span:last-child {
    display: none;
  }
}
.dashboard-shell {
  height: 100%;
  overflow: auto;
  padding: 18px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.page-kicker {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.page-title { margin: 3px 0 0; font-size: 22px; line-height: 1.2; }
.page-subtitle { margin-top: 4px; color: var(--muted); font-size: 13px; }
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.saas-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  transition: .16s ease;
}
html[data-theme="normal"] .saas-card { background: #fff; }
.saas-card:hover { border-color: rgba(37,211,102,0.35); }
.metric-card { position: relative; overflow: hidden; }
.metric-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(37,211,102,0.10);
}
.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.metric-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.04em;
}
.metric-note { margin-top: 4px; color: var(--muted); font-size: 12px; }
.lead-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 180px 160px;
  gap: 10px;
  margin-bottom: 12px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.pager-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pager .btn {
  min-height: 32px;
}
.chat-message-pager {
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(9,18,14,0.72);
}
html[data-theme="normal"] .chat-message-pager {
  background: rgba(255,255,255,0.82);
}
.modern-table-wrap {
  max-height: calc(100vh - 230px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
html[data-theme="normal"] .modern-table-wrap { background: #fff; }
.modern-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
}
.status-badge.hot,
.status-badge.high,
.status-badge.new {
  color: var(--green);
  border-color: rgba(37,211,102,0.35);
  background: rgba(37,211,102,0.08);
}
.status-badge.pending,
.status-badge.follow {
  color: var(--amber);
  border-color: rgba(248,184,78,0.35);
  background: rgba(248,184,78,0.08);
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.template-card-grid,
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.template-card,
.media-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--panel-2);
  transition: .16s ease;
}
html[data-theme="normal"] .template-card,
html[data-theme="normal"] .media-card { background: #fff; }
.template-card:hover,
.media-card:hover {
  border-color: var(--green);
  transform: translateY(-1px);
}
.template-card-body {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin-top: 8px;
  min-height: 54px;
}
.media-drop {
  border: 1px dashed rgba(37,211,102,0.45);
  border-radius: 12px;
  padding: 18px;
  background: rgba(37,211,102,0.06);
  text-align: center;
  color: var(--muted);
  margin-bottom: 12px;
}
.media-card-preview {
  height: 150px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-weight: 900;
}
.media-card-preview img,
.media-card-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.campaign-audience-sidebar {
  position: sticky;
  top: 70px;
  align-self: start;
  max-height: calc(100vh - 84px);
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }
@media (max-width: 1060px) {
  body { overflow: auto; }
  .app { min-height: 100vh; height: auto; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .topbar { grid-column: 1; grid-row: 1; }
  .tabs {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .tabs::before, .tabs::after { display: none; }
  .tab { width: auto; white-space: nowrap; }
  .main { grid-column: 1; grid-row: 3; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: space-between; }
  .top-search { width: 100%; max-width: none; }
  .stats { width: 100%; grid-template-columns: repeat(2, 1fr); }
  .sender-layout, .inbox-layout { grid-template-columns: 1fr; }
  .sidebar, .conv-sidebar { min-height: 460px; border-right: 0; border-bottom: 1px solid var(--line); }
  .grid, .analytics-grid, .workspace-overview, .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .lead-toolbar { grid-template-columns: 1fr 1fr; }
  .main, .view { overflow: visible; }
  .chat { min-height: 680px; }
}
@media (max-width: 640px) {
  .tabs { overflow-x: auto; padding-left: 12px; padding-right: 12px; }
  .content, .logs { padding: 12px; }
  .filter-grid, .template-grid, .actions, .mini-grid, .import-row, .meta-form-row, .meta-toolbar, .meta-selected .import-row, .mapper-row, .donut-wrap, .media-library, .workspace-overview, .dashboard-grid, .lead-toolbar { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 8px; }
  .user-profile strong, .user-profile span span { display: none; }
  .sender-layout, .inbox-layout { display: block; }
  .sidebar, .conv-sidebar { min-height: 390px; max-height: 58vh; }
  .lead-chips { justify-content: flex-start; }
  .chat-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .chat-actions { align-self: stretch; justify-content: flex-end; }
  .bubble { max-width: 92%; }
  .messages { padding: 14px; }
  .reply { padding: 10px; }
  .modern-table-wrap { border: 0; background: transparent; overflow: visible; }
  .modern-table,
  .modern-table tbody,
  .modern-table tr,
  .modern-table td {
    display: block;
    width: 100%;
  }
  .modern-table thead { display: none; }
  .modern-table tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .modern-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border: 0;
    white-space: normal;
  }
  .modern-table td::before {
    content: attr(data-label);
    flex: 0 0 92px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  .campaign-audience-sidebar {
    position: static;
    max-height: none;
  }
}
html[data-layout="mobile"] body {
  overflow: auto;
}
html[data-layout="mobile"] .app {
  min-height: 100vh;
  height: auto;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  padding-bottom: 76px;
}
html[data-layout="mobile"] .topbar {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: auto;
  padding: 10px 12px;
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 14px 30px rgba(0,0,0,0.22);
}
html[data-layout="mobile"] .brand-mark {
  width: 34px;
  height: 34px;
}
html[data-layout="mobile"] .brand h1 {
  font-size: 16px;
}
html[data-layout="mobile"] .brand p {
  display: none;
}
html[data-layout="mobile"] .stats {
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
html[data-layout="mobile"] .stat {
  padding: 7px 8px;
  border-radius: 10px;
}
html[data-layout="mobile"] .stat strong {
  font-size: 16px;
}
html[data-layout="mobile"] .stat span {
  font-size: 9px;
}
html[data-layout="mobile"] .top-actions {
  width: 100%;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: space-between;
}
html[data-layout="mobile"] .top-search {
  order: 5;
  width: 100%;
  max-width: none;
  flex-basis: 100%;
}
html[data-layout="mobile"] .user-profile strong,
html[data-layout="mobile"] .user-profile span span {
  display: none;
}
html[data-layout="mobile"] .theme-switch,
html[data-layout="mobile"] .layout-switch {
  flex: 1;
}
html[data-layout="mobile"] .theme-option,
html[data-layout="mobile"] .layout-option {
  flex: 1;
  padding: 0 8px;
}
html[data-layout="mobile"] .health {
  width: 100%;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
}
html[data-layout="mobile"] .tabs {
  grid-column: 1;
  grid-row: auto;
  position: fixed;
  z-index: 60;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(9,18,14,0.94);
  box-shadow: 0 18px 42px rgba(0,0,0,0.36);
  backdrop-filter: blur(14px);
}
html[data-theme="normal"][data-layout="mobile"] .tabs {
  background: rgba(255,255,255,0.96);
}
html[data-layout="mobile"] .tabs::before,
html[data-layout="mobile"] .tabs::after {
  display: none;
}
html[data-layout="mobile"] .side-logo,
html[data-layout="mobile"] .nav-section,
html[data-layout="mobile"] .nav-footnote {
  display: none;
}
html[data-layout="mobile"] .tab {
  min-width: 0;
  min-height: 54px;
  width: auto;
  padding: 5px 3px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border-radius: 13px;
  font-size: 10px;
  white-space: nowrap;
}
html[data-layout="mobile"] .tab.active::before {
  display: none;
}
html[data-layout="mobile"] .nav-ico {
  width: 25px;
  height: 25px;
  border-radius: 9px;
}
html[data-layout="mobile"] .nav-ico svg {
  width: 14px;
  height: 14px;
}
html[data-layout="mobile"] .badge {
  position: absolute;
  top: 3px;
  right: 5px;
  margin: 0;
}
html[data-layout="mobile"] .main {
  grid-column: 1;
  grid-row: 2;
  overflow: visible;
}
html[data-layout="mobile"] .view {
  overflow: visible;
}
html[data-layout="mobile"] .sender-layout,
html[data-layout="mobile"] .inbox-layout {
  display: block;
  height: auto;
}
html[data-layout="mobile"] .sidebar,
html[data-layout="mobile"] .conv-sidebar {
  min-height: 360px;
  max-height: 54vh;
  border-right: 0;
  border-bottom: 1px solid var(--line);
}
html[data-layout="mobile"] .content,
html[data-layout="mobile"] .logs {
  padding: 12px;
}
html[data-layout="mobile"] .workspace-overview,
html[data-layout="mobile"] .dashboard-grid,
html[data-layout="mobile"] .grid,
html[data-layout="mobile"] .analytics-grid,
html[data-layout="mobile"] .lead-toolbar,
html[data-layout="mobile"] .filter-grid,
html[data-layout="mobile"] .template-grid,
html[data-layout="mobile"] .actions,
html[data-layout="mobile"] .mini-grid,
html[data-layout="mobile"] .import-row,
html[data-layout="mobile"] .meta-form-row,
html[data-layout="mobile"] .meta-toolbar,
html[data-layout="mobile"] .meta-selected .import-row,
html[data-layout="mobile"] .mapper-row,
html[data-layout="mobile"] .donut-wrap,
html[data-layout="mobile"] .media-library {
  grid-template-columns: 1fr;
}
html[data-layout="mobile"] .billing-rate-grid {
  grid-template-columns: 1fr;
}
html[data-layout="mobile"] .mapper-controls {
  grid-template-columns: 1fr;
}
html[data-layout="mobile"] .card,
html[data-layout="mobile"] .overview-card,
html[data-layout="mobile"] .chart-card {
  border-radius: 14px;
}
html[data-layout="mobile"] .mode-tabs {
  grid-template-columns: 1fr;
}
html[data-layout="mobile"] .preview-phone {
  max-width: 340px;
}
html[data-layout="mobile"] .chat {
  min-height: calc(100vh - 220px);
}
html[data-layout="mobile"] #view-inbox .inbox-layout {
  height: calc(100vh - 86px);
  overflow: hidden;
}
html[data-layout="mobile"] #view-inbox .conv-sidebar {
  height: calc(100vh - 170px);
  max-height: none;
  min-height: 0;
}
html[data-layout="mobile"] #view-inbox .chat {
  display: none;
  height: calc(100vh - 86px);
  min-height: 0;
  grid-template-rows: auto auto 1fr auto auto auto;
}
html.chat-open[data-layout="mobile"] #view-inbox .conv-sidebar {
  display: none;
}
html.chat-open[data-layout="mobile"] #view-inbox .chat {
  display: grid;
}
html[data-layout="mobile"] .chat-back {
  display: grid;
}
html[data-layout="mobile"] .chat-head {
  align-items: center;
  flex-direction: row;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 8px 10px;
}
html[data-layout="mobile"] .lead-chips {
  display: none;
}
html[data-layout="mobile"] .chat-actions {
  align-self: center;
  justify-content: flex-end;
  margin-left: auto;
}
html[data-layout="mobile"] .messages {
  padding: 10px;
  background: #efeae2;
}
html[data-layout="mobile"] .bubble {
  max-width: 92%;
  border: 0;
  color: #111b21;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
html[data-layout="mobile"] .message-row {
  max-width: 96%;
}
html[data-layout="mobile"] .bubble.sent {
  background: #d9fdd3;
  color: #111b21;
}
html[data-layout="mobile"] .bubble.received {
  background: #fff;
  color: #111b21;
}
html[data-layout="mobile"] .bubble time {
  color: #667781;
}
html[data-layout="mobile"] .quick-floating {
  left: 10px;
  right: 10px;
  bottom: 52px;
  width: auto;
}
html[data-layout="mobile"] .chat-crm {
  left: 10px;
  right: 10px;
  bottom: 128px;
  width: auto;
  max-height: 44vh;
}
html[data-layout="mobile"] .chat-media img,
html[data-layout="mobile"] .chat-media video {
  max-width: 72vw;
}
html[data-layout="mobile"] .msg-avatar {
  width: 22px;
  height: 22px;
  font-size: 9px;
}
html[data-layout="mobile"] .reply {
  position: sticky;
  bottom: 76px;
  z-index: 25;
  padding: 10px;
}

/* SaaS polish layer: cleaner hierarchy, softer chrome, and stronger mobile ergonomics. */
body {
  letter-spacing: 0;
}
.topbar {
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
}
.card,
.overview-card,
.chart-card,
.table-card,
.camp-form {
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.12);
}
.btn,
.tab,
.conversation,
.student,
.media-tile,
.meta-pick {
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.btn:hover,
.media-tile:hover,
.meta-pick:hover {
  transform: translateY(-1px);
}
.page-subtitle,
.composer-hint,
.import-status {
  line-height: 1.55;
}
.conversation {
  min-height: 74px;
}
.conv-preview,
.student-meta,
.tiny {
  line-height: 1.45;
}
.bubble {
  font-size: 13px;
  line-height: 1.55;
}
.messages {
  scroll-behavior: smooth;
}
.campaign-media-library {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: 220px;
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .topbar {
    gap: 10px;
    padding: 10px;
  }
  .brand h1 {
    font-size: 15px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-shell,
  .content,
  .logs {
    padding: 10px;
  }
  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
  .page-title {
    font-size: 22px;
  }
  .page-subtitle {
    font-size: 13px;
  }
  .card,
  .overview-card,
  .chart-card {
    padding: 12px;
  }
  .campaign-media-library,
  .media-library {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .reply {
    grid-template-columns: 1fr auto;
    background: var(--surface);
  }
  .reply textarea {
    min-height: 48px;
    border-radius: 18px;
  }
  .reply .btn-primary {
    min-width: 62px;
    border-radius: 16px;
  }
}

/* 2026 SaaS redesign pass: drawer mobile nav, WhatsApp-like inbox, lighter chrome. */
:root {
  --saas-bg: #07110d;
  --saas-card: rgba(17, 28, 23, 0.92);
  --saas-card-2: rgba(22, 36, 29, 0.92);
  --saas-border: rgba(164, 214, 185, 0.16);
  --saas-border-strong: rgba(37, 211, 102, 0.34);
  --saas-shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
  --wa-chat-bg: #0b141a;
  --wa-received: #202c33;
  --wa-sent: #005c4b;
  --wa-text: #e9edef;
}
html[data-theme="normal"] {
  --saas-bg: #f6faf8;
  --saas-card: rgba(255, 255, 255, 0.96);
  --saas-card-2: rgba(250, 253, 251, 0.96);
  --saas-border: rgba(16, 64, 40, 0.12);
  --saas-border-strong: rgba(23, 182, 94, 0.36);
  --saas-shadow: 0 18px 40px rgba(19, 71, 45, 0.10);
  --wa-chat-bg: #efeae2;
  --wa-received: #ffffff;
  --wa-sent: #d9fdd3;
  --wa-text: #111b21;
}
body {
  background:
    radial-gradient(circle at 20% 0%, rgba(37, 211, 102, 0.08), transparent 32%),
    var(--saas-bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
.mobile-menu-btn,
.drawer-scrim,
.mobile-bottom-nav {
  display: none;
}
.topbar {
  background: rgba(10, 20, 15, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom-color: var(--saas-border);
}
html[data-theme="normal"] .topbar {
  background: rgba(255, 255, 255, 0.86);
}
.brand p,
.nav-footnote,
.page-subtitle,
.composer-hint {
  color: var(--muted);
}
.tabs {
  background: linear-gradient(180deg, rgba(19, 168, 107, 0.14), transparent 210px), rgba(8, 16, 12, 0.96);
  border-right-color: var(--saas-border);
}
html[data-theme="normal"] .tabs {
  background: linear-gradient(180deg, rgba(23, 182, 94, 0.12), transparent 220px), #ffffff;
}
.tab {
  min-height: 44px;
  border-radius: 12px;
  color: var(--soft);
}
.tab.active {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.22), rgba(76, 201, 240, 0.10));
  border-color: var(--saas-border-strong);
  box-shadow: 0 12px 28px rgba(37, 211, 102, 0.08);
}
.main {
  background: transparent;
}
.saas-card,
.card,
.overview-card,
.chart-card,
.table-card,
.camp-form,
.login-card {
  background: var(--saas-card);
  border-color: var(--saas-border);
  border-radius: 16px;
  box-shadow: var(--saas-shadow);
}
.stat,
.mini,
.metric-card,
.lead-toolbar,
.filters,
.selectbar {
  border-color: var(--saas-border);
}
.btn,
.top-icon,
.user-profile,
input,
select,
textarea {
  border-radius: 12px;
}
.btn-primary,
.inbox-filter.active {
  background: #16c66a;
  border-color: #16c66a;
  color: #041108;
}
.top-search {
  min-width: min(260px, 24vw);
}
.dashboard-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric-card::after,
.overview-card::after {
  opacity: 0.45;
}
.inbox-layout {
  grid-template-columns: 360px minmax(0, 1fr);
}
.conv-sidebar {
  background: var(--saas-card);
}
.inbox-tools {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.inbox-filter {
  border-radius: 999px;
  min-height: 34px;
}
.conversation {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  min-height: 78px;
  padding: 12px 16px;
  border-left-width: 4px;
  border-bottom-color: var(--saas-border);
}
.conversation:hover {
  background: rgba(37, 211, 102, 0.08);
}
.conversation.active {
  background: rgba(37, 211, 102, 0.14);
}
.conv-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}
.conv-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  max-height: 40px;
}
.hot-dot {
  display: inline-flex;
  min-height: 18px;
  align-items: center;
  border-radius: 999px;
  padding: 0 7px;
  background: rgba(248, 184, 78, 0.15);
  color: var(--amber);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}
.chat {
  background: transparent;
}
.chat-head {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  background: var(--saas-card);
  border-bottom-color: var(--saas-border);
}
.messages {
  background:
    radial-gradient(circle at 16px 16px, rgba(255,255,255,0.035) 1px, transparent 1px) 0 0/22px 22px,
    var(--wa-chat-bg);
  padding: 18px;
}
.message-row {
  gap: 8px;
}
.message-row.sent {
  justify-content: flex-end;
}
.message-row.grouped .msg-avatar {
  opacity: 0;
}
.msg-avatar {
  box-shadow: none;
}
.bubble {
  max-width: min(680px, 72%);
  border: 0;
  border-radius: 14px;
  color: var(--wa-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}
.bubble.sent {
  background: var(--wa-sent);
  color: var(--wa-text);
  border-bottom-right-radius: 4px;
}
.bubble.received {
  background: var(--wa-received);
  color: var(--wa-text);
  border-bottom-left-radius: 4px;
}
.bubble time {
  color: rgba(233, 237, 239, 0.68);
}
html[data-theme="normal"] .bubble time {
  color: #667781;
}
.reply {
  position: sticky;
  bottom: 0;
  z-index: 18;
  background: var(--saas-card);
  border-top-color: var(--saas-border);
  grid-template-columns: minmax(0, 1fr) 84px;
  padding: 12px 16px;
}
.reply textarea {
  min-height: 52px;
  border-radius: 18px;
}
.reply .btn-primary {
  border-radius: 18px;
}
.lead-toolbar {
  background: var(--saas-card);
  border-radius: 16px;
  box-shadow: var(--saas-shadow);
}
.modern-table-wrap {
  overflow-x: auto;
}
.media-dropzone,
.campaign-media-library,
.media-library {
  border-radius: 16px;
}
.skeleton-card,
.skeleton-line,
.skeleton-avatar {
  position: relative;
  overflow: hidden;
}
.skeleton-card::after,
.skeleton-line::after,
.skeleton-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  animation: crmShimmer 1.35s infinite;
}
@keyframes crmShimmer {
  100% { transform: translateX(100%); }
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .inbox-layout {
    grid-template-columns: 330px minmax(0, 1fr);
  }
  .top-search {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
    font-size: 14px;
  }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    padding-bottom: 68px;
  }
  .mobile-menu-btn {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--saas-border);
    border-radius: 12px;
    background: var(--saas-card-2);
    color: var(--text);
    flex: 0 0 auto;
  }
  .mobile-menu-btn svg {
    width: 20px;
    height: 20px;
  }
  .topbar {
    grid-column: 1;
    position: sticky;
    top: 0;
    z-index: 70;
    min-height: 62px;
    padding: 10px 12px;
  }
  .brand {
    min-width: 0;
    flex: 1 1 auto;
  }
  .brand-mark {
    width: 34px;
    height: 34px;
  }
  .brand p,
  .stats,
  .layout-switch,
  .health,
  .user-profile span:not(.user-avatar-small),
  .top-actions .top-icon:not(#notificationBtn) {
    display: none;
  }
  .top-actions {
    flex: 0 0 auto;
    gap: 6px;
  }
  .tabs {
    position: fixed;
    z-index: 90;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 318px);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    padding: 18px 14px 90px;
    overflow-y: auto;
  }
  html.drawer-open .tabs {
    transform: translateX(0);
  }
  .drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.42);
    border: 0;
  }
  html.drawer-open .drawer-scrim {
    display: block;
  }
  .mobile-bottom-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 75;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--saas-border);
    border-radius: 20px;
    background: rgba(8, 18, 13, 0.92);
    box-shadow: 0 18px 42px rgba(0,0,0,0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  html[data-theme="normal"] .mobile-bottom-nav {
    background: rgba(255,255,255,0.94);
  }
  .mobile-bottom-nav button {
    position: relative;
    min-width: 0;
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }
  .mobile-bottom-nav button.active {
    background: var(--green);
    color: #041108;
  }
  .mobile-bottom-nav strong {
    position: absolute;
    top: 2px;
    right: 5px;
    min-width: 17px;
    height: 17px;
    border-radius: 999px;
    background: var(--rose);
    color: #fff;
    font-size: 10px;
    line-height: 17px;
  }
  .main {
    grid-column: 1;
    grid-row: 2;
    overflow: auto;
  }
  .dashboard-grid,
  .analytics-grid,
  .grid,
  .workspace-overview {
    grid-template-columns: 1fr;
  }
  #view-inbox .inbox-layout {
    height: calc(100vh - 130px);
  }
  #view-inbox .conv-sidebar {
    height: calc(100vh - 130px);
    background: var(--saas-card);
  }
  html.chat-open[data-layout="mobile"] .mobile-bottom-nav {
    display: none;
  }
  html.chat-open[data-layout="mobile"] .app {
    padding-bottom: 0;
  }
  html[data-layout="mobile"] #view-inbox .chat {
    height: calc(100vh - 62px);
  }
  .inbox-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .conversation {
    min-height: 76px;
    padding: 11px 12px;
  }
  .chat-head {
    min-height: 58px;
    padding: 8px 10px;
  }
  .floating-chat-search,
  .chat-message-pager,
  .reply-tools {
    display: none;
  }
  .messages {
    padding: 12px 10px;
  }
  .bubble {
    max-width: 86%;
    font-size: 14px;
  }
  .reply {
    bottom: 0;
    padding: 8px;
    grid-template-columns: minmax(0, 1fr) 62px;
  }
  .modern-table,
  .modern-table tbody,
  .modern-table tr,
  .modern-table td {
    display: block;
    width: 100%;
  }
  .modern-table thead {
    display: none;
  }
  .modern-table tr {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--saas-border);
    border-radius: 16px;
    background: var(--saas-card);
    box-shadow: var(--saas-shadow);
  }
  .modern-table td {
    border: 0;
    padding: 5px 0;
  }
}

/* Hotfix pass: prevent desktop topbar overlap, clean inbox footer, improve mobile. */
.topbar {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(360px, auto) minmax(360px, 1fr);
  align-items: center;
  gap: 10px;
}
.mobile-menu-btn {
  grid-column: auto;
}
.brand {
  min-width: 0;
  flex: none;
}
.brand h1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.stats {
  width: auto;
  grid-template-columns: repeat(4, minmax(80px, 92px));
  justify-content: start;
  gap: 7px;
}
.stat {
  min-width: 0;
  overflow: hidden;
  padding: 7px 9px;
  border-radius: 12px;
}
.stat strong { font-size: 17px; line-height: 1; }
.stat span { font-size: 10px; white-space: nowrap; }
.top-actions {
  flex: none;
  min-width: 0;
  justify-content: end;
  display: flex;
  align-items: center;
}
.top-search {
  flex: 0 1 320px;
  width: min(320px, 24vw);
  min-width: 240px;
  max-width: 320px;
}
.top-search input {
  width: 100%;
  min-width: 0;
}
.inbox-layout {
  grid-template-columns: 330px minmax(0, 1fr);
}
.conv-sidebar {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.inbox-tools {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.inbox-tools::-webkit-scrollbar {
  display: none;
}
.inbox-filter {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 0 10px;
  line-height: 1.05;
}
#inboxPager {
  min-height: 44px;
  padding: 7px 10px;
  border-top: 1px solid var(--saas-border);
  background: var(--saas-card);
}
#inboxPager > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#inboxPager .pager-actions span {
  display: none;
}
#inboxPager .btn {
  min-height: 30px;
  padding: 0 10px;
}
.conversation {
  padding: 11px 14px;
}
.conv-right {
  min-width: 46px;
}

@media (max-width: 1500px) {
  .topbar {
    grid-template-columns: minmax(195px, 220px) minmax(320px, auto) minmax(300px, 1fr);
  }
  .stats {
    grid-template-columns: repeat(4, minmax(72px, 82px));
    gap: 6px;
  }
  .top-search {
    flex-basis: 250px;
    width: 250px;
    min-width: 210px;
    max-width: 250px;
  }
  .user-profile {
    max-width: 104px;
  }
  .brand h1 { max-width: 165px; font-size: 16px; }
  .stat strong { font-size: 16px; }
}

@media (max-width: 1280px) {
  .topbar {
    grid-template-columns: minmax(185px, 210px) minmax(280px, auto) minmax(170px, max-content);
  }
  .stats {
    grid-template-columns: repeat(4, 68px);
  }
  .stat {
    padding: 7px 8px;
  }
  .stat span {
    font-size: 10px;
  }
  .top-search {
    display: none;
  }
  .user-profile { max-width: 42px; padding-right: 6px; }
  .user-profile > span:not(.user-avatar-small) { display: none; }
}

@media (max-width: 760px) {
  .topbar {
    display: flex;
    align-items: center;
    min-height: 58px;
  }
  .brand h1 {
    max-width: 190px;
    font-size: 15px;
  }
  .main {
    height: calc(100vh - 126px);
  }
  #view-inbox .inbox-layout {
    height: calc(100vh - 126px);
  }
  #view-inbox .conv-sidebar {
    height: calc(100vh - 126px);
  }
  html.chat-open[data-layout="mobile"] .main,
  html.chat-open[data-layout="mobile"] #view-inbox .inbox-layout,
  html.chat-open[data-layout="mobile"] #view-inbox .chat {
    height: calc(100vh - 58px);
  }
  html[data-layout="mobile"] #view-inbox .chat {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .side-head {
    padding: 12px;
  }
  .filters {
    padding: 10px 12px;
  }
  .inbox-tools {
    gap: 7px;
  }
  .inbox-filter {
    min-height: 36px;
    min-width: 74px;
    font-size: 11px;
  }
  .conversation {
    grid-template-columns: 42px minmax(0, 1fr) 48px;
    min-height: 74px;
    padding: 10px 12px;
  }
  .avatar {
    width: 38px;
    height: 38px;
  }
  #inboxPager {
    min-height: 38px;
    padding: 5px 10px;
    font-size: 11px;
  }
  html[data-layout="mobile"] .chat-head {
    position: sticky;
    top: 0;
    min-height: 56px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
  }
  html[data-layout="mobile"] .messages {
    min-height: 0;
    padding: 10px 8px;
  }
  html[data-layout="mobile"] .reply {
    position: sticky;
    bottom: 0;
    padding: 8px;
    border-top: 1px solid rgba(0,0,0,0.08);
  }
  html[data-layout="mobile"] .reply textarea {
    min-height: 44px;
    max-height: 96px;
  }
}

/* Mobile drawer conflict fix: override older mobile bottom-nav sidebar rules. */
@media (max-width: 760px) {
  html[data-layout="mobile"] .tabs {
    position: fixed;
    z-index: 90;
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: min(82vw, 312px);
    height: 100vh;
    max-height: none;
    display: flex;
    grid-template-columns: none;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 16px 14px 92px;
    border: 0;
    border-right: 1px solid var(--saas-border);
    border-radius: 0 22px 22px 0;
    background:
      linear-gradient(180deg, rgba(37,211,102,0.16), transparent 220px),
      var(--surface);
    box-shadow: 18px 0 50px rgba(0,0,0,0.30);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-106%);
    transition: transform 0.22s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
  html[data-theme="normal"][data-layout="mobile"] .tabs {
    background:
      linear-gradient(180deg, rgba(23,182,94,0.16), transparent 220px),
      #ffffff;
  }
  html.drawer-open[data-layout="mobile"] .tabs {
    transform: translateX(0);
  }
  html[data-layout="mobile"] .tabs::before,
  html[data-layout="mobile"] .tabs::after {
    content: none;
    display: none;
  }
  html[data-layout="mobile"] .side-logo {
    display: flex;
    width: auto;
    min-height: 58px;
    height: auto;
    margin: 0 2px 12px;
    padding: 8px 8px 14px;
    border-bottom: 1px solid var(--saas-border);
  }
  html[data-layout="mobile"] .side-logo-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    flex: 0 0 auto;
  }
  html[data-layout="mobile"] .side-logo strong,
  html[data-layout="mobile"] .side-logo span {
    display: block;
  }
  html[data-layout="mobile"] .nav-section {
    display: block;
    margin: 12px 8px 6px;
    font-size: 10px;
  }
  html[data-layout="mobile"] .tabs .tab {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 12px;
    border-radius: 13px;
    font-size: 14px;
    text-align: left;
    white-space: nowrap;
  }
  html[data-layout="mobile"] .tabs .tab > span:not(.nav-ico):not(.badge) {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html[data-layout="mobile"] .tabs .nav-ico {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex: 0 0 34px;
  }
  html[data-layout="mobile"] .tabs .nav-ico svg {
    width: 17px;
    height: 17px;
  }
  html[data-layout="mobile"] .tabs .badge {
    position: static;
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    font-size: 11px;
  }
  html[data-layout="mobile"] .nav-footnote {
    display: block;
    margin: 14px 2px 0;
    padding: 12px;
    border-radius: 14px;
  }
  html[data-layout="mobile"] .drawer-scrim {
    display: none;
  }
  html.drawer-open[data-layout="mobile"] .drawer-scrim {
    display: block;
  }
}

/* Forced mobile mode should look mobile even inside a wider desktop browser viewport. */
html[data-layout="mobile"] body {
  overflow: hidden;
}
html[data-layout="mobile"] .app {
  grid-template-columns: 1fr;
  grid-template-rows: 58px minmax(0, 1fr);
  height: 100vh;
  padding-bottom: 60px;
}
html[data-layout="mobile"] .topbar {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 70;
  min-height: 58px;
  height: 58px;
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  overflow: hidden;
}
html[data-layout="mobile"] .mobile-menu-btn {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}
html[data-layout="mobile"] .brand {
  flex: 1 1 0;
  min-width: 0;
  gap: 7px;
}
html[data-layout="mobile"] .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  flex: 0 0 34px;
}
html[data-layout="mobile"] .brand h1 {
  max-width: calc(100vw - 192px);
  font-size: 14px;
  line-height: 1.15;
}
html[data-layout="mobile"] .brand p,
html[data-layout="mobile"] .stats,
html[data-layout="mobile"] .top-search,
html[data-layout="mobile"] .health,
html[data-layout="mobile"] #logoutBtn,
html[data-layout="mobile"] .user-profile > span:not(.user-avatar-small) {
  display: none !important;
}
html[data-layout="mobile"] .top-actions {
  grid-column: 3;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}
html[data-layout="mobile"] .top-icon,
html[data-layout="mobile"] .user-profile {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
}
html[data-layout="mobile"] .user-avatar-small {
  width: 28px;
  height: 28px;
}
html[data-layout="mobile"] .main {
  grid-column: 1;
  grid-row: 2;
  height: calc(100vh - 118px);
  overflow: hidden;
}
html[data-layout="mobile"] #view-inbox,
html[data-layout="mobile"] #view-inbox .inbox-layout {
  height: 100%;
  min-height: 0;
}
html[data-layout="mobile"] #view-inbox .inbox-layout {
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}
html[data-layout="mobile"] #view-inbox .conv-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  border-right: 0;
  border-bottom: 0;
}
html[data-layout="mobile"] #view-inbox .chat {
  display: none;
  height: 100%;
  min-height: 0;
}
html.chat-open[data-layout="mobile"] #view-inbox .conv-sidebar {
  display: none;
}
html.chat-open[data-layout="mobile"] #view-inbox .chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
html[data-layout="mobile"] #view-inbox .side-head {
  min-height: 56px;
  padding: 10px 14px;
}
html[data-layout="mobile"] #view-inbox .filters {
  padding: 10px 14px 8px;
}
html[data-layout="mobile"] #conversationSearch {
  min-height: 42px;
  font-size: 14px;
}
html[data-layout="mobile"] .inbox-tools {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}
html[data-layout="mobile"] .inbox-filter {
  flex: 0 0 auto;
  min-width: 78px;
  min-height: 36px;
}
html[data-layout="mobile"] #conversationList {
  min-height: 0;
  overflow: auto;
  padding-bottom: 6px;
}
html[data-layout="mobile"] #inboxPager {
  display: none;
}
html[data-layout="mobile"] .conversation {
  grid-template-columns: 42px minmax(0, 1fr) 48px;
  min-height: 72px;
  padding: 10px 14px;
}
html[data-layout="mobile"] .conv-preview {
  -webkit-line-clamp: 1;
  max-height: 20px;
}
html[data-layout="mobile"] .mobile-bottom-nav {
  left: 10px;
  right: 10px;
  bottom: 8px;
  min-height: 52px;
  padding: 5px;
  border-radius: 18px;
}
html[data-layout="mobile"] .mobile-bottom-nav button {
  min-height: 42px;
  border-radius: 13px;
  font-size: 11px;
}
html.chat-open[data-layout="mobile"] .mobile-bottom-nav {
  display: none;
}
html.chat-open[data-layout="mobile"] .app {
  padding-bottom: 0;
}
html.chat-open[data-layout="mobile"] .main {
  height: calc(100vh - 58px);
}

/* Premium SaaS visual system pass - frontend only, backend-safe. */
:root {
  --rk-bg: #0b1110;
  --rk-bg-2: #101715;
  --rk-card: rgba(18, 26, 23, 0.92);
  --rk-card-solid: #121a17;
  --rk-rail: #0d1512;
  --rk-border: rgba(219, 236, 226, 0.105);
  --rk-border-strong: rgba(39, 197, 112, 0.22);
  --rk-text: #edf4ef;
  --rk-muted: #9bad9f;
  --rk-faint: #708277;
  --rk-accent: #22c76f;
  --rk-accent-2: #0f9f6e;
  --rk-danger: #ef5f5f;
  --rk-warning: #dca64d;
  --rk-shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
  --rk-soft-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}
html[data-theme="normal"] {
  --rk-bg: #f7faf8;
  --rk-bg-2: #eef5f1;
  --rk-card: rgba(255, 255, 255, 0.94);
  --rk-card-solid: #ffffff;
  --rk-rail: #f3faf6;
  --rk-border: rgba(20, 70, 45, 0.11);
  --rk-border-strong: rgba(23, 182, 94, 0.22);
  --rk-text: #101f18;
  --rk-muted: #5d7066;
  --rk-faint: #788a80;
  --rk-shadow: 0 22px 55px rgba(22, 72, 45, 0.12);
  --rk-soft-shadow: 0 14px 32px rgba(22, 72, 45, 0.09);
}
body {
  font-family: "DM Sans", Inter, Arial, sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(34, 199, 111, 0.12), transparent 28rem),
    linear-gradient(135deg, var(--rk-bg), var(--rk-bg-2));
  color: var(--rk-text);
}
button,
.btn,
.tab,
.conversation,
.top-icon,
.user-profile,
.theme-option,
.layout-option {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(34, 199, 111, 0.76);
  outline-offset: 2px;
}
.app {
  background: transparent;
}
.topbar {
  min-height: 72px;
  padding: 12px 18px;
  gap: 14px;
  background: rgba(14, 20, 18, 0.86);
  border-bottom: 1px solid var(--rk-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(16px);
}
html[data-theme="normal"] .topbar {
  background: rgba(255, 255, 255, 0.88);
}
.brand {
  flex: 0 1 280px;
  min-width: 210px;
}
.brand-mark,
.side-logo-mark,
.nav-ico,
.user-avatar-small,
.avatar {
  border-radius: 12px;
  background: linear-gradient(135deg, var(--rk-accent), #34d2c5);
  box-shadow: 0 10px 22px rgba(34, 199, 111, 0.16);
}
.brand h1 {
  font-size: 20px;
  line-height: 1.05;
  font-weight: 800;
}
.brand p {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--rk-muted);
}
.stats {
  width: auto;
  flex: 0 0 auto;
  grid-template-columns: repeat(4, minmax(96px, 112px));
  gap: 8px;
}
.stat {
  min-width: 0;
  padding: 8px 11px;
  border-color: var(--rk-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.045);
}
html[data-theme="normal"] .stat {
  background: rgba(255, 255, 255, 0.78);
}
.stat strong {
  font-size: 21px;
  line-height: 1;
  font-weight: 850;
}
.stat span {
  font-size: 11px;
  color: var(--rk-muted);
}
.top-actions {
  flex: 1 1 380px;
  gap: 8px;
}
.top-search {
  flex: 1 1 300px;
  min-width: 240px;
  max-width: 440px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--rk-border);
  background: rgba(255,255,255,0.055);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
html[data-theme="normal"] .top-search {
  background: #fff;
}
.top-search input {
  min-width: 0;
  font-size: 14px;
}
.top-icon,
.user-profile,
.theme-switch,
.layout-switch {
  flex: 0 0 auto;
}
.top-icon,
.user-profile {
  height: 44px;
  border-radius: 14px;
  border-color: var(--rk-border);
  background: rgba(255,255,255,0.052);
}
html[data-theme="normal"] .top-icon,
html[data-theme="normal"] .user-profile {
  background: #fff;
}
.user-profile {
  min-width: 128px;
  max-width: 172px;
  overflow: hidden;
}
.user-profile strong,
.user-profile span span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.theme-switch,
.layout-switch {
  min-height: 44px;
  border-radius: 14px;
  border-color: var(--rk-border);
  background: rgba(255,255,255,0.045);
}
.layout-option,
.theme-option {
  min-width: 38px;
  min-height: 36px;
  padding: 0 9px;
  border-radius: 11px;
}
.layout-option svg,
.theme-option svg {
  width: 17px;
  height: 17px;
}
.layout-option.active,
.theme-option.active {
  background: var(--rk-accent);
  box-shadow: 0 10px 18px rgba(34,199,111,0.18);
}
.health {
  max-width: 18px;
  overflow: hidden;
}
.health #healthText {
  display: none;
}
.tabs {
  background:
    radial-gradient(circle at 50% 0%, rgba(34, 199, 111, 0.12), transparent 18rem),
    var(--rk-rail);
  border-right: 1px solid var(--rk-border);
}
.side-logo {
  border-bottom-color: var(--rk-border);
}
.nav-section {
  letter-spacing: .14em;
  color: var(--rk-faint);
}
.tab {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--rk-muted);
  font-weight: 800;
}
.tab:hover {
  background: rgba(255,255,255,0.055);
  color: var(--rk-text);
}
.tab.active {
  border-color: var(--rk-border-strong);
  background: linear-gradient(135deg, rgba(34,199,111,0.18), rgba(52,210,197,0.08));
  color: var(--rk-text);
  box-shadow: 0 14px 34px rgba(34,199,111,0.12);
}
.main {
  background:
    radial-gradient(circle at 85% 0%, rgba(34, 199, 111, 0.08), transparent 24rem),
    var(--rk-bg-2);
}
.dashboard-shell,
.super-crm-panel,
.card,
.analytics-card,
.settings-card,
.composer-card,
.crm-lead-card,
.pipeline-column,
.followup-card,
.media-card {
  border: 1px solid var(--rk-border);
  border-radius: 18px;
  background: var(--rk-card);
  box-shadow: var(--rk-soft-shadow);
}
.super-kpi,
.stat-card,
.kpi-card {
  border: 1px solid var(--rk-border);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02)),
    var(--rk-card-solid);
  box-shadow: var(--rk-soft-shadow);
}
.btn {
  border-radius: 12px;
  font-weight: 800;
  box-shadow: none;
}
.btn:hover,
.top-icon:hover,
.user-profile:hover,
.tab:hover,
.conversation:hover {
  transform: translateY(-1px);
}
.btn-primary,
.btn-wa,
.inbox-filter.active,
.mobile-bottom-nav button.active {
  background: linear-gradient(135deg, var(--rk-accent), var(--rk-accent-2));
  color: #06100b;
  border-color: transparent;
}
.conversation {
  grid-template-columns: 20px 40px minmax(0, 1fr) auto;
  min-height: 78px;
  padding: 11px 14px;
  gap: 10px;
  border-bottom-color: var(--rk-border);
}
.conversation strong {
  font-size: 14px;
  line-height: 1.2;
  font-weight: 850;
}
.conv-preview {
  color: var(--rk-muted);
  font-size: 12px;
  line-height: 1.35;
  max-height: 33px;
}
.conv-right {
  font-size: 10.5px;
  color: var(--rk-faint);
}
.conversation.active {
  border-left: 3px solid var(--rk-accent);
  background: linear-gradient(90deg, rgba(34,199,111,0.16), rgba(34,199,111,0.045));
}
.unread,
.badge {
  background: linear-gradient(135deg, var(--rk-accent), #2cd88c);
  color: #06100b;
}
.inbox-bulk-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) repeat(3, auto);
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 48px;
  overflow: hidden;
  border-color: var(--rk-border);
  background: rgba(255,255,255,0.045);
}
.inbox-bulk-count {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-bulk-bar .btn {
  min-height: 32px;
  padding: 7px 10px;
  white-space: nowrap;
}
.conv-sidebar,
.chat,
.chat-head,
.reply {
  border-color: var(--rk-border);
}
.chat {
  background:
    radial-gradient(circle at 28px 28px, rgba(255,255,255,0.035) 1.2px, transparent 1.2px) 0 0/22px 22px,
    linear-gradient(180deg, rgba(34,199,111,0.055), transparent 220px),
    #111815;
}
html[data-theme="normal"] .chat {
  background:
    radial-gradient(circle at 28px 28px, rgba(15,70,44,0.055) 1.2px, transparent 1.2px) 0 0/22px 22px,
    linear-gradient(180deg, rgba(34,199,111,0.055), transparent 220px),
    #f0f4ef;
}
.chat-head {
  min-height: 72px;
  background: rgba(17,24,21,0.9);
  backdrop-filter: blur(14px);
}
html[data-theme="normal"] .chat-head {
  background: rgba(255,255,255,0.92);
}
.lead-chips .chip,
.chip {
  border-color: var(--rk-border);
  background: rgba(255,255,255,0.06);
}
.bubble {
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.14);
  line-height: 1.48;
}
.message-row.sent .bubble,
.bubble.sent {
  background: #d8ffd1;
  color: #07150d;
}
.message-row.received .bubble,
.bubble.received {
  background: rgba(255,255,255,0.96);
  color: #101916;
}
.reply {
  gap: 10px;
  padding: 12px 16px;
  background: rgba(10, 16, 14, 0.9);
  backdrop-filter: blur(16px);
}
html[data-theme="normal"] .reply {
  background: rgba(255,255,255,0.94);
}
.reply textarea,
.reply input,
textarea,
input,
select {
  border-radius: 14px;
  border-color: var(--rk-border);
}
.reply textarea:focus,
.reply input:focus,
textarea:focus,
input:focus,
select:focus {
  border-color: rgba(34,199,111,0.72);
  box-shadow: 0 0 0 4px rgba(34,199,111,0.12);
}
.modern-table,
table {
  border-color: var(--rk-border);
}
.modern-table th,
table th {
  color: var(--rk-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 11px;
}
.modern-table td,
table td {
  border-color: var(--rk-border);
}
@media (max-width: 1580px) {
  .stats {
    grid-template-columns: repeat(4, minmax(82px, 96px));
  }
  .stat {
    padding: 7px 9px;
  }
  .stat strong {
    font-size: 18px;
  }
  .top-search {
    min-width: 220px;
    max-width: 340px;
  }
}
@media (max-width: 1360px) {
  .brand {
    flex-basis: 230px;
    min-width: 190px;
  }
  .brand p,
  .stat span {
    display: none;
  }
  .stats {
    grid-template-columns: repeat(4, 66px);
  }
  .stat strong {
    text-align: center;
  }
  .user-profile {
    min-width: 44px;
    width: 44px;
  }
  .user-profile > span:not(.user-avatar-small) {
    display: none;
  }
}
@media (max-width: 1180px) {
  .stats {
    display: none;
  }
  .top-actions {
    flex: 1 1 auto;
  }
  .top-search {
    max-width: none;
  }
}
@media (max-width: 760px) {
  .topbar {
    box-shadow: 0 8px 24px rgba(0,0,0,0.16);
  }
  html[data-layout="mobile"] .brand h1 {
    font-size: 16px;
  }
  html[data-layout="mobile"] .brand p,
  html[data-layout="mobile"] .stats,
  html[data-layout="mobile"] .top-search,
  html[data-layout="mobile"] .health,
  html[data-layout="mobile"] #logoutBtn {
    display: none;
  }
  html[data-layout="mobile"] .top-actions {
    gap: 6px;
  }
  html[data-layout="mobile"] .theme-switch,
  html[data-layout="mobile"] .layout-switch {
    min-height: 34px;
    padding: 2px;
    border-radius: 11px;
  }
  html[data-layout="mobile"] .layout-option,
  html[data-layout="mobile"] .theme-option {
    min-width: 31px;
    min-height: 30px;
    padding: 0 6px;
  }
  html[data-layout="mobile"] .conversation {
    grid-template-columns: 18px 38px minmax(0, 1fr) auto;
    min-height: 68px;
    padding: 9px 12px;
  }
  html[data-layout="mobile"] .inbox-bulk-bar {
    grid-template-columns: auto minmax(0, 1fr);
  }
  html[data-layout="mobile"] .inbox-bulk-bar .btn {
    min-height: 30px;
    padding: 6px 8px;
    font-size: 11px;
  }
  html[data-layout="mobile"] .chat-head {
    min-height: 58px;
    padding: 8px 12px;
  }
  html[data-layout="mobile"] .reply {
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }
  html[data-layout="mobile"] .reply textarea,
  html[data-layout="mobile"] .reply input {
    min-height: 44px;
  }
  html[data-layout="mobile"] .mobile-bottom-nav {
    border-color: var(--rk-border);
    background: rgba(10,16,14,0.92);
    box-shadow: 0 18px 42px rgba(0,0,0,0.26);
    backdrop-filter: blur(18px);
  }
  html[data-theme="normal"][data-layout="mobile"] .mobile-bottom-nav {
    background: rgba(255,255,255,0.93);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Final compact premium mobile/inbox polish. */
:root {
  --native-dark: #101614;
  --native-dark-2: #151d1a;
  --native-dark-3: #1b2521;
  --native-line: rgba(210, 232, 220, 0.10);
  --native-text: #edf5ef;
  --native-muted: #a4b8ad;
  --native-subtle: #7f9288;
}
html[data-theme="normal"] {
  --native-dark: #f7faf8;
  --native-dark-2: #ffffff;
  --native-dark-3: #edf5f0;
  --native-line: rgba(15, 65, 39, 0.10);
  --native-text: #102118;
  --native-muted: #546b5f;
  --native-subtle: #6f8278;
}
.topbar,
.tabs,
.conv-sidebar,
.chat-head,
.reply,
#inboxPager,
.mobile-bottom-nav {
  transition: background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.conversation,
.inbox-filter,
.btn,
.tab,
.top-icon,
.user-profile {
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.conversation:active,
.mobile-bottom-nav button:active,
.inbox-filter:active {
  transform: scale(0.985);
}
html[data-layout="mobile"] body {
  background: var(--native-dark);
  color: var(--native-text);
}
html[data-layout="mobile"] .app {
  grid-template-rows: 50px minmax(0, 1fr);
  padding-bottom: 52px;
}
html[data-layout="mobile"] .topbar {
  height: 50px;
  min-height: 50px;
  padding: 6px 10px;
  background: rgba(16, 22, 20, 0.96);
  border-bottom: 1px solid var(--native-line);
  box-shadow: 0 8px 22px rgba(0,0,0,0.16);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
}
html[data-theme="normal"][data-layout="mobile"] .topbar {
  background: rgba(255,255,255,0.96);
}
html[data-layout="mobile"] .mobile-menu-btn,
html[data-layout="mobile"] .top-icon,
html[data-layout="mobile"] .user-profile {
  width: 34px;
  height: 34px;
  min-height: 34px;
  flex-basis: 34px;
  border-radius: 10px;
  border-color: transparent;
  background: rgba(255,255,255,0.045);
  box-shadow: none;
}
html[data-layout="mobile"] .mobile-menu-btn {
  grid-column: 1;
}
html[data-layout="mobile"] .brand {
  gap: 8px;
  grid-column: 2;
  min-width: 0;
}
html[data-layout="mobile"] .brand-mark {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  border-radius: 9px;
  font-size: 12px;
  box-shadow: 0 0 0 3px rgba(37,211,102,0.08);
}
html[data-layout="mobile"] .brand h1 {
  max-width: 100%;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}
html[data-layout="mobile"] .user-avatar-small {
  width: 25px;
  height: 25px;
  font-size: 11px;
  border-radius: 8px;
}
html[data-layout="mobile"] .main {
  height: calc(100vh - 102px);
  background: var(--native-dark);
}
html[data-layout="mobile"] #view-inbox .side-head {
  min-height: 48px;
  padding: 8px 14px;
  background: var(--native-dark);
  border-bottom: 1px solid var(--native-line);
}
html[data-layout="mobile"] .section-title {
  font-size: 11px;
  letter-spacing: .10em;
  color: var(--native-muted);
  font-weight: 750;
}
html[data-layout="mobile"] #refreshInbox {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}
html[data-layout="mobile"] #view-inbox .filters {
  padding: 9px 14px 8px;
  gap: 8px;
  background: var(--native-dark);
  border-bottom: 1px solid var(--native-line);
}
html[data-layout="mobile"] #conversationSearch {
  min-height: 38px;
  border-radius: 14px;
  border-color: var(--native-line);
  background: var(--native-dark-2);
  color: var(--native-text);
  font-size: 13px;
  padding: 0 13px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.025);
}
html[data-layout="mobile"] #conversationSearch::placeholder {
  color: var(--native-subtle);
}
html[data-layout="mobile"] .inbox-tools {
  gap: 6px;
}
html[data-layout="mobile"] .inbox-filter {
  min-width: auto;
  min-height: 31px;
  padding: 0 12px;
  border-radius: 999px;
  border-color: var(--native-line);
  background: var(--native-dark-2);
  color: var(--native-muted);
  font-size: 11px;
  font-weight: 650;
}
html[data-layout="mobile"] .inbox-filter.active {
  background: #19c36b;
  border-color: #19c36b;
  color: #06120c;
  box-shadow: 0 8px 18px rgba(25,195,107,0.18);
}
html[data-layout="mobile"] #conversationList {
  background: var(--native-dark);
  padding-bottom: 2px;
}
html[data-layout="mobile"] .conversation {
  grid-template-columns: 38px minmax(0, 1fr) 44px;
  min-height: 62px;
  padding: 8px 14px;
  gap: 10px;
  border-left: 0;
  border-bottom: 1px solid var(--native-line);
  background: transparent;
}
html[data-layout="mobile"] .conversation:hover,
html[data-layout="mobile"] .conversation.active {
  background: rgba(37,211,102,0.06);
  border-left: 0;
}
html[data-layout="mobile"] .avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
  border-radius: 50%;
  background: linear-gradient(135deg, #21d07c, #32c7be);
  box-shadow: 0 6px 14px rgba(0,0,0,0.14);
}
html[data-layout="mobile"] .conv-name {
  font-size: 14px;
  font-weight: 720;
  line-height: 1.2;
  color: var(--native-text);
}
html[data-layout="mobile"] .conv-preview {
  margin-top: 3px;
  color: var(--native-muted);
  font-size: 13px;
  line-height: 1.25;
  max-height: 17px;
}
html[data-layout="mobile"] .conv-right {
  font-size: 11px;
  color: var(--native-subtle);
}
html[data-layout="mobile"] .unread {
  min-width: 20px;
  height: 20px;
  margin-top: 5px;
  background: #25d366;
  color: #041108;
  font-size: 11px;
  box-shadow: 0 5px 12px rgba(37,211,102,0.18);
}
html[data-layout="mobile"] .hot-dot {
  min-height: 16px;
  padding: 0 6px;
  font-size: 9px;
}
html[data-layout="mobile"] .mobile-bottom-nav {
  left: 12px;
  right: 12px;
  bottom: max(7px, env(safe-area-inset-bottom));
  min-height: 46px;
  padding: 4px;
  border-radius: 17px;
  border-color: var(--native-line);
  background: rgba(16,22,20,0.92);
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
}
html[data-theme="normal"][data-layout="mobile"] .mobile-bottom-nav {
  background: rgba(255,255,255,0.94);
}
html[data-layout="mobile"] .mobile-bottom-nav button {
  min-height: 38px;
  border-radius: 13px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--native-muted);
}
html[data-layout="mobile"] .mobile-bottom-nav button.active {
  background: #1fc76e;
  color: #041108;
  box-shadow: 0 8px 18px rgba(31,199,110,0.22);
}
html[data-layout="mobile"] .mobile-bottom-nav strong {
  top: -2px;
  right: -1px;
  min-width: 18px;
  height: 18px;
  font-size: 10px;
  line-height: 18px;
}
html.chat-open[data-layout="mobile"] .main {
  height: calc(100vh - 50px);
}
html.chat-open[data-layout="mobile"] .topbar {
  display: none;
}
html.chat-open[data-layout="mobile"] .main {
  height: 100vh;
}
html[data-layout="mobile"] .chat-head {
  min-height: 50px;
  padding: 6px 10px;
}
html[data-layout="mobile"] .reply {
  padding: 7px 8px max(7px, env(safe-area-inset-bottom));
}
html[data-layout="mobile"] .reply textarea {
  min-height: 40px;
  border-radius: 16px;
}
html[data-layout="mobile"] .reply .btn-primary {
  min-width: 58px;
  border-radius: 15px;
}

/* Final topbar anti-overlap pass: icon toggles and compact mobile theme control. */
.topbar {
  grid-template-columns: minmax(240px, 300px) minmax(390px, 460px) minmax(0, 1fr) !important;
  column-gap: 14px;
}
.stats {
  grid-template-columns: repeat(4, minmax(86px, 104px)) !important;
  justify-content: start;
}
.top-actions {
  min-width: 0;
  gap: 8px;
  overflow: hidden;
}
.top-search {
  flex: 1 1 260px !important;
  width: auto !important;
  min-width: 190px !important;
  max-width: 340px !important;
}
.top-search input {
  text-overflow: ellipsis;
}
.theme-switch,
.layout-switch {
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
}
.theme-option,
.layout-option {
  width: 34px;
  min-width: 34px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
}
.theme-option svg,
.layout-option svg {
  width: 16px;
  height: 16px;
}
.layout-option {
  min-width: 34px;
}

@media (max-width: 1600px) {
  .topbar {
    grid-template-columns: minmax(210px, 250px) minmax(340px, 390px) minmax(0, 1fr) !important;
    column-gap: 10px;
  }
  .stats {
    grid-template-columns: repeat(4, minmax(76px, 88px)) !important;
  }
  .top-search {
    min-width: 170px !important;
    max-width: 280px !important;
  }
  .user-profile {
    max-width: 88px;
  }
}

@media (max-width: 1360px) {
  .topbar {
    grid-template-columns: minmax(190px, 220px) minmax(300px, 340px) minmax(0, 1fr) !important;
  }
  .stats {
    grid-template-columns: repeat(4, minmax(66px, 76px)) !important;
  }
  .top-search {
    display: none !important;
  }
  .user-profile > span:not(.user-avatar-small),
  .health {
    display: none;
  }
}

html[data-layout="mobile"] .topbar {
  overflow: visible;
}
html[data-layout="mobile"] .brand h1 {
  max-width: calc(100vw - 220px);
}
html[data-layout="mobile"] .theme-switch {
  display: inline-flex !important;
  width: auto;
  flex: 0 0 auto;
  order: 2;
  padding: 2px;
  border-radius: 12px;
}
html[data-layout="mobile"] .theme-option {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}
html[data-layout="mobile"] .theme-option svg {
  width: 15px;
  height: 15px;
}
html[data-layout="mobile"] .layout-switch {
  display: none !important;
}
html[data-layout="mobile"] .top-actions {
  gap: 5px;
  overflow: visible;
}
html[data-layout="mobile"] .top-actions #notificationBtn {
  order: 1;
}
html[data-layout="mobile"] .user-profile {
  order: 3;
}

/* Mobile dashboard final polish: compact SaaS/native layout. */
@media (max-width: 760px) {
  html[data-layout="mobile"] body {
    font-size: 13px;
  }
  html[data-layout="mobile"] .app {
    padding-bottom: 58px;
  }
  html[data-layout="mobile"] .topbar {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 58px !important;
    height: auto !important;
    padding: 8px 10px !important;
    position: sticky;
    top: 0;
    z-index: 70;
  }
  html[data-layout="mobile"] .mobile-menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }
  html[data-layout="mobile"] .brand {
    min-width: 0;
    flex-basis: auto;
    gap: 8px;
  }
  html[data-layout="mobile"] .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 12px;
  }
  html[data-layout="mobile"] .brand h1 {
    max-width: 100%;
    font-size: 14px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html[data-layout="mobile"] .stats,
  html[data-layout="mobile"] .top-search,
  html[data-layout="mobile"] .health,
  html[data-layout="mobile"] .layout-switch,
  html[data-layout="mobile"] #logoutBtn {
    display: none !important;
  }
  html[data-layout="mobile"] .top-actions {
    width: auto !important;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px !important;
    margin: 0;
    grid-column: 3;
  }
  html[data-layout="mobile"] .theme-switch {
    display: inline-flex !important;
    order: 1;
    flex: 0 0 auto !important;
    width: auto !important;
    padding: 2px !important;
    border-radius: 12px;
    background: rgba(255,255,255,0.055);
  }
  html[data-layout="mobile"] .theme-option {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    border-radius: 10px;
  }
  html[data-layout="mobile"] #notificationBtn {
    order: 2;
    width: 34px;
    height: 34px;
  }
  html[data-layout="mobile"] .user-profile {
    order: 3;
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 12px;
  }
  html[data-layout="mobile"] .user-profile > span:not(.user-avatar-small) {
    display: none !important;
  }
  html[data-layout="mobile"] .user-avatar-small {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }
  html[data-layout="mobile"] .dashboard-shell {
    padding: 12px 10px 76px !important;
  }
  html[data-layout="mobile"] #view-dashboard .page-head {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }
  html[data-layout="mobile"] #view-dashboard .page-head > div {
    min-width: 0;
  }
  html[data-layout="mobile"] #view-dashboard .page-kicker {
    font-size: 10px;
    letter-spacing: .1em;
  }
  html[data-layout="mobile"] #view-dashboard .page-title {
    margin-top: 2px;
    font-size: clamp(20px, 6vw, 26px);
    line-height: 1.08;
    letter-spacing: -0.03em;
  }
  html[data-layout="mobile"] #view-dashboard .page-subtitle {
    margin-top: 5px;
    font-size: 12.5px;
    line-height: 1.35;
    max-width: 30ch;
  }
  html[data-layout="mobile"] #view-dashboard .page-head .btn {
    min-height: 34px;
    padding: 0 10px;
    font-size: 11px;
    border-radius: 10px;
    white-space: nowrap;
  }
  html[data-layout="mobile"] .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-bottom: 10px !important;
  }
  html[data-layout="mobile"] .saas-card {
    padding: 11px !important;
    border-radius: 13px !important;
    box-shadow: 0 8px 22px rgba(0,0,0,0.16);
  }
  html[data-layout="mobile"] .metric-card::after {
    width: 58px;
    height: 58px;
    right: -22px;
    top: -22px;
    opacity: .55;
  }
  html[data-layout="mobile"] .metric-label {
    font-size: 9px;
    letter-spacing: .07em;
    line-height: 1.15;
  }
  html[data-layout="mobile"] .metric-value {
    margin-top: 6px;
    font-size: clamp(24px, 8vw, 34px);
    line-height: 1;
    letter-spacing: -0.045em;
  }
  html[data-layout="mobile"] .metric-note {
    margin-top: 4px;
    font-size: 10.5px;
    line-height: 1.25;
  }
  html[data-layout="mobile"] #view-dashboard .analytics-grid {
    grid-template-columns: 1fr !important;
    gap: 9px !important;
    margin-top: 9px !important;
  }
  html[data-layout="mobile"] #view-dashboard .dashboard-shell > .analytics-grid:nth-child(4),
  html[data-layout="mobile"] #view-dashboard .dashboard-shell > .analytics-grid:nth-child(3) .saas-card:nth-child(2) {
    display: none;
  }
  html[data-layout="mobile"] #view-dashboard .card-title {
    font-size: 11px;
    margin-bottom: 8px;
  }
  html[data-layout="mobile"] #view-dashboard .bar-row {
    grid-template-columns: 48px 1fr 40px;
    gap: 7px;
    font-size: 10.5px;
  }
  html[data-layout="mobile"] .mobile-bottom-nav {
    left: 10px !important;
    right: 10px !important;
    bottom: max(6px, env(safe-area-inset-bottom)) !important;
    min-height: 42px !important;
    padding: 4px !important;
    border-radius: 16px !important;
  }
  html[data-layout="mobile"] .mobile-bottom-nav button {
    min-height: 34px !important;
    border-radius: 12px !important;
    font-size: 10px !important;
  }
  html[data-layout="mobile"] .mobile-bottom-nav strong {
    transform: scale(.9);
    transform-origin: top right;
  }
}

@media (max-width: 380px) {
  html[data-layout="mobile"] .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
  html[data-layout="mobile"] #view-dashboard .page-head {
    grid-template-columns: 1fr;
  }
  html[data-layout="mobile"] #view-dashboard .page-head .btn {
    justify-self: start;
  }
}

/* Final mobile inbox stability: keep chat inside the viewport like a native app. */
@media (max-width: 760px) {
  html.chat-open[data-layout="mobile"],
  html.chat-open[data-layout="mobile"] body {
    width: 100%;
    height: 100%;
    overflow: hidden !important;
  }
  html.chat-open[data-layout="mobile"] .topbar,
  html.chat-open[data-layout="mobile"] .tabs,
  html.chat-open[data-layout="mobile"] .mobile-bottom-nav {
    display: none !important;
  }
  html.chat-open[data-layout="mobile"] .app,
  html.chat-open[data-layout="mobile"] .main,
  html.chat-open[data-layout="mobile"] #view-inbox,
  html.chat-open[data-layout="mobile"] #view-inbox .inbox-layout {
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    padding: 0 !important;
    display: block !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .conv-sidebar {
    display: none !important;
  }
  html.chat-open[data-layout="mobile"] #chatPanel.chat {
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    display: grid !important;
    grid-template-rows: 52px minmax(0, 1fr) auto auto auto !important;
    overflow: hidden !important;
    background: #efeae2 !important;
  }
  html.chat-open[data-theme="dark"][data-layout="mobile"] #chatPanel.chat {
    background: #0b1511 !important;
  }
  html.chat-open[data-layout="mobile"] .chat-head {
    position: relative !important;
    top: auto !important;
    min-height: 52px !important;
    height: 52px !important;
    padding: 6px 8px !important;
    gap: 7px !important;
    flex-direction: row !important;
    align-items: center !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
  }
  html.chat-open[data-layout="mobile"] .chat-back {
    display: grid !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
  }
  html.chat-open[data-layout="mobile"] .chat-head .avatar {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    font-size: 13px !important;
  }
  html.chat-open[data-layout="mobile"] .chat-title {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }
  html.chat-open[data-layout="mobile"] .chat-title strong,
  html.chat-open[data-layout="mobile"] .chat-title .tiny {
    display: block !important;
    max-width: 48vw !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  html.chat-open[data-layout="mobile"] .lead-chips,
  html.chat-open[data-layout="mobile"] .presence-indicator,
  html.chat-open[data-layout="mobile"] .floating-chat-search,
  html.chat-open[data-layout="mobile"] .chat-message-pager {
    display: none !important;
  }
  html.chat-open[data-layout="mobile"] .chat-actions {
    margin-left: auto !important;
    display: flex !important;
    gap: 5px !important;
  }
  html.chat-open[data-layout="mobile"] .chat-actions .icon-btn {
    width: 32px !important;
    height: 32px !important;
  }
  html.chat-open[data-layout="mobile"] .chat-actions .human-toggle {
    min-width: 38px !important;
    width: 38px !important;
    padding: 0 !important;
    font-size: 0 !important;
  }
  html.chat-open[data-layout="mobile"] .chat-actions .human-toggle::after {
    content: "H";
    font-size: 12px;
    font-weight: 900;
  }
  html.chat-open[data-layout="mobile"] .messages {
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 10px 8px 12px !important;
    gap: 6px !important;
    display: flex !important;
    flex-direction: column !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
  html.chat-open[data-layout="mobile"] .message-row {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    align-items: flex-end !important;
    gap: 6px !important;
    margin: 0 !important;
    min-width: 0 !important;
  }
  html.chat-open[data-layout="mobile"] .message-row.sent {
    justify-content: flex-end !important;
    padding-left: 42px !important;
    padding-right: 4px !important;
  }
  html.chat-open[data-layout="mobile"] .message-row.received {
    justify-content: flex-start !important;
    padding-left: 2px !important;
    padding-right: 42px !important;
  }
  html.chat-open[data-layout="mobile"] .message-row.sent .msg-avatar,
  html.chat-open[data-layout="mobile"] .message-row .msg-avatar.ghost {
    display: none !important;
  }
  html.chat-open[data-layout="mobile"] .message-row.received .msg-avatar {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    font-size: 10px !important;
  }
  html.chat-open[data-layout="mobile"] .bubble {
    width: fit-content !important;
    max-width: min(76vw, 340px) !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 8px 10px 6px !important;
    border: 0 !important;
    border-radius: 14px !important;
    font-size: 13.5px !important;
    line-height: 1.42 !important;
    overflow: hidden !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .16) !important;
  }
  html.chat-open[data-layout="mobile"] .bubble.sent {
    margin-left: auto !important;
    border-bottom-right-radius: 5px !important;
    background: #d9fdd3 !important;
    color: #111b21 !important;
  }
  html.chat-open[data-layout="mobile"] .bubble.received {
    margin-right: auto !important;
    border-bottom-left-radius: 5px !important;
    background: #fff !important;
    color: #111b21 !important;
  }
  html.chat-open[data-theme="dark"][data-layout="mobile"] .bubble.received {
    background: #18241f !important;
    color: #ecf5ef !important;
  }
  html.chat-open[data-theme="dark"][data-layout="mobile"] .bubble.sent {
    background: #123c2a !important;
    color: #ecf5ef !important;
  }
  html.chat-open[data-layout="mobile"] .message-text,
  html.chat-open[data-layout="mobile"] .chat-media-caption {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }
  html.chat-open[data-layout="mobile"] .bubble time {
    margin-top: 4px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    color: rgba(17, 27, 33, .58) !important;
  }
  html.chat-open[data-theme="dark"][data-layout="mobile"] .bubble time {
    color: rgba(236, 245, 239, .62) !important;
  }
  html.chat-open[data-layout="mobile"] .chat-media img,
  html.chat-open[data-layout="mobile"] .chat-media video {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 10px !important;
  }
  html.chat-open[data-layout="mobile"] .quick-dock {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-height: 42px !important;
    padding: 6px 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    border-top: 1px solid rgba(255, 255, 255, .08) !important;
    background: #07100c !important;
    flex-shrink: 0 !important;
  }
  html.chat-open[data-theme="normal"][data-layout="mobile"] .quick-dock {
    background: #f5fbf7 !important;
    border-top-color: rgba(14, 100, 55, .12) !important;
  }
  html.chat-open[data-layout="mobile"] .quick-tab {
    min-height: 30px !important;
    padding: 0 12px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
  }
  html.chat-open[data-layout="mobile"] .quick-floating {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 96px !important;
    width: auto !important;
    max-height: 36vh !important;
    z-index: 80 !important;
  }
  html.chat-open[data-layout="mobile"] .chat-crm {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 96px !important;
    width: auto !important;
    max-height: 42vh !important;
    overflow: auto !important;
    z-index: 82 !important;
  }
  html.chat-open[data-layout="mobile"] .reply-tools {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-height: 36px !important;
    padding: 5px 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-shrink: 0 !important;
  }
  html.chat-open[data-layout="mobile"] .attach-btn {
    min-height: 28px !important;
    padding: 0 10px !important;
    border-radius: 999px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
  }
  html.chat-open[data-layout="mobile"] .attachment-preview {
    max-width: 72vw !important;
    min-height: 28px !important;
    font-size: 11px !important;
    flex: 0 0 auto !important;
  }
  html.chat-open[data-layout="mobile"] .reply {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 54px !important;
    gap: 8px !important;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom)) !important;
    border-top: 1px solid rgba(255, 255, 255, .08) !important;
    background: #07100c !important;
    flex-shrink: 0 !important;
  }
  html.chat-open[data-theme="normal"][data-layout="mobile"] .reply {
    background: #f5fbf7 !important;
    border-top-color: rgba(14, 100, 55, .12) !important;
  }
  html.chat-open[data-layout="mobile"] .reply textarea {
    min-width: 0 !important;
    width: 100% !important;
    min-height: 40px !important;
    max-height: 88px !important;
    padding: 10px 12px !important;
    border-radius: 16px !important;
    font-size: 14px !important;
    line-height: 1.35 !important;
    resize: none !important;
  }
  html.chat-open[data-layout="mobile"] .reply .btn-primary,
  html.chat-open[data-layout="mobile"] #replyBtn {
    width: 54px !important;
    min-width: 54px !important;
    min-height: 40px !important;
    padding: 0 !important;
    border-radius: 16px !important;
    font-size: 12px !important;
  }
}

/* Final WhatsApp inbox polish: desktop and mobile share one stable chat language. */
.chat-back {
  display: none !important;
}
.floating-chat-search {
  display: none !important;
}
.chat-message-pager {
  display: none !important;
}
#view-inbox .chat {
  min-width: 0;
  overflow: hidden;
  grid-template-rows: 58px minmax(0, 1fr) auto auto !important;
}
#view-inbox .messages {
  background:
    radial-gradient(circle at 16px 16px, rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 22px 22px,
    #0b1411;
  padding: 18px 28px !important;
  gap: 7px !important;
  overflow-x: hidden !important;
}
html[data-theme="normal"] #view-inbox .messages {
  background:
    radial-gradient(circle at 16px 16px, rgba(0,0,0,.04) 1px, transparent 1px) 0 0 / 22px 22px,
    #efeae2;
}
#view-inbox .message-row {
  width: 100%;
  max-width: 100% !important;
  gap: 7px;
}
#view-inbox .message-row.sent {
  justify-content: flex-end;
}
#view-inbox .message-row.received {
  justify-content: flex-start;
}
#view-inbox .message-row.sent .msg-avatar,
#view-inbox .message-row .msg-avatar.ghost {
  display: none !important;
}
#view-inbox .message-row.received .msg-avatar {
  width: 26px;
  height: 26px;
  min-width: 26px;
  font-size: 10px;
}
#view-inbox .bubble {
  width: fit-content !important;
  max-width: min(58vw, 620px) !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 8px 10px 6px !important;
  border: 0 !important;
  border-radius: 10px !important;
  font-size: 14px !important;
  line-height: 1.42 !important;
  white-space: pre-wrap !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.20) !important;
}
#view-inbox .bubble.sent {
  background: #005c4b !important;
  color: #e9edef !important;
  border-bottom-right-radius: 3px !important;
}
#view-inbox .bubble.received {
  background: #202c33 !important;
  color: #e9edef !important;
  border-bottom-left-radius: 3px !important;
}
html[data-theme="normal"] #view-inbox .bubble.sent {
  background: #d9fdd3 !important;
  color: #111b21 !important;
}
html[data-theme="normal"] #view-inbox .bubble.received {
  background: #fff !important;
  color: #111b21 !important;
}
#view-inbox .message-text,
#view-inbox .chat-media-caption {
  display: block;
  white-space: pre-wrap !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
#view-inbox .bubble time {
  margin-top: 4px !important;
  font-size: 10px !important;
  line-height: 1.15 !important;
  color: rgba(233,237,239,.62) !important;
}
html[data-theme="normal"] #view-inbox .bubble time {
  color: #667781 !important;
}
#view-inbox .chat-head {
  min-width: 0;
  min-height: 58px;
  padding: 9px 18px !important;
}
#view-inbox .chat-title strong,
#view-inbox .chat-title .tiny {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#view-inbox .quick-dock {
  min-height: 42px;
  padding: 6px 18px !important;
  gap: 8px;
}
#view-inbox .quick-tab {
  min-height: 30px !important;
  padding: 0 14px !important;
}
#view-inbox .reply-tools {
  min-height: 38px;
  padding: 6px 18px !important;
}
#view-inbox .attach-btn {
  min-height: 28px !important;
  padding: 0 11px !important;
}
#view-inbox .reply {
  grid-template-columns: minmax(0, 1fr) 76px !important;
  gap: 10px !important;
  padding: 9px 18px !important;
}
#view-inbox .reply textarea {
  min-width: 0 !important;
  width: 100% !important;
  min-height: 44px !important;
  max-height: 110px !important;
  border-radius: 18px !important;
  resize: none !important;
}
#view-inbox #replyBtn {
  min-width: 76px !important;
  width: 76px !important;
  min-height: 44px !important;
  border-radius: 18px !important;
}
.followup-folder-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(130px,1fr));
  gap:12px;
  margin-bottom:14px;
}
.followup-folder-card {
  border:1px solid var(--border);
  border-radius:16px;
  background:var(--s1);
  padding:14px;
  box-shadow:var(--shadow);
}
.followup-folder-card span {
  color:var(--muted);
  display:block;
  font-size:11px;
  font-weight:800;
  letter-spacing:.5px;
  text-transform:uppercase;
}
.followup-folder-card strong {
  display:block;
  font-size:26px;
  margin-top:8px;
}
.followup-lead-card {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:12px;
  align-items:center;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--s1);
}
.followup-lead-card + .followup-lead-card { margin-top:9px; }
.followup-lead-card p {
  margin:5px 0 0;
  color:var(--text2);
  line-height:1.45;
}
.followup-score {
  min-width:54px;
  min-height:54px;
  border-radius:16px;
  display:grid;
  place-items:center;
  background:var(--glow2);
  border:1px solid var(--border-hi);
  color:var(--green);
  font-size:18px;
  font-weight:800;
}
.followup-filters {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:12px;
}
.followup-mode-row {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:0 0 12px;
}
.followup-bulk-row {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
  margin:0 0 12px;
  padding:10px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--s1);
}
.followup-search-row {
  display:grid;
  grid-template-columns:minmax(240px, 1fr) auto;
  gap:10px;
  align-items:end;
  margin:0 0 12px;
  padding:12px;
  border:1px solid rgba(37, 211, 102, .18);
  border-radius:18px;
  background:linear-gradient(135deg, rgba(37,211,102,.10), rgba(59,130,246,.07));
  box-shadow:0 14px 34px rgba(15, 23, 42, .06);
}
.followup-keyword-field {
  display:grid;
  gap:6px;
  min-width:0;
}
.followup-keyword-field span {
  color:var(--muted);
  font-size:11px;
  font-weight:900;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.followup-keyword-field input {
  width:100%;
  min-height:44px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--card);
  color:var(--text);
  padding:0 14px;
  font:inherit;
  outline:none;
}
.followup-keyword-field input:focus {
  border-color:rgba(37, 211, 102, .72);
  box-shadow:0 0 0 4px rgba(37, 211, 102, .12);
}
.followup-quick-keywords {
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:7px;
}
.followup-select-all {
  display:inline-flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:12px;
  font-weight:800;
}
.followup-select-all input,
.followup-card-check {
  width:16px;
  height:16px;
  accent-color:var(--green);
}
.followup-selected-count {
  margin-right:auto;
  color:var(--muted);
  font-size:12px;
  font-weight:800;
}
.followup-mode-btn.active {
  background:var(--green);
  border-color:var(--green);
  color:#041108;
}
@media (max-width: 760px) {
  .followup-search-row {
    grid-template-columns:1fr;
  }
  .followup-quick-keywords {
    justify-content:flex-start;
  }
}
.followup-course-pill {
  display:inline-flex;
  align-items:center;
  gap:6px;
  max-width:100%;
  margin-top:6px;
  padding:6px 10px;
  border-radius:999px;
  background:rgba(37,211,102,.10);
  border:1px solid rgba(37,211,102,.24);
  color:var(--green);
  font-size:12px;
  font-weight:800;
}
.followup-course-pill small {
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--muted);
  font-weight:700;
}
.followup-filter.active {
  background:var(--green);
  border-color:var(--green);
  color:#041108;
}
@media (min-width: 761px) {
  #view-inbox .inbox-layout {
    grid-template-columns: 340px minmax(0, 1fr) !important;
  }
  #view-inbox .chat-media img,
  #view-inbox .chat-media video {
    max-width: min(360px, 46vw) !important;
  }
}
@media (max-width: 760px) {
  .followup-folder-grid { grid-template-columns:1fr 1fr; }
.followup-lead-card { grid-template-columns:1fr; }
  html.chat-open[data-layout="mobile"] #chatPanel.chat {
    grid-template-rows: 50px minmax(0, 1fr) auto auto auto !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  html.chat-open[data-layout="mobile"] .chat-back {
    display: grid !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .messages {
    padding: 8px 7px 10px !important;
    gap: 5px !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .message-row.sent {
    padding-left: 32px !important;
    padding-right: 2px !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .message-row.received {
    padding-left: 2px !important;
    padding-right: 32px !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .bubble {
    max-width: 78vw !important;
    font-size: 13.5px !important;
    line-height: 1.4 !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .chat-head {
    min-height: 50px !important;
    height: 50px !important;
    padding: 5px 7px !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .quick-dock {
    min-height: 38px !important;
    padding: 5px 7px !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .reply-tools {
    min-height: 34px !important;
    padding: 4px 7px !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .reply {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    grid-template-columns: minmax(0, calc(100vw - 78px)) 48px !important;
    gap: 7px !important;
    padding: 6px 7px calc(6px + env(safe-area-inset-bottom)) !important;
    overflow: hidden !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox .reply textarea {
    min-height: 40px !important;
    max-height: 84px !important;
    padding: 9px 11px !important;
    border-radius: 17px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox #replyBtn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 40px !important;
    border-radius: 17px !important;
    font-size: 0 !important;
    overflow: hidden !important;
  }
  html.chat-open[data-layout="mobile"] #view-inbox #replyBtn::before {
    content: "Send";
    font-size: 11px;
    font-weight: 800;
  }
}

/* Keep desktop/mobile view switch visible on mobile topbar. */
@media (max-width: 760px) {
  html[data-layout="mobile"] .layout-switch {
    display: inline-flex !important;
    width: 74px !important;
    height: 38px !important;
    min-height: 38px !important;
    flex: 0 0 74px !important;
    padding: 3px !important;
    gap: 2px !important;
    border-radius: 12px !important;
  }
  html[data-layout="mobile"] .layout-option {
    width: 33px !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 !important;
    border-radius: 9px !important;
  }
  html[data-layout="mobile"] .layout-option svg {
    width: 15px !important;
    height: 15px !important;
  }
  html[data-layout="mobile"] .top-actions {
    gap: 4px !important;
  }
  html[data-layout="mobile"] .brand h1 {
    max-width: calc(100vw - 282px) !important;
  }
}
@media (max-width: 430px) {
  html[data-layout="mobile"] .brand h1 {
    display: none !important;
  }
  html[data-layout="mobile"] .brand {
    flex: 0 0 auto !important;
  }
}

/* Mobile stability override: one clean source of truth for drawer, topbar, inbox and bottom nav. */
html[data-layout="mobile"],
html[data-layout="mobile"] body {
  width: 100%;
  min-width: 0;
  overflow: hidden !important;
  background: var(--native-dark, var(--bg));
}
html[data-layout="mobile"] * {
  min-width: 0;
}
html[data-layout="mobile"] .app {
  width: 100%;
  height: 100dvh !important;
  min-height: 100dvh !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: 52px minmax(0, 1fr) !important;
  padding: 0 0 calc(58px + env(safe-area-inset-bottom)) !important;
  overflow: hidden !important;
}
html[data-layout="mobile"] .topbar {
  grid-column: 1 !important;
  grid-row: 1 !important;
  position: relative !important;
  top: auto !important;
  z-index: 70 !important;
  width: 100% !important;
  height: 52px !important;
  min-height: 52px !important;
  display: grid !important;
  grid-template-columns: 38px minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 7px !important;
  padding: 7px 8px !important;
  overflow: hidden !important;
  border-bottom: 1px solid var(--native-line, var(--line)) !important;
}
html[data-layout="mobile"] .mobile-menu-btn {
  display: grid !important;
  grid-column: 1 !important;
  width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  border-radius: 11px !important;
  padding: 0 !important;
}
html[data-layout="mobile"] .brand {
  grid-column: 2 !important;
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  min-width: 0 !important;
  overflow: hidden !important;
}
html[data-layout="mobile"] .brand-mark {
  width: 31px !important;
  height: 31px !important;
  flex: 0 0 31px !important;
  border-radius: 10px !important;
  font-size: 12px !important;
}
html[data-layout="mobile"] .brand h1 {
  display: block !important;
  max-width: 100% !important;
  margin: 0 !important;
  font-size: 13px !important;
  line-height: 1.1 !important;
  font-weight: 750 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
html[data-layout="mobile"] .brand p,
html[data-layout="mobile"] .stats,
html[data-layout="mobile"] .top-search,
html[data-layout="mobile"] .health,
html[data-layout="mobile"] #logoutBtn,
html[data-layout="mobile"] .user-profile > span:not(.user-avatar-small) {
  display: none !important;
}
html[data-layout="mobile"] .top-actions {
  grid-column: 3 !important;
  width: auto !important;
  display: flex !important;
  flex: 0 0 auto !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 4px !important;
  margin: 0 !important;
  overflow: visible !important;
}
html[data-layout="mobile"] .layout-switch,
html[data-layout="mobile"] .theme-switch {
  display: inline-flex !important;
  flex: 0 0 auto !important;
  width: auto !important;
  min-height: 34px !important;
  height: 34px !important;
  padding: 2px !important;
  gap: 2px !important;
  border-radius: 11px !important;
}
html[data-layout="mobile"] .layout-option,
html[data-layout="mobile"] .theme-option {
  width: 29px !important;
  min-width: 29px !important;
  height: 29px !important;
  min-height: 29px !important;
  padding: 0 !important;
  border-radius: 9px !important;
}
html[data-layout="mobile"] .layout-option svg,
html[data-layout="mobile"] .theme-option svg {
  width: 14px !important;
  height: 14px !important;
}
html[data-layout="mobile"] .top-icon,
html[data-layout="mobile"] .user-profile {
  display: grid !important;
  place-items: center !important;
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  border-radius: 11px !important;
}
html[data-layout="mobile"] .user-avatar-small {
  width: 25px !important;
  height: 25px !important;
  border-radius: 8px !important;
  font-size: 10px !important;
}
@media (max-width: 430px) {
  html[data-layout="mobile"] .brand h1 { display: none !important; }
  html[data-layout="mobile"] .brand { flex: 0 0 auto !important; }
}
html[data-layout="mobile"] .main {
  grid-column: 1 !important;
  grid-row: 2 !important;
  width: 100% !important;
  height: calc(100dvh - 52px - 58px - env(safe-area-inset-bottom)) !important;
  min-height: 0 !important;
  overflow: auto !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}
html[data-layout="mobile"] .view {
  width: 100% !important;
  min-width: 0 !important;
  overflow: visible !important;
}
html[data-layout="mobile"] .dashboard-shell,
html[data-layout="mobile"] .logs,
html[data-layout="mobile"] .content {
  padding: 12px 10px 18px !important;
}
html[data-layout="mobile"] .grid,
html[data-layout="mobile"] .analytics-grid,
html[data-layout="mobile"] .workspace-overview,
html[data-layout="mobile"] .dashboard-grid,
html[data-layout="mobile"] .lead-toolbar,
html[data-layout="mobile"] .sender-layout,
html[data-layout="mobile"] .inbox-layout {
  grid-template-columns: minmax(0, 1fr) !important;
}
html[data-layout="mobile"] .tabs {
  position: fixed !important;
  inset: 0 auto 0 0 !important;
  z-index: 110 !important;
  width: min(300px, 86vw) !important;
  max-width: 86vw !important;
  height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  padding: calc(14px + env(safe-area-inset-top)) 12px 14px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  transform: translateX(-105%) !important;
  transition: transform .22s ease !important;
  border-right: 1px solid var(--native-line, var(--line)) !important;
  border-radius: 0 20px 20px 0 !important;
  background: rgba(11, 20, 17, .98) !important;
  box-shadow: 22px 0 60px rgba(0,0,0,.32) !important;
}
html[data-theme="normal"][data-layout="mobile"] .tabs {
  background: rgba(255,255,255,.98) !important;
}
html.drawer-open[data-layout="mobile"] .tabs {
  transform: translateX(0) !important;
}
html[data-layout="mobile"] .tabs::before,
html[data-layout="mobile"] .tabs::after {
  display: none !important;
}
html[data-layout="mobile"] .side-logo {
  display: flex !important;
  margin: 0 0 10px !important;
  padding: 8px 6px 14px !important;
  border-bottom: 1px solid var(--native-line, var(--line)) !important;
}
html[data-layout="mobile"] .nav-section {
  display: block !important;
  margin: 12px 8px 6px !important;
  font-size: 10px !important;
}
html[data-layout="mobile"] .nav-footnote {
  display: block !important;
  margin-top: auto !important;
}
html[data-layout="mobile"] .tabs .tab {
  width: 100% !important;
  min-height: 44px !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  padding: 0 10px !important;
  border-radius: 13px !important;
  font-size: 13px !important;
  text-align: left !important;
}
html[data-layout="mobile"] .tabs .tab > span:not(.nav-ico):not(.badge) {
  display: inline !important;
}
html[data-layout="mobile"] .tabs .nav-ico {
  width: 32px !important;
  height: 32px !important;
  flex: 0 0 32px !important;
}
html[data-layout="mobile"] .tabs .badge {
  position: static !important;
  margin-left: auto !important;
}
html[data-layout="mobile"] .drawer-scrim {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100 !important;
  display: none !important;
  border: 0 !important;
  background: rgba(0,0,0,.48) !important;
}
html.drawer-open[data-layout="mobile"] .drawer-scrim {
  display: block !important;
}
html[data-layout="mobile"] .mobile-bottom-nav {
  position: fixed !important;
  left: 10px !important;
  right: 10px !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  z-index: 90 !important;
  height: 50px !important;
  min-height: 50px !important;
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 3px !important;
  padding: 4px !important;
  border-radius: 18px !important;
  overflow: visible !important;
}
html[data-layout="mobile"] .mobile-bottom-nav button {
  min-width: 0 !important;
  min-height: 40px !important;
  border-radius: 14px !important;
  font-size: 10px !important;
}
html[data-layout="mobile"] .mobile-bottom-nav strong {
  top: -4px !important;
  right: 8px !important;
}
html[data-layout="mobile"] #view-inbox,
html[data-layout="mobile"] #view-inbox .inbox-layout {
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
html[data-layout="mobile"] #view-inbox .inbox-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
}
html[data-layout="mobile"] #view-inbox .conv-sidebar {
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
  border: 0 !important;
}
html[data-layout="mobile"] #view-inbox .side-head {
  min-height: 46px !important;
  padding: 8px 14px !important;
}
html[data-layout="mobile"] #view-inbox .filters {
  padding: 8px 14px !important;
}
html[data-layout="mobile"] #conversationSearch {
  min-height: 38px !important;
}
html[data-layout="mobile"] #conversationList {
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-bottom: 8px !important;
}
html[data-layout="mobile"] .conversation {
  grid-template-columns: 40px minmax(0, 1fr) 46px !important;
  min-height: 64px !important;
  padding: 8px 14px !important;
}
html[data-layout="mobile"] #view-inbox .chat {
  display: none !important;
}
html.chat-open[data-layout="mobile"] .app {
  grid-template-rows: minmax(0, 1fr) !important;
  padding: 0 !important;
}
html.chat-open[data-layout="mobile"] .topbar,
html.chat-open[data-layout="mobile"] .mobile-bottom-nav {
  display: none !important;
}
html.chat-open[data-layout="mobile"] .main {
  grid-row: 1 !important;
  height: 100dvh !important;
  overflow: hidden !important;
}
html.chat-open[data-layout="mobile"] #view-inbox .conv-sidebar {
  display: none !important;
}
html.chat-open[data-layout="mobile"] #view-inbox .chat {
  display: grid !important;
}
html.chat-open[data-layout="mobile"] #chatPanel.chat {
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 0 !important;
  grid-template-rows: 52px minmax(0, 1fr) auto auto auto !important;
  overflow: hidden !important;
}
html.chat-open[data-layout="mobile"] .reply {
  grid-template-columns: minmax(0, 1fr) 52px !important;
  width: 100% !important;
  max-width: 100vw !important;
}
html.chat-open[data-layout="mobile"] #replyBtn {
  display: inline-flex !important;
  width: 52px !important;
  min-width: 52px !important;
}
html.chat-open[data-layout="mobile"] .chat-actions {
  gap: 3px !important;
  flex: 0 0 auto !important;
}
html.chat-open[data-layout="mobile"] .chat-actions .icon-btn {
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
}
html.chat-open[data-layout="mobile"] .chat-title strong,
html.chat-open[data-layout="mobile"] .chat-title .tiny {
  max-width: 35vw !important;
}
@media (max-width: 380px) {
  html[data-layout="mobile"] .topbar {
    grid-template-columns: 34px minmax(0, 1fr) auto !important;
    gap: 5px !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
  }
  html[data-layout="mobile"] .mobile-menu-btn,
  html[data-layout="mobile"] .top-icon,
  html[data-layout="mobile"] .user-profile {
    width: 31px !important;
    min-width: 31px !important;
    height: 31px !important;
    min-height: 31px !important;
    border-radius: 10px !important;
  }
  html[data-layout="mobile"] .brand-mark {
    width: 28px !important;
    height: 28px !important;
    flex-basis: 28px !important;
  }
  html[data-layout="mobile"] .layout-switch,
  html[data-layout="mobile"] .theme-switch {
    height: 31px !important;
    min-height: 31px !important;
    padding: 1px !important;
  }
  html[data-layout="mobile"] .layout-option,
  html[data-layout="mobile"] .theme-option {
    width: 27px !important;
    min-width: 27px !important;
    height: 27px !important;
    min-height: 27px !important;
  }
  html[data-layout="mobile"] .top-actions {
    gap: 3px !important;
  }
}
@media (max-width: 340px) {
  html[data-layout="mobile"] .brand-mark {
    display: none !important;
  }
}

/* UI/UX Pro stabilization layer: frontend-only, backend/API safe. */
:root {
  --uix-radius-xs: 8px;
  --uix-radius-sm: 12px;
  --uix-radius-md: 16px;
  --uix-radius-lg: 22px;
  --uix-shadow-soft: 0 18px 50px rgba(10, 35, 24, 0.10);
  --uix-shadow-card: 0 12px 34px rgba(10, 35, 24, 0.08);
  --uix-ease: 180ms cubic-bezier(.2,.8,.2,1);
}
.app {
  min-width: 0 !important;
}
.topbar {
  min-height: 72px !important;
  padding: 12px 20px !important;
  gap: 12px !important;
  justify-content: flex-start !important;
  overflow: hidden !important;
  box-shadow: 0 1px 0 var(--line), 0 14px 34px rgba(6, 16, 11, 0.04);
}
.brand {
  flex: 0 0 300px !important;
  min-width: 220px !important;
}
.brand h1 {
  font-size: 19px !important;
  line-height: 1.12 !important;
}
.brand p {
  max-width: 240px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.stats {
  flex: 0 0 auto !important;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(96px, 112px)) !important;
  gap: 10px !important;
  min-width: 0 !important;
}
.stat {
  min-width: 0 !important;
  height: 56px !important;
  padding: 9px 12px !important;
  border-radius: var(--uix-radius-sm) !important;
  box-shadow: none !important;
}
.stat strong {
  font-size: 22px !important;
  line-height: 1 !important;
}
.stat span {
  font-size: 12px !important;
}
.top-actions {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  overflow: hidden !important;
}
.top-search {
  flex: 1 1 300px !important;
  min-width: 190px !important;
  max-width: 420px !important;
  height: 48px !important;
  border-radius: var(--uix-radius-sm) !important;
}
.top-search input {
  min-width: 0 !important;
  text-overflow: ellipsis !important;
}
.top-icon,
.layout-switch,
.theme-switch,
.user-profile {
  flex: 0 0 auto !important;
}
.layout-switch,
.theme-switch {
  height: 48px !important;
  border-radius: var(--uix-radius-sm) !important;
}
.layout-option,
.theme-option,
.top-icon {
  transition: background var(--uix-ease), border-color var(--uix-ease), transform var(--uix-ease) !important;
}
.layout-option:hover,
.theme-option:hover,
.top-icon:hover,
.btn:hover,
.inbox-filter:hover {
  transform: translateY(-1px);
}
@media (max-width: 1440px) {
  .brand { flex-basis: 270px !important; }
  .stats { grid-template-columns: repeat(4, minmax(86px, 102px)) !important; }
  .top-search { max-width: 360px !important; }
}
@media (max-width: 1240px) {
  .brand p { display: none !important; }
  .brand { flex-basis: 235px !important; }
  .stats { grid-template-columns: repeat(3, minmax(86px, 100px)) !important; }
  .stat:nth-child(4) { display: none !important; }
}
@media (max-width: 1080px) {
  .stats { display: none !important; }
  .brand { flex-basis: 250px !important; }
}
.inbox-layout {
  grid-template-columns: minmax(360px, 390px) minmax(0, 1fr) !important;
  min-width: 0 !important;
}
.conv-sidebar {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto !important;
  min-width: 0 !important;
  overflow: hidden !important;
  border-right: 1px solid var(--line) !important;
  background: var(--surface) !important;
}
.side-head {
  min-width: 0 !important;
  align-items: flex-start !important;
  gap: 12px !important;
  padding: 18px 20px 12px !important;
}
.side-head .section-title {
  line-height: 1.1 !important;
  padding-top: 7px !important;
}
.inbox-head-actions {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
  max-width: 210px !important;
}
.global-bot-toggle,
.human-toggle,
#resumeAllBotsBtn,
#refreshInbox {
  min-height: 36px !important;
  border-radius: 999px !important;
}
.filters {
  padding: 14px 20px 12px !important;
  gap: 12px !important;
  border-top: 1px solid var(--line-soft) !important;
  border-bottom: 1px solid var(--line) !important;
}
#conversationSearch {
  height: 44px !important;
  min-height: 44px !important;
  border-radius: var(--uix-radius-sm) !important;
  padding: 0 14px !important;
  font-size: 14px !important;
}
.inbox-tools {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding-bottom: 2px !important;
  scrollbar-width: none;
}
.inbox-tools::-webkit-scrollbar {
  display: none;
}
.inbox-filter {
  flex: 0 0 auto !important;
  min-height: 36px !important;
  padding: 0 15px !important;
  border-radius: 999px !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  transition: background var(--uix-ease), border-color var(--uix-ease), color var(--uix-ease), transform var(--uix-ease) !important;
}
.inbox-bulk-bar {
  position: relative !important;
  z-index: 4 !important;
  display: none !important;
  grid-template-columns: 18px minmax(92px, 1fr) auto auto auto !important;
  align-items: center !important;
  gap: 8px !important;
  min-height: 46px !important;
  padding: 8px 14px !important;
  border-top: 0 !important;
  border-bottom: 1px solid var(--line) !important;
  background: color-mix(in srgb, var(--green) 9%, var(--surface)) !important;
}
.inbox-bulk-bar.show {
  display: grid !important;
}
.inbox-bulk-count {
  font-size: 12px !important;
  white-space: nowrap !important;
}
.inbox-bulk-bar .btn {
  min-height: 32px !important;
  padding: 0 10px !important;
  border-radius: 999px !important;
  font-size: 11px !important;
  white-space: nowrap !important;
}
#conversationList {
  min-height: 0 !important;
  overflow: auto !important;
  background: var(--surface) !important;
}
.conversation {
  grid-template-columns: 22px 40px minmax(0, 1fr) 48px !important;
  align-items: center !important;
  gap: 10px !important;
  min-height: 78px !important;
  padding: 10px 14px !important;
  border-left: 3px solid transparent !important;
  border-bottom: 1px solid var(--line-soft) !important;
  overflow: hidden !important;
  transition: background var(--uix-ease), border-color var(--uix-ease), transform var(--uix-ease) !important;
}
.conversation:hover {
  background: color-mix(in srgb, var(--green) 8%, var(--surface)) !important;
  transform: none !important;
}
.conversation.active {
  border-left-color: var(--green) !important;
  background: color-mix(in srgb, var(--green) 11%, var(--surface)) !important;
  padding-left: 14px !important;
}
.conversation.checked {
  background: color-mix(in srgb, var(--green) 14%, var(--surface)) !important;
}
.conversation-check-wrap {
  width: 18px !important;
  height: 40px !important;
  display: grid !important;
  place-items: center !important;
}
.conversation-check {
  width: 16px !important;
  height: 16px !important;
  accent-color: var(--green);
}
.conversation .avatar {
  width: 40px !important;
  height: 40px !important;
}
.conversation > span:nth-child(3) {
  min-width: 0 !important;
  overflow: hidden !important;
}
.conv-name,
.conv-preview {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.conv-name {
  display: block !important;
  white-space: nowrap !important;
  font-size: 14px !important;
  line-height: 1.25 !important;
}
.conv-preview {
  font-size: 12px !important;
  color: var(--muted) !important;
}
.conv-more {
  font-size: 10px !important;
  margin-top: 3px !important;
}
.conv-right {
  justify-self: end !important;
  min-width: 42px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 4px !important;
  font-size: 10px !important;
}
.unread {
  margin-top: 0 !important;
  min-width: 20px !important;
  height: 20px !important;
  box-shadow: 0 6px 16px rgba(23, 182, 94, 0.22) !important;
}
#inboxPager {
  min-height: 42px !important;
  padding: 8px 14px !important;
  border-top: 1px solid var(--line) !important;
  background: var(--surface) !important;
}
.chat {
  min-width: 0 !important;
  overflow: hidden !important;
  background:
    radial-gradient(circle at 18px 18px, rgba(16, 33, 24, 0.035) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--surface-2) !important;
}
.chat-head {
  min-height: 72px !important;
  padding: 12px 20px !important;
  gap: 12px !important;
  background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
  backdrop-filter: blur(14px) !important;
}
.chat-title {
  min-width: 0 !important;
}
.chat-title strong,
.chat-title .tiny {
  max-width: 260px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.lead-chips {
  min-width: 0 !important;
  overflow-x: auto !important;
  scrollbar-width: none;
}
.lead-chips::-webkit-scrollbar {
  display: none;
}
.chat-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 0 0 auto !important;
}
.chat-actions .icon-btn {
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
  border-radius: var(--uix-radius-sm) !important;
}
.empty {
  color: var(--muted) !important;
}
.empty h2 {
  color: var(--text) !important;
  margin-bottom: 8px !important;
}
.messages {
  min-width: 0 !important;
  padding: 22px 28px !important;
}
.bubble {
  border-radius: 16px !important;
  box-shadow: var(--uix-shadow-card) !important;
}
.reply-tools,
.quick-dock,
.reply {
  background: color-mix(in srgb, var(--surface) 96%, transparent) !important;
  backdrop-filter: blur(12px) !important;
}
.reply {
  grid-template-columns: minmax(0, 1fr) 96px !important;
  gap: 12px !important;
  padding: 12px 18px !important;
}
.reply textarea {
  min-width: 0 !important;
  min-height: 52px !important;
  max-height: 130px !important;
  border-radius: var(--uix-radius-md) !important;
  padding: 14px 16px !important;
}
.reply .btn-primary {
  min-width: 0 !important;
  border-radius: var(--uix-radius-md) !important;
}
.btn,
.icon-btn,
.top-icon,
.inbox-filter,
.conversation,
.user-profile {
  outline: none;
}
.btn:focus-visible,
.icon-btn:focus-visible,
.top-icon:focus-visible,
.inbox-filter:focus-visible,
.conversation:focus-visible,
.user-profile:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 26%, transparent) !important;
  border-color: var(--green) !important;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
@media (max-width: 760px) {
  html[data-layout="mobile"] .topbar {
    min-height: 62px !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    overflow: visible !important;
  }
  html[data-layout="mobile"] .brand {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  html[data-layout="mobile"] .brand h1 {
    font-size: 16px !important;
  }
  html[data-layout="mobile"] .top-actions {
    flex: 0 0 auto !important;
    gap: 6px !important;
  }
  html[data-layout="mobile"] .top-search,
  html[data-layout="mobile"] .stats,
  html[data-layout="mobile"] .user-profile span,
  html[data-layout="mobile"] .health {
    display: none !important;
  }
  html[data-layout="mobile"] #view-inbox .inbox-layout {
    grid-template-columns: 1fr !important;
    height: calc(100dvh - 62px) !important;
  }
  html[data-layout="mobile"] #view-inbox .conv-sidebar {
    height: calc(100dvh - 136px) !important;
    max-height: none !important;
    grid-template-rows: auto auto auto minmax(0, 1fr) !important;
  }
  html[data-layout="mobile"] .side-head {
    padding: 12px 14px 8px !important;
  }
  html[data-layout="mobile"] .inbox-head-actions {
    max-width: 190px !important;
    gap: 6px !important;
  }
  html[data-layout="mobile"] .filters {
    padding: 10px 14px !important;
  }
  html[data-layout="mobile"] #conversationSearch {
    height: 40px !important;
    min-height: 40px !important;
    font-size: 13px !important;
  }
  html[data-layout="mobile"] .inbox-bulk-bar.show {
    display: flex !important;
  }
  html[data-layout="mobile"] .inbox-bulk-bar {
    position: relative !important;
    min-height: 42px !important;
    padding: 7px 10px !important;
    gap: 6px !important;
    overflow-x: auto !important;
  }
  html[data-layout="mobile"] .inbox-bulk-count {
    flex: 0 0 auto !important;
  }
  html[data-layout="mobile"] .conversation {
    grid-template-columns: 20px 38px minmax(0, 1fr) 42px !important;
    min-height: 68px !important;
    padding: 8px 12px !important;
    gap: 8px !important;
  }
  html[data-layout="mobile"] .conversation .avatar {
    width: 38px !important;
    height: 38px !important;
  }
  html[data-layout="mobile"] .conv-name {
    font-size: 13px !important;
  }
  html[data-layout="mobile"] .conv-preview {
    -webkit-line-clamp: 1 !important;
    max-height: 18px !important;
  }
  html[data-layout="mobile"] #inboxPager {
    display: none !important;
  }
  html.chat-open[data-layout="mobile"] #chatPanel.chat {
    grid-template-rows: 58px minmax(0, 1fr) auto auto auto !important;
  }
  html.chat-open[data-layout="mobile"] .chat-head {
    min-height: 58px !important;
    padding: 8px 10px !important;
    gap: 8px !important;
  }
  html.chat-open[data-layout="mobile"] .chat-title strong,
  html.chat-open[data-layout="mobile"] .chat-title .tiny {
    max-width: 42vw !important;
  }
  html.chat-open[data-layout="mobile"] .chat-actions {
    gap: 4px !important;
  }
  html.chat-open[data-layout="mobile"] .chat-actions .icon-btn {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    border-radius: 10px !important;
  }
  html.chat-open[data-layout="mobile"] .messages {
    padding: 12px 10px !important;
  }
  html.chat-open[data-layout="mobile"] .reply {
    grid-template-columns: minmax(0, 1fr) 54px !important;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
    gap: 8px !important;
  }
  html.chat-open[data-layout="mobile"] .reply textarea {
    min-height: 48px !important;
    padding: 12px !important;
  }
  html.chat-open[data-layout="mobile"] #replyBtn {
    width: 54px !important;
    min-width: 54px !important;
    min-height: 48px !important;
  }
}
.super-crm-panel {
  margin: 14px 0;
}
.super-crm-command {
  margin: 16px 0;
  border: 1px solid rgba(37, 211, 102, 0.22) !important;
  background:
    linear-gradient(135deg, rgba(37, 211, 102, 0.08), rgba(76, 201, 240, 0.04)),
    var(--saas-card) !important;
}
.super-crm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.super-kpi {
  padding: 14px;
  border: 1px solid var(--saas-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  min-height: 104px;
}
html[data-theme="normal"] .super-kpi {
  background: rgba(255, 255, 255, 0.72);
}
.super-kpi span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.super-kpi strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}
.super-kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}
.super-crm-actions,
.super-crm-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.super-crm-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.super-crm-form textarea {
  grid-column: span 2;
  min-height: 52px;
  resize: vertical;
}
.super-crm-bulk {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.super-crm-bulk strong {
  color: var(--text);
  min-width: 90px;
}
.super-crm-board,
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.crm-column {
  border: 1px solid var(--saas-border);
  border-radius: 16px;
  background: var(--saas-card);
  min-height: 220px;
  overflow: hidden;
}
.crm-column-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--saas-border);
  color: var(--text);
  font-weight: 900;
}
.crm-column-head span {
  color: var(--muted);
  font-size: 12px;
}
.crm-column-list {
  display: grid;
  gap: 10px;
  padding: 12px;
  max-height: 62vh;
  overflow: auto;
}
.crm-lead-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.035);
}
html[data-theme="normal"] .crm-lead-card {
  background: #fff;
}
.crm-lead-card strong {
  color: var(--text);
}
.crm-lead-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.crm-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.advanced-lead-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.advanced-lead-filters .btn {
  min-height: 44px;
}
.crm-column.drag-over {
  outline: 2px solid var(--green);
  outline-offset: -4px;
  background: color-mix(in srgb, var(--green) 10%, var(--saas-card));
}
.crm-lead-card[draggable="true"] {
  cursor: grab;
}
.crm-lead-card.dragging {
  opacity: .58;
  transform: scale(.99);
}
.timeline-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(460px, 100vw);
  z-index: 120;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px rgba(0,0,0,.22);
}
.timeline-drawer.show {
  display: grid;
}
.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.timeline-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}
.timeline-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.timeline-list {
  overflow: auto;
  padding: 16px 18px 24px;
}
.timeline-item {
  position: relative;
  padding: 0 0 16px 24px;
  border-left: 1px solid var(--line);
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 2px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 16%, transparent);
}
.timeline-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.timeline-item p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.45;
}
.timeline-item time {
  color: var(--muted);
  font-size: 11px;
}
.crm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(0,0,0,.52);
  backdrop-filter: blur(8px);
}
.crm-modal-overlay.show { display: grid; }
.crm-modal {
  width: min(920px, 100%);
  max-height: min(86vh, 820px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(0,0,0,.34);
}
.crm-modal.small { width: min(540px, 100%); }
.crm-modal-head,
.crm-modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.crm-modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}
.crm-modal-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}
.crm-modal-body {
  overflow: auto;
  padding: 18px;
}
.crm-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.crm-detail {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, var(--green) 3%);
}
.crm-detail span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.crm-detail strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  word-break: break-word;
}
.crm-remark-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.crm-remark {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255,255,255,.035);
}
.crm-remark small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.crm-scorebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.crm-scorebar i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.crm-scorebar b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}
.rk-bucket-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}
.rk-bucket {
  border: 1px solid var(--saas-border);
  border-radius: 16px;
  background: var(--saas-card);
  overflow: hidden;
}
.rk-bucket-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 900;
}
.rk-bucket-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}
/* RK Calling Dashboard - premium CRM command center */
.calling-dashboard {
  --call-bg: color-mix(in srgb, var(--panel) 90%, transparent);
  --call-ink: var(--text);
  --call-muted: var(--muted);
  --call-line: color-mix(in srgb, var(--line) 82%, transparent);
  --call-green: #16a34a;
  --call-gold: #b7791f;
  --call-red: #dc2626;
}
.calling-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--call-line);
  border-radius: 22px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--panel) 96%, #fff 4%), color-mix(in srgb, var(--green-soft) 72%, var(--panel) 28%));
  box-shadow: 0 20px 60px rgba(15, 23, 42, .08);
}
.calling-hero .page-title {
  margin: 4px 0 0;
  font-size: clamp(28px, 3vw, 44px);
  letter-spacing: -0.03em;
}
.calling-hero .page-subtitle {
  max-width: 760px;
}
.calling-hero-actions,
.calling-toolbar,
.calling-filter,
.calling-ops {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.calling-hero-actions {
  justify-content: flex-end;
}
.calling-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.calling-kpi {
  position: relative;
  overflow: hidden;
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--call-line);
  border-radius: 20px;
  background: var(--call-bg);
  box-shadow: 0 14px 36px rgba(15, 23, 42, .07);
}
.calling-kpi::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -30px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--green) 12%, transparent);
}
.calling-kpi span,
.calling-kpi small {
  display: block;
  color: var(--call-muted);
}
.calling-kpi span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.calling-kpi strong {
  display: block;
  margin-top: 12px;
  color: var(--call-ink);
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
  letter-spacing: -0.04em;
}
.calling-kpi small {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.35;
}
.calling-kpi.accent { border-color: color-mix(in srgb, var(--green) 30%, var(--call-line)); }
.calling-kpi.good::after { background: color-mix(in srgb, var(--call-green) 18%, transparent); }
.calling-kpi.urgent::after { background: color-mix(in srgb, var(--call-red) 14%, transparent); }
.calling-kpi.hot::after { background: color-mix(in srgb, var(--call-gold) 18%, transparent); }
.calling-toolbar {
  justify-content: space-between;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--call-line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
}
.calling-filter {
  flex: 1 1 520px;
}
.calling-filter input,
.calling-filter select {
  min-height: 42px;
  border-radius: 13px;
}
.calling-filter input {
  flex: 1 1 280px;
  min-width: 220px;
}
.calling-filter select {
  flex: 0 1 190px;
}
.calling-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr);
  gap: 14px;
  margin-top: 14px;
}
.calling-grid.bottom {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.calling-panel {
  min-width: 0;
  border: 1px solid var(--call-line);
  border-radius: 20px;
  background: var(--call-bg);
  box-shadow: 0 14px 36px rgba(15, 23, 42, .07);
}
.calling-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--call-line);
}
.calling-panel-head strong {
  display: block;
  font-size: 15px;
  letter-spacing: .01em;
}
.calling-panel-head span,
.calling-panel-head small {
  display: block;
  margin-top: 4px;
  color: var(--call-muted);
  font-size: 12px;
}
.calling-list {
  display: grid;
  gap: 10px;
  padding: 12px;
  max-height: 560px;
  overflow: auto;
}
.calling-list.compact {
  max-height: 420px;
}
.calling-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--call-line) 78%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.calling-row:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--green) 35%, var(--call-line));
  box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
}
.calling-rank {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: var(--call-ink);
  font-weight: 900;
}
.calling-main {
  min-width: 0;
}
.calling-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.calling-main span,
.calling-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--call-muted);
  font-size: 12px;
}
.calling-main span {
  margin-top: 3px;
}
.calling-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.calling-score,
.calling-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--call-ink);
}
.calling-score.hot {
  background: color-mix(in srgb, var(--call-gold) 20%, transparent);
}
.calling-board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--call-line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
}
.calling-board-row strong,
.calling-board-row span {
  display: block;
}
.calling-board-row span {
  color: var(--call-muted);
  font-size: 12px;
}
.calling-board-stats {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.calling-mini-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.calling-mini {
  padding: 14px;
  border: 1px solid var(--call-line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}
.calling-mini span,
.calling-mini small {
  display: block;
  color: var(--call-muted);
  font-size: 12px;
}
.calling-mini strong {
  display: block;
  margin-top: 8px;
  color: var(--call-ink);
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.03em;
}
.calling-mini small {
  margin-top: 6px;
}
.calling-admin-suite {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--green) 22%, var(--call-line));
  border-radius: 22px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--panel) 92%, var(--green) 5%), color-mix(in srgb, var(--surface) 94%, transparent)),
    radial-gradient(circle at top right, color-mix(in srgb, var(--green) 13%, transparent), transparent 34%);
  box-shadow: 0 22px 64px rgba(15, 23, 42, .10);
}
.calling-admin-suite[hidden] {
  display: none !important;
}
.calling-admin-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  padding: 4px 4px 14px;
}
.calling-admin-head h3 {
  margin: 4px 0 0;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.05;
  letter-spacing: -0.025em;
}
.calling-admin-head p {
  max-width: 780px;
  margin: 7px 0 0;
  color: var(--call-muted);
  font-size: 13px;
  line-height: 1.45;
}
.calling-admin-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--green) 28%, var(--call-line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 12%, var(--panel));
  color: var(--call-ink);
  font-size: 12px;
  font-weight: 900;
}
.calling-admin-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}
.calling-admin-kpi {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--call-line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 10px 26px rgba(15, 23, 42, .06);
}
.calling-admin-kpi span,
.calling-admin-kpi small {
  display: block;
  overflow: hidden;
  color: var(--call-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calling-admin-kpi span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.calling-admin-kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.04em;
}
.calling-admin-kpi small {
  margin-top: 7px;
  font-size: 11px;
}
.calling-admin-kpi.good { border-color: color-mix(in srgb, #16a34a 28%, var(--call-line)); }
.calling-admin-kpi.warn { border-color: color-mix(in srgb, #d97706 34%, var(--call-line)); }
.calling-admin-kpi.bad { border-color: color-mix(in srgb, #dc2626 34%, var(--call-line)); }
.calling-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, .8fr);
  gap: 12px;
  margin-top: 12px;
}
.calling-admin-grid.lower {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.calling-admin-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--call-line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 93%, transparent);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .07);
}
.calling-matrix {
  display: grid;
  gap: 8px;
  padding: 12px;
  max-height: 520px;
  overflow: auto;
}
.calling-matrix-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) repeat(7, minmax(54px, .55fr)) minmax(72px, .7fr);
  align-items: center;
  gap: 8px;
  min-width: 780px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--call-line) 78%, transparent);
  border-radius: 13px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  font-size: 12px;
}
.calling-matrix-row.head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--surface) 92%, var(--green) 5%);
  color: var(--call-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.calling-matrix-row strong {
  overflow: hidden;
  color: var(--call-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calling-health,
.calling-risk-mark {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}
.calling-health.good { background: color-mix(in srgb, #16a34a 15%, transparent); color: #15803d; }
.calling-health.warn { background: color-mix(in srgb, #d97706 18%, transparent); color: #a16207; }
.calling-health.bad { background: color-mix(in srgb, #dc2626 16%, transparent); color: #b91c1c; }
.calling-risk-mark {
  width: 34px;
  height: 34px;
  background: color-mix(in srgb, #dc2626 16%, transparent);
  color: #b91c1c;
}
.calling-row.risk {
  border-color: color-mix(in srgb, #dc2626 22%, var(--call-line));
}
.calling-pulse-row,
.calling-quality {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--call-line) 80%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
}
.calling-pulse-row strong,
.calling-pulse-row span,
.calling-pulse-row small,
.calling-quality strong,
.calling-quality span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calling-pulse-row strong,
.calling-quality strong {
  font-size: 13px;
}
.calling-pulse-row span,
.calling-pulse-row small,
.calling-quality span {
  color: var(--call-muted);
  font-size: 12px;
}
.calling-quality {
  grid-template-columns: minmax(110px, .55fr) minmax(0, 1fr);
}
.calling-quality.warn { border-color: color-mix(in srgb, #d97706 22%, var(--call-line)); }
.calling-quality.bad { border-color: color-mix(in srgb, #dc2626 22%, var(--call-line)); }
.calling-bucket-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}
.calling-bucket {
  min-width: 0;
  border: 1px solid var(--call-line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  overflow: hidden;
}
.calling-bucket-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--call-line);
  font-size: 12px;
  font-weight: 900;
}
.calling-bucket-body {
  display: grid;
  gap: 8px;
  padding: 10px;
  max-height: 250px;
  overflow: auto;
}
.calling-tiny-lead {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--call-line) 80%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
}
.calling-tiny-lead strong,
.calling-tiny-lead span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calling-tiny-lead strong {
  font-size: 12px;
}
.calling-tiny-lead span {
  color: var(--call-muted);
  font-size: 11px;
}
.calling-activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 15%, transparent);
}
.calling-roi {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--call-line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
}
.calling-roi strong,
.calling-roi span {
  display: block;
}
.calling-roi span {
  color: var(--call-muted);
  font-size: 12px;
}
.calling-attendance-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.calling-control-stack {
  display: grid;
  gap: 8px;
}
html[data-theme="dark"] .calling-hero {
  background: linear-gradient(135deg, rgba(10, 20, 16, .94), rgba(13, 39, 28, .88));
}
@media (max-width: 900px) {
  .advanced-lead-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-detail-grid,
  .rk-bucket-body { grid-template-columns: 1fr; }
  .calling-bucket-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .super-crm-kpi-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .calling-kpi-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .calling-mini-kpis { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .calling-admin-kpis { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .calling-admin-grid,
  .calling-admin-grid.lower { grid-template-columns: 1fr; }
  .calling-grid,
  .calling-grid.bottom { grid-template-columns: 1fr; }
  .super-crm-board,
  .pipeline-board { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .super-crm-form { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 640px) {
  .super-crm-kpi-grid { grid-template-columns: 1fr; }
  .calling-dashboard { padding-bottom: 88px; }
  .calling-hero,
  .calling-toolbar { align-items: stretch; flex-direction: column; }
  .calling-hero { padding: 14px; border-radius: 18px; }
  .calling-hero-actions .btn,
  .calling-ops .btn { flex: 1 1 auto; }
  .calling-kpi-grid,
  .calling-mini-kpis,
  .calling-admin-kpis,
  .calling-grid,
  .calling-grid.bottom { grid-template-columns: 1fr; }
  .calling-admin-suite { padding: 10px; border-radius: 18px; }
  .calling-admin-head { grid-template-columns: 1fr; }
  .calling-admin-status { justify-content: center; width: 100%; }
  .calling-matrix { overflow-x: auto; }
  .calling-kpi { min-height: 108px; padding: 15px; }
  .calling-filter input,
  .calling-filter select { min-width: 100%; flex-basis: 100%; }
  .calling-row { grid-template-columns: auto minmax(0, 1fr); }
  .calling-actions { grid-column: 1 / -1; justify-content: stretch; }
  .calling-actions .btn { flex: 1 1 auto; }
  .super-crm-board,
  .pipeline-board { grid-template-columns: 1fr; }
  .super-crm-form { grid-template-columns: 1fr; }
  .super-crm-form textarea { grid-column: auto; }
  .super-crm-actions .btn,
  .super-crm-bulk .btn,
  .super-crm-bulk select,
  .super-crm-bulk input {
    width: 100%;
  }
  .advanced-lead-filters { grid-template-columns: 1fr; }
}
.login-screen {
  overflow-x: hidden !important;
}
.login-card {
  box-sizing: border-box !important;
}
@media (max-width: 480px) {
  .login-screen {
    width: 100vw !important;
    min-width: 0 !important;
    padding: 16px !important;
    place-items: center !important;
  }
  .login-card {
    width: calc(100vw - 64px) !important;
    max-width: 360px !important;
    min-width: 0 !important;
    padding: 22px 18px !important;
    overflow: hidden !important;
  }
  .login-brand {
    min-width: 0 !important;
  }
  .login-brand > div:last-child {
    min-width: 0 !important;
  }
  .login-card input,
  .login-card button,
  .login-card .login-field,
  .login-card .login-help,
  .login-card .login-alert {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .login-card h1,
  .login-card p,
  .login-help {
    overflow-wrap: anywhere !important;
  }
}
/* Last-mile premium override: keeps the CRM dense, stable and enterprise-grade. */
body {
  font-family: "DM Sans", Inter, Arial, sans-serif !important;
}
.topbar {
  min-height: 72px !important;
  padding: 12px 18px !important;
  gap: 12px !important;
  background: color-mix(in srgb, var(--surface) 88%, transparent) !important;
  border-bottom: 1px solid var(--rk-border, var(--line)) !important;
  box-shadow: 0 12px 34px rgba(0,0,0,.18) !important;
  backdrop-filter: blur(16px) !important;
}
.brand {
  flex: 0 1 280px !important;
  min-width: 200px !important;
}
.brand h1 {
  font-size: 20px !important;
  font-weight: 850 !important;
  letter-spacing: -0.01em !important;
}
.brand p {
  max-width: 250px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.stats {
  width: auto !important;
  flex: 0 0 auto !important;
  grid-template-columns: repeat(4, minmax(88px, 106px)) !important;
  gap: 8px !important;
}
.stat {
  min-width: 0 !important;
  padding: 8px 10px !important;
  border-radius: 14px !important;
  border-color: var(--rk-border, var(--line)) !important;
  background: color-mix(in srgb, var(--surface) 84%, var(--green) 4%) !important;
}
.stat strong {
  font-size: 20px !important;
  line-height: 1 !important;
  font-weight: 900 !important;
}
.stat span {
  color: var(--muted) !important;
  font-size: 11px !important;
}
.top-actions {
  flex: 1 1 390px !important;
  min-width: 0 !important;
  gap: 8px !important;
}
.top-search {
  flex: 1 1 300px !important;
  min-width: 220px !important;
  max-width: 420px !important;
  height: 44px !important;
  border-radius: 14px !important;
  border-color: var(--rk-border, var(--line)) !important;
  background: color-mix(in srgb, var(--surface) 90%, transparent) !important;
}
.top-search input {
  min-width: 0 !important;
  font-size: 14px !important;
}
.top-icon,
.user-profile,
.layout-switch,
.theme-switch {
  flex: 0 0 auto !important;
  border-radius: 14px !important;
  border-color: var(--rk-border, var(--line)) !important;
  background: color-mix(in srgb, var(--surface) 90%, transparent) !important;
}
.top-icon,
.user-profile {
  height: 44px !important;
}
.user-profile {
  max-width: 168px !important;
  overflow: hidden !important;
}
.user-profile strong,
.user-profile span span {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.layout-option,
.theme-option {
  min-width: 38px !important;
  min-height: 36px !important;
  border-radius: 11px !important;
}
.layout-option.active,
.theme-option.active,
.btn-primary,
.btn-wa,
.inbox-filter.active {
  background: linear-gradient(135deg, var(--green), var(--green-2)) !important;
  color: #06120b !important;
  border-color: transparent !important;
  box-shadow: 0 12px 24px color-mix(in srgb, var(--green) 18%, transparent) !important;
}
.tabs {
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--green) 13%, transparent), transparent 230px),
    color-mix(in srgb, var(--surface) 92%, #020806 8%) !important;
  border-right: 1px solid var(--rk-border, var(--line)) !important;
}
.tab {
  min-height: 46px !important;
  border-radius: 14px !important;
  border: 1px solid transparent !important;
}
.tab.active {
  border-color: color-mix(in srgb, var(--green) 34%, transparent) !important;
  background: linear-gradient(135deg, color-mix(in srgb, var(--green) 18%, transparent), rgba(76,201,240,.06)) !important;
  box-shadow: 0 14px 32px color-mix(in srgb, var(--green) 12%, transparent) !important;
}
.main {
  background:
    radial-gradient(circle at 82% 0%, color-mix(in srgb, var(--green) 8%, transparent), transparent 360px),
    var(--surface-2) !important;
}
.dashboard-shell,
.super-crm-panel,
.card,
.analytics-card,
.settings-card,
.composer-card,
.crm-lead-card,
.pipeline-column,
.followup-card,
.media-card,
.super-kpi {
  border-color: var(--rk-border, var(--line)) !important;
  border-radius: 18px !important;
  background: color-mix(in srgb, var(--surface) 93%, transparent) !important;
  box-shadow: 0 14px 34px rgba(0,0,0,.13) !important;
}
.inbox-bulk-bar {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) repeat(3, auto) !important;
  align-items: center !important;
  gap: 8px !important;
  min-height: 48px !important;
  padding: 8px 12px !important;
  overflow: hidden !important;
}
.inbox-bulk-count {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.inbox-bulk-bar .btn {
  min-height: 32px !important;
  padding: 7px 10px !important;
  white-space: nowrap !important;
}
.conversation {
  grid-template-columns: 20px 40px minmax(0,1fr) auto !important;
  min-height: 76px !important;
  padding: 10px 14px !important;
  gap: 10px !important;
}
.conversation strong {
  font-weight: 850 !important;
}
.conv-preview {
  color: color-mix(in srgb, var(--muted) 88%, var(--text) 12%) !important;
}
.chat {
  background:
    radial-gradient(circle at 18px 18px, rgba(255,255,255,.035) 1px, transparent 1px) 0 0/23px 23px,
    linear-gradient(180deg, color-mix(in srgb, var(--green) 6%, transparent), transparent 220px),
    var(--surface-2) !important;
}
.chat-head {
  min-height: 70px !important;
  border-color: var(--rk-border, var(--line)) !important;
}
.reply {
  border-color: var(--rk-border, var(--line)) !important;
}
@media (max-width: 1580px) {
  .stats {
    grid-template-columns: repeat(4, minmax(74px, 92px)) !important;
  }
  .top-search {
    max-width: 340px !important;
  }
}
@media (max-width: 1360px) {
  .brand {
    min-width: 185px !important;
    flex-basis: 220px !important;
  }
  .brand p,
  .stat span {
    display: none !important;
  }
  .stats {
    grid-template-columns: repeat(4, 64px) !important;
  }
  .stat strong {
    text-align: center !important;
    font-size: 18px !important;
  }
  .user-profile {
    min-width: 44px !important;
    width: 44px !important;
  }
  .user-profile > span:not(.user-avatar-small) {
    display: none !important;
  }
}
@media (max-width: 1180px) {
  .stats {
    display: none !important;
  }
  .top-search {
    max-width: none !important;
  }
}
@media (max-width: 760px) {
  html[data-layout="mobile"] .topbar {
    min-height: 54px !important;
    height: 54px !important;
    padding: 7px 10px !important;
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) auto !important;
  }
  html[data-layout="mobile"] .brand {
    min-width: 0 !important;
  }
  html[data-layout="mobile"] .top-search,
  html[data-layout="mobile"] .stats,
  html[data-layout="mobile"] .health,
  html[data-layout="mobile"] #logoutBtn,
  html[data-layout="mobile"] .brand p {
    display: none !important;
  }
  html[data-layout="mobile"] .conversation {
    min-height: 66px !important;
    padding: 8px 12px !important;
  }
  html[data-layout="mobile"] .inbox-bulk-bar {
    grid-template-columns: auto minmax(0, 1fr) !important;
    overflow-x: auto !important;
  }
}

/* Emergency layout stabilizer: prevent premium layer from squeezing/overlapping UI. */
html,
body,
.app,
.main,
.view,
.inbox-layout,
.dashboard-shell,
.super-crm-panel,
.chat,
.conv-sidebar {
  min-width: 0 !important;
}
body {
  overflow-x: hidden !important;
}
.topbar {
  overflow: hidden !important;
  flex-wrap: nowrap !important;
}
.brand,
.top-actions,
.top-search,
.user-profile,
.chat-title,
.lead-chips,
.conversation > span,
.crm-lead-card,
.super-crm-panel,
.card {
  min-width: 0 !important;
}
.top-actions {
  overflow: hidden !important;
}
.top-search input,
.brand h1,
.brand p,
.user-profile strong,
.user-profile span span,
.conv-name,
.conv-preview {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.inbox-bulk-bar {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  overflow: visible !important;
}
.inbox-bulk-bar .btn {
  flex: 0 0 auto !important;
}
.reply {
  grid-template-columns: minmax(0, 1fr) minmax(74px, 96px) !important;
  overflow: hidden !important;
}
.reply textarea,
.reply input {
  min-width: 0 !important;
}
.modern-table,
table {
  min-width: 0 !important;
}
.table-wrap,
.modern-table-wrap,
.analytics-table-wrap,
.reports-table-wrap {
  overflow-x: auto !important;
}
@media (max-width: 1500px) {
  .stats {
    display: none !important;
  }
  .brand {
    flex-basis: 260px !important;
  }
}
@media (max-width: 1180px) {
  .top-search {
    min-width: 180px !important;
    max-width: none !important;
  }
  .brand {
    min-width: 172px !important;
    flex-basis: 210px !important;
  }
  .brand p {
    display: none !important;
  }
}
@media (max-width: 920px) {
  .top-search {
    display: none !important;
  }
  .topbar {
    min-height: 62px !important;
  }
}
@media (max-width: 760px) {
  html[data-layout="mobile"],
  html[data-layout="mobile"] body {
    width: 100vw !important;
    overflow-x: hidden !important;
  }
  html[data-layout="mobile"] .app {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    grid-template-rows: 56px minmax(0, 1fr) !important;
  }
  html[data-layout="mobile"] .topbar {
    min-height: 56px !important;
    height: 56px !important;
    overflow: hidden !important;
    grid-template-columns: 36px minmax(0, 1fr) auto !important;
  }
  html[data-layout="mobile"] .brand {
    flex: 1 1 auto !important;
    max-width: none !important;
  }
  html[data-layout="mobile"] .brand h1 {
    max-width: 42vw !important;
    white-space: nowrap !important;
  }
  html[data-layout="mobile"] .top-actions {
    max-width: 45vw !important;
    overflow: hidden !important;
    justify-content: flex-end !important;
  }
  html[data-layout="mobile"] .user-profile {
    display: none !important;
  }
  html[data-layout="mobile"] .layout-switch,
  html[data-layout="mobile"] .theme-switch {
    display: inline-flex !important;
    min-width: 0 !important;
  }
  html[data-layout="mobile"] .layout-option,
  html[data-layout="mobile"] .theme-option {
    min-width: 30px !important;
    width: 30px !important;
  }
  html[data-layout="mobile"] #view-inbox .inbox-layout {
    height: calc(100dvh - 56px) !important;
    max-width: 100vw !important;
    overflow: hidden !important;
  }
  html[data-layout="mobile"] .reply {
    grid-template-columns: minmax(0, 1fr) 58px !important;
    width: 100% !important;
  }
html[data-layout="mobile"] #replyBtn {
    width: 58px !important;
    min-width: 58px !important;
  }
}

/* RK Super CRM final polish: classic calling CRM panels and startup safety */
.startup-error-card {
  margin: 18px auto;
  max-width: 920px;
  padding: 16px 18px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(254, 242, 242, 0.96), rgba(255, 255, 255, 0.96));
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  color: #1f2937;
  z-index: 20;
}

.startup-error-card strong {
  display: block;
  margin-bottom: 6px;
  color: #991b1b;
  font-size: 15px;
}

.startup-error-card p {
  margin: 0;
  color: #7f1d1d;
  line-height: 1.45;
}

.rk-classic-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.rk-classic-dashboard .saas-card {
  min-width: 0;
}

.rk-classic-wide {
  grid-column: span 2;
}

.rk-classic-row,
.rk-classic-cardline {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(90px, 1.4fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.rk-classic-cardline {
  grid-template-columns: minmax(0, 1fr) auto;
}

.rk-classic-row:hover,
.rk-classic-cardline:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.rk-classic-row i,
.rk-classic-month i {
  position: relative;
  display: block;
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
}

.rk-classic-row i b,
.rk-classic-month i b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #34d399);
}

.rk-classic-cardline strong,
.rk-classic-row strong {
  font-weight: 800;
}

.rk-classic-cardline span,
.rk-classic-row span {
  color: var(--muted);
  font-size: 12px;
}

.rk-classic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.rk-classic-months {
  display: grid;
  grid-template-columns: repeat(12, minmax(34px, 1fr));
  gap: 8px;
  min-height: 150px;
  align-items: end;
}

.rk-classic-month {
  display: grid;
  grid-template-rows: auto 86px auto;
  gap: 6px;
  align-items: end;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

.rk-classic-month i {
  width: 100%;
  height: 86px;
  display: flex;
  align-items: end;
}

.rk-classic-month i b {
  width: 100%;
  height: 10%;
}

.lead-badge-stack {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.status-badge.muted {
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
}

.table-remark {
  display: -webkit-box;
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.lead-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 5px;
}

.lead-count-chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  color: var(--text);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0;
}

.success-text {
  color: var(--accent);
  font-weight: 700;
}

/* Leads cockpit: keep RK CRM columns dense without wrapping into giant rows */
#view-leads .modern-table-wrap {
  max-height: calc(100dvh - 310px);
  min-height: 420px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-2) 92%, transparent);
}

#view-leads .modern-table {
  width: max-content;
  min-width: 1680px !important;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

#view-leads .modern-table th,
#view-leads .modern-table td {
  padding: 11px 12px;
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1.25;
}

#view-leads .modern-table th {
  top: 0;
  height: 46px;
  background: color-mix(in srgb, var(--panel-2) 94%, var(--accent) 6%);
  box-shadow: 0 1px 0 var(--border);
  font-size: 11px;
}

#view-leads .modern-table tbody tr {
  height: 74px;
  transition: background .16s ease, box-shadow .16s ease;
}

#view-leads .modern-table tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

#view-leads .modern-table th:nth-child(1),
#view-leads .modern-table td:nth-child(1) { width: 42px; text-align: center; }
#view-leads .modern-table th:nth-child(2),
#view-leads .modern-table td:nth-child(2) { width: 46px; text-align: center; }
#view-leads .modern-table th:nth-child(3),
#view-leads .modern-table td:nth-child(3) { width: 86px; }
#view-leads .modern-table th:nth-child(4),
#view-leads .modern-table td:nth-child(4) { width: 178px; }
#view-leads .modern-table th:nth-child(5),
#view-leads .modern-table td:nth-child(5) { width: 124px; }
#view-leads .modern-table th:nth-child(6),
#view-leads .modern-table td:nth-child(6) { width: 108px; }
#view-leads .modern-table th:nth-child(7),
#view-leads .modern-table td:nth-child(7) { width: 136px; }
#view-leads .modern-table th:nth-child(8),
#view-leads .modern-table td:nth-child(8) { width: 128px; }
#view-leads .modern-table th:nth-child(9),
#view-leads .modern-table td:nth-child(9) { width: 118px; }
#view-leads .modern-table th:nth-child(10),
#view-leads .modern-table td:nth-child(10) { width: 126px; }
#view-leads .modern-table th:nth-child(11),
#view-leads .modern-table td:nth-child(11) { width: 124px; }
#view-leads .modern-table th:nth-child(12),
#view-leads .modern-table td:nth-child(12) { width: 96px; }
#view-leads .modern-table th:nth-child(13),
#view-leads .modern-table td:nth-child(13) { width: 104px; }
#view-leads .modern-table th:nth-child(14),
#view-leads .modern-table td:nth-child(14) { width: 86px; }
#view-leads .modern-table th:nth-child(15),
#view-leads .modern-table td:nth-child(15) { width: 96px; }
#view-leads .modern-table th:nth-child(16),
#view-leads .modern-table td:nth-child(16) { width: 160px; }
#view-leads .modern-table th:nth-child(17),
#view-leads .modern-table td:nth-child(17) { width: 470px; }

#view-leads .modern-table td:nth-child(4) strong,
#view-leads .modern-table td:nth-child(7),
#view-leads .modern-table td:nth-child(8),
#view-leads .modern-table td:nth-child(16) {
  white-space: normal;
}

#view-leads .row-actions {
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  max-width: 460px;
  padding-bottom: 2px;
  align-items: center;
}

#view-leads .row-actions .btn {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.lead-more-select {
  flex: 0 0 auto;
  min-height: 28px;
  max-width: 92px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  outline: none;
  cursor: pointer;
}

.lead-more-select:hover,
.lead-more-select:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

#view-leads .crm-scorebar {
  min-width: 74px;
}

#view-leads .pager {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

@media (max-width: 760px) {
  #view-leads .dashboard-shell {
    padding: 10px 8px 118px;
  }

  #view-leads .page-head {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
  }

  #view-leads .page-title {
    font-size: 22px;
    line-height: 1.15;
  }

  #view-leads .page-subtitle {
    display: none;
  }

  #view-leads .lead-toolbar,
  #view-leads .advanced-lead-filters {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    padding: 10px !important;
    border-radius: 18px !important;
    background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
    border: 1px solid var(--border) !important;
  }

  #view-leads .lead-toolbar input:first-child,
  #view-leads .advanced-lead-filters #clearLeadFiltersBtn {
    grid-column: 1 / -1;
  }

  #view-leads .lead-toolbar input,
  #view-leads .lead-toolbar select,
  #view-leads .advanced-lead-filters input,
  #view-leads .advanced-lead-filters select,
  #view-leads .advanced-lead-filters button {
    min-width: 0 !important;
    min-height: 42px !important;
    border-radius: 14px !important;
    font-size: 13px !important;
  }

  #view-leads .super-crm-panel {
    padding: 12px !important;
    border-radius: 20px !important;
  }

  #view-leads .super-crm-panel.lead-editor-closed {
    padding: 10px !important;
    border-radius: 18px !important;
  }

  #view-leads .super-crm-panel .card-title {
    font-size: 13px !important;
    gap: 6px;
  }

  #view-leads .super-crm-panel .card-title span {
    display: none;
  }

  #view-leads .super-crm-panel.lead-editor-closed .card-title {
    margin-bottom: 8px;
  }

  #view-leads .super-crm-panel.lead-editor-closed .card-title::after {
    content: "Tap New Lead or Edit to open";
    display: inline-flex;
    margin-left: auto;
    padding: 4px 9px;
    border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
    border-radius: 999px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
  }

  #view-leads .super-crm-actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding: 2px 0 8px !important;
    scroll-snap-type: x proximity;
  }

  #view-leads .super-crm-actions .btn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 112px !important;
    min-height: 38px !important;
    padding: 0 14px !important;
    border-radius: 999px !important;
    scroll-snap-align: start;
  }

  #view-leads .super-crm-panel.lead-editor-closed .super-crm-actions {
    padding-bottom: 0 !important;
  }

  #view-leads .super-crm-panel.lead-editor-closed .super-crm-actions .btn:not(#newLeadBtn):not(#distributeLeadsBtn):not(#repairLeadDatesBtn):not(#shuffleNotAnsweredBtn):not(#shuffleStaleFollowupsBtn) {
    display: none !important;
  }

  #view-leads .super-crm-panel.lead-editor-closed .super-crm-form,
  #view-leads .super-crm-panel.lead-editor-closed .super-crm-bulk {
    display: none !important;
  }

  #view-leads .super-crm-panel.lead-editor-open .super-crm-form,
  #view-leads .super-crm-panel.lead-editor-open .super-crm-bulk {
    animation: leadEditorReveal 180ms ease-out both;
  }

  #view-leads .super-crm-form {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  #view-leads .super-crm-form input,
  #view-leads .super-crm-form select,
  #view-leads .super-crm-form textarea {
    min-height: 42px !important;
    border-radius: 14px !important;
    font-size: 13px !important;
  }

  #view-leads .super-crm-form textarea,
  #view-leads #leadFormName,
  #view-leads #leadFormPhone,
  #view-leads #leadFormRemark {
    grid-column: 1 / -1;
  }

  #view-leads .super-crm-bulk {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    align-items: stretch !important;
  }

  #view-leads .super-crm-bulk strong,
  #view-leads .super-crm-bulk #bulkUpdateLeadsBtn {
    grid-column: 1 / -1;
  }

  #view-leads .modern-table-wrap {
    max-height: none;
    min-height: 0;
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
    padding-top: 8px;
  }

  #view-leads .modern-table {
    width: 100%;
    min-width: 0 !important;
    display: block !important;
  }

  #view-leads .modern-table tbody {
    display: grid !important;
    gap: 12px !important;
  }

  #view-leads .modern-table tbody tr {
    position: relative;
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 6px 10px;
    height: auto;
    min-height: 162px;
    padding: 16px 14px 14px !important;
    border: 1px solid var(--border) !important;
    border-radius: 22px !important;
    background: color-mix(in srgb, var(--surface) 96%, var(--accent) 4%) !important;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08) !important;
    overflow: visible !important;
  }

  #view-leads .modern-table th,
  #view-leads .modern-table td {
    display: block !important;
    width: auto !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: normal;
    min-height: 0 !important;
  }

  #view-leads .modern-table td::before {
    display: none !important;
  }

  #view-leads .modern-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    text-align: left !important;
    padding-top: 2px !important;
  }

  #view-leads .modern-table td:nth-child(2),
  #view-leads .modern-table td:nth-child(3),
  #view-leads .modern-table td:nth-child(6),
  #view-leads .modern-table td:nth-child(8),
  #view-leads .modern-table td:nth-child(9),
  #view-leads .modern-table td:nth-child(11),
  #view-leads .modern-table td:nth-child(14),
  #view-leads .modern-table td:nth-child(15) {
    display: none !important;
  }

  #view-leads .modern-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  #view-leads .modern-table td:nth-child(4) strong {
    display: block;
    font-size: 15px;
    line-height: 1.25;
    color: var(--text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view-leads .modern-table td:nth-child(5) {
    grid-column: 2;
    grid-row: 2;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  #view-leads .modern-table td:nth-child(7) {
    grid-column: 2 / -1;
    grid-row: 3;
    color: var(--text);
    font-size: 13px;
    font-weight: 750;
    overflow-wrap: anywhere;
  }

  #view-leads .modern-table td:nth-child(10) {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    max-width: 110px;
  }

  #view-leads .modern-table td:nth-child(12),
  #view-leads .modern-table td:nth-child(13) {
    display: inline-flex !important;
    grid-row: 4;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
  }

  #view-leads .modern-table td:nth-child(12) {
    grid-column: 2;
  }

  #view-leads .modern-table td:nth-child(13) {
    grid-column: 3;
    justify-self: end;
  }

  #view-leads .modern-table td:nth-child(16) {
    grid-column: 1 / -1;
    grid-row: 5;
    padding-top: 8px !important;
    border-top: 1px solid var(--border) !important;
  }

  #view-leads .lead-counts {
    gap: 5px;
    margin-bottom: 6px;
  }

  #view-leads .lead-count-chip {
    min-height: 22px;
    padding: 0 8px;
    font-size: 10px;
  }

  #view-leads .table-remark {
    max-width: none;
    font-size: 12px;
    -webkit-line-clamp: 1;
  }

  #view-leads .modern-table td:nth-child(17) {
    grid-column: 1 / -1;
    grid-row: 6;
    padding-top: 8px !important;
    position: relative;
    z-index: 2;
  }

  #view-leads .row-actions {
    max-width: 100%;
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
    flex-wrap: initial;
  }

  #view-leads .row-actions [data-lead-outcome] {
    display: none !important;
  }

  #view-leads .row-actions .btn,
  #view-leads .lead-more-select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 34px !important;
    justify-content: center;
    padding: 0 8px !important;
    font-size: 11px !important;
  }

  #view-leads .lead-more-select {
    grid-column: 1 / -1;
    text-align: center;
  }

  #view-leads .pager {
    position: static !important;
    margin: 14px 0 0;
    padding: 8px !important;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  }
}

@keyframes leadEditorReveal {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .rk-classic-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .rk-classic-dashboard,
  .rk-classic-wide {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .rk-classic-row,
  .rk-classic-cardline {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .rk-classic-actions {
    justify-content: flex-start;
  }

  .rk-classic-months {
    grid-template-columns: repeat(6, minmax(36px, 1fr));
  }
}

/* v11 premium polish layer: visual-only, backend-safe. */
:root {
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --uix-muted-readable: #b8ccc0;
}

html[data-theme="normal"] {
  --uix-muted-readable: #5b6f64;
}

body {
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif !important;
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::placeholder {
  color: var(--muted);
  opacity: 0.68;
}

:focus::placeholder {
  opacity: 0.38;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 28%, transparent);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--green) 42%, var(--muted) 18%);
}

.btn,
.top-icon,
.icon-btn,
.tab,
.conversation,
.inbox-filter,
.user-profile,
input,
select,
textarea,
.saas-card,
.card,
.table-card,
.followup-folder-card,
.calling-kpi,
.super-kpi,
.overview-card {
  border-radius: var(--radius-md);
}

.saas-card,
.card,
.table-card,
.followup-folder-card,
.calling-kpi,
.super-kpi,
.overview-card {
  border-color: color-mix(in srgb, var(--line) 78%, transparent);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.10);
}

html[data-theme="normal"] .saas-card,
html[data-theme="normal"] .card,
html[data-theme="normal"] .table-card,
html[data-theme="normal"] .followup-folder-card,
html[data-theme="normal"] .calling-kpi,
html[data-theme="normal"] .super-kpi,
html[data-theme="normal"] .overview-card {
  box-shadow: 0 16px 38px rgba(24, 76, 48, 0.08);
}

@media (hover: hover) {
  .saas-card:hover,
  .overview-card:hover,
  .followup-folder-card:hover,
  .calling-kpi:hover,
  .super-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.16);
    border-color: color-mix(in srgb, var(--green) 26%, var(--line));
  }
}

.saas-card,
.overview-card,
.followup-folder-card,
.calling-kpi,
.super-kpi {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.btn:active,
.top-icon:active,
.icon-btn:active,
.tab:active,
.conversation:active,
.inbox-filter:active,
.mobile-bottom-nav button:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.top-icon:focus-visible,
.inbox-filter:focus-visible,
.conversation:focus-visible,
.user-profile:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none !important;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--green) 28%, transparent),
    0 0 0 5px color-mix(in srgb, var(--green) 10%, transparent) !important;
  border-color: color-mix(in srgb, var(--green) 72%, var(--line)) !important;
}

.brand-sub,
.metric-note,
.page-subtitle,
.conversation-preview,
.tiny,
.table-remark,
.logs small,
.card-title span,
.meta-template span,
.lead-count-chip {
  color: var(--uix-muted-readable);
}

.stat {
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--green);
  opacity: 0.78;
}

.stat:nth-of-type(2)::before { background: var(--cyan); }
.stat:nth-of-type(3)::before { background: var(--amber); }
.stat:nth-of-type(4)::before { background: var(--rose); }

.stat strong {
  letter-spacing: 0;
}

table th,
.modern-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  cursor: default;
  letter-spacing: 0.07em;
}

.modern-table th::after {
  content: "";
}

.status-badge.converted,
.status-badge.admission,
.status-badge.admitted,
.status-badge.admission-done {
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.10);
}

.status-badge.interested,
.status-badge.warm {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 36%, transparent);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
}

.status-badge.lost,
.status-badge.not-interested,
.status-badge.cold {
  color: var(--rose);
  border-color: color-mix(in srgb, var(--rose) 34%, transparent);
  background: color-mix(in srgb, var(--rose) 10%, transparent);
}

.status-badge.follow-up,
.status-badge.followup {
  color: var(--cyan);
  border-color: color-mix(in srgb, var(--cyan) 34%, transparent);
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
}

.empty-rich {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 26px 18px;
  text-align: center;
  color: var(--uix-muted-readable);
}

.empty-rich-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 28%, transparent);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--green) 10%, transparent);
}

.empty-rich strong {
  color: var(--text);
  font-size: 15px;
}

.empty-rich p {
  margin: 0;
  max-width: 360px;
  font-size: 13px;
  line-height: 1.45;
}

.tick.pending {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.tick.read {
  color: #34b7f1 !important;
  text-shadow: 0 0 6px rgba(52, 183, 241, 0.28);
}

.tick.failed {
  color: var(--rose) !important;
}

.reply .btn-primary:hover {
  box-shadow: 0 10px 26px color-mix(in srgb, var(--green) 34%, transparent);
}

html[data-layout="mobile"] .mobile-bottom-nav button {
  gap: 4px;
  letter-spacing: 0;
}

html[data-layout="mobile"] .reply,
html[data-layout="mobile"] .chat-composer,
html[data-layout="mobile"] .composer {
  padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
}

/* Lead editor should stay closed until New Lead/Edit is clicked. */
#view-leads .super-crm-panel.lead-editor-closed .card-title::after {
  content: "Click New Lead or Edit to open";
  display: inline-flex;
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--green) 28%, var(--line));
  border-radius: 999px;
  color: var(--uix-muted-readable, var(--muted));
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

#view-leads .super-crm-panel.lead-editor-closed .super-crm-form,
#view-leads .super-crm-panel.lead-editor-closed .super-crm-bulk {
  display: none !important;
}

#view-leads .super-crm-panel.lead-editor-closed .super-crm-actions .btn:not(#newLeadBtn):not(#distributeLeadsBtn):not(#repairLeadDatesBtn):not(#shuffleNotAnsweredBtn):not(#shuffleStaleFollowupsBtn) {
  display: none !important;
}

html[data-user-role="counsellor"] .admin-settings-only,
html[data-user-role="manager"] .admin-settings-only,
html[data-user-role="counsellor"] .billing-admin-only,
html[data-user-role="manager"] .billing-admin-only,
html[data-user-role="counsellor"] .crm-sync-admin-only,
html[data-user-role="manager"] .crm-sync-admin-only {
  display: none !important;
}

#view-leads .row-actions {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  align-items: center;
  gap: 7px;
  max-width: 410px;
  overflow: visible;
}

#view-leads .row-actions .btn,
#view-leads .row-actions .lead-more-select {
  width: 100%;
  min-width: 0;
  max-width: none;
  justify-content: center;
}

/* v18 parity finish: actionable reports, follow-up paging, team attendance, mobile CRM cards */
.followup-sort-select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  font-weight: 800;
}

.followup-folder-pager {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.daily-metric-card {
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.daily-metric-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--green) 42%, var(--line));
  box-shadow: 0 18px 45px color-mix(in srgb, var(--green) 14%, transparent);
}

.daily-link {
  border: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.daily-drilldown-panel {
  margin-top: 14px;
}

#dailyDrilldownList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.attendance-team-list {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--green) 16%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--green) 7%, transparent);
}

.attendance-team-list > strong {
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.attendance-team-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
}

.attendance-team-list small {
  color: var(--uix-muted-readable, var(--muted));
  font-weight: 700;
}

@media (max-width: 760px) {
  #view-leads .modern-table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  #view-leads .modern-table,
  #view-leads .modern-table thead,
  #view-leads .modern-table tbody,
  #view-leads .modern-table tr,
  #view-leads .modern-table td {
    display: block;
    width: 100%;
  }

  #view-leads .modern-table thead {
    display: none;
  }

  #view-leads .modern-table tr {
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--green) 16%, var(--line));
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 16px 38px rgba(0, 0, 0, .10);
  }

  #view-leads .modern-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 7px 0;
    border: 0;
    white-space: normal;
  }

  #view-leads .modern-table td::before {
    content: attr(data-label);
    color: var(--uix-muted-readable, var(--muted));
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .06em;
  }

  #view-leads .modern-table td[data-label="Actions"] {
    display: block;
    padding-top: 10px;
  }

  #view-leads .modern-table td[data-label="Actions"]::before {
    display: none;
  }

  #view-leads .row-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    max-width: none;
  }

  #dailyDrilldownList {
    grid-template-columns: 1fr;
  }

  .attendance-team-list div {
    display: grid;
  }
}

.crm-card-actions {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.crm-card-actions .btn,
.crm-card-actions .lead-more-select {
  width: 100%;
  min-width: 0;
  max-width: none;
  justify-content: center;
}

.pipeline-pager {
  display: grid;
  grid-template-columns: minmax(64px, auto) 1fr minmax(64px, auto);
  gap: 8px;
  align-items: center;
  padding: 10px 2px 2px;
  color: var(--muted);
  font-size: 12px;
}

.pipeline-pager span {
  text-align: center;
  font-weight: 700;
}

.calling-chart-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 14px 0 18px;
}

.calling-chart-card {
  position: relative;
  overflow: hidden;
}

.calling-chart-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% 0%, rgba(37,211,102,0.14), transparent 34%),
    linear-gradient(135deg, rgba(76,201,240,0.06), transparent 48%);
  opacity: .9;
}

.calling-chart-card > * {
  position: relative;
  z-index: 1;
}

.calling-chart-wide {
  grid-column: span 2;
}

.calling-chart-wrap {
  min-height: 210px;
}

html[data-theme="normal"] .calling-chart-card::before {
  background:
    radial-gradient(circle at 88% 0%, rgba(37,211,102,0.12), transparent 34%),
    linear-gradient(135deg, rgba(59,130,246,0.05), transparent 48%);
}

@media (max-width: 760px) {
  #view-leads .row-actions,
  .crm-card-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #view-leads .row-actions [data-lead-outcome] {
    display: inline-flex !important;
  }
}

.premium-charts-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0 24px;
}

.performance-charts-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.performance-charts-row .premium-chart-wide {
  grid-column: span 2;
}

.performance-kpi-row {
  margin-bottom: 18px;
}

.premium-chart-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

html[data-theme="normal"] .premium-chart-card {
  background: linear-gradient(180deg, #ffffff, #f7fbf8);
}

.premium-chart-wide {
  grid-column: span 2;
}

.premium-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.premium-chart-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.premium-chart-title {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.premium-chart-wrap {
  flex: 1 1 auto;
  position: relative;
  min-height: 220px;
  width: 100%;
}

.live-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(37,211,102,0.12);
  color: var(--green);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(37,211,102,0.25);
  white-space: nowrap;
}

.live-pulse span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulseLive 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseLive {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

@media (max-width: 1280px) {
  .premium-charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calling-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calling-chart-wide {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .premium-charts-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 12px 0 18px;
  }

  .premium-chart-wide {
    grid-column: auto;
  }

  .premium-chart-card {
    border-radius: 12px;
    padding: 13px;
  }

  .premium-chart-wrap {
    min-height: 190px;
  }

  .calling-chart-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 12px 0 16px;
  }

  .calling-chart-wrap {
    min-height: 190px;
  }
}

#view-leads .super-crm-panel.lead-editor-open .super-crm-form,
#view-leads .super-crm-panel.lead-editor-open .super-crm-bulk {
  animation: leadEditorReveal 180ms ease-out both;
}

/* RK CRM parity: lead profile opens as a focused right-side work drawer. */
.lead-drawer-overlay {
  place-items: stretch end;
  padding: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.54));
}

.lead-drawer-overlay.show {
  display: grid;
}

.lead-drawer {
  width: min(560px, 100vw);
  height: 100vh;
  max-height: none;
  border-radius: 24px 0 0 24px;
  border-width: 0 0 0 1px;
  background:
    radial-gradient(circle at 16% 0%, color-mix(in srgb, var(--green) 14%, transparent), transparent 320px),
    var(--surface);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.34);
  animation: leadDrawerIn 0.22s ease both;
}

.lead-drawer .crm-modal-head {
  align-items: flex-start;
  padding: 18px 20px 14px;
  background: color-mix(in srgb, var(--surface) 92%, var(--green) 4%);
  position: sticky;
  top: 0;
  z-index: 2;
}

.lead-drawer .crm-modal-body {
  padding: 16px 18px 18px;
}

.lead-drawer .crm-modal-foot {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px max(12px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px);
}

.lead-drawer .crm-modal-foot .btn {
  min-width: 0;
  width: 100%;
  justify-content: center;
  padding: 0 10px;
  white-space: nowrap;
}

.lead-drawer-profile {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--green) 20%, var(--line));
  border-radius: 20px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--green) 12%, transparent), transparent),
    color-mix(in srgb, var(--surface) 92%, var(--panel) 8%);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.12);
}

.lead-drawer-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #06130d;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--green) 30%, transparent);
}

.lead-drawer-main {
  min-width: 0;
}

.lead-drawer-name {
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-drawer-sub {
  margin-top: 3px;
  overflow: hidden;
  color: var(--uix-muted-readable, var(--muted));
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.lead-drawer-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.lead-drawer-strip div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, var(--green) 5%);
}

.lead-drawer-strip span {
  display: block;
  color: var(--uix-muted-readable, var(--muted));
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lead-drawer-strip strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 19px;
  font-weight: 900;
}

.lead-drawer .crm-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lead-drawer-section {
  margin-top: 16px;
}

.lead-drawer-timeline {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.lead-drawer-timeline > div {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 92%, var(--green) 3%);
}

.lead-drawer-timeline strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.lead-drawer-timeline span {
  overflow: hidden;
  color: var(--uix-muted-readable, var(--muted));
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes leadDrawerIn {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 760px) {
  .lead-drawer-overlay {
    place-items: stretch;
  }

  .lead-drawer {
    width: 100vw;
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border-left: 0;
  }

  .lead-drawer .crm-modal-head {
    padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
  }

  .lead-drawer .crm-modal-body {
    padding: 12px 12px 16px;
  }

  .lead-drawer-profile {
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 12px;
    border-radius: 18px;
  }

  .lead-drawer-avatar {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    font-size: 18px;
  }

  .lead-drawer-name {
    font-size: 16px;
  }

  .lead-drawer-strip,
  .lead-drawer .crm-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lead-drawer-timeline > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .lead-drawer .crm-modal-foot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .lead-drawer .crm-modal-foot .btn:last-child {
    grid-column: 1 / -1;
  }
}

/* v17 premium interaction layer: drawer commands, WhatsApp chat rail, campaign stepper, settings tabs */
.lead-command-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 12px;
  align-items: center;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--green) 22%, var(--line));
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 88%, var(--green) 6%);
}

.lead-command-panel strong,
.permission-matrix-head strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.lead-command-panel span,
.permission-matrix-head span {
  display: block;
  margin-top: 3px;
  color: var(--uix-muted-readable, var(--muted));
  font-size: 12px;
  font-weight: 700;
}

.lead-command-menu {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  padding: 0 14px;
}

.campaign-stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.campaign-step {
  position: relative;
  min-width: 0;
  min-height: 86px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--green) 14%, var(--line));
  border-radius: 18px;
  background:
    linear-gradient(140deg, color-mix(in srgb, var(--green) 8%, transparent), transparent 62%),
    color-mix(in srgb, var(--surface) 94%, var(--panel) 6%);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.08);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.campaign-step:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--green) 42%, var(--line));
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.12);
}

.campaign-step span {
  grid-row: 1 / 3;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--green) 16%, var(--surface));
  color: var(--green);
  font-weight: 900;
}

.campaign-step strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-step small {
  overflow: hidden;
  color: var(--uix-muted-readable, var(--muted));
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-step.done span {
  background: var(--green);
  color: #06130d;
}

.campaign-step.active {
  border-color: var(--green);
  box-shadow: 0 18px 46px color-mix(in srgb, var(--green) 22%, transparent);
}

.settings-tabs {
  position: sticky;
  top: var(--topbar-height, 72px);
  z-index: 8;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 12px;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}

.settings-tabs button {
  flex: 0 0 auto;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--uix-muted-readable, var(--muted));
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}

.settings-tabs button:hover,
.settings-tabs button.active {
  border-color: var(--green);
  background: var(--green);
  color: #06130d;
  transform: translateY(-1px);
}

.settings-panel-hidden {
  display: none !important;
}

.permission-matrix {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--green) 18%, var(--line));
  border-radius: 20px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--green) 8%, transparent), transparent),
    var(--surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
}

.permission-grid,
.api-health-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.permission-grid div,
.api-health-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, var(--green) 5%);
}

.permission-grid span,
.api-health-grid span {
  display: block;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.permission-grid strong,
.api-health-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.api-health-grid small {
  display: block;
  margin-top: 5px;
  color: var(--uix-muted-readable, var(--muted));
  font-weight: 700;
  line-height: 1.35;
}

.production-health-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--green) 16%, var(--line));
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--green) 14%, transparent), transparent 42%),
    color-mix(in srgb, var(--surface) 92%, var(--green) 4%);
}

.production-health-head span {
  display: block;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.production-health-head strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.production-health-head small {
  display: block;
  margin-top: 7px;
  color: var(--uix-muted-readable, var(--muted));
  font-weight: 750;
}

.health-good { color: var(--green) !important; }
.health-watch { color: var(--amber) !important; }
.health-risk { color: var(--rose) !important; }

.production-health-warnings {
  display: grid;
  gap: 8px;
}

.health-warning,
.health-ok {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--amber) 34%, var(--line));
  background: color-mix(in srgb, var(--amber) 11%, var(--surface));
}

.health-ok {
  border-color: color-mix(in srgb, var(--green) 28%, var(--line));
  background: color-mix(in srgb, var(--green) 9%, var(--surface));
}

.health-warning strong,
.health-ok strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.health-warning span,
.health-ok span {
  color: var(--uix-muted-readable, var(--muted));
  font-weight: 750;
  line-height: 1.35;
}

.production-health-grid strong {
  font-size: 14px;
}

#view-inbox .chat {
  position: relative;
  overflow: hidden;
}

#view-inbox .chat-head {
  gap: 10px;
  background: color-mix(in srgb, var(--surface) 94%, var(--green) 3%);
  backdrop-filter: blur(18px);
}

.chat-ai-state {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border: 1px solid color-mix(in srgb, var(--green) 25%, var(--line));
  border-radius: 999px;
  color: var(--green);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.chat-ai-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 14%, transparent);
}

.chat-ai-state.human {
  border-color: color-mix(in srgb, var(--amber) 40%, var(--line));
  color: var(--amber);
}

.chat-profile-rail {
  position: absolute;
  inset: 70px 14px 96px auto;
  z-index: 16;
  width: min(360px, calc(100% - 28px));
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--green) 18%, var(--line));
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 96%, var(--panel) 4%);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.26);
  transform: translateX(calc(100% + 28px));
  opacity: 0;
  pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
}

.chat-profile-rail.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-profile-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(14px);
}

.chat-profile-head > div {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
}

.chat-profile-head .avatar {
  grid-row: 1 / 3;
  width: 42px;
  height: 42px;
  border-radius: 15px;
}

.chat-profile-head strong,
.chat-profile-head small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-profile-status {
  margin: 12px 14px;
  padding: 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  color: var(--green);
}

.chat-profile-status.human {
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  color: var(--amber);
}

.chat-profile-status span,
.chat-profile-grid span {
  display: block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.chat-profile-status strong,
.chat-profile-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
}

.chat-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 12px;
}

.chat-profile-grid div,
.chat-profile-section {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 90%, var(--green) 4%);
}

.chat-profile-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 12px;
}

.chat-profile-section {
  margin: 0 14px 12px;
}

.chat-profile-section h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.chat-profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-profile-tags span {
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  color: var(--green);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
}

.chat-profile-notes p {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.chat-profile-notes small,
.chat-profile-section small {
  display: block;
  color: var(--uix-muted-readable, var(--muted));
  font-weight: 700;
}

#view-inbox .messages {
  background:
    radial-gradient(circle at 18px 18px, color-mix(in srgb, var(--green) 9%, transparent) 1.5px, transparent 1.5px) 0 0 / 34px 34px,
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 92%, var(--green) 3%), color-mix(in srgb, var(--panel) 96%, transparent));
}

#view-inbox .bubble {
  border-radius: 18px 18px 18px 6px;
}

#view-inbox .bubble.sent {
  border-radius: 18px 18px 6px 18px;
}

#view-inbox .chat-media img,
#view-inbox .chat-media video {
  border-radius: 14px;
}

@media (max-width: 1100px) {
  .campaign-stepper {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .permission-grid,
  .api-health-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .lead-command-panel,
  .campaign-stepper {
    grid-template-columns: 1fr;
  }

  .campaign-step {
    min-height: 66px;
  }

  .settings-tabs {
    top: 64px;
    margin-inline: -4px;
    padding-inline: 4px;
  }

  .chat-ai-state,
  #view-inbox .lead-chips {
    display: none;
  }

  .chat-profile-rail {
    position: fixed;
    inset: calc(58px + env(safe-area-inset-top)) 10px calc(86px + env(safe-area-inset-bottom)) 10px;
    width: auto;
    border-radius: 20px;
  }

  .chat-profile-rail.open {
    transform: translateX(0);
  }

.chat-profile-actions,
  .chat-profile-grid {
    grid-template-columns: 1fr;
  }
}

/* v19 in-place Phase 1 polish: calmer enterprise CRM chrome, faster lead actions, no backend changes. */
:root {
  --rk-enterprise-shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --rk-enterprise-line: color-mix(in srgb, var(--line) 78%, var(--green) 10%);
}

html[data-theme="normal"] body {
  background:
    radial-gradient(circle at top left, rgba(16, 185, 129, 0.08), transparent 34%),
    linear-gradient(180deg, #f8faf9 0%, #f3f7f5 100%);
}

.topbar {
  min-height: 78px;
  border-bottom: 1px solid var(--rk-enterprise-line);
  box-shadow: 0 14px 42px rgba(15, 23, 42, 0.06);
}

.brand h1,
.page-title {
  letter-spacing: -0.01em;
}

.stats .stat,
.overview-card,
.metric-card,
.calling-kpi,
.followup-folder-card,
.saas-card {
  border-color: var(--rk-enterprise-line);
  box-shadow: var(--rk-enterprise-shadow);
}

.tab {
  border-radius: 16px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.tab:hover {
  transform: translateX(2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.tab.active {
  box-shadow: 0 18px 44px rgba(16, 185, 129, 0.14);
}

#view-leads .super-crm-panel {
  border: 1px solid color-mix(in srgb, var(--green) 14%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 96%, var(--green) 4%), var(--surface)),
    var(--surface);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.08);
}

#view-leads .super-crm-panel .card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

#view-leads .super-crm-panel.lead-editor-closed {
  position: sticky;
  top: 88px;
  z-index: 8;
}

#view-leads .super-crm-actions {
  align-items: center;
  scrollbar-width: thin;
}

#view-leads .super-crm-actions .btn {
  min-height: 40px !important;
  border-radius: 14px !important;
  font-weight: 850;
}

#view-leads .super-crm-panel.lead-editor-closed .super-crm-actions .btn:not(#newLeadBtn):not(#distributeLeadsBtn):not(#repairLeadDatesBtn):not(#shuffleNotAnsweredBtn):not(#shuffleStaleFollowupsBtn) {
  display: none !important;
}

#view-leads .super-crm-form input,
#view-leads .super-crm-form select,
#view-leads .super-crm-form textarea,
#view-leads .advanced-lead-filters input,
#view-leads .advanced-lead-filters select {
  border-color: color-mix(in srgb, var(--line) 86%, var(--green) 8%);
  background: color-mix(in srgb, var(--surface) 96%, var(--panel) 4%);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#view-leads .super-crm-form input:focus,
#view-leads .super-crm-form select:focus,
#view-leads .super-crm-form textarea:focus,
#view-leads .advanced-lead-filters input:focus,
#view-leads .advanced-lead-filters select:focus {
  border-color: color-mix(in srgb, var(--green) 58%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent);
}

#view-leads .modern-table-wrap {
  border-radius: 22px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.07);
}

#view-leads .modern-table th {
  font-size: 11px;
  letter-spacing: .055em;
}

#view-leads .modern-table tbody tr {
  transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

#view-leads .modern-table tbody tr:hover {
  transform: translateY(-1px);
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--green) 70%, transparent);
}

#view-leads .modern-table th:nth-child(17),
#view-leads .modern-table td:nth-child(17) {
  width: 600px;
}

#view-leads .row-actions {
  display: grid !important;
  grid-template-columns: 58px 54px 74px 56px 74px 82px 78px !important;
  gap: 6px !important;
  max-width: 594px !important;
  overflow: visible !important;
}

#view-leads .row-actions .btn,
#view-leads .row-actions .lead-more-select {
  min-height: 30px !important;
  border-radius: 999px !important;
  padding-inline: 8px !important;
  font-size: 11px !important;
  font-weight: 850 !important;
}

#view-leads .row-actions .btn-ghost {
  background: color-mix(in srgb, var(--surface) 92%, var(--green) 5%);
}

#view-leads .lead-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

#view-leads .lead-count-chip {
  min-height: 22px;
  border: 1px solid color-mix(in srgb, var(--green) 20%, var(--line));
  background: color-mix(in srgb, var(--surface) 90%, var(--green) 6%);
}

.lead-drawer {
  border-radius: 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.22);
}

.lead-drawer-profile,
.lead-command-panel,
.campaign-stepper,
.settings-tabs,
.permission-matrix {
  border-color: var(--rk-enterprise-line);
  box-shadow: var(--rk-enterprise-shadow);
}

@media (max-width: 760px) {
  html[data-layout="mobile"] .topbar {
    min-height: 62px !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
  }

  html[data-layout="mobile"] #view-leads .super-crm-panel.lead-editor-closed {
    position: static;
  }

  html[data-layout="mobile"] #view-leads .super-crm-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible !important;
  }

  html[data-layout="mobile"] #view-leads .super-crm-actions .btn {
    min-width: 0 !important;
    width: 100% !important;
  }

  html[data-layout="mobile"] #view-leads .modern-table tr {
    border-radius: 22px !important;
    padding: 14px !important;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.16);
  }

  html[data-layout="mobile"] #view-leads .modern-table td[data-label="Actions"] {
    display: block !important;
    padding-top: 12px !important;
  }

  html[data-layout="mobile"] #view-leads .row-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    max-width: none !important;
  }

  html[data-layout="mobile"] #view-leads .row-actions .btn,
  html[data-layout="mobile"] #view-leads .row-actions .lead-more-select {
    min-height: 38px !important;
    font-size: 12px !important;
  }
}

/* v19 premium visual system: enterprise CRM depth, semantic color, richer cards, UI-only. */
:root {
  --premium-ink: #0b1220;
  --premium-slate: #243244;
  --premium-blue: #2563eb;
  --premium-sky: #0891b2;
  --premium-gold: #c27a12;
  --premium-violet: #7c3aed;
  --premium-red: #dc2626;
  --premium-mint: #10b981;
  --premium-shadow: 0 24px 70px rgba(2, 8, 23, 0.14);
  --premium-shadow-soft: 0 14px 38px rgba(15, 23, 42, 0.09);
  --premium-ring: color-mix(in srgb, var(--green) 18%, var(--line));
}

html[data-theme="normal"] {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef4f7;
  --panel: #ffffff;
  --panel-2: #f8fbfa;
  --line: #d8e2e6;
  --line-soft: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --soft: #334155;
}

html[data-theme="dark"],
html:not([data-theme="normal"]) {
  --surface: #101820;
  --surface-2: #111d27;
  --panel: #14202a;
  --panel-2: #0c141c;
  --line: #263746;
  --text: #edf6f3;
  --muted: #9fb0bd;
}

html[data-theme="normal"] body {
  background:
    linear-gradient(180deg, #f7fafc 0%, #eef5f3 48%, #f8fafc 100%) !important;
}

html:not([data-theme="normal"]) body {
  background:
    linear-gradient(180deg, #07100f 0%, #0b1218 52%, #0a1016 100%) !important;
}

.topbar {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, var(--premium-blue) 4%), var(--surface)) !important;
  border-bottom-color: color-mix(in srgb, var(--line) 78%, var(--premium-blue) 10%) !important;
}

.brand-mark,
.side-logo-mark {
  background: linear-gradient(135deg, #1fd36f 0%, #14b8a6 54%, #2563eb 100%) !important;
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.22), inset 0 1px 0 rgba(255,255,255,0.22) !important;
}

.tabs {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 86%, var(--green) 7%), var(--bg)) !important;
}

html:not([data-theme="normal"]) .tabs {
  background:
    linear-gradient(180deg, #0d171a 0%, #07100f 100%) !important;
}

.tab .tab-icon {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green) 78%, #22d3ee), color-mix(in srgb, var(--green-2) 76%, #2563eb)) !important;
}

.tab:nth-of-type(4n + 1) .tab-icon { background: linear-gradient(135deg, #14b8a6, #2563eb) !important; }
.tab:nth-of-type(4n + 2) .tab-icon { background: linear-gradient(135deg, #22c55e, #0f766e) !important; }
.tab:nth-of-type(4n + 3) .tab-icon { background: linear-gradient(135deg, #f59e0b, #b45309) !important; }
.tab:nth-of-type(4n + 4) .tab-icon { background: linear-gradient(135deg, #38bdf8, #4f46e5) !important; }

.btn,
.tab,
.stat,
.saas-card,
.card,
.calling-kpi,
.followup-folder-card,
.followup-lead-card,
.crm-lead-card,
.daily-metric-card,
.premium-chart-card {
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.btn:hover,
.tab:hover,
.saas-card:hover,
.card:hover,
.calling-kpi:hover,
.followup-folder-card:hover,
.followup-lead-card:hover,
.crm-lead-card:hover,
.daily-metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--premium-shadow) !important;
}

.stats .stat {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 92%, var(--premium-sky) 4%), color-mix(in srgb, var(--surface) 94%, var(--panel-2) 6%)) !important;
}

.stats .stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--green);
}

.stats .stat:nth-child(2)::before { background: var(--premium-blue); }
.stats .stat:nth-child(3)::before { background: var(--premium-gold); }
.stats .stat:nth-child(4)::before { background: var(--premium-red); }

.stats .stat:nth-child(2) {
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 92%, var(--premium-blue) 5%), var(--surface)) !important;
}
.stats .stat:nth-child(3) {
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 90%, var(--premium-gold) 7%), var(--surface)) !important;
}
.stats .stat:nth-child(4) {
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 91%, var(--premium-red) 5%), var(--surface)) !important;
}

.dashboard-shell,
.page-head {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 94%, var(--premium-blue) 3%), color-mix(in srgb, var(--surface) 94%, var(--green) 3%)) !important;
  border: 1px solid color-mix(in srgb, var(--line) 84%, var(--premium-blue) 8%) !important;
}

.page-kicker {
  color: var(--premium-sky) !important;
}

.page-title {
  color: var(--text) !important;
}

.super-crm-kpi-grid .super-kpi,
.dashboard-grid .metric-card,
.overview-card {
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--premium-blue) 10%) !important;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 94%, var(--green) 3%), color-mix(in srgb, var(--surface) 96%, var(--premium-slate) 4%)) !important;
  box-shadow: var(--premium-shadow-soft) !important;
}

.super-crm-kpi-grid .super-kpi::before,
.dashboard-grid .metric-card::before,
.overview-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: var(--green);
}

.super-crm-kpi-grid .super-kpi:nth-child(4n + 2)::before,
.dashboard-grid .metric-card:nth-child(4n + 2)::before,
.overview-card:nth-child(4n + 2)::before { background: var(--premium-blue); }
.super-crm-kpi-grid .super-kpi:nth-child(4n + 3)::before,
.dashboard-grid .metric-card:nth-child(4n + 3)::before,
.overview-card:nth-child(4n + 3)::before { background: var(--premium-gold); }
.super-crm-kpi-grid .super-kpi:nth-child(4n + 4)::before,
.dashboard-grid .metric-card:nth-child(4n + 4)::before,
.overview-card:nth-child(4n + 4)::before { background: var(--premium-red); }

.calling-hero,
.calling-admin-suite,
.calling-chart-card,
.premium-chart-card {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 94%, var(--premium-ink) 5%), color-mix(in srgb, var(--surface) 93%, var(--green) 4%)) !important;
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--premium-blue) 12%) !important;
  box-shadow: var(--premium-shadow) !important;
}

.calling-kpi,
.calling-admin-kpi,
.calling-mini {
  position: relative;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--line) 78%, var(--premium-sky) 12%) !important;
}

.calling-kpi::before,
.calling-admin-kpi::before,
.calling-mini::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--premium-sky);
}

.calling-kpi.good::before,
.calling-admin-kpi.good::before { background: var(--green); }
.calling-kpi.urgent::before,
.calling-admin-kpi.bad::before { background: var(--premium-red); }
.calling-kpi.hot::before,
.calling-admin-kpi.warn::before { background: var(--premium-gold); }

.followup-folder-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important;
}

.followup-folder-card {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--line) 78%, var(--premium-blue) 10%) !important;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 92%, var(--premium-blue) 4%), var(--surface)) !important;
}

.followup-folder-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--green);
}

.followup-folder-card:nth-child(2)::before { background: var(--premium-gold); }
.followup-folder-card:nth-child(3)::before { background: var(--premium-blue); }
.followup-folder-card:nth-child(4)::before { background: var(--premium-violet); }
.followup-folder-card:nth-child(5)::before { background: var(--premium-red); }

.followup-folder-card strong {
  font-size: clamp(24px, 2.4vw, 34px) !important;
}

.followup-lead-card {
  position: relative;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--line) 78%, var(--premium-blue) 10%) !important;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 94%, var(--premium-sky) 3%), var(--surface)) !important;
  box-shadow: var(--premium-shadow-soft) !important;
}

.followup-lead-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--premium-sky);
}

.followup-lead-card.followup-documents::before { background: var(--premium-gold); }
.followup-lead-card.followup-details::before { background: var(--green); }
.followup-lead-card.followup-course::before { background: var(--premium-blue); }
.followup-lead-card.followup-yes::before { background: var(--premium-violet); }
.followup-lead-card.followup-other::before { background: var(--premium-red); }

.followup-lead-card.followup-documents {
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 90%, var(--premium-gold) 8%), var(--surface)) !important;
}
.followup-lead-card.followup-details {
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 91%, var(--green) 7%), var(--surface)) !important;
}
.followup-lead-card.followup-course {
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 91%, var(--premium-blue) 7%), var(--surface)) !important;
}
.followup-lead-card.followup-yes {
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 91%, var(--premium-violet) 7%), var(--surface)) !important;
}

.followup-score {
  color: var(--text) !important;
  background:
    radial-gradient(circle at 35% 25%, rgba(255,255,255,0.26), transparent 42%),
    linear-gradient(145deg, color-mix(in srgb, var(--green) 22%, var(--surface)), color-mix(in srgb, var(--premium-blue) 12%, var(--surface))) !important;
  border-color: color-mix(in srgb, var(--green) 28%, var(--line)) !important;
}

.followup-course-pill,
.status-badge,
.meta-status,
.calling-pill,
.lead-count-chip {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}

.modern-table-wrap,
.super-crm-panel,
.lead-command-panel,
.campaign-stepper,
.settings-tabs,
.permission-matrix {
  border-color: color-mix(in srgb, var(--line) 82%, var(--premium-blue) 9%) !important;
  box-shadow: var(--premium-shadow-soft) !important;
}

#view-leads .modern-table tbody tr:hover,
.calling-row:hover,
.calling-board-row:hover,
.calling-tiny-lead:hover {
  background: color-mix(in srgb, var(--surface) 88%, var(--premium-blue) 6%) !important;
}

.btn-primary,
button.btn-primary,
.followup-mode-btn.active,
.followup-filter.active {
  background: linear-gradient(135deg, #18c66f, #0e9f6e) !important;
  border-color: #0e9f6e !important;
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.22) !important;
}

.btn-call {
  background: linear-gradient(135deg, #22d3ee, #2563eb) !important;
  border-color: #2563eb !important;
  color: #f8fafc !important;
}

.btn-danger,
button[data-delete-lead],
button[data-chat-delete],
button[data-delete-selected] {
  background: color-mix(in srgb, var(--premium-red) 10%, var(--surface)) !important;
  border-color: color-mix(in srgb, var(--premium-red) 28%, var(--line)) !important;
  color: color-mix(in srgb, var(--premium-red) 84%, var(--text)) !important;
}

.bar-fill {
  background: linear-gradient(90deg, var(--green), var(--premium-sky), var(--premium-blue)) !important;
}

html[data-theme="normal"] .modern-table th,
html[data-theme="normal"] .calling-matrix-row.head {
  background: #edf5f3 !important;
}

html:not([data-theme="normal"]) .modern-table th,
html:not([data-theme="normal"]) .calling-matrix-row.head {
  background: #111f28 !important;
}

@keyframes premium-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-shell > *,
.followup-lead-card,
.calling-panel,
.calling-chart-card,
.premium-chart-card {
  animation: premium-rise 260ms ease both;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 760px) {
  html[data-layout="mobile"] .page-head,
  html[data-layout="mobile"] .dashboard-shell {
    border-radius: 20px !important;
  }

  html[data-layout="mobile"] .followup-folder-grid,
  html[data-layout="mobile"] .super-crm-kpi-grid,
  html[data-layout="mobile"] .calling-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  html[data-layout="mobile"] .followup-folder-card,
  html[data-layout="mobile"] .super-kpi,
  html[data-layout="mobile"] .calling-kpi {
    min-height: 96px !important;
    padding: 13px !important;
    border-radius: 18px !important;
  }

  html[data-layout="mobile"] .followup-lead-card {
    border-radius: 20px !important;
    padding: 14px 14px 14px 18px !important;
  }

  html[data-layout="mobile"] .followup-score {
    min-width: 48px !important;
    min-height: 48px !important;
    border-radius: 14px !important;
  }
}

/* Campaign report cockpit: paginated, compact, premium reporting table. */
#view-campaigns .grid {
  align-items: start;
}

#view-campaigns .card {
  overflow: hidden;
}

.campaign-report-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(620px, calc(100vh - 250px));
  min-height: 390px;
}

.campaign-report-table {
  min-height: 0;
  overflow: auto;
  border-radius: 18px !important;
}

.campaign-report-table table {
  min-width: 680px;
  border-collapse: separate;
  border-spacing: 0;
}

.campaign-report-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 94%, var(--green) 4%), var(--surface-2)) !important;
  box-shadow: 0 1px 0 var(--line);
}

.campaign-report-table tbody tr {
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.campaign-report-table tbody tr:hover {
  background: color-mix(in srgb, var(--surface) 88%, var(--premium-blue) 7%) !important;
}

.campaign-report-table tbody tr.campaign-row-active {
  background: color-mix(in srgb, var(--surface) 84%, var(--green) 10%) !important;
  box-shadow: inset 4px 0 0 var(--green);
}

.campaign-report-name {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.campaign-mode-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--premium-blue) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--premium-blue) 18%, var(--line));
  color: color-mix(in srgb, var(--premium-blue) 80%, var(--text));
  font-size: 11px;
  font-weight: 850;
}

.campaign-report-good {
  color: var(--green);
}

.campaign-report-bad {
  color: var(--premium-red);
}

.campaign-report-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(54px, auto));
  gap: 6px;
  align-items: center;
}

.campaign-report-actions .btn {
  min-height: 30px !important;
  border-radius: 999px !important;
  padding-inline: 10px !important;
  font-size: 11px !important;
  white-space: nowrap;
}

.campaign-report-pager {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, var(--green) 8%);
}

.campaign-report-pager span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

#view-campaigns .campaign-media-library {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
  max-height: 220px !important;
  padding-right: 4px;
}

#view-campaigns .media-tile {
  border-radius: 14px !important;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 94%, var(--premium-blue) 4%), var(--surface)) !important;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

@media (max-width: 1060px) {
  .campaign-report-card {
    max-height: none;
  }
}

@media (max-width: 760px) {
  html[data-layout="mobile"] .campaign-report-card {
    min-height: 0;
    border-radius: 20px !important;
  }

  html[data-layout="mobile"] .campaign-report-table table {
    min-width: 0;
  }

  html[data-layout="mobile"] .campaign-report-table thead {
    display: none;
  }

  html[data-layout="mobile"] .campaign-report-table tbody,
  html[data-layout="mobile"] .campaign-report-table tr,
  html[data-layout="mobile"] .campaign-report-table td {
    display: block;
    width: 100%;
  }

  html[data-layout="mobile"] .campaign-report-table tr {
    margin: 0 0 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
  }

  html[data-layout="mobile"] .campaign-report-table td {
    padding: 5px 0 !important;
    border: 0 !important;
  }

  html[data-layout="mobile"] .campaign-report-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  html[data-layout="mobile"] .campaign-report-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* v19.1 Leads card board: card-first CRM view on desktop and mobile. */
#view-leads .modern-table-wrap {
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#view-leads .modern-table {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  table-layout: auto !important;
  border-spacing: 0 !important;
  background: transparent !important;
}

#view-leads .modern-table thead {
  display: none !important;
}

#view-leads .modern-table tbody {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
  gap: 16px;
  width: 100%;
}

#view-leads .modern-table tbody tr {
  position: relative;
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  grid-template-areas:
    "select name status"
    "select phone final"
    "course course course"
    "college counsellor score"
    "call follow docs"
    "tracking tracking tracking"
    "actions actions actions";
  gap: 8px 12px;
  height: auto !important;
  min-height: 0 !important;
  padding: 16px !important;
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent) !important;
  border-radius: 22px !important;
  background:
    radial-gradient(circle at 92% 0%, color-mix(in srgb, var(--premium-blue) 12%, transparent), transparent 30%),
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 96%, var(--green) 4%), color-mix(in srgb, var(--surface) 94%, var(--premium-mint) 6%)) !important;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.12) !important;
  overflow: hidden !important;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

html[data-theme="normal"] #view-leads .modern-table tbody tr {
  background:
    radial-gradient(circle at 92% 0%, rgba(56, 189, 248, .13), transparent 32%),
    linear-gradient(135deg, #ffffff, #f4fff8) !important;
  box-shadow: 0 18px 42px rgba(29, 78, 55, .10) !important;
}

#view-leads .modern-table tbody tr::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--green), var(--premium-blue));
  opacity: .9;
}

#view-leads .modern-table tbody tr:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--green) 34%, var(--line)) !important;
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.18) !important;
}

#view-leads .modern-table td {
  display: block !important;
  width: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: normal !important;
  line-height: 1.3;
}

#view-leads .modern-table td::before {
  display: none !important;
}

#view-leads .modern-table td:nth-child(1) {
  grid-area: select;
  align-self: start;
  padding-top: 3px !important;
  text-align: left !important;
}

#view-leads .modern-table td:nth-child(1) input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

#view-leads .modern-table td:nth-child(2),
#view-leads .modern-table td:nth-child(3),
#view-leads .modern-table td:nth-child(6) {
  display: none !important;
}

#view-leads .modern-table td:nth-child(4) {
  grid-area: name;
  min-width: 0;
}

#view-leads .modern-table td:nth-child(4) strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
  letter-spacing: 0;
}

#view-leads .modern-table td:nth-child(4) .tiny {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--premium-gold) 14%, transparent);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

#view-leads .modern-table td:nth-child(5) {
  grid-area: phone;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

#view-leads .modern-table td:nth-child(7) {
  grid-area: course;
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-height: 38px !important;
  padding: 9px 11px !important;
  border: 1px solid color-mix(in srgb, var(--premium-blue) 20%, var(--line)) !important;
  border-radius: 15px;
  background: color-mix(in srgb, var(--premium-blue) 9%, transparent);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

#view-leads .modern-table td:nth-child(7)::after {
  content: "Course";
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
}

#view-leads .modern-table td:nth-child(8),
#view-leads .modern-table td:nth-child(9),
#view-leads .modern-table td:nth-child(12),
#view-leads .modern-table td:nth-child(13),
#view-leads .modern-table td:nth-child(14) {
  display: inline-flex !important;
  align-items: center;
  align-self: start;
  min-width: 0;
  margin-right: 6px;
  padding: 5px 9px !important;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent) !important;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

#view-leads .modern-table td:nth-child(8)::before,
#view-leads .modern-table td:nth-child(9)::before,
#view-leads .modern-table td:nth-child(12)::before,
#view-leads .modern-table td:nth-child(13)::before,
#view-leads .modern-table td:nth-child(14)::before {
  display: inline !important;
  margin-right: 4px;
  color: color-mix(in srgb, var(--text) 72%, var(--muted));
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}

#view-leads .modern-table td:nth-child(8)::before { content: "College"; }
#view-leads .modern-table td:nth-child(9)::before { content: "Counsellor"; }
#view-leads .modern-table td:nth-child(12)::before { content: "Call"; }
#view-leads .modern-table td:nth-child(13)::before { content: "Follow"; }
#view-leads .modern-table td:nth-child(14)::before { content: "Docs"; }

#view-leads .modern-table td:nth-child(8) { grid-area: college; }
#view-leads .modern-table td:nth-child(9) { grid-area: counsellor; }
#view-leads .modern-table td:nth-child(12) { grid-area: call; }
#view-leads .modern-table td:nth-child(13) { grid-area: follow; }
#view-leads .modern-table td:nth-child(14) { grid-area: docs; }

#view-leads .modern-table td:nth-child(10) {
  grid-area: status;
  justify-self: end;
}

#view-leads .modern-table td:nth-child(11) {
  grid-area: final;
  justify-self: start;
  align-self: start;
  margin-top: 0;
}

#view-leads .modern-table td:nth-child(15) {
  grid-area: score;
  justify-self: end;
  align-self: center;
  min-width: 92px !important;
}

#view-leads .modern-table td:nth-child(16) {
  grid-area: tracking;
  display: grid !important;
  gap: 8px;
  padding-top: 12px !important;
  border-top: 1px solid color-mix(in srgb, var(--line) 76%, transparent) !important;
}

#view-leads .lead-counts {
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 !important;
}

#view-leads .lead-count-chip {
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 10%, transparent);
  border-color: color-mix(in srgb, var(--green) 24%, var(--line));
  font-size: 10px;
}

#view-leads .table-remark {
  display: -webkit-box;
  max-width: none !important;
  color: color-mix(in srgb, var(--text) 78%, var(--muted));
  font-size: 12px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#view-leads .modern-table td:nth-child(17) {
  grid-area: actions;
  padding-top: 4px !important;
}

#view-leads .row-actions {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px !important;
  max-width: none !important;
  overflow: visible !important;
  padding: 0 !important;
}

#view-leads .row-actions .btn,
#view-leads .lead-more-select {
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 34px !important;
  justify-content: center;
  padding: 0 9px !important;
  border-radius: 999px !important;
  font-size: 11px !important;
}

#view-leads .lead-more-select {
  text-align: center;
  background: color-mix(in srgb, var(--surface) 88%, var(--premium-violet) 8%);
}

#view-leads .pager {
  position: static !important;
  margin-top: 16px;
  padding: 10px 12px !important;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .08);
}

@media (min-width: 1500px) {
  #view-leads .modern-table tbody {
    grid-template-columns: repeat(3, minmax(390px, 1fr));
  }
}

@media (max-width: 1120px) {
  #view-leads .modern-table tbody {
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  }

  #view-leads .row-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  #view-leads .modern-table tbody {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  #view-leads .modern-table tbody tr {
    grid-template-columns: 28px minmax(0, 1fr) auto !important;
    grid-template-areas:
      "select name status"
      "select phone final"
      "course course course"
      "college college college"
      "counsellor counsellor counsellor"
      "call follow docs"
      "score score score"
      "tracking tracking tracking"
      "actions actions actions" !important;
    padding: 14px !important;
    border-radius: 20px !important;
  }

  #view-leads .modern-table td:nth-child(11) {
    margin-top: 0;
  }

  #view-leads .modern-table td:nth-child(15) {
    justify-self: stretch;
    min-width: 0 !important;
  }

  #view-leads .row-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 460px) {
  #view-leads .modern-table tbody tr {
    grid-template-columns: 26px minmax(0, 1fr) !important;
    grid-template-areas:
      "select name"
      "select phone"
      "status status"
      "final final"
      "course course"
      "college college"
      "counsellor counsellor"
      "call call"
      "follow follow"
      "docs docs"
      "score score"
      "tracking tracking"
      "actions actions" !important;
  }

  #view-leads .modern-table td:nth-child(10) {
    justify-self: start;
  }

  #view-leads .row-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* v19.1.1 Lead card stability fixes: no floating controls, no overlapping labels. */
#view-leads .super-crm-panel.lead-editor-closed {
  position: relative !important;
  top: auto !important;
  z-index: 1 !important;
  margin: 16px 0 20px !important;
  overflow: visible !important;
}

#view-leads .super-crm-panel .card-title {
  flex-wrap: wrap !important;
  row-gap: 6px !important;
}

#view-leads .super-crm-panel.lead-editor-closed .card-title::after {
  margin-left: auto;
  white-space: nowrap;
}

#view-leads .super-crm-panel.lead-editor-closed .super-crm-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  overflow: visible !important;
  padding: 0 !important;
}

#view-leads .super-crm-panel.lead-editor-closed .super-crm-actions .btn {
  flex: 0 1 auto !important;
  min-width: 138px !important;
  white-space: nowrap !important;
}

#view-leads .modern-table tbody tr {
  grid-template-columns: 34px minmax(0, 1fr) minmax(88px, auto) !important;
  grid-template-areas:
    "select name status"
    "select phone final"
    "course course course"
    "college college score"
    "counsellor counsellor score"
    "call follow docs"
    "tracking tracking tracking"
    "actions actions actions" !important;
  align-items: start;
}

#view-leads .modern-table td:nth-child(7) {
  min-width: 0 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap !important;
}

#view-leads .modern-table td:nth-child(7)::after {
  flex: 0 0 auto;
}

#view-leads .modern-table td:nth-child(8),
#view-leads .modern-table td:nth-child(9),
#view-leads .modern-table td:nth-child(12),
#view-leads .modern-table td:nth-child(13),
#view-leads .modern-table td:nth-child(14) {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  gap: 5px;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis;
}

#view-leads .modern-table td:nth-child(8)::before,
#view-leads .modern-table td:nth-child(9)::before,
#view-leads .modern-table td:nth-child(12)::before,
#view-leads .modern-table td:nth-child(13)::before,
#view-leads .modern-table td:nth-child(14)::before {
  flex: 0 0 auto;
  margin-right: 0 !important;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#view-leads .modern-table td:nth-child(15) {
  justify-self: stretch !important;
  width: 100% !important;
  min-width: 0 !important;
}

#view-leads .modern-table td:nth-child(15) .crm-scorebar {
  width: 100%;
  min-width: 0;
}

#view-leads .row-actions {
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)) !important;
  align-items: stretch;
}

#view-leads .row-actions .btn,
#view-leads .lead-more-select {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 760px) {
  #view-leads .super-crm-panel.lead-editor-closed {
    margin: 10px 0 14px !important;
  }

  #view-leads .super-crm-panel.lead-editor-closed .card-title::after {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }

  #view-leads .super-crm-panel.lead-editor-closed .super-crm-actions .btn {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 0 !important;
  }

  #view-leads .modern-table tbody tr {
    grid-template-columns: 28px minmax(0, 1fr) auto !important;
    grid-template-areas:
      "select name status"
      "select phone final"
      "course course course"
      "college college college"
      "counsellor counsellor counsellor"
      "call follow docs"
      "score score score"
      "tracking tracking tracking"
      "actions actions actions" !important;
  }
}

/* v19.1.2 Calling dashboard command polish: clickable KPIs and richer stat rows. */
#view-calling .calling-kpi[data-calling-drill],
#view-calling .calling-mini[data-calling-drill] {
  cursor: pointer;
  user-select: none;
}

#view-calling .calling-kpi[data-calling-drill]:focus-visible,
#view-calling .calling-mini[data-calling-drill]:focus-visible,
#view-calling .calling-bucket-head:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 35%, transparent);
  outline-offset: 3px;
}

#view-calling .calling-kpi em {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--green) 24%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, var(--green) 8%);
  color: color-mix(in srgb, var(--ink) 82%, var(--green));
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease, border-color .18s ease;
}

#view-calling .calling-kpi:hover em,
#view-calling .calling-kpi:focus-visible em {
  opacity: 1;
  transform: translateY(0);
}

#view-calling .calling-kpi[data-calling-drill]:active,
#view-calling .calling-mini[data-calling-drill]:active {
  transform: translateY(0) scale(.992);
}

#view-calling .calling-bucket-head {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--call-line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 96%, var(--green) 3%), color-mix(in srgb, var(--surface) 94%, var(--premium-sky) 5%));
  color: inherit;
  cursor: pointer;
  text-align: left;
}

#view-calling .calling-bucket-head:hover {
  background: color-mix(in srgb, var(--surface) 86%, var(--green) 10%);
}

#view-calling .calling-bucket-head strong {
  min-width: 34px;
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: color-mix(in srgb, var(--ink) 86%, var(--green));
  text-align: center;
}

#view-calling .calling-stat-row {
  grid-template-columns: minmax(110px, 1.2fr) minmax(110px, 2fr) minmax(48px, auto);
  min-height: 44px;
  padding: 7px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

#view-calling .calling-stat-row:last-child {
  border-bottom: 0;
}

#view-calling .bar-label {
  display: grid;
  gap: 2px;
  min-width: 0;
}

#view-calling .bar-label strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view-calling .bar-label small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

#view-calling .calling-stat-row .bar-track {
  height: 12px;
  background: color-mix(in srgb, var(--line) 54%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 42%, transparent);
}

#view-calling .calling-stat-row .bar-fill {
  background: linear-gradient(90deg, var(--premium-sky), var(--green));
}

#view-calling .calling-stat-row > strong {
  justify-self: end;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, var(--premium-sky) 8%);
  color: var(--ink);
  text-align: center;
}

@media (max-width: 760px) {
  #view-calling .calling-kpi em {
    display: none;
  }

  #view-calling .calling-stat-row {
    grid-template-columns: 1fr minmax(72px, .8fr) auto;
    gap: 8px;
  }
}

/* v19.1.3 Calling dashboard premium control-room pass. */
#view-calling .calling-dashboard {
  background:
    radial-gradient(circle at 16% 8%, color-mix(in srgb, var(--premium-sky) 16%, transparent), transparent 28%),
    radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--premium-gold) 11%, transparent), transparent 24%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, var(--premium-blue) 4%), color-mix(in srgb, var(--surface) 96%, var(--green) 3%));
}

#view-calling .calling-insight-grid {
  align-items: stretch;
}

#view-calling .calling-insight-panel,
#view-calling .calling-bucket-panel,
#view-calling .calling-attendance-panel {
  --insight-accent: var(--premium-blue);
  --insight-soft: color-mix(in srgb, var(--insight-accent) 10%, transparent);
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 95%, var(--insight-accent) 5%), color-mix(in srgb, var(--surface) 90%, var(--green) 4%)) !important;
  border-color: color-mix(in srgb, var(--line) 72%, var(--insight-accent) 22%) !important;
}

#view-calling .calling-insight-panel::before,
#view-calling .calling-bucket-panel::before,
#view-calling .calling-attendance-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--insight-accent), color-mix(in srgb, var(--insight-accent) 30%, var(--green)));
  opacity: .95;
}

#view-calling .calling-insight-panel::after,
#view-calling .calling-bucket-panel::after,
#view-calling .calling-attendance-panel::after {
  content: "";
  position: absolute;
  right: -42px;
  top: -46px;
  width: 150px;
  height: 150px;
  border-radius: 44px;
  background:
    radial-gradient(circle at 36% 36%, color-mix(in srgb, #fff 58%, transparent), transparent 34%),
    color-mix(in srgb, var(--insight-accent) 15%, transparent);
  transform: rotate(18deg);
  pointer-events: none;
}

#view-calling .insight-funnel { --insight-accent: #2563eb; }
#view-calling .insight-course { --insight-accent: #06b6d4; }
#view-calling .insight-duplicate { --insight-accent: #f43f5e; }
#view-calling .insight-month { --insight-accent: #8b5cf6; }
#view-calling .insight-source { --insight-accent: #14b8a6; }
#view-calling .insight-roi { --insight-accent: #ca8a04; }
#view-calling .calling-bucket-panel { --insight-accent: #0ea5e9; }
#view-calling .calling-attendance-panel { --insight-accent: #22c55e; }

#view-calling .calling-insight-panel .calling-panel-head,
#view-calling .calling-bucket-panel .calling-panel-head,
#view-calling .calling-attendance-panel .calling-panel-head {
  position: relative;
  z-index: 1;
  padding-bottom: 12px;
  border-bottom-color: color-mix(in srgb, var(--line) 70%, var(--insight-accent) 16%);
}

#view-calling .calling-insight-panel .calling-panel-head strong,
#view-calling .calling-bucket-panel .calling-panel-head strong,
#view-calling .calling-attendance-panel .calling-panel-head strong {
  color: color-mix(in srgb, var(--ink) 88%, var(--insight-accent));
  font-size: 17px;
}

#view-calling .calling-insight-panel .calling-panel-head span,
#view-calling .calling-bucket-panel .calling-panel-head span,
#view-calling .calling-attendance-panel .calling-panel-head span {
  color: color-mix(in srgb, var(--muted) 84%, var(--insight-accent));
  font-weight: 650;
}

#view-calling .bar-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  padding: 12px 14px 16px;
}

#view-calling .calling-insight-panel .calling-stat-row {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
  border-radius: 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--insight-accent) 8%, transparent));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--insight-accent) 8%, transparent);
}

#view-calling .calling-insight-panel .calling-stat-row .bar-fill {
  background: linear-gradient(90deg, var(--insight-accent), color-mix(in srgb, var(--green) 62%, var(--insight-accent))) !important;
}

#view-calling .calling-insight-panel .calling-stat-row > strong {
  background: color-mix(in srgb, var(--insight-accent) 13%, var(--surface));
}

#view-calling .calling-roi,
#view-calling .calling-board-row {
  position: relative;
  z-index: 1;
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--premium-sky) 7%, transparent));
  box-shadow: 0 10px 24px rgba(15, 23, 42, .055);
}

#view-calling .calling-roi::before,
#view-calling .calling-board-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--insight-accent, var(--green)) 75%, var(--premium-sky));
}

#view-calling .calling-bucket-grid {
  gap: 12px;
}

#view-calling .calling-bucket {
  border-radius: 18px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 95%, var(--premium-sky) 4%), color-mix(in srgb, var(--surface) 92%, var(--green) 3%));
  box-shadow: 0 14px 30px rgba(15, 23, 42, .07);
}

#view-calling .calling-bucket-body {
  gap: 10px;
  padding: 12px;
}

#view-calling .calling-tiny-lead {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--premium-sky) 8%, transparent));
  text-align: left;
}

#view-calling .calling-tiny-avatar {
  display: grid !important;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--green), var(--premium-sky));
  color: #fff !important;
  font-size: 13px !important;
  font-weight: 900;
}

#view-calling .calling-tiny-copy {
  display: grid !important;
  gap: 2px;
  min-width: 0;
}

#view-calling .calling-tiny-copy strong,
#view-calling .calling-tiny-copy small,
#view-calling .calling-tiny-course {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view-calling .calling-tiny-copy strong {
  color: var(--ink);
  font-size: 13px;
}

#view-calling .calling-tiny-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

#view-calling .calling-tiny-course {
  max-width: 92px;
  padding: 5px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 11%, var(--surface));
  color: color-mix(in srgb, var(--ink) 84%, var(--green));
  font-size: 10.5px !important;
  font-weight: 850;
}

#view-calling .calling-attendance-actions .btn {
  min-height: 48px;
  border-radius: 16px;
}

@media (max-width: 760px) {
  #view-calling .calling-insight-panel .calling-stat-row {
    grid-template-columns: minmax(0, 1fr) minmax(70px, .6fr) auto;
    padding: 9px;
  }

  #view-calling .calling-tiny-lead {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  #view-calling .calling-tiny-course {
    grid-column: 2;
    justify-self: start;
    max-width: 100%;
  }
}

/* v19.1.4 Phase 1 premium CRM polish */
.super-kpi[data-dashboard-drill] {
  position: relative;
  cursor: pointer;
  outline: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.super-kpi[data-dashboard-drill] em {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--green) 28%, var(--border));
  color: color-mix(in srgb, var(--green) 80%, var(--text));
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
  opacity: .78;
}

.super-kpi[data-dashboard-drill]:hover,
.super-kpi[data-dashboard-drill]:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--green) 46%, var(--border));
  box-shadow: 0 18px 42px rgba(2, 132, 199, .12), 0 8px 24px rgba(21, 128, 61, .10);
}

.dashboard-insights-drawer {
  margin-top: 14px;
  border: 1px solid var(--saas-border);
  border-radius: 24px;
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--cyan) 8%, transparent), transparent 28%),
    radial-gradient(circle at 90% 0%, color-mix(in srgb, var(--amber) 8%, transparent), transparent 24%),
    var(--saas-card);
  box-shadow: 0 18px 48px rgba(15, 23, 42, .06);
  overflow: hidden;
}

.dashboard-insights-drawer > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 20px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.dashboard-insights-drawer > summary::-webkit-details-marker {
  display: none;
}

.dashboard-insights-drawer > summary::after {
  content: "Open";
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.dashboard-insights-drawer[open] > summary::after {
  content: "Hide";
  color: var(--green);
}

.dashboard-insights-drawer > summary small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.dashboard-insights-drawer .rk-classic-dashboard {
  margin: 0;
  padding: 0 16px 16px;
}

.dashboard-ops-grid {
  align-items: stretch;
}

.pipeline-command-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--saas-border);
  border-radius: 22px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 88%, white), color-mix(in srgb, var(--green) 5%, var(--surface))),
    var(--surface);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .05);
}

.pipeline-command-bar input,
.pipeline-command-bar select {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
}

.pipeline-command-bar .btn {
  min-height: 48px;
  white-space: nowrap;
}

.pipeline-filter-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.pipeline-empty {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 22px;
}

.pipeline-board .crm-column {
  box-shadow: 0 14px 36px rgba(15, 23, 42, .06);
}

.pipeline-board .crm-column-head {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green) 8%, transparent), color-mix(in srgb, var(--cyan) 7%, transparent));
}

@media (max-width: 1280px) {
  .pipeline-command-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .pipeline-command-bar {
    grid-template-columns: 1fr 1fr;
    padding: 10px;
    border-radius: 18px;
  }

  .pipeline-command-bar input {
    grid-column: 1 / -1;
  }

  .dashboard-insights-drawer > summary {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .dashboard-insights-drawer > summary::after {
    align-self: stretch;
    text-align: center;
  }
}

/* v19.1.5 Phase 1 mobile stability pack: inbox, filters, cards and touch ergonomics. */
#view-inbox .conv-sidebar {
  overflow: hidden;
}

#view-inbox .side-head,
#view-inbox .filters {
  position: sticky;
  z-index: 6;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, var(--green) 3%), var(--surface));
}

#view-inbox .side-head {
  top: 0;
}

#view-inbox .filters {
  top: 64px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 14px 28px rgba(15, 23, 42, .04);
}

#view-inbox .inbox-tools {
  display: flex !important;
  gap: 8px !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

#view-inbox .inbox-tools::-webkit-scrollbar {
  display: none;
}

#view-inbox .inbox-filter {
  flex: 0 0 auto;
  min-width: max-content;
  min-height: 38px;
  padding-inline: 15px;
  scroll-snap-align: start;
  white-space: nowrap;
}

html:not(.inbox-select-mode) #view-inbox .conversation {
  grid-template-columns: 42px minmax(0, 1fr) auto !important;
}

html:not(.inbox-select-mode) #view-inbox .conversation-check-wrap {
  display: none !important;
}

html.inbox-select-mode #view-inbox .conversation {
  grid-template-columns: 22px 42px minmax(0, 1fr) auto !important;
}

#inboxSelectModeBtn.active {
  background: color-mix(in srgb, var(--green) 16%, var(--surface)) !important;
  border-color: color-mix(in srgb, var(--green) 42%, var(--line)) !important;
  color: var(--green) !important;
}

#view-inbox .conv-name {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

#view-inbox .conv-name .hot-dot {
  flex: 0 0 auto;
}

#view-inbox .conv-preview {
  line-height: 1.35;
}

#view-inbox .conv-more {
  width: fit-content;
  margin-top: 2px;
}

#view-inbox .inbox-bulk-bar {
  transform-origin: top;
  transition: opacity 160ms ease, transform 160ms ease, max-height 160ms ease;
}

#view-leads .lead-filter-toggle {
  white-space: nowrap;
}

@media (max-width: 980px) {
  #view-leads .lead-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(150px, .55fr);
  }

  #view-leads .lead-toolbar input {
    grid-column: 1 / -1;
  }

  #view-leads .lead-filter-toggle {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  html:not([data-layout="desktop"]) .app {
    grid-template-columns: 1fr !important;
  }

  html:not([data-layout="desktop"]) .main {
    min-width: 0;
    overflow-x: hidden;
  }

  html[data-layout="mobile"] .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
  }

  html[data-layout="mobile"] .brand h1 {
    font-size: 17px !important;
    max-width: 190px;
  }

  html[data-layout="mobile"] .layout-switch,
  html[data-layout="mobile"] .theme-switch {
    display: inline-flex !important;
  }

  html[data-layout="mobile"] #view-inbox .side-head {
    min-height: 58px;
    padding: 10px 14px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  html[data-layout="mobile"] #view-inbox .section-title {
    font-size: 12px !important;
    letter-spacing: .1em;
  }

  html[data-layout="mobile"] #view-inbox .inbox-head-actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 7px !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  html[data-layout="mobile"] #view-inbox .inbox-head-actions::-webkit-scrollbar {
    display: none;
  }

  html[data-layout="mobile"] #view-inbox .inbox-head-actions .btn,
  html[data-layout="mobile"] #view-inbox .inbox-head-actions .icon-btn,
  html[data-layout="mobile"] #view-inbox .global-bot-toggle {
    flex: 0 0 auto;
    min-height: 34px !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
  }

  html[data-layout="mobile"] #view-inbox .filters {
    top: 98px;
    padding: 10px 14px 12px !important;
  }

  html[data-layout="mobile"] #conversationSearch {
    min-height: 42px !important;
    border-radius: 15px !important;
    font-size: 15px !important;
  }

  html[data-layout="mobile"] #view-inbox .inbox-filter {
    min-height: 38px !important;
    padding: 8px 15px !important;
    font-size: 12px !important;
  }

  html[data-layout="mobile"] #view-inbox .conversation {
    min-height: 64px !important;
    padding: 9px 14px !important;
    gap: 10px !important;
  }

  html[data-layout="mobile"] #view-inbox .conversation .avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
  }

  html[data-layout="mobile"] #view-inbox .conv-name {
    font-size: 14px !important;
  }

  html[data-layout="mobile"] #view-inbox .conv-preview {
    -webkit-line-clamp: 1 !important;
    color: color-mix(in srgb, var(--muted) 70%, var(--text) 30%) !important;
    font-size: 12.5px !important;
  }

  html[data-layout="mobile"] #view-inbox .conv-right {
    min-width: 42px;
    font-size: 11px !important;
  }

  html[data-layout="mobile"] #view-inbox .unread {
    min-width: 22px;
    height: 22px;
    font-size: 11px;
  }

  html[data-layout="mobile"] #view-inbox .inbox-bulk-bar {
    position: sticky;
    top: 184px;
    z-index: 5;
    grid-template-columns: auto minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--line);
    background: var(--surface) !important;
  }

  html[data-layout="mobile"] #view-inbox .inbox-bulk-bar .btn {
    flex: 1 1 auto !important;
    min-width: 86px;
  }

  html[data-layout="mobile"] #inboxPager {
    display: none !important;
  }

  html[data-layout="mobile"] #view-leads .lead-toolbar {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  html[data-layout="mobile"] #view-leads .lead-toolbar input,
  html[data-layout="mobile"] #view-leads .lead-filter-toggle {
    grid-column: 1 / -1;
  }

  html[data-layout="mobile"] #view-leads .advanced-lead-filters {
    display: none !important;
  }

  html[data-layout="mobile"].lead-filters-open #view-leads .advanced-lead-filters {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
  }

  html[data-layout="mobile"].lead-filters-open #view-leads .advanced-lead-filters #clearLeadFiltersBtn,
  html[data-layout="mobile"].lead-filters-open #view-leads .advanced-lead-filters input,
  html[data-layout="mobile"].lead-filters-open #view-leads .advanced-lead-filters select {
    min-width: 0;
  }

  html[data-layout="mobile"] #view-leads .super-crm-panel.lead-editor-closed {
    padding: 12px !important;
  }

  html[data-layout="mobile"] #view-leads .super-crm-panel.lead-editor-closed .card-title {
    font-size: 13px !important;
  }

  html[data-layout="mobile"] #view-leads .super-crm-actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 8px !important;
    scrollbar-width: none;
  }

  html[data-layout="mobile"] #view-leads .super-crm-actions::-webkit-scrollbar {
    display: none;
  }

  html[data-layout="mobile"] #view-leads .super-crm-actions .btn,
  html[data-layout="mobile"] #view-leads .shuffle-folder {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 124px !important;
  }

  html[data-layout="mobile"] .super-crm-kpi-grid,
  html[data-layout="mobile"] .calling-kpi-grid,
  html[data-layout="mobile"] .calling-mini-kpis,
  html[data-layout="mobile"] .followup-folder-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  html[data-layout="mobile"] .super-kpi,
  html[data-layout="mobile"] .calling-kpi,
  html[data-layout="mobile"] .followup-folder-card {
    min-height: 96px !important;
    padding: 13px !important;
  }

  html[data-layout="mobile"] .super-kpi strong,
  html[data-layout="mobile"] .calling-kpi strong,
  html[data-layout="mobile"] .followup-folder-card strong {
    font-size: clamp(24px, 8vw, 34px) !important;
  }

  html[data-layout="mobile"] .pipeline-command-bar {
    grid-template-columns: 1fr !important;
  }

  html[data-layout="mobile"] .pipeline-board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(84vw, 1fr);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
  }

  html[data-layout="mobile"] .pipeline-board > * {
    scroll-snap-align: start;
  }
}

/* Phase 3 command intelligence polish */
.lead-pager-summary {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.active-drill-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 5px 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--green) 34%, var(--line));
  color: var(--text);
  font-weight: 850;
}

.active-drill-chip button {
  min-height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 0 9px;
  background: color-mix(in srgb, var(--green) 24%, white);
  color: #064e3b;
  font-weight: 850;
  cursor: pointer;
}

.calling-command-digest {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.calling-digest-card {
  position: relative;
  min-height: 110px;
  display: grid;
  align-content: start;
  gap: 6px;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 22px;
  padding: 16px;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--digest-color, #10b981) 16%, transparent), transparent 42%),
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 94%, white), color-mix(in srgb, var(--surface) 88%, var(--digest-color, #10b981) 6%));
  color: var(--text);
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.07);
  cursor: pointer;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.calling-digest-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--digest-color, #10b981);
}

.calling-digest-card:hover,
.calling-digest-card:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--digest-color, #10b981) 45%, var(--line));
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.12);
  outline: none;
}

.calling-digest-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.calling-digest-card strong {
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1;
  color: var(--text);
}

.calling-digest-card small {
  color: var(--muted);
  font-weight: 700;
}

.calling-digest-card.danger { --digest-color: #ef4444; }
.calling-digest-card.gold { --digest-color: #f59e0b; }
.calling-digest-card.blue { --digest-color: #2563eb; }
.calling-digest-card.green { --digest-color: #10b981; }

#view-calling .calling-kpi,
#view-calling .calling-mini,
#view-calling .calling-digest-card {
  isolation: isolate;
}

#view-calling .calling-kpi strong,
#view-calling .calling-mini strong {
  letter-spacing: 0;
}

#view-calling .calling-row .calling-main small,
#view-calling .calling-board-row span,
#view-calling .calling-tiny-lead span {
  color: color-mix(in srgb, var(--muted) 86%, var(--text));
}

#view-calling .calling-row.risk {
  border-color: color-mix(in srgb, #ef4444 30%, var(--line)) !important;
}

html[data-theme="dark"] .calling-digest-card,
html.dark .calling-digest-card {
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--digest-color, #10b981) 18%, transparent), transparent 42%),
    linear-gradient(145deg, rgba(10, 18, 15, 0.96), rgba(7, 15, 14, 0.92));
}

html[data-theme="dark"] .active-drill-chip,
html.dark .active-drill-chip {
  background: color-mix(in srgb, var(--green) 14%, #07100d);
}

@media (max-width: 1100px) {
  .calling-command-digest {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  html[data-layout="mobile"] .calling-command-digest {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(72vw, 1fr);
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
  }

  html[data-layout="mobile"] .calling-digest-card {
    scroll-snap-align: start;
    min-height: 96px;
    border-radius: 20px;
  }

  html[data-layout="mobile"] .lead-pager-summary {
    width: 100%;
    display: grid;
    gap: 6px;
  }

  html[data-layout="mobile"] .active-drill-chip {
    width: fit-content;
    max-width: 100%;
  }
}
