:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-subtle: #f8fafb;
  --sidebar: #101b2a;
  --sidebar-hover: #18283a;
  --text: #122033;
  --text-secondary: #647184;
  --text-muted: #8b96a5;
  --border: #dfe4ea;
  --border-strong: #cfd6df;
  --primary: #126b8a;
  --primary-dark: #0e5068;
  --teal: #138c83;
  --indigo: #5965a8;
  --amber: #b57616;
  --rose: #a84c60;
  --success: #238a6b;
  --danger: #b44055;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --sidebar-width: 208px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(18, 107, 138, 0.22);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.auth-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.auth-card-stack {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.auth-copy {
  display: grid;
  gap: 4px;
}

.auth-card strong {
  display: block;
  font-size: 15px;
}

.auth-card p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.clerk-sign-in-mount {
  width: 100%;
}

.clerk-sign-in-mount:empty {
  min-height: 180px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 16px 12px 14px;
  background: var(--sidebar);
  color: #ffffff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 16px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--teal), var(--primary));
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span {
  margin-top: 2px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.56);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.66);
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-item.is-active {
  border-color: rgba(255, 255, 255, 0.06);
  background: #172638;
  color: #ffffff;
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 2px;
  border-radius: 999px;
  background: var(--teal);
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  color: rgba(255, 255, 255, 0.62);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.nav-item.is-active .nav-icon {
  color: #7adad2;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.035);
}

.security-note strong,
.security-note span {
  display: block;
}

.security-note strong {
  font-size: 11px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.84);
}

.security-note span:not(.security-dot) {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.46);
  font-size: 10px;
  line-height: 1.35;
}

.security-dot,
.sync-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(35, 138, 107, 0.12);
}

.main-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 18px 22px 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.light {
  color: rgba(255, 255, 255, 0.66);
}

.topbar h1,
.hero-panel h2,
.database-hero h2,
.panel h3,
.drawer-header h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 23px;
  line-height: 1.18;
  letter-spacing: 0;
}

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

.sync-status {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.sync-status.is-stale .sync-dot {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(181, 118, 22, 0.12);
}

.sync-status.is-error .sync-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 64, 85, 0.12);
}

.user-chip {
  display: flex;
  min-width: 148px;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--teal), var(--primary));
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.user-chip strong,
.user-chip span {
  display: block;
}

.user-chip strong {
  max-width: 112px;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.15;
}

.btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.btn-ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text-secondary);
}

.sidebar .btn-ghost {
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.68);
}

.sidebar .btn-ghost:hover:not(:disabled) {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.btn-light {
  border-color: rgba(255, 255, 255, 0.22);
  background: #ffffff;
  color: var(--primary-dark);
}

.btn-link {
  min-height: 28px;
  padding: 0;
  background: transparent;
  color: var(--primary);
}

.btn-full {
  width: 100%;
}

.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 1.45;
}

.alert-error {
  border: 1px solid #e9b8c3;
  background: #fff2f4;
  color: #81283a;
}

.view-panel {
  display: block;
}

.hero-panel,
.database-hero {
  display: flex;
  min-height: 98px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #122033 0%, #10283a 68%, #123e45 100%);
  color: #ffffff;
}

