/* ===== Dashboard layout ===== */
.dashboard {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.dashboard__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.dashboard__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Period switch */
.period-switch {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.period-switch__btn {
  padding: 0.45rem 0.85rem;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}
.period-switch__btn:hover { color: var(--primary); }
.period-switch__btn.is-active {
  background: var(--primary);
  color: #fff;
}

/* ===== KPI grid ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 1.4rem 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.kpi-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.kpi-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 19px;
}
.kpi-card__icon--blue { background: var(--primary-50); }
.kpi-card__icon--sky { background: rgba(159, 212, 239, 0.25); }
.kpi-card__icon--green { background: rgba(16, 185, 129, 0.12); }
.kpi-card__icon--amber { background: rgba(245, 158, 11, 0.12); }
.kpi-card__trend {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}
.kpi-card__trend--up { color: #047857; background: rgba(16, 185, 129, 0.12); }
.kpi-card__trend--down { color: #b45309; background: rgba(245, 158, 11, 0.14); }
.kpi-card__value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.1;
}
.kpi-card__label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Chart card ===== */
.chart-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 1.6rem 1.75rem;
  margin-bottom: 2rem;
}
.chart-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chart-card__title {
  margin: 0 0 0.2rem;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.chart-card__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.chart-card__legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.legend-dot--primary { background: var(--primary); }
.legend-dot--sky { background: var(--accent-sky); }
.chart-card__body {
  width: 100%;
  height: 280px;
}
#mainChart {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Agents section ===== */
.agents-section {
  margin-bottom: 2rem;
}
.agents-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary);
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.agent-tile {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-md);
  border-radius: 18px;
  padding: 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.agent-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-sky);
}
.agent-tile__head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}
.agent-tile__avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(48, 116, 243, 0.2);
}
.agent-tile__name-wrap {
  flex: 1;
  min-width: 0;
}
.agent-tile__name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-tile__llm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  padding: 2px 7px;
  background: var(--bg-base);
  border-radius: 999px;
}
.agent-tile__status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-top: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}
.agent-tile__status--paused { background: var(--neutral); box-shadow: 0 0 0 3px rgba(160, 164, 173, 0.25); }

.agent-tile__stats {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.agent-tile__calls {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.agent-tile__calls-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.agent-tile__calls-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.agent-tile__trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  margin-top: 4px;
  width: fit-content;
}
.agent-tile__trend--up { color: #047857; background: rgba(16, 185, 129, 0.12); }
.agent-tile__trend--down { color: #b91c1c; background: rgba(239, 68, 68, 0.1); }

.agent-tile__spark {
  width: 120px;
  height: 44px;
}
.agent-tile__spark svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Secondary stats grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-md);
  border-radius: 18px;
  padding: 1.4rem 1.5rem;
}
.stat-card__title {
  margin: 0 0 0.15rem;
  font-size: 15px;
  font-weight: 600;
}
.stat-card__subtitle {
  margin: 0 0 1.1rem;
  font-size: 12.5px;
  color: var(--text-muted);
}
.stat-card__note {
  margin: 0.85rem 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Token bar */
.token-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.85rem;
  background: var(--bg-base);
}
.token-bar__segment { height: 100%; transition: width 0.5s ease; }
.token-bar__segment--input { background: var(--primary); }
.token-bar__segment--output { background: var(--accent-sky); }
.token-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 13px;
}
.token-legend strong { font-weight: 600; font-size: 14px; }
.token-legend small { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.token-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.token-footer .label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.token-footer strong { font-size: 15px; font-weight: 600; }

/* Top list */
.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  counter-reset: top;
}
.top-list li {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  counter-increment: top;
}
.top-list li::before {
  content: counter(top);
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-50);
  color: var(--primary);
}
.top-list__name { flex: 1; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list__value { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.top-list__pct {
  flex-basis: 100%;
  height: 3px;
  background: var(--bg-base);
  border-radius: 2px;
  margin-top: 4px;
  order: 99;
  overflow: hidden;
}
.top-list__pct span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-sky));
  border-radius: 2px;
}
.top-list li {
  flex-wrap: wrap;
  row-gap: 0;
}

/* Hours chart */
.hours-chart {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  align-items: end;
  height: 80px;
}
.hours-chart__bar {
  background: linear-gradient(180deg, var(--primary), var(--accent-sky));
  border-radius: 2px 2px 0 0;
  min-height: 3px;
  transition: opacity 0.2s;
  position: relative;
}
.hours-chart__bar:hover { opacity: 0.8; }
.hours-chart__bar.is-peak {
  background: linear-gradient(180deg, #1e4fb3, var(--primary));
}

/* Activity list */
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.activity-list li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.activity-list li:last-child { border-bottom: none; padding-bottom: 0; }
.activity-list__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: var(--primary-50);
  flex-shrink: 0;
}
.activity-list__text {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  min-width: 0;
}
.activity-list__text strong { font-weight: 600; }
.activity-list__time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .dashboard { padding: 1.75rem 1.25rem 3rem; }
  .chart-card__body { height: 220px; }
}
@media (max-width: 640px) {
  .dashboard { padding: 1.25rem 0.75rem 2.5rem; }
  .dashboard__header { flex-direction: column; align-items: flex-start; }
  .kpi-card__value { font-size: 24px; }
  .agent-tile__spark { width: 90px; }
  .chart-card { padding: 1.25rem; }
  .chart-card__body { height: 200px; }
}
