/* =============================================================================
   CognitixERP SaaS — dashboard kit layer (cgx-dash-*)
   -----------------------------------------------------------------------------
   Mirrors the ERP's dashboard-shared.css vocabulary (cgx-dash-page / header / kpi /
   panel / stat-tile / quick-btn / glance / dist-row) so the two products read as one
   family, tinted with the console's own brand ramp (violet #6a5cff → #9b5cff → #c45cff).

   Loaded AFTER cgx-admin.css. Gradients are opaque brand colours — readable in both
   light and dark mode — while panels, tiles and text read from --mud-palette-*
   variables so the theme switch stays correct. Class names are cgx-dash-* only;
   nothing here touches the landing page's cgx-* vocabulary.

   Design pass 2026-11-15: the kit was rebuilt to read as one product rather than a
   grid of boxes. What changed and why —
     • depth comes from layered tints and a single hairline, not from drop shadows on
       everything, because a console is stared at for eight hours a day;
     • the KPI card's gradient now carries a top highlight and a brand-tinted lift on
       hover, so the four headline numbers feel like the headline;
     • every number that matters is set in tabular figures and a heavier optical size,
       so columns of counts align and a glance from across the room works;
     • panels got an eyebrow + rule header, which is what makes a wall of panels
       scannable instead of uniform.
   Nothing here changes what any page renders or which value a tile shows.
============================================================================= */

/* ---- Shared tokens for the kit ------------------------------------------- */
.cgx-dash-page,
.cgx-dash-kpi-grid {
  --cgx-dash-gap: 1rem;
  --cgx-dash-ink: #ffffff;
}

/* ---- Page shell ---- */
.cgx-dash-page {
  margin-top: .5rem;
  margin-bottom: 2.25rem;
}

.cgx-dash-header { margin-bottom: 1.5rem; }

.cgx-dash-header__title {
  font-weight: 800;
  letter-spacing: -.022em;
}

.cgx-dash-kpi-grid { margin-bottom: 1.5rem; }

.cgx-dash-loading { margin-bottom: 1rem; border-radius: 999px; }

/* A section label between blocks of panels: small, uppercase, and ruled, so a long
   page reads as chapters instead of one continuous scroll of cards. */
.cgx-dash-eyebrow {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.75rem 0 1rem;
  color: var(--mud-palette-text-secondary);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.cgx-dash-eyebrow::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--mud-palette-lines-default), transparent);
}

.cgx-dash-eyebrow__count {
  padding: 2px 9px;
  border-radius: var(--cgx-radius-pill);
  background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent);
  color: var(--mud-palette-primary);
  font-size: .68rem;
  letter-spacing: .04em;
}

/* ---- KPI cards: quiet surface, loud number, one accent ------------------ */
/* The card is a surface, not a swatch. The accent arrives from the component as
   --cgx-kpi-accent and is used in exactly three places — the icon token, the share
   ring, and the rule under the number — so four cards in a row read as four facts
   rather than as a colour test. Depth comes from the border and one shadow; the
   hover lifts the card and warms the border, which is the only motion on the page
   that says "this one is under your pointer". */
.cgx-dash-kpi {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .9rem;
  isolation: isolate;
  border-radius: 16px;
  padding: 1.05rem 1.15rem;
  min-height: 126px;
  color: var(--mud-palette-text-primary);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--cgx-kpi-accent, #6a5cff) 9%, transparent), transparent 60%),
    var(--mud-palette-surface);
  border: 1px solid var(--mud-palette-lines-default);
  box-shadow: var(--cgx-shadow-card);
  transition: transform var(--cgx-tap), box-shadow var(--cgx-tap), border-color var(--cgx-tap);
}

@media (hover: hover) {
  .cgx-dash-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--cgx-shadow-lift);
    border-color: color-mix(in srgb, var(--cgx-kpi-accent, #6a5cff) 38%, var(--mud-palette-lines-default));
  }
}

.cgx-dash-kpi__body { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }

.cgx-dash-kpi__top { display: flex; align-items: center; gap: .55rem; min-width: 0; }