.hero-panel h2,
.database-hero h2 {
  max-width: 680px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.hero-panel p:not(.eyebrow),
.database-hero p:not(.eyebrow) {
  max-width: 720px;
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.45;
}

.hero-meta {
  min-width: 180px;
  padding: 10px 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.hero-meta span,
.hero-meta strong {
  display: block;
}

.hero-meta span {
  color: rgba(255, 255, 255, 0.52);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-meta strong {
  margin-top: 5px;
  color: #ffffff;
  font-size: 12px;
  line-height: 1.35;
}

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

.kpi-card {
  position: relative;
  display: flex;
  min-height: 110px;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-top: 2px solid var(--text-muted);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-card.accent-blue { border-top-color: var(--primary); }
.kpi-card.accent-teal { border-top-color: var(--teal); }
.kpi-card.accent-indigo { border-top-color: var(--indigo); }
.kpi-card.accent-amber { border-top-color: var(--amber); }
.kpi-card.accent-rose { border-top-color: var(--rose); }
.kpi-card.accent-slate { border-top-color: var(--text-muted); }

.kpi-label {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
}

.kpi-number {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.kpi-number.currency {
  font-size: 27px;
}

.kpi-foot {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.3;
}

.dashboard-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.dashboard-grid-main {
  grid-template-columns: minmax(0, 2fr) minmax(250px, 0.72fr);
  align-items: stretch;
}

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

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-header-row {
  align-items: center;
}

.panel h3 {
  font-size: 15px;
  line-height: 1.22;
  letter-spacing: 0;
}

.panel-tag {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.chart-wrap {
  position: relative;
  height: 228px;
}

.chart-wrap.chart-wide {
  height: 252px;
}

.chart-wrap.compact {
  height: 190px;
}

.rank-list {
  display: grid;
  gap: 10px;
  padding-top: 1px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
}

.rank-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-total {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
}

.rank-bar {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f4;
}

.rank-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.action-stack {
  display: grid;
  gap: 6px;
}

.action-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease;
}

.action-row:hover {
  border-color: var(--border);
  background: var(--surface-subtle);
}

.action-row span strong,
.action-row span small {
  display: block;
}

.action-row span strong {
  overflow: hidden;
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-row span small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.3;
}

.action-row b {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.action-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-teal { background: var(--teal); }
.dot-amber { background: var(--amber); }
.dot-slate { background: var(--text-muted); }

.recent-list {
  display: grid;
  overflow: hidden;
  border-top: 1px solid var(--border);
}

.recent-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.85fr) minmax(155px, 0.7fr) minmax(240px, 1.6fr) auto;
  min-height: 52px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.recent-row:hover {
  background: var(--surface-subtle);
}

.contact-block strong,
.contact-block span,
.reason-block strong,
.reason-block span {
  display: block;
}

.contact-block strong,
.reason-block strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-block span,
.reason-block span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.25;
}

.reason-block strong {
  color: var(--text-secondary);
  font-weight: 650;
}

.loading-block,
.table-empty,
.empty-state {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.loading-block {
  padding: 24px 14px;
}

.badge {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge-comprador {
  border-color: #a7d8d3;
  background: #ebf8f6;
  color: #0c7069;
}

.badge-asesor {
  border-color: #c8cdeb;
  background: #f1f2fb;
  color: #4f5a9d;
}

.badge-asesor_potencial {
  border-color: #ebd2a4;
  background: #fff7e8;
  color: #8a5b14;
}

.badge-evento_capacitacion {
  border-color: #c9d9e7;
  background: #f0f6fa;
  color: #44687f;
}

.badge-propietario_vendedor {
  border-color: #e6bac5;
  background: #fff2f5;
  color: #94394d;
}

.badge-perfil_comercial,
.badge-inversion_general,
.badge-mixto {
  border-color: #cdd2e7;
  background: #f4f5fb;
  color: #565f8c;
}

.badge-indefinido {
  border-color: #d7dde4;
  background: #f5f7f9;
  color: #657184;
}

.badge-anuncio {
  border-color: #a7d8d3;
  background: #ebf8f6;
  color: #0c7069;
}

.badge-ruta_historica {
  border-color: #d7dde4;
  background: #f5f7f9;
  color: #657184;
}

.badge-conversacion {
  border-color: #bed4e2;
  background: #eef6fa;
  color: #2d657f;
}

.badge-signal {
  border-color: #d7dde4;
  background: #ffffff;
  color: var(--text-secondary);
  font-weight: 700;
}

.filters-panel {
  margin-bottom: 14px;
  padding: 14px;
}

.filters-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.45fr) repeat(4, minmax(128px, 0.65fr));
  gap: 10px;
}

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

.field span,
.page-size-control span {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 750;
}

.field input,
.field select,
.page-size-control select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.field input::placeholder {
  color: #9ca7b4;
}

.filters-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.table-toolbar h3 {
  margin-bottom: 2px;
}

.muted {
  color: var(--text-muted);
  font-size: 10px;
}

.page-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-size-control select {
  width: 72px;
  min-height: 34px;
}

.table-scroll {
  width: 100%;
  max-height: calc(100vh - 270px);
  overflow: auto;
}

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

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e9eef2;
  vertical-align: middle;
  text-align: left;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 800;
}

.data-table td {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.42;
}

.data-table tbody tr {
  height: 54px;
}

.data-table tbody tr:hover {
  background: var(--surface-subtle);
}

.data-table .table-empty {
  padding: 32px 20px;
}

.table-contact strong,
.table-contact span {
  display: block;
}

.table-contact strong {
  max-width: 190px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-contact span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
}

.table-reason {
  max-width: 360px;
  color: #4f5d6b;
}

.signal-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 210px;
}

.confidence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 10px;
}

.confidence-bar {
  width: 50px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf1;
}

.confidence-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.table-action {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.table-action:hover {
  border-color: #a9c6d4;
  background: #f2f8fa;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
}

.pagination span {
  min-width: 130px;
  color: var(--text-secondary);
  font-size: 11px;
  text-align: center;
}

.campaign-kpis {
  margin-top: 0;
}

.empty-state {
  display: grid;
  height: 252px;
  place-content: center;
  padding: 18px;
}

.empty-state strong {
  color: var(--text);
  font-size: 14px;
}

.empty-state p {
  max-width: 390px;
  margin: 6px auto 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

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

.insight-list > div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.insight-list > div:last-child {
  border-bottom: 0;
}

.insight-list span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: #eef6fa;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
}

.insight-list p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

.insight-list strong {
  color: var(--text);
}

.database-hero {
  min-height: 104px;
}

.database-hero .btn {
  min-width: 190px;
}

.policy-card {
  min-height: 124px;
  padding: 15px;
}

.policy-number {
  display: inline-grid;
  min-width: 28px;
  height: 22px;
  place-items: center;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: #eef6fa;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
}

.policy-card h3 {
  font-size: 14px;
}

.policy-card p {
  margin: 7px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.48;
}

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

.column-grid span {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 650;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px 0;
  color: var(--text-muted);
  font-size: 10px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(16, 27, 42, 0.42);
}

.lead-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 310;
  width: min(460px, 100vw);
  overflow: auto;
  background: var(--surface);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
  transform: translateX(102%);
  transition: transform 200ms ease;
}

.lead-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.drawer-header h2 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

.phone-link {
  display: inline-block;
  margin-top: 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.drawer-content {
  padding: 16px 18px 24px;
}

.drawer-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.drawer-stat,
.drawer-note {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.drawer-stat span,
.drawer-note span {
  display: block;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
}

.drawer-stat strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
}

.drawer-note {
  margin-bottom: 10px;
}

.drawer-note p {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.48;
}

.conversation-title {
  margin: 16px 0 10px;
  color: var(--text);
  font-size: 12px;
}

.message-list {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.message-row {
  display: flex;
}

.message-row.is-human {
  justify-content: flex-end;
}

.message-row.is-ai {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 86%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.is-human .message-bubble {
  border-color: #b8d9d4;
  background: #eef9f7;
  color: #214e49;
}

.message-row.is-ai .message-bubble {
  background: #ffffff;
  color: #465667;
}

.message-id {
  display: block;
  margin-top: 5px;
  color: rgba(100, 113, 132, 0.62);
  font-size: 8px;
  text-align: right;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 500;
  max-width: 360px;
  padding: 11px 13px;
  border: 1px solid #b9d8d2;
  border-radius: var(--radius-md);
  background: #ecf8f5;
  color: #23695d;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
  font-size: 11px;
  font-weight: 750;
}

.toast.is-error {
  border-color: #efbdc7;
  background: #fff2f4;
  color: #8b2940;
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .field-search {
    grid-column: span 2;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 196px;
  }

  .main-content {
    padding: 16px;
  }

  .dashboard-grid-main,
  .dashboard-grid-thirds {
    grid-template-columns: 1fr;
  }

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

  .recent-row {
    grid-template-columns: minmax(170px, 1fr) minmax(160px, 0.8fr) auto;
  }

  .recent-row .reason-block {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 820px) {
  .sidebar {
    position: sticky;
    top: 0;
    inset: auto;
    width: 100%;
    padding: 10px;
  }

  .sidebar-brand {
    padding: 0 2px 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .nav-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    min-width: 132px;
    justify-content: flex-start;
    min-height: 40px;
  }

  .nav-item.is-active::before {
    inset: auto 10px 0;
    width: auto;
    height: 2px;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .sync-status {
    flex: 1 1 160px;
    padding-left: 0;
  }

  .user-chip {
    margin-left: auto;
  }

  .hero-panel,
  .database-hero {
    align-items: flex-start;
    flex-direction: column;
    min-height: auto;
  }

  .hero-meta {
    width: 100%;
    min-width: 0;
    padding: 8px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    border-left: 0;
  }

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

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

  .field-search {
    grid-column: 1 / -1;
  }

  .database-hero .btn {
    width: 100%;
  }

  .recent-row {
    grid-template-columns: 1fr auto;
  }

  .recent-row .badges,
  .recent-row .reason-block {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 22px;
  }

  .hero-panel h2,
  .database-hero h2 {
    font-size: 19px;
  }

  .topbar-actions .btn {
    flex: 0 0 auto;
  }

  .user-chip {
    width: 100%;
    margin-left: 0;
  }

  .kpi-grid,
  .filters-grid,
  .column-grid,
  .drawer-summary-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    min-height: 104px;
  }

  .filters-actions {
    flex-direction: column-reverse;
  }

  .filters-actions .btn {
    width: 100%;
  }

  .panel,
  .hero-panel,
  .database-hero {
    padding: 14px;
  }

  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-footer {
    flex-direction: column;
    gap: 6px;
  }

  .lead-drawer {
    width: 100vw;
  }

  .drawer-header,
  .drawer-content {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.rank-10, .confidence-10 { width: 10%; }
.rank-20, .confidence-20 { width: 20%; }
.rank-30, .confidence-30 { width: 30%; }
.rank-40, .confidence-40 { width: 40%; }
.rank-50, .confidence-50 { width: 50%; }
.rank-60, .confidence-60 { width: 60%; }
.rank-70, .confidence-70 { width: 70%; }
.rank-80, .confidence-80 { width: 80%; }
.rank-90, .confidence-90 { width: 90%; }
.rank-100, .confidence-100 { width: 100%; }
.confidence-0 { width: 0; }
