/* Cards and the blocks that live on them: stats, list rows, notes, empty and locked states. */

.card {
  position: relative; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--sh-card);
}
.card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head > div:first-child:not(.right) { flex: 1 1 0; min-width: 0; }
.card-head h3 { font-size: var(--fs-m); font-weight: 600; }
.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: 18px; }
.card-body.tight { padding: 10px; }
.card-empty { padding: 16px 18px; color: var(--ink-3); font-size: var(--fs-s); }
.card-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-l) var(--r-l); background: var(--panel-2);
  font-size: var(--fs-xs); color: var(--ink-4);
}
.card-foot.pager { justify-content: space-between; }

/* A card that opens and closes; the summary is the head. */
details.collapsecard > summary { list-style: none; cursor: pointer; }
details.collapsecard > summary::-webkit-details-marker { display: none; }
details.collapsecard > summary .chev { margin-left: auto; display: inline-flex; color: var(--brand-text); transition: transform .2s ease; }
details.collapsecard > summary .chev svg { width: 18px; height: 18px; }
details.collapsecard[open] > summary .chev { transform: rotate(180deg); }
details.collapsecard:not([open]) > summary { border-bottom: 0; }

.fillscroll { max-height: max(320px, calc(100dvh - 300px)); overflow-y: auto; overscroll-behavior: contain; }

/* Section heading inside a card: icon tile, title and one line of explanation. */
.sect { display: flex; gap: 12px; align-items: center; padding-bottom: 12px; }
.sect.sep { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.sect-ic {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--r-m);
  background: var(--brand-soft); color: var(--brand-text);
}
.sect-ic svg { width: 16px; height: 16px; }
.sect-t b { display: block; font-size: var(--fs-m); font-weight: 600; }
.sect-t span { display: block; margin-top: 1px; font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-4); }

/* ---------- Stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi, .stat {
  position: relative; min-width: 0; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--sh-card);
}
.kpi .k-l, .stat .label { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: var(--tr-caps); text-transform: uppercase; color: var(--ink-4); }
.kpi .k-v, .stat .value {
  margin-top: 6px; font-size: 28px; font-weight: 700; line-height: 1.1;
  letter-spacing: var(--tr-tight); font-variant-numeric: tabular-nums; color: var(--ink);
}
.kpi .k-v small, .stat .value small { margin-left: 1px; font-size: var(--fs-l); font-weight: 600; letter-spacing: 0; color: var(--ink-4); }
.kpi .k-v.ok, .stat .value.ok { color: var(--ok); }
.kpi .k-v.warn, .stat .value.warn { color: var(--warn); }
.kpi .k-v.bad, .stat .value.bad { color: var(--bad); }
.kpi .k-d, .stat .delta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: var(--fs-xs); color: var(--ink-4); }
.kpi .k-d.up, .stat .delta.up { color: var(--ok); }
.kpi .k-d.down, .stat .delta.down { color: var(--bad); }
.kpi .k-spark, .stat .spark { margin-top: 10px; }
.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); }

/* ---------- List rows ---------- */
.lrow {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel);
}
.lrow.flat { margin: 0; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; }
.lrow.flat:last-child { border-bottom: 0; }
.lrow .lr-main { flex: 1; min-width: 0; }
.lrow .lr-title { font-size: var(--fs-s); font-weight: 600; }
.lrow .lr-sub { margin-top: 1px; font-size: var(--fs-xs); color: var(--ink-4); }
.lrow .lr-side { display: flex; align-items: center; gap: 8px; flex: none; }

.deflist { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 12px; margin: 0 0 16px; font-size: var(--fs-s); }
.deflist dt { color: var(--ink-4); }
.deflist dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- 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%, transparent);
  background: color-mix(in srgb, var(--tone) 7%, 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); }
.note p:last-child { margin-bottom: 0; }
.note b, .note strong { color: var(--ink); }

/* A note with an icon in front. */
.gnote-inline {
  display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--r-m);
  border: 1px solid var(--warn-line); background: var(--warn-soft);
}
.gnote-inline svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--warn); }
.gnote-inline span { font-size: var(--fs-xs); line-height: 1.6; color: var(--ink-2); }

/* ---------- Empty and locked states ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty h3 { margin-bottom: 6px; color: var(--ink); }

.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.inline { border: 0; border-radius: 0; min-height: clamp(240px, 40vh, 520px); flex: 1 1 auto; }
.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); }
.emptystate .es-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
/* 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; }
.card > .card-body:has(> .emptystate.inline) { flex: 1 1 auto; display: flex; padding: 0; min-height: 0; }

.emptystate.chart-empty { flex: 1; min-height: 140px; }

.locked {
  max-width: 520px; margin: 40px auto; padding: 40px 24px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel);
}
.locked h3 { margin: 0 0 6px; }
.locked p { margin: 0 0 16px; font-size: var(--fs-s); color: var(--ink-3); }

/* A banner that explains a limit and offers the way past it. */
.upsell {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 14px 18px;
  border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel);
}
.upsell .up-icon {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px;
  border-radius: var(--r-m); background: var(--brand-soft); color: var(--brand-text);
}
.upsell .up-icon svg { width: 17px; height: 17px; }
.upsell .up-text { flex: 1; min-width: 0; }
.upsell .up-text b { display: block; font-size: var(--fs-s); }
.upsell .up-text span { font-size: var(--fs-xs); color: var(--ink-4); }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lrow { flex-wrap: wrap; }
  .lrow .lr-side { margin-left: auto; }
}

@media (max-width: 700px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi .k-v, .stat .value { font-size: 23px; }
  .emptystate { min-height: 240px; padding: 32px 16px; }
  .emptystate .es-actions { width: 100%; flex-direction: column; align-items: stretch; }
}

@media (max-width: 520px) {
  .deflist { grid-template-columns: 1fr; gap: 2px 0; }
  .deflist dd { margin: 0 0 8px; }
}

/* ---------- 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); }
.tl .ti.mute { --tone: var(--ink-5); }
.tl .ti .tt { font-weight: 600; color: var(--ink); }
.tl .ti .tm { font-size: var(--fs-xs); color: var(--ink-4); font-variant-numeric: tabular-nums; }
