/* my-gui layout: shell, cards, headings, alerts, tables, chart frame (step 373b).
   Values measured on the running My Atlas (docs/look.md, D538): do not "improve" them.
   Shades follow the theme: rgba(var(--m-shade), calc(alpha * var(--m-sk))) is the dark value times --m-sk. */

/* ---------- app shell ---------- */
.m-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: 52px minmax(0, 1fr) 34px;
  height: 100vh;
  height: 100dvh;
}
.m-topbar {
  grid-column: 1 / -1;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 12px 0 16px;
  background: var(--m-panel);
  border-bottom: 1px solid var(--m-line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.m-appname { font-size: 13.5px; font-weight: 800; white-space: nowrap; }
.m-topbar .m-nav-toggle { display: none; }
.m-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; font-size: 12.5px; color: var(--m-text-3); }
.m-crumbs a { padding: 2px 4px; color: var(--m-text-2); }
.m-crumbs [aria-current] { color: var(--m-text); font-weight: 700; }

/* the two scrollers are positioned: an absolute child (.m-sr) otherwise hangs on the page, makes the
   document itself scroll and takes the top bar with it */
.m-sidenav {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: var(--m-panel);
  border-right: 1px solid var(--m-line);
}
.m-main {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 28px;
}
.m-statusbar {
  grid-column: 1 / -1;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  padding: 0 12px;
  font-size: 12px;
  color: var(--m-text-2);
  white-space: nowrap;
  background: var(--m-panel);
  border-top: 1px solid var(--m-line);
}

/* navigation list */
.m-list { display: flex; flex-direction: column; gap: 2px; }
.m-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 0 8px;
  border-radius: var(--m-r);
  color: var(--m-text-2);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.m-row .m-grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-row:hover { color: var(--m-text); background: rgba(var(--m-ink), .04); }
.m-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--m-ring); }
.m-row[aria-current="page"] {
  color: var(--m-text);
  background: linear-gradient(90deg, rgba(var(--m-accent-rgb), .2), rgba(var(--m-accent-rgb), .04));
  box-shadow: inset 2px 0 0 var(--m-accent), inset 0 0 0 1px rgba(var(--m-accent-rgb), .22);
}
.m-ico {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--m-well);
  box-shadow: var(--m-well-sh);
}
.m-ico .m-i { width: 12px; height: 12px; }
.m-row[aria-current="page"] .m-ico { color: var(--m-accent); }

/* narrow screens: the side navigation is a drawer, opened by .m-shell.is-nav-open */
@media (max-width: 767px) {
  .m-shell { position: relative; grid-template-columns: minmax(0, 1fr); }
  .m-topbar .m-nav-toggle { display: inline-flex; }
  .m-main { grid-column: 1; padding: 16px 16px 24px; }
  /* grid-row 2 + top 52px is the measured geometry: the drawer starts one top bar below the top bar */
  .m-sidenav {
    position: absolute;
    top: 52px;
    bottom: 34px;
    left: 0;
    z-index: 35;
    width: 280px;
    background: var(--m-glass-strong);
    box-shadow: 0 24px 60px -12px rgba(var(--m-shade), calc(.85 * var(--m-sk)));
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    transform: translateX(-102%);
    transition: transform .35s var(--m-ease);
  }
  .m-shell.is-nav-open .m-sidenav { transform: none; }
}
@media (max-width: 540px) {
  .m-topbar .m-appname, .m-topbar .m-crumbs { display: none; }
}

/* ---------- layout utilities ---------- */
.m-grow { flex: 1 1 0%; }
.m-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(var(--min, 240px), 1fr)); gap: var(--gap, 16px); }
.m-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.m-vsep { flex: 0 0 auto; width: 1px; height: 20px; margin: 0 2px; background: var(--m-line); }
.m-msep { height: 1px; margin: 5px 8px; background: var(--m-line); }

/* flex and grid children may shrink below their content */
.m-grow, .m-grid, .m-card, .m-card-body, .m-cluster, .m-stat, .m-stat-foot, .m-chart, .m-field, .m-input-wrap, .m-select, .m-input, .m-table-card { min-width: 0; }

/* ---------- cards ---------- */
.m-card, .m-table-card {
  background: var(--m-card);
  border: 1px solid rgba(var(--m-ink), .067);
  box-shadow: inset 0 1px 0 rgba(var(--m-ink), .035), 0 10px 30px -22px rgba(var(--m-shade), calc(.9 * var(--m-sk)));
}
.m-card { position: relative; border-radius: var(--m-r-md); }
.m-card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.m-card-body { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 16px; }
/* a card body that is also a cluster stays a column (measured), centred and wrapping by .m-cluster */
.m-plate {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--m-accent);
  background: var(--m-well);
  box-shadow: var(--m-well-sh);
}
.m-plate .m-i { width: 15px; height: 15px; }

