/* Cards and the blocks that live on them: stats, notes, empty states and a timeline. Popups and the admin build on them. */

.card {
  position: relative; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--sh-card);
}
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.card-head > div:first-child:not(.right), .card-head > .head-ic + div { flex: 1 1 0; min-width: 0; }
/* An icon tile in front of a card's title, tinted with --tone. */
.head-ic {
  --tone: var(--brand-text);
  display: grid; place-items: center; flex: none; align-self: flex-start; width: 40px; height: 40px; border-radius: var(--r-l);
  background: color-mix(in srgb, var(--tone) 14%, var(--tone-base, transparent)); color: var(--tone);
}
.head-ic svg, .card-head .head-ic svg { width: 18px; height: 18px; color: var(--tone); vertical-align: 0; }
/* On a phone the title of a card with an icon keeps its row, and whatever stands on the right moves under it. */
@media (max-width: 600px) {
  .card-head > .head-ic + div { flex-basis: calc(100% - 52px); }
  .card-head > .head-ic + div + .right, .card-head > .head-ic + div + * { margin-left: 52px; }
}
.tone-brand { --tone: var(--brand-text); }
.tone-ok { --tone: var(--ok); }
.tone-warn { --tone: var(--warn); }
.tone-bad { --tone: var(--bad); --tone-base: var(--bad-base); }
.tone-sky { --tone: var(--accent-sky); }
.tone-steel { --tone: var(--accent-steel); }
.tone-teal { --tone: var(--accent-teal); }
.tone-gold { --tone: var(--accent-gold); }
.tone-graphite { --tone: var(--accent-graphite); }
.tone-mute { --tone: var(--ink-3); }
.card-head h3 { font-size: var(--fs-l); font-weight: 600; letter-spacing: var(--tr-snug); }
.card-head .sub { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--ink-4); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-head svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--brand-text); }
.card-head .btn svg { color: inherit; vertical-align: 0; }
.card-body { padding: 20px 22px; }
.card-body.tight { padding: 10px; }

.card-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px; border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-card) var(--r-card); background: var(--panel-2);
  font-size: var(--fs-xs); color: var(--ink-4);
}
.card-foot.pager { justify-content: space-between; }

/* ---------- Stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  position: relative; min-width: 0; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--sh-card);
}
.kpi .k-l { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: var(--tr-caps); text-transform: uppercase; color: var(--ink-4); }
.kpi .k-v {
  margin-top: 6px; font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1.1;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--ink);
}
.kpi .k-v small { margin-left: 1px; font-size: var(--fs-l); font-weight: 600; letter-spacing: 0; color: var(--ink-4); }
.kpi .k-v.ok { color: var(--ok); }
.kpi .k-v.warn { color: var(--warn); }
.kpi .k-v.bad { color: var(--bad); }
.kpi .k-d { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: var(--fs-xs); color: var(--ink-4); }
.kpi .k-d.up { color: var(--ok); }
.kpi .k-d.down { color: var(--bad); }

.trend { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px 1px 4px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-3); background: var(--panel-3); }
.trend svg { width: 12px; height: 12px; }
.trend.up { color: var(--ok); background: var(--ok-soft); }
.trend.down { color: var(--bad); background: var(--bad-soft); }

/* ---------- Notes ----------
   A tinted line of guidance. Brand by default; ok, warn and bad carry their status. */
.note {
  --tone: var(--brand-text);
  padding: 12px 14px; border-radius: var(--r-m);
  border: 1px solid color-mix(in srgb, var(--tone) 24%, var(--tone-base, transparent));
  background: color-mix(in srgb, var(--tone) 7%, var(--tone-base, var(--panel)));
  font-size: var(--fs-s); line-height: 1.55; color: var(--ink-2);
}
.note.ok { --tone: var(--ok); }
.note.warn { --tone: var(--warn); }
.note.bad { --tone: var(--bad); --tone-base: var(--bad-base); }
.note.info { --tone: var(--info); }
.note p:last-child { margin-bottom: 0; }
/* One sentence per line: the lines of one note stay together. */
.note p:has(+ p) { margin-bottom: 4px; }
.note b, .note strong { color: var(--ink); }

/* ---------- Empty states ---------- */
.emptystate {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: clamp(220px, 30vh, 360px); padding: 40px 24px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r-l);
}
.emptystate .es-icon {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px;
  border-radius: var(--r-l); background: var(--brand-soft); color: var(--brand-text);
}
.emptystate .es-icon svg { width: 22px; height: 22px; }
.emptystate h3 { margin-bottom: 8px; font-size: var(--fs-xl); font-weight: 700; }
.emptystate p { max-width: 46ch; margin: 0 0 22px; font-size: var(--fs-m); line-height: 1.65; color: var(--ink-3); }

/* The small one inside a card: a soft brand tinted panel instead of a dashed frame. */
.emptystate.compact { min-height: 0; padding: 22px 18px; border: 0; background: var(--brand-soft); }
.emptystate.compact .es-icon { width: 36px; height: 36px; margin-bottom: 10px; background: var(--panel); }
.emptystate.compact .es-icon svg { width: 17px; height: 17px; }
.emptystate.compact h3 { margin-bottom: 4px; font-size: var(--fs-m); font-weight: 600; }
.emptystate.compact p { margin-bottom: 12px; font-size: var(--fs-s); }
.emptystate.compact p:last-child { margin-bottom: 0; }

.emptystate.chart-empty { flex: 1; min-height: 140px; }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi .k-v { font-size: 23px; }
  .emptystate { min-height: 240px; padding: 32px 16px; }
}

/* ---------- Timeline ---------- */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl .ti { --tone: var(--brand); position: relative; padding-bottom: 16px; font-size: var(--fs-s); }
.tl .ti:last-child { padding-bottom: 0; }
.tl .ti::before {
  content: ""; position: absolute; left: -21px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--panel); border: 2px solid var(--tone);
}
.tl .ti.ok { --tone: var(--ok); }
.tl .ti.warn { --tone: var(--warn); }
.tl .ti.bad { --tone: var(--bad); --tone-base: var(--bad-base); }
.tl .ti.mute { --tone: var(--ink-5); }
.tl .ti .tt { font-weight: 600; color: var(--ink); }
