/* ==========================================================================
   App frame + dashboard grid
   A fixed-width sidebar, a slim app bar, and the content column. The document
   itself scrolls (the sidebar and the bar are sticky) so printing, the HTML
   export and in-page anchors all behave as on an ordinary page.
   ========================================================================== */

.page {
  display: flex;
  align-items: flex-start;
  min-height: 100dvh;
  background: var(--bg-color);
}

.app__side {
  position: sticky;
  top: 0;
  z-index: 60;
  flex: 0 0 auto;
  width: var(--sidebar-width);
  height: 100dvh;
  transition: width 0.22s ease;
}
.app__main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page-glow) no-repeat;
}
.app__bar { position: sticky; top: 0; z-index: 50; }
.app__scrim { display: none; }

/* the content column */
.shell {
  width: 100%;
  max-width: var(--w-shell);
  margin: 0 auto;
  padding: 22px 28px 48px;
}

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-divider);
  overflow: hidden;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  height: var(--appbar-height);
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--sidebar-divider);
}
.sidebar__toggle {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-item-text);
  flex: 0 0 auto;
  transition: background 0.12s, color 0.12s;
}
.sidebar__toggle:hover { background: var(--sidebar-item-hover-bg); color: var(--sidebar-item-hover-text); }
.sidebar__toggle svg { width: 15px; height: 15px; }

.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0 12px;
}
.sidebar__section {
  padding: 16px 18px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-section);
  white-space: nowrap;
}
.sidebar__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  color: var(--sidebar-item-text);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.sidebar__item:hover {
  background: var(--sidebar-item-hover-bg);
  color: var(--sidebar-item-hover-text);
  text-decoration: none;
}
/* Where you are: a wash of the accent, its icon in the accent, and a short
   bar of it against the edge of the menu. */
.sidebar__item[aria-current="page"] {
  background: var(--sidebar-item-active-bg);
  color: var(--sidebar-item-active-text);
  font-weight: 500;
}
.sidebar__item[aria-current="page"] .sidebar__icon { color: var(--sidebar-item-active-icon); }
.sidebar__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.sidebar__icon { display: grid; place-items: center; width: 16px; height: 16px; flex: 0 0 auto; }
.sidebar__icon svg { width: 15px; height: 15px; }
.sidebar__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Something is waiting: a round counter in --danger, as the bell's dot is. */
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  flex: 0 0 auto;
}

.sidebar__foot {
  flex: 0 0 auto;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--sidebar-divider);
  font-size: 10.5px;
  color: var(--sidebar-section);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The rail: the menu closed down to its icons. Desktop only — on a narrow
   window the menu is a drawer instead, and always opens at full width. */
@media (min-width: 901px) {
  html.sidebar-closed { --sidebar-width: var(--sidebar-rail); }
  html.sidebar-closed .sidebar__brand { justify-content: center; padding: 0; }
  html.sidebar-closed .sidebar__brand .logo,
  html.sidebar-closed .sidebar__label,
  html.sidebar-closed .sidebar__foot { display: none; }
  html.sidebar-closed .sidebar__section {
    height: 1px;
    margin: 8px 12px;
    padding: 0;
    background: var(--sidebar-divider);
    font-size: 0;
  }
  html.sidebar-closed .sidebar__group:first-child .sidebar__section { display: none; }
  html.sidebar-closed .sidebar__item { justify-content: center; margin: 2px 8px; padding: 8px 0; }
  html.sidebar-closed .nav-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    font-size: 8.5px;
    line-height: 14px;
  }
}