/* ---------- headings and text ---------- */
.m-h1, .m-h2, .m-h3, .m-h4 { margin: 0; font-family: var(--m-font); }
.m-h1 { font-size: 22px; font-weight: 800; line-height: 1.2; letter-spacing: -.005em; }
.m-h2 { font-size: 17px; font-weight: 800; line-height: 1.25; }
.m-h3 { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.m-h4 { font-size: 13px; }
.m-body { max-width: 68ch; font-size: 13.5px; font-weight: 400; line-height: 1.55; color: var(--m-text-2); }
.m-small { font-size: 12px; color: var(--m-text-2); }
.m-label { font-size: 10.5px; font-weight: 800; line-height: 1.2; letter-spacing: .1em; text-transform: uppercase; color: var(--m-text-3); }
.m-num { font-variant-numeric: tabular-nums; }
.m-trunc { display: block; max-width: var(--max, 280px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* accent mark (the chart data marks carry the same class; their fill comes from charts.js) */
.m-mark {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--m-accent);
  box-shadow: 0 0 14px -3px rgba(var(--m-accent-rgb), .6);
}

/* estimated data: <span class="m-est"><svg class="m-i"><use href="#i-est"></use></svg>…</span> */
.m-est { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--m-est-ink); vertical-align: middle; }
.m-est .m-i { width: 12px; height: 12px; color: var(--m-est); }

/* ---------- status ---------- */
.m-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; line-height: 1.45; color: var(--m-text-2); white-space: nowrap; }
.m-status::before { content: ""; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--m-text-3); }
.m-status--good::before { background: var(--m-good); box-shadow: 0 0 6px rgba(12, 163, 12, .55); }
.m-status--warn::before { background: var(--m-warn); box-shadow: 0 0 6px rgba(250, 178, 25, .55); }
.m-status--crit::before { background: var(--m-danger); box-shadow: 0 0 6px rgba(247, 47, 75, .55); }
.m-status--info::before { background: var(--m-accent); box-shadow: 0 0 6px var(--m-glow); }
.m-status--live::before { background: var(--m-accent); box-shadow: 0 0 6px var(--m-accent); animation: m-pulse .9s ease-in-out infinite; }
@keyframes m-pulse { 50% { opacity: .35; } }

/* ---------- alerts ---------- */
.m-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  background: linear-gradient(90deg, rgba(var(--m-accent-rgb), .14), rgba(var(--m-accent-rgb), .04));
  box-shadow: inset 0 0 0 1px rgba(var(--m-accent-rgb), .3);
}
.m-alert b { font-weight: 800; }
.m-alert > .m-i { margin-top: 1px; color: var(--m-accent); }
.m-alert--good { background: linear-gradient(90deg, rgba(12, 163, 12, .13), rgba(12, 163, 12, .03)); box-shadow: inset 0 0 0 1px rgba(12, 163, 12, .4); }
.m-alert--good > .m-i { color: var(--m-good-text); }
.m-alert--warn { background: linear-gradient(90deg, rgba(250, 178, 25, .14), rgba(250, 178, 25, .04)); box-shadow: inset 0 0 0 1px rgba(250, 178, 25, .35); }
.m-alert--warn > .m-i { color: var(--m-warn-text); }
.m-alert--crit { background: linear-gradient(90deg, rgba(247, 47, 75, .13), rgba(247, 47, 75, .03)); box-shadow: inset 0 0 0 1px rgba(247, 47, 75, .45); }
.m-alert--crit > .m-i { color: var(--m-danger-text); }

/* ---------- progress: <div class="m-progress"><i style="--v:62%"></i></div> ---------- */
.m-progress { position: relative; height: 6px; min-width: 48px; overflow: hidden; border-radius: var(--m-r-pill); background: var(--m-well); box-shadow: var(--m-well-sh); }
.m-progress > i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: block;
  width: var(--v, 0%);
  border-radius: var(--m-r-pill);
  background: linear-gradient(90deg, var(--m-accent-2), var(--m-accent));
  box-shadow: 0 0 8px -1px var(--m-glow);
  transition: width .6s var(--m-ease);
}
.m-progress--warn > i { background: var(--m-warn); box-shadow: none; }

/* ---------- stat tile (no transform here: the app flips the tiles) ---------- */
.m-stat { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; }
.m-stat-label { font-size: 12px; font-weight: 700; color: var(--m-text-2); }
.m-stat-value { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.m-stat-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; line-height: 1.45; color: var(--m-text-2); }

/* ---------- empty state and skeleton ---------- */
.m-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 20px; text-align: center; color: var(--m-text-3); }
.m-empty b { font-size: 13.5px; color: var(--m-text); }
.m-empty .m-plate { width: 44px; height: 44px; margin-bottom: 4px; border-radius: var(--m-r-lg); }
.m-skel {
  min-height: 12px;
  border-radius: var(--m-r-sm);
  background: linear-gradient(90deg, rgba(var(--m-ink), .05) 0%, rgba(var(--m-ink), .1) 40%, rgba(var(--m-ink), .05) 80%);
  background-size: 300% 100%;
  animation: m-shimmer 1.6s linear infinite;
}
@keyframes m-shimmer { from { background-position-x: 0; } to { background-position-x: -300%; } }

