/* ─── Analytics Dashboard ───────────────────────────────────
   Single dashboard, global period toggle.
   Mains: green + violet. Rest neutral.
──────────────────────────────────────────────────────────── */
.analytics-grid { display: flex; flex-direction: column; gap: 20px; }

/* ── Toolbar / period toggle ── */
/* Analytics period toolbar: in the body, above the grid */
#view-analytics .an-toolbar-wrap { margin-bottom: 20px; }
.an-toolbar {
  display: flex; align-items: center; justify-content: flex-start; gap: 12px;
}
.an-period-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  height: 33.5px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-btn); padding: 3px;
}
.an-period-toggle button {
  border: none; background: none; cursor: pointer;
  padding: 5px 16px; border-radius: var(--r-btn);
  font-size: 13px; font-weight: 500; color: var(--tsec);
  font-family: inherit; transition: all 0.15s;
}
.an-period-toggle button:hover { color: var(--text); }
.an-period-toggle button.active { background: var(--primary); color: var(--white); font-weight: 600; }
/* ── Period navigation ── */
.an-nav {
  display: inline-flex; align-items: center; gap: 4px;
  height: 33.5px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-btn); padding: 2px;
}
.an-nav-label { font-size: 13.5px; font-weight: 700; color: var(--text); min-width: 84px; text-align: center; }
.an-nav-btn {
  width: 27px; height: 27px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: var(--primary); color: var(--white);
  border-radius: 50%; cursor: pointer; transition: all 0.15s;
}
.an-nav-btn:hover:not(:disabled) { background: var(--primary-hover); }
.an-nav-btn:disabled { opacity: 0.4; cursor: default; }
.an-nav-btn .material-symbols-outlined { font-size: 18px; }

/* ── KPI cards ── */
.an-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.an-kpi { position: relative; padding: 18px 18px 16px; }
.an-kpi-icon {
  width: 32px; height: 32px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--tsec); margin-bottom: 8px;
}
/* icon fill = lightest tint of its colour, card stays white */
.an-kpi-green  .an-kpi-icon { color: var(--green-dark);   background: var(--green); }
.an-kpi-violet .an-kpi-icon { color: var(--lav-d);        background: var(--lav); }
.an-kpi-amber  .an-kpi-icon { color: var(--amber-strong); background: var(--amber-bg); }
.an-kpi-grey   .an-kpi-icon { color: var(--tsec);         background: var(--bg); }
/* Eye-toggle legend for the overview line chart */
.an-line-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.an-leg {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px; border: 1px solid var(--border); background: var(--white);
  border-radius: 999px; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600; color: var(--text); transition: all 0.15s;
}
.an-leg:hover { background: var(--bg); }
.an-leg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.an-leg .material-symbols-outlined { font-size: 15px; color: var(--tsec); }
.an-leg-off { opacity: 0.55; }
.an-leg-off .an-leg-name { color: var(--tsec); }
.an-leg-off .an-leg-dot { background: var(--border-s) !important; }
.an-kpi-value {
  font-size: 28px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1;
  color: var(--text); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.an-kpi-value.an-pos { color: var(--green-dark); }
.an-kpi-sub { font-size: 11.5px; color: var(--tsec); min-height: 16px; }
.an-delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.an-delta .material-symbols-outlined { font-size: 15px; }
.an-delta-up   { color: var(--green-dark); }
.an-delta-down { color: var(--danger); }

/* ── Requires your attention (subtle) ── */
.an-attention { padding: 18px 22px; border: 1px solid var(--border-s); }
.an-attn-list { display: flex; flex-direction: column; gap: 8px; }
.an-attn-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--r-md);
}
.an-attn-icon {
  width: 32px; height: 32px; border-radius: var(--r-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--tsec); background: var(--bg);
}
/* icon carries severity colour + soft matching fill */
.an-attn-urgent  .an-attn-icon { color: var(--danger);        background: var(--danger-bg); }
.an-attn-warning .an-attn-icon { color: var(--amber-strong);  background: var(--warning-bg); }
.an-attn-info    .an-attn-icon { color: var(--lav-d);         background: var(--lav); }
.an-attn-text { flex: 1; min-width: 0; }
.an-attn-title { font-size: 13px; font-weight: 600; color: var(--text); }
.an-attn-detail { font-size: 12px; color: var(--tsec); margin-top: 1px; }
.an-attn-btn {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--white);
  color: var(--tsec); font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 13px; border-radius: var(--r-btn); cursor: pointer; transition: all 0.15s;
}
.an-attn-btn:hover { background: var(--bg); color: var(--text); }
.an-attn-news { text-decoration: none; color: inherit; transition: background 0.12s; }
.an-attn-news:hover { background: var(--bg); }
.an-attn-go { font-size: 17px; color: var(--tph); flex-shrink: 0; }
.an-attn-empty {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--tsec); padding: 4px 2px;
}
.an-attn-empty .material-symbols-outlined { font-size: 19px; color: var(--green-strong); }