/* ---------------------------------------------------------------- app bar */
.appbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--appbar-height);
  padding: 0 28px;
  background: var(--appbar-bg);
  border-bottom: 1px solid var(--border-color);
}
.appbar__menu { display: none; }
.appbar__title {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__crumb { font-weight: 400; color: var(--text-light); }
.appbar__crumb::after { content: "/"; margin: 0 7px; opacity: 0.6; }
.appbar__utility { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.appbar__utility .flagchip { margin-right: 4px; }
.appbar__divider { width: 1px; height: 18px; margin: 0 4px; background: var(--border-color); }
.appbar__user {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  transition: background 0.12s;
}
.appbar__user:hover { background: var(--hover-bg); }
.appbar__user > svg { width: 13px; height: 13px; color: var(--text-light); }
.appbar__who { padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border-color); }
.appbar__who-name { font-size: 13px; font-weight: 600; color: var(--text-main); }
.appbar__who-line { font-size: 11px; color: var(--text-light); overflow-wrap: anywhere; }

.dash {
  display: grid;
  gap: clamp(12px, 1.1vw, 16px);
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.05fr);
  grid-template-areas:
    "hero  hero  hero"
    "chart mini  rail"
    "table table meter";
  align-items: start;
}

.dash__hero { grid-area: hero; }
.dash__chart { grid-area: chart; }
.dash__mini { grid-area: mini; display: flex; flex-direction: column; gap: clamp(12px, 1.1vw, 16px); }
.dash__rail { grid-area: rail; }
.dash__table { grid-area: table; }
.dash__meter { grid-area: meter; }

/* stretch the paired columns so their bottoms line up with the chart card */
.dash__chart,
.dash__rail { height: 100%; }
.dash__mini > .card { flex: 1 1 0; }

/* ------------------------------------------------------------------- hero
   Overview's opening: the greeting, then the four KPI tiles in one row. */
.hero { display: flex; flex-direction: column; gap: 16px; }

.hero__date { font-size: var(--t-label-size); color: var(--text-light); margin-bottom: 2px; }
.hero__hello {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink-900);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hero__hello b { font-weight: 600; color: var(--brand-700); }
.hero__wave { font-size: 0.9em; }
.hero__note {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 96ch;
}
.hero__note b { font-weight: 600; color: var(--text-main); }

.hero__tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

/* --------------------------------------------------------- chart card bits */
.chartcard { height: 100%; }
.chartcard__figure { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.chartcard__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--good-bg);
  color: var(--good-fg);
  font-size: var(--t-label-size);
  font-weight: 600;
  margin-bottom: 5px;
}
.chartcard__delta svg { width: 11px; height: 11px; }
.chartcard__plot { margin-top: auto; padding-top: var(--s-2); }

/* ------------------------------------------------------------- rail card */
.rail { height: 100%; }
.rail__section-title { font-size: var(--t-card-title-size); font-weight: 600; color: var(--ink-900); }
.rail__section-sub { font-size: var(--t-label-size); font-weight: 400; color: var(--ink-400); margin-top: 2px; }

/* ---------------------------------------------------------------- sign in */
.auth {
  min-height: 100dvh;
  max-width: var(--w-auth);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: clamp(14px, 1.6vw, 22px);
  padding: clamp(14px, 2.2vw, 30px);
  /* centred and narrower than the box, so it fades out before either edge */
  background:
    radial-gradient(700px 380px at 50% -140px, rgba(var(--primary-rgb), var(--glow-alpha)), transparent 70%) no-repeat,
    var(--bg-color);
}

/* left: the emerald showcase panel */
.auth__aside {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  padding: clamp(22px, 2.6vw, 40px);
  border-radius: var(--radius-lg);
  color: var(--white);
  background:
    radial-gradient(780px 470px at 108% 2%, rgba(174, 232, 203, 0.34), transparent 62%),
    radial-gradient(660px 540px at -14% 104%, rgba(207, 233, 168, 0.3), transparent 58%),
    linear-gradient(146deg, #17B57F 0%, #0A7D53 46%, #042A1C 100%);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  isolation: isolate;
}
.auth__aside::after {
  content: "";
  position: absolute;
  inset: auto -18% -32% -18%;
  height: 320px;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.16), transparent);
  z-index: -1;
}