.cgx-dash-kpi__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--cgx-kpi-accent, var(--mud-palette-primary));
  background: color-mix(in srgb, var(--cgx-kpi-accent, #6a5cff) 14%, transparent);
}

.cgx-dash-kpi__label {
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: -.005em;
  color: var(--mud-palette-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The number is the card. Tabular so four of them keep their columns as the values
   move between polls, and a two-pixel accent rule underneath ties it to the variant
   without painting the whole tile. */
.cgx-dash-kpi__value {
  font-weight: 800;
  letter-spacing: -.028em;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: clamp(1.55rem, 2.1vw, 1.95rem);
  padding-bottom: .3rem;
  border-bottom: 2px solid color-mix(in srgb, var(--cgx-kpi-accent, #6a5cff) 26%, transparent);
}

.cgx-dash-kpi__footer {
  font-size: .78rem;
  color: var(--mud-palette-text-secondary);
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}

.cgx-dash-kpi__footer a {
  color: var(--cgx-kpi-accent, var(--mud-palette-primary));
  font-weight: 700;
}

.cgx-dash-kpi__footer a:hover { text-decoration: underline; }

/* A verdict in words: "3 unreachable" reads as a problem before the number does. */
.cgx-dash-kpi__meta--up { color: var(--mud-palette-success); font-weight: 700; }
.cgx-dash-kpi__meta--down { color: var(--mud-palette-error); font-weight: 700; }

.cgx-dash-kpi__chart { display: flex; align-items: center; justify-content: flex-end; }

.cgx-dash-kpi__badge--light {
  align-self: flex-start;
  background: color-mix(in srgb, var(--cgx-kpi-accent, #6a5cff) 12%, transparent);
  color: color-mix(in srgb, var(--cgx-kpi-accent, #6a5cff) 82%, var(--mud-palette-text-primary));
  border: 1px solid color-mix(in srgb, var(--cgx-kpi-accent, #6a5cff) 22%, transparent);
  border-radius: var(--cgx-radius-pill);
  padding: 2px 10px;
  font-size: .74rem;
  font-weight: 700;
}

.cgx-dash-kpi__badge--dark {
  align-self: flex-start;
  background: color-mix(in srgb, var(--mud-palette-text-secondary) 14%, transparent);
  color: var(--mud-palette-text-secondary);
  border: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 80%, transparent);
  border-radius: var(--cgx-radius-pill);
  padding: 2px 10px;
  font-size: .74rem;
  font-weight: 700;
}

.cgx-dash-kpi__badge--light .mud-chip-root,
.cgx-dash-kpi__badge--dark .mud-chip-root {
  background: transparent;
  color: inherit;
}

/* ---- Content panels ---- */
.cgx-dash-panel {
  position: relative;
  border-radius: 18px;
  padding: 1.05rem 1.15rem 1.1rem;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--mud-palette-surface) 92%, var(--mud-palette-primary) 2%), var(--mud-palette-surface));
  border: 1px solid var(--mud-palette-lines-default);
  box-shadow: var(--cgx-shadow-card);
}

.cgx-dash-panel--spaced { margin-bottom: .9rem; }

.cgx-dash-panel--stacked { margin-top: .9rem; }

.cgx-dash-panel__header {
  position: relative;
  margin-bottom: .9rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 70%, transparent);
}

/* The one brand mark a panel gets: a short rule under the title's left edge. Enough to
   tie the panel to the product without painting a stripe across every card in the app. */
.cgx-dash-panel__header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 42px;
  height: 2px;
  border-radius: 2px;
  background: var(--cgx-grad);
}

.cgx-dash-panel__title {
  font-weight: 700;
  letter-spacing: -.015em;
}

/* ---- Stat tiles ---- */
.cgx-dash-stat-tile {
  text-align: center;
  padding: 14px 10px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--mud-palette-primary) 7%, var(--mud-palette-surface));
  border: 1px solid var(--mud-palette-lines-default);
  transition: border-color var(--cgx-tap), transform var(--cgx-tap);
}

@media (hover: hover) {
  .cgx-dash-stat-tile:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--mud-palette-primary) 35%, var(--mud-palette-lines-default));
  }
}

.cgx-dash-stat-tile--success { background: color-mix(in srgb, var(--mud-palette-success) 10%, var(--mud-palette-surface)); }
.cgx-dash-stat-tile--danger { background: color-mix(in srgb, var(--mud-palette-error) 10%, var(--mud-palette-surface)); }
.cgx-dash-stat-tile--info { background: color-mix(in srgb, var(--mud-palette-info) 11%, var(--mud-palette-surface)); }
.cgx-dash-stat-tile--warning { background: color-mix(in srgb, var(--mud-palette-warning) 14%, var(--mud-palette-surface)); }
.cgx-dash-stat-tile--secondary { background: color-mix(in srgb, var(--cgx-brand-2) 11%, var(--mud-palette-surface)); }

.cgx-dash-stat-tile--compact { padding: 10px 8px 9px; }