/* ── Chart row ── */
.an-kpis, .an-row, .an-charts-grid { display: grid; gap: 20px; }
.an-row { grid-template-columns: 1fr 1fr; }
.an-row-hero { grid-template-columns: repeat(4, 1fr); }
.an-row-hero > .an-card-chart { grid-column: span 3; }
.an-charts-grid { grid-template-columns: repeat(2, 1fr); }
.an-charts-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 600px)  { .an-charts-grid { grid-template-columns: 1fr; } }
.an-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px; min-width: 0;
}
.an-card > .kpi-label { margin-bottom: 16px; }
.an-chart-wrap { height: 200px; position: relative; }
.an-chart-wrap-lg { height: 280px; }
.an-hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--tph); }

/* ── Donut ── */
.an-card-donut { container-type: inline-size; }
/* Narrow card: donut spans the width, legend stacks below */
.an-donut-layout { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.an-donut-wrap { position: relative; width: 170px; height: 170px; flex-shrink: 0; }
.an-donut-legend { width: 100%; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
/* Wide enough card (≈ over half width): donut + legend side by side */
@container (min-width: 520px) {
  .an-donut-layout { flex-direction: row; align-items: center; gap: 18px; }
  .an-donut-wrap { width: 150px; height: 150px; }
  .an-donut-legend { flex: 1; width: auto; }
}
.an-donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
  transition: opacity 0.12s;
}
.an-donut-wrap:hover .an-donut-center { opacity: 0; }
.an-donut-center-val { font-size: 16px; font-weight: 800; letter-spacing: -0.4px; color: var(--text); font-variant-numeric: tabular-nums; }
.an-donut-center-lbl { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--tph); }
.an-legend-row { display: flex; align-items: center; gap: 8px; }
.an-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.an-legend-name { font-size: 13px; font-weight: 600; color: var(--text); }
.an-legend-val { margin-left: auto; font-size: 12px; color: var(--tsec); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Income by client ── */
.an-clients { display: flex; flex-direction: column; gap: 12px; }
.an-client-row { display: flex; align-items: center; gap: 14px; }
.an-client-name {
  flex: 0 0 140px; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.an-client-bar-wrap { flex: 1; height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.an-client-bar { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.an-client-amount {
  flex: 0 0 90px; text-align: right; font-size: 13px; font-weight: 700;
  color: var(--text); font-variant-numeric: tabular-nums;
}

/* ── Empty states ── */
.an-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 6px; padding: 28px 20px; color: var(--tsec);
}
.an-empty .material-symbols-outlined { font-size: 32px; color: var(--tph); margin-bottom: 4px; }
.an-empty p { font-size: 13px; font-weight: 600; }
.an-empty-hint { font-size: 12px !important; font-weight: 400 !important; color: var(--tph); max-width: 260px; }
.an-empty-sm { padding: 18px; }
.an-disclaimer { font-size: 11px; color: var(--tph); margin: 12px 0 0; }
.an-kpi-disclaimer { display: none; }

@media (max-width: 900px) {
  .an-kpis { grid-template-columns: repeat(2, 1fr); }
  .an-row, .an-row-hero { grid-template-columns: 1fr; }
}