/* A whisper of grain so the large gradient never reads as flat vector fill. */
.auth__aside::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  background-size: 140px 140px;
  opacity: 0.055;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 0;
}
.auth__aside > * { position: relative; z-index: 1; }

.auth__aside-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

.auth__pitch { margin-top: clamp(12px, 2vw, 26px); }
.auth__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  font-size: var(--t-micro-size);
  font-weight: 600;
  letter-spacing: var(--t-micro-track);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}
.auth__title {
  margin-top: var(--s-4);
  font-size: clamp(30px, 3.3vw, 52px);
  line-height: 1.06;
  font-weight: 400;
  letter-spacing: -0.03em;
}
.auth__title b { font-weight: 600; }
.auth__lede {
  margin-top: var(--s-4);
  max-width: 44ch;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.78);
}

.auth__proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.auth__proof-item {
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
}
.auth__proof-value { font-size: 20px; font-weight: 600; letter-spacing: -0.025em; }
.auth__proof-label { margin-top: 2px; font-size: var(--t-label-size); font-weight: 400; color: rgba(255, 255, 255, 0.72); }

/* the floating showcase stack — real components, tilted and layered */
.stack {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: clamp(14px, 2vw, 26px) 0 clamp(18px, 2.4vw, 30px);
  display: flex;
  flex-direction: column;
}
.stack__glow {
  position: absolute;
  inset: -14% -10% -10% -10%;
  background: radial-gradient(closest-side, rgba(174, 232, 203, 0.3), transparent 72%);
  filter: blur(4px);
  pointer-events: none;
}
.stack__card {
  position: relative;
  z-index: 2;
  width: 88%;
  transform: rotate(-2deg);
  filter: drop-shadow(0 26px 44px rgba(0, 0, 0, 0.45));
}
.stack__notice {
  position: relative;
  z-index: 3;
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -24px -2px 0 0;
  padding: 9px 15px 9px 9px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 16px 32px -14px rgba(0, 0, 0, 0.55);
}
.stack__notice-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--brand-600);
  color: var(--white);
  flex: 0 0 auto;
}
.stack__notice-mark svg { width: 12px; height: 12px; }
.stack__notice-text { display: flex; flex-direction: column; line-height: 1.35; }
.stack__notice-text b { font-size: 12.5px; font-weight: 600; color: var(--ink-900); }
.stack__notice-text span { font-size: 10.5px; font-weight: 400; color: var(--ink-400); }

.stack__tile {
  position: relative;
  z-index: 1;
  width: 84%;
  margin: -14px 0 0 auto;
  padding: 14px 16px 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 22px 44px -20px rgba(0, 0, 0, 0.55);
  transform: rotate(1.6deg);
}
.stack__tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: 4px;
}
.stack__tile-head span { font-size: var(--t-label-size); font-weight: 600; color: var(--ink-500); }
.stack__tile-foot { display: flex; gap: var(--s-5); margin-top: 6px; }
.stack__tile-foot span { display: flex; flex-direction: column; line-height: 1.3; }
.stack__tile-foot b { font-size: 13.5px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink-900); }
.stack__tile-foot small { font-size: 10.5px; font-weight: 400; color: var(--ink-400); }

/* the bottom bar: who is in the book, and how much of it there is */
.auth__proofbar {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.auth__faces { display: flex; align-items: center; }
.auth__faces .avatar { margin-right: -11px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92); }
.auth__faces .avatar:last-of-type { margin-right: 0; }
.auth__faces-more {
  margin-left: 14px;
  font-size: var(--t-label-size);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}