.cgx-dash-stat-tile__value {
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

/* ---- Quick actions ---- */
.cgx-dash-quick-btn {
  justify-content: flex-start;
  border-radius: 12px;
  margin-bottom: .5rem;
  text-transform: none;
  font-weight: 600;
  letter-spacing: -.005em;
  border: 1px solid transparent;
  transition: background var(--cgx-tap), border-color var(--cgx-tap), transform var(--cgx-tap);
}

@media (hover: hover) {
  .cgx-dash-quick-btn:hover {
    transform: translateX(2px);
    border-color: color-mix(in srgb, var(--mud-palette-primary) 28%, transparent);
  }
}

/* ---- At a glance / distribution rows ---- */
.cgx-dash-glance-dot { font-size: 10px; }

.cgx-dash-dist-row { margin-bottom: .25rem; }

.cgx-dash-dist-row__label {
  flex: 1;
  font-weight: 600;
  letter-spacing: -.005em;
}

.cgx-dash-dist-row--spaced { margin-bottom: .6rem; }

.cgx-dash-link-footer {
  margin-top: .7rem;
  padding-top: .6rem;
  border-top: 1px dashed color-mix(in srgb, var(--mud-palette-lines-default) 85%, transparent);
}

/* ---- Inline SVG charts (decorative; numbers live in text) ---- */
.cgx-dash-chart--spark { width: 100%; max-width: 132px; height: 52px; display: block; }

.cgx-dash-chart--donut { width: 152px; height: 152px; display: block; margin: .25rem auto 0; }

.cgx-dash-chart--bars { width: 100%; height: auto; display: block; }

/* The trend chart fills its panel and keeps its own aspect ratio, so the month axis stays legible
   from a phone to an ultrawide without a second layout. */
.cgx-dash-chart--area { width: 100%; height: auto; display: block; }

.cgx-dash-chart__donut-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }

.cgx-dash-chart__donut-label { font-size: 11px; font-weight: 700; fill: #8b95a8; letter-spacing: .08em; text-transform: uppercase; }

/* ---- Health pulse on the hero ---- */
.cgx-dash-pulse {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--mud-palette-success);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--mud-palette-success) 55%, transparent);
  animation: cgx-dash-pulse 2.2s ease-out infinite;
}

.cgx-dash-pulse--bad {
  background: var(--mud-palette-error);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--mud-palette-error) 55%, transparent);
}

@keyframes cgx-dash-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mud-palette-success) 45%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---- Dashboard tables inside panels ---- */
.cgx-dash-table { border-radius: 12px; }

.cgx-dash-td-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cgx-dash-td-strong { font-weight: 600; }

/* ---- The one alert that outranks the page ------------------------------- */
/* Money taken and no workspace delivered. It gets weight over every other notice on the
   console: a left severity rail, a deeper card shadow, and a title that reads first. */
.cgx-dash-critical {
  border-radius: 16px;
  border-left: 4px solid rgba(255, 255, 255, .85);
  box-shadow: var(--cgx-shadow-lift);
  padding: 1rem 1.15rem;
}

.cgx-dash-critical .mud-typography-h6 {
  font-weight: 800;
  letter-spacing: -.015em;
}

/* ---- Share ring, legend, meters ----------------------------------------- */
.cgx-dash-chart--ring { display: block; }
.cgx-dash-chart__ring-track { stroke: color-mix(in srgb, var(--mud-palette-text-secondary) 18%, transparent); }
.cgx-dash-chart__ring-value { font-size: 13px; font-weight: 800; letter-spacing: -.02em; }

/* A panel's own "view all", top-right — the ERP console puts one on every list panel and it is
   the difference between a summary and a dead end. */
.cgx-dash-panel__link {
  margin-inline-start: auto;
  font-size: .78rem;
  font-weight: 700;
  color: var(--mud-palette-primary);
  text-decoration: none;
  white-space: nowrap;
}

.cgx-dash-panel__link:hover { text-decoration: underline; }

.cgx-dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: .6rem;
  font-size: .76rem;
  color: var(--mud-palette-text-secondary);
}

.cgx-dash-legend__item { display: inline-flex; align-items: center; gap: 6px; }

.cgx-dash-legend__dot {
  width: 9px; height: 9px; border-radius: 3px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mud-palette-surface) 70%, transparent);
}

/* A proportion with the number beside it: usage against a ceiling, share of a total. The
   bar is the shape, the caption is the fact, and the fill turns amber past four-fifths so
   a limit that is nearly reached is visible before it is reached. */