/* ---------- tables ---------- */
.m-table-card { border-radius: var(--m-r-lg); }
.m-table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--m-line); }
.m-table-toolbar .m-spacer { flex: 1 1 0%; }
.m-table-toolbar .m-input-wrap { flex: 1 1 220px; max-width: 320px; }
.m-table-scroll { max-width: 100%; overflow: auto; }
.m-table-wrap { overflow-x: auto; }

.m-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; color: var(--m-text-2); }
.m-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  padding: 0 12px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  color: var(--m-text-3);
  background: var(--m-card-solid);
  border-bottom: 1px solid var(--m-line);
}
.m-table td {
  height: 44px;
  padding: 0 12px;
  vertical-align: middle;
  white-space: nowrap;
  border-bottom: 1px solid rgba(var(--m-ink), .05);
  transition: box-shadow .32s var(--m-ease);
}
.m-table tbody tr { transition: background .12s ease; }
.m-table--compact th { height: 32px; }
.m-table--compact td { height: 34px; }
/* .m-table--sm measured the same as the plain table: the class stays for the app, without a rule */

.m-table th.m-col-num, .m-table td.m-col-num, .m-table td.m-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--m-text); }
.m-table td.m-id { font-variant-numeric: tabular-nums; text-align: left; color: var(--m-text); }
.m-table td.m-strong, .m-table .m-strong { font-weight: 700; color: var(--m-text); }

/* sortable header: the app sorts and sets aria-sort, the kit draws the arrow */
.m-table th.m-sort { cursor: pointer; user-select: none; }
.m-table th.m-sort:hover { color: var(--m-text-2); }
.m-table th.m-sort:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--m-ring); }
.m-table th.m-sort::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  vertical-align: 1px;
  opacity: 0;
  transform: rotate(45deg);
  transition: transform .25s var(--m-spring), opacity .15s;
}
.m-table th.m-sort[aria-sort="ascending"], .m-table th.m-sort[aria-sort="descending"] { color: var(--m-accent); }
.m-table th.m-sort[aria-sort="ascending"]::after { opacity: 1; vertical-align: -2px; transform: rotate(225deg); }
.m-table th.m-sort[aria-sort="descending"]::after { opacity: 1; }

.m-table .m-empty-row td, .m-table tbody tr:last-child td { border-bottom: 0; }
/* an id column keeps the text colour, in the header too, sorted or not */
.m-table th.m-id, .m-table th.m-id.m-sort:hover, .m-table th.m-id.m-sort[aria-sort] { color: var(--m-text); font-variant-numeric: tabular-nums; }

/* ---------- legend (the dot colour comes from the app's own class on the item) ---------- */
.m-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; line-height: 1.45; color: var(--m-text-2); }
.m-legend-i { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.m-legend-i::before { content: ""; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; background: var(--c, transparent); }

/* ---------- chart frame (the drawing itself is js/charts.js) ---------- */
.m-chart { display: flex; flex-direction: column; gap: 10px; }
.m-chart-sub { margin-top: 3px; font-size: 12px; line-height: 1.45; color: var(--m-text-3); }
.m-chart-plot { position: relative; min-height: 160px; }
:is(.m-chart, .m-chart-plot) svg:not(.m-i) { display: block; }
.m-chart-plot svg:not(.m-i) { overflow: visible; }
:is(.m-chart, .m-chart-plot) svg:not(.m-i) { width: 100%; }
/* the svg:not() raises these over a plain "svg text.m-t-strong" app rule; the soft and strong looks need .m-chart */
.m-chart-plot svg:not(.m-i) text, .m-chart svg:not(.m-i) text { font: 600 11px var(--m-font); fill: var(--m-text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-chart svg:not(.m-i) .m-t-soft text, .m-chart svg:not(.m-i) text.m-t-soft { font-size: 10px; font-weight: 500; opacity: .8; }
.m-chart svg:not(.m-i) text.m-t-strong { font-weight: 800; fill: var(--m-text); }
:is(.m-chart, .m-chart-plot) .m-mark { transition: opacity .2s ease; }
.m-gridline { stroke: var(--m-grid); stroke-width: 1; }
.m-baseline { stroke: var(--m-axis); stroke-width: 1; }
.m-crosshair { stroke: var(--m-line-strong); stroke-width: 1; }
.m-bar-cut { fill: var(--m-card-solid); }
.m-bar-trace, .m-bar-trace-glow { fill: none; }
/* shown by .is-on (or by inline style) */
.m-chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--m-glass-edge);
  border-radius: var(--m-r);
  font-size: 12px;
  white-space: nowrap;
  color: var(--m-text-2);
  background: var(--m-glass-strong);
  box-shadow: 0 14px 34px -12px rgba(var(--m-shade), calc(.85 * var(--m-sk)));
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s ease, transform .2s var(--m-spring);
}
.m-chart-tip.is-on { opacity: 1; transform: none; }
.m-chart-tip b { display: block; margin-bottom: 4px; font-weight: 800; color: var(--m-text); }