/* right: the form panel */
.auth__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-5);
  padding: clamp(10px, 1.6vw, 26px);
}
.auth__form {
  width: 100%;
  max-width: var(--w-form);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding: clamp(24px, 2.6vw, 38px);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--card-shadow), inset 0 0 0 1px var(--border-color);
}
.auth__form-head { display: flex; flex-direction: column; gap: 6px; }
.auth__form-kicker {
  font-size: var(--t-micro-size);
  font-weight: 600;
  letter-spacing: var(--t-micro-track);
  text-transform: uppercase;
  color: var(--brand-600);
}
.auth__form-title { font-size: clamp(23px, 2.1vw, 29px); font-weight: 600; letter-spacing: -0.028em; color: var(--ink-900); margin-top: 2px; }
.auth__form-sub { font-size: var(--t-body-size); font-weight: 400; color: var(--ink-400); }
.auth__fields { display: flex; flex-direction: column; gap: var(--s-4); }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.auth__or {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-label-size);
  font-weight: 600;
  color: var(--ink-300);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth__or::before,
.auth__or::after { content: ""; height: 1px; flex: 1 1 auto; background: var(--ink-150); }
.auth__alt { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.auth__foot { font-size: var(--t-cell-size); font-weight: 400; color: var(--ink-400); text-align: center; }
.auth__legal {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  width: 100%;
  max-width: var(--w-form);
  font-size: var(--t-label-size);
  font-weight: 400;
  color: var(--ink-400);
  line-height: 1.6;
}
.auth__legal svg { flex: 0 0 auto; margin-top: 2px; color: var(--ink-300); }

.auth__demo {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--brand-025);
  box-shadow: inset 0 0 0 1px var(--brand-100);
  font-size: var(--t-label-size);
  font-weight: 400;
  color: var(--brand-800);
  line-height: 1.55;
}
.auth__demo svg { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 2px; }
.auth__demo code {
  font-family: var(--font-sans);
  font-weight: 600;
  background: var(--brand-100);
  padding: 0 5px;
  border-radius: 5px;
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 1400px) {
  .dash {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    grid-template-areas:
      "hero  hero"
      "chart mini"
      "rail  meter"
      "table table";
  }
}

@media (max-width: 1100px) {
  .hero__tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__aside { order: 2; }
  .auth__proofbar { margin-top: var(--s-5); }
  .stack { max-width: 100%; }
}

@media (max-width: 620px) {
  .stack__card,
  .stack__tile { transform: none; width: 100%; }
  .stack__tile { margin-left: 0; }
  .stack__notice { align-self: stretch; margin-right: 0; }
}

@media (max-width: 820px) {
  .dash {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "hero" "chart" "mini" "rail" "meter" "table";
  }
  .hero__tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth__proof { grid-template-columns: minmax(0, 1fr); }
  .auth__alt { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .hero__tiles { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Sub-page shell + the layout primitives every page composes from
   ========================================================================== */

/* Overview grew a third row: the loan book, the approvals queue and the ledger
   integrity check sit together because they are the three things an admin opens
   the portal to find out. They share one nested grid rather than three grid
   areas so the row stays even at any width.

   The rail spans BOTH of those rows. The float card plus its composition is
   naturally taller than the bar chart beside it, and a rail confined to row 2
   forced that whole row to the rail's height — leaving a 200px hole under the
   chart and another under the mini column. Spanning lets the chart, the mini
   column and the trio each take their own natural height instead. */
.dash {
  grid-template-areas:
    "hero  hero  hero"
    "chart mini  rail"
    "trio  trio  rail"
    "table table meter";
}
.dash__trio {
  grid-area: trio;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 1.1vw, 16px);
  align-items: stretch;
}
.dash__trio > .card { height: 100%; }

/* Natural height now that the rail no longer sets the row. */
.dash__chart { height: auto; align-self: stretch; }
/* The chart and the mini column share a row: whichever is shorter stretches to
   the other, so neither leaves a hole under it. */
.dash__mini { align-self: stretch; }
/* On a wide card the plot stops growing and sits centred instead. */
.chartcard__plot .chart svg { max-height: 400px; }

/* --------------------------------------------------------- the sub-page */
.sub { display: flex; flex-direction: column; gap: clamp(12px, 1.1vw, 18px); }


.sub__head { padding: clamp(4px, 0.6vw, 10px) clamp(4px, 0.6vw, 8px) 0; }
.sub__tools { position: sticky; top: calc(var(--appbar-height) + 8px); z-index: 30; }
.sub__main { display: flex; flex-direction: column; gap: clamp(12px, 1.1vw, 16px); }
.sub__note {
  font-size: var(--t-label-size);
  font-weight: 400;
  color: var(--ink-400);
  padding: 0 4px;
}
.sub__note code {
  font-family: ui-monospace, Consolas, Menlo, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--ink-100);
  color: var(--ink-600);
}

/* ------------------------------------------------ composable page grids */
.cols { display: grid; gap: clamp(12px, 1.1vw, 16px); align-items: start; }
.cols--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* register pages: the table on the left, the selected record on the right */
.cols--main-rail { grid-template-columns: minmax(0, 1.72fr) minmax(0, 1fr); }
.cols--rail-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1.72fr); }
.cols--wide-narrow { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); }
/* a jump index beside the one record it opens — narrower than a register's
   table, because the left column here is a means of navigation, not content */