.cgx-dash-meter { display: flex; flex-direction: column; gap: 4px; margin-bottom: .7rem; }
.cgx-dash-meter__head { display: flex; align-items: baseline; gap: .5rem; font-size: .82rem; }
.cgx-dash-meter__label { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cgx-dash-meter__value { font-variant-numeric: tabular-nums; color: var(--mud-palette-text-secondary); font-size: .78rem; }
.cgx-dash-meter__track {
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mud-palette-text-secondary) 14%, transparent);
  overflow: hidden;
}
.cgx-dash-meter__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--cgx-grad);
  transition: width 320ms cubic-bezier(.2, .7, .3, 1);
}
.cgx-dash-meter__fill--high { background: linear-gradient(90deg, #c77700, #fbbf24); }
.cgx-dash-meter__fill--over { background: linear-gradient(90deg, #be123c, #fb7185); }

/* One tenant's ceilings under its name. The meters are the shape, the name is the subject, and
   the exceeded limits are said in words so the colour is never the only signal. */
.cgx-dash-meter-group { padding-bottom: .75rem; margin-bottom: .75rem; border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 70%, transparent); }
.cgx-dash-meter-group:last-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
.cgx-dash-meter-group__head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .35rem; }
.cgx-dash-meter-group__name { font-weight: 700; letter-spacing: -.01em; }
.cgx-dash-meter-group__limits {
  margin-inline-start: auto;
  font-size: .72rem;
  font-weight: 700;
  color: var(--mud-palette-warning);
  text-align: right;
}

/* ---- The floating action dock ------------------------------------------ */
/* The console's quick actions lived in a panel at the bottom of a long page. They are the
   six things an operator does most, so they now ride at the bottom-right of every dashboard
   state: a small round stack that opens into the rail. It is a plain details-free component —
   one button toggles a class — and it never covers the page's own scroll, because it sits
   outside the content column. */
.cgx-dock {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.cgx-dock__items {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px) scale(.98);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms cubic-bezier(.2, .7, .3, 1);
}

.cgx-dock.is-open .cgx-dock__items { opacity: 1; transform: none; pointer-events: auto; }

.cgx-dock__action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--mud-palette-surface);
  border: 1px solid var(--mud-palette-lines-default);
  box-shadow: var(--cgx-shadow-card);
  color: var(--mud-palette-text-primary);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--cgx-tap), border-color var(--cgx-tap), box-shadow var(--cgx-tap);
}

@media (hover: hover) {
  .cgx-dock__action:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--mud-palette-primary) 40%, var(--mud-palette-lines-default));
    box-shadow: var(--cgx-shadow-lift);
  }
}

.cgx-dock__action .mud-icon-root { color: var(--cgx-kpi-accent, var(--mud-palette-primary)); }

.cgx-dock__fab {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  color: #fff;
  background: var(--cgx-grad);
  box-shadow: 0 14px 30px -12px rgba(106, 92, 255, .9);
  cursor: pointer;
  transition: transform var(--cgx-tap), box-shadow var(--cgx-tap);
}

@media (hover: hover) {
  .cgx-dock__fab:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -12px rgba(106, 92, 255, .95); }
}

.cgx-dock.is-open .cgx-dock__fab { transform: rotate(135deg); }

/* ---- The one bit of motion a dashboard earns --------------------------- */
/* The headline row arrives as a row, not as four boxes appearing one HTTP call at a time.
   It runs once per load, 40ms apart, and only where the page is already painted — a
   skeleton that fades is a lie about what just happened. */
@keyframes cgx-dash-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.cgx-dash-rise > * {
  animation: cgx-dash-rise 320ms cubic-bezier(.2, .7, .3, 1) both;
}

.cgx-dash-rise > *:nth-child(2) { animation-delay: 40ms; }
.cgx-dash-rise > *:nth-child(3) { animation-delay: 80ms; }
.cgx-dash-rise > *:nth-child(4) { animation-delay: 120ms; }

/* ---- Responsive: the headline row must survive a phone ------------------- */
@media (max-width: 600px) {
  .cgx-dash-kpi {
    min-height: 0;
    padding: .85rem .9rem;
    gap: .6rem;
  }

  .cgx-dash-kpi__chart { display: none; }
  .cgx-dash-panel { padding: .9rem; border-radius: 16px; }
  .cgx-dock { right: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .cgx-dash-pulse { animation: none; }

  .cgx-dash-rise > *,
  .cgx-dash-rise > *:nth-child(2),
  .cgx-dash-rise > *:nth-child(3),
  .cgx-dash-rise > *:nth-child(4) { animation: none; }

  .cgx-dash-kpi,
  .cgx-dash-kpi:hover,
  .cgx-dash-stat-tile,
  .cgx-dash-stat-tile:hover,
  .cgx-dash-quick-btn,
  .cgx-dash-quick-btn:hover,
  .cgx-dock__action,
  .cgx-dock__action:hover,
  .cgx-dock__fab,
  .cgx-dock__fab:hover,
  .cgx-dock.is-open .cgx-dock__fab,
  .cgx-dock__items {
    transition: none;
    transform: none;
  }
}
