:root {
  --bg: #f8f5fc;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --text: #2c3e50;
  --muted: #7f8c8d;
  --border: #e0d8eb;
  --shadow: 0 10px 30px rgba(94, 42, 132, 0.10);
  --blue: #3498db;
  --green: #27ae60;
  --amber: #f39c12;
  --red: #e74c3c;
  --purple: #5e2a84;
  --purple-light: #8b5a9f;
  --purple-dark: #3d1a5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(94, 42, 132, 0.10), transparent 26%),
    radial-gradient(circle at top right, rgba(52, 152, 219, 0.08), transparent 24%),
    var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--purple-dark), var(--purple));
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.brand {
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
}

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

.topbar a,
.topbar button {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.topbar a:hover,
.topbar button:hover { background: rgba(255, 255, 255, 0.14); transform: translateY(-1px); }

.container { max-width: 1480px; margin: 0 auto; padding: 24px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-head h1,
h1 { margin: 0; font-size: 2rem; letter-spacing: -0.03em; }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 12px;
}

.tab-button {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(94, 42, 132, 0.18);
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab-button.is-active {
  background: linear-gradient(135deg, var(--purple-dark), var(--purple));
  color: #fff;
  border-color: transparent;
}

.muted { color: var(--muted); }

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.cards-6 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.section-grid { margin-top: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.kpi-card { min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi { font-size: 2.25rem; line-height: 1; font-weight: 800; letter-spacing: -0.04em; }
.kpi-label { margin-top: 8px; font-size: 0.9rem; font-weight: 600; color: var(--text); }
.kpi-note { margin-top: 4px; font-size: 0.78rem; color: var(--muted); }

.section-card h2,
.card h2 { margin: 0; font-size: 1.02rem; letter-spacing: -0.02em; color: var(--purple); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.micro-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.micro-kpis div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(94, 42, 132, 0.06);
  border: 1px solid rgba(94, 42, 132, 0.12);
}

.micro-kpis strong {
  display: block;
  font-size: 1.1rem;
}

.micro-kpis span {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.micro-kpis div span + span {
  margin-top: 2px;
  color: #334155;
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin: 16px 0;
}

label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.9rem; }

input,
select,
button,
.button {
  padding: 10px 12px;
  border: 1px solid rgba(94, 42, 132, 0.18);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text);
}

button,
.button {
  background: linear-gradient(135deg, var(--purple-dark), var(--purple));
  color: #fff;
  border: 0;
  box-shadow: 0 8px 18px rgba(94, 42, 132, 0.18);
}

.button { display: inline-flex; align-items: center; text-decoration: none; }

button:hover,
.button:hover { filter: brightness(1.05); }

table { width: 100%; border-collapse: collapse; }

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  vertical-align: top;
}

th {
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
}

tbody tr:hover { background: rgba(94, 42, 132, 0.05); }

.table-wrap { overflow-x: auto; }

.callers-frequent-table {
  margin-top: 6px;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.72);
}

.callers-frequent-table table {
  min-width: 1180px;
}

.callers-frequent-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(253, 252, 254, 0.98);
  backdrop-filter: blur(10px);
}

.callers-frequent-table th a {
  color: inherit;
  text-decoration: none;
}

.callers-frequent-table th a:hover {
  color: var(--purple);
}

.callers-frequent-table tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.05);
}

.callers-frequent-table tbody tr:hover {
  background: rgba(94, 42, 132, 0.08);
}

.callers-frequent-table td,
.callers-frequent-table th {
  padding: 12px 10px;
}

.callers-frequent-table .caller-cell a {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

.callers-frequent-table .caller-cell a:hover {
  color: var(--purple);
}

.callers-frequent-table .num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-green { background: #dcfce7; color: #166534; }
.pill-amber { background: #fef3c7; color: #92400e; }
.pill-red { background: #fee2e2; color: #991b1b; }
.pill-blue { background: #eadcf6; color: var(--purple); }
.pill-muted { background: #e2e8f0; color: #475569; }
.pill-anonymous { background: #ede9fe; color: #6d28d9; }
.pill-member { background: #dcfce7; color: #166534; }
.pill-queue { background: #dbeafe; color: #1d4ed8; }
.pill-ivr { background: #fef3c7; color: #92400e; }
.pill-mailbox { background: #e2e8f0; color: #475569; }
.pill-busy_closed { background: #fee2e2; color: #991b1b; }
.pill-unknown { background: #e2e8f0; color: #475569; }

.section-card canvas { width: 100% !important; height: 300px !important; }

.chart-box {
  position: relative;
  height: 300px;
}

.chart-box-small {
  height: 240px;
}

.chart-box-rota {
  height: 520px;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

[data-tab-panel][hidden] {
  display: none !important;
}

[data-tab-panel] {
  width: 100%;
}

.expandable-table {
  margin-top: 14px;
}

.expandable-table summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--purple);
  list-style: none;
  padding: 10px 0;
}

.expandable-table summary::-webkit-details-marker {
  display: none;
}

.expandable-table[open] summary {
  margin-bottom: 10px;
}

.expandable-table table {
  margin-top: 4px;
}

[data-tab-panel] > .grid.two {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.stack { display: grid; gap: 12px; }
.sync-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.sync-result { min-height: 96px; display: grid; gap: 10px; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.pagination-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.error { color: var(--red); }

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 0.9em;
}

@media (max-width: 860px) {
  .page-head { align-items: flex-start; }
  .topbar { position: static; }
  .container { padding: 18px; }
}