.cols--index-main { grid-template-columns: minmax(232px, 0.52fr) minmax(0, 1.9fr); }
.cols--stretch { align-items: stretch; }
.cols--stretch > .card { height: 100%; }

/* a card whose body is a table: the head keeps its padding, the table does not */
.card--table { padding: 0; gap: 0; }
.card--table > .card__head { padding: 18px var(--s-5) 10px; }
.card--table > .u-scroll-x,
.card--table > div > .u-scroll-x { padding: 0 var(--s-5); }

.card__figrow { display: flex; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap; }
.card__figrow .t-figure { line-height: 1; }

@media (max-width: 1400px) {
  /* Two equal columns, and the chart takes the full width — it is the one card
     that gets better with more of it.

     The rail spans the two short cards beside it (the mini column plus the
     cycle meter) because it is roughly as tall as both together. Pairing the
     rail with the meter alone, as this breakpoint used to, left a 470px hole
     beside the meter. */
  .dash {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "hero  hero"
      "chart chart"
      "mini  rail"
      "meter rail"
      "trio  trio"
      "table table";
  }
  /* Three cards at ~300px each ellipse their own row titles. Two, and the odd
     one out takes the full width. */
  .dash__trio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash__trio > :nth-child(3):last-child { grid-column: span 2; }

  .cols--main-rail,
  .cols--rail-main,
  .cols--wide-narrow { grid-template-columns: minmax(0, 1fr); }
  .cols--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1200px) {
  .cols--3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .dash {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "hero" "chart" "mini" "rail" "trio" "meter" "table";
  }
  .dash__trio { grid-template-columns: minmax(0, 1fr); }
  .dash__trio > :nth-child(3):last-child { grid-column: auto; }
  .cols--2 { grid-template-columns: minmax(0, 1fr); }
  /* A sticky filter row costs more than it gives once it is two rows tall. */
  .sub__tools { position: static; }
  /* the index stops being a sidebar and becomes a picker above the record */
  .cols--index-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .cols--4 { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------- the frame, narrow window
   The menu leaves the flow and becomes a drawer over a scrim. */
@media (max-width: 900px) {
  .app__side {
    position: fixed;
    left: 0;
    top: 0;
    width: 232px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  html.sidebar-open .app__side { transform: none; box-shadow: var(--sh-xl); }
  html.sidebar-open .app__scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.5);
  }
  .sidebar__toggle { display: none; }
  .appbar { padding: 0 10px; }
  .appbar__menu { display: grid; }
  .appbar__crumb,
  .appbar__utility .flagchip,
  .appbar__user-name { display: none; }
  .shell { padding: 14px 12px 32px; }
}
