/*
 * Simply Mail admin. The same tokens as the iOS and Android apps: a cool porcelain
 * canvas, white paper, green-black ink and one deep teal accent, set in Atkinson
 * Hyperlegible Next. Spacing runs on the apps' 4/8/12/16/20/24/32/48 scale and the
 * corners are the apps' card (22), tile (14) and badge (10) radii. The layout follows
 * the rs6 dashboard: a collapsible sidebar, a top bar, KPI cards on a tray, charts.
 *
 * The admin is read at a desk, so the type ramp is a step smaller than the phone's
 * (body 16 instead of 18); weights and tracking are the apps'.
 */

@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 400; font-display: swap; src: url("/assets/atkinson_regular-711ac5cd.ttf") format("truetype"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 500; font-display: swap; src: url("/assets/atkinson_medium-fcac9a0a.ttf") format("truetype"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 600; font-display: swap; src: url("/assets/atkinson_semibold-102efe56.ttf") format("truetype"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 700; font-display: swap; src: url("/assets/atkinson_bold-cfac09bf.ttf") format("truetype"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 800; font-display: swap; src: url("/assets/atkinson_extrabold-e2ec94f4.ttf") format("truetype"); }

:root {
  color-scheme: light;

  /* Surfaces */
  --canvas: #F3F5F0;
  --surface: #FFFFFF;
  --surface-muted: #E7ECE6;
  --line: #D3DBD4;
  --line-strong: #9FADA7;
  /* The rs6 "tray": a recessed frame that holds paper. */
  --tray: #E7ECE6;
  --tray-paper: #FFFFFF;
  --tray-edge: rgba(21, 35, 32, 0.05);
  --paper-edge: rgba(21, 35, 32, 0.07);
  --row-hover: #F6F8F4;

  /* Text */
  --ink: #152320;
  --ink-2: #46544F;
  --ink-3: #56645F;

  /* The one accent */
  --accent: #0C6B5B;
  --on-accent: #FFFFFF;
  --accent-soft: #DDEEE8;
  --accent-ink: #0A5145;

  /* Outcomes */
  --danger: #B3261E;
  --on-danger: #FFFFFF;
  --danger-soft: #FBE6E2;

  --inverse: #1D2B27;
  --inverse-ink: #F3F7F5;

  /* Category tints (background, ink) */
  --sage-bg: #DDEEE8;  --sage-ink: #0A5145;
  --sand-bg: #F4EAD8;  --sand-ink: #6A4813;
  --clay-bg: #F7E3DB;  --clay-ink: #8A3A1E;
  --sky-bg: #DEEAF4;   --sky-ink: #1F4E73;
  --slate-bg: #E4E7F1; --slate-ink: #39476A;
  --moss-bg: #E8EDD6;  --moss-ink: #4A5919;

  /* Elevation: a soft drop in light mode, a hairline in dark. */
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.055), 0 1px 1.5px rgba(0, 0, 0, 0.04);
  --shadow-pop: 0 18px 40px -12px rgba(21, 35, 32, 0.28), 0 2px 6px rgba(21, 35, 32, 0.08);
  --card-border: transparent;

  /* Spacing (SMSpace) */
  --s-xxs: 4px; --s-xs: 8px; --s-s: 12px; --s-m: 16px; --s-l: 20px; --s-xl: 24px; --s-xxl: 32px; --s-xxxl: 48px;

  /* Radii (SMRadius) */
  --r-card: 22px; --r-tile: 14px; --r-badge: 10px;
  /* The tray's paper sits concentrically inside the card radius. */
  --tray-pad: 6px;
  --r-tray-paper: 16px;

  --nav-w: 256px;
  --font: "Atkinson Hyperlegible Next", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #0E1513;
    --surface: #18211E;
    --surface-muted: #24302B;
    --line: #33403B;
    --line-strong: #5B6B65;
    --tray: #18211E;
    --tray-paper: #24302B;
    --tray-edge: rgba(255, 255, 255, 0.03);
    --paper-edge: #33403B;
    --row-hover: #1D2824;
    --ink: #EDF2EF;
    --ink-2: #B1C0B9;
    --ink-3: #9AAAA3;
    --accent: #63C7B1;
    --on-accent: #062820;
    --accent-soft: #173A33;
    --accent-ink: #93DFCD;
    --danger: #FF8E7E;
    --on-danger: #3D1E1A;
    --danger-soft: #3D1E1A;
    --inverse: #E4ECE8;
    --inverse-ink: #13201C;
    --sage-bg: #173A33;  --sage-ink: #93DFCD;
    --sand-bg: #3A2E19;  --sand-ink: #F0D3A2;
    --clay-bg: #3D241B;  --clay-ink: #F5C1AD;
    --sky-bg: #1B2D3D;   --sky-ink: #B5D3EE;
    --slate-bg: #232A3C; --slate-ink: #C3CDEB;
    --moss-bg: #2B3219;  --moss-ink: #D3DFA6;
    --shadow: none;
    --shadow-pop: 0 18px 40px -12px rgba(0, 0, 0, 0.7);
    --card-border: #33403B;
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body.sm-app {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Resets carry no weight (:where), so every component class wins over them. */
:where(.sm-app) :where(h1, h2, h3, p, ul) { margin: 0; }
:where(.sm-app) :where(a) { color: inherit; text-decoration: none; }
:where(.sm-app) :where(button) { font: inherit; }
:where(.sm-app) :where(svg) { flex: none; }

.sm-app :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.sm-num { font-variant-numeric: tabular-nums; }
.sm-mono { font-family: var(--mono); font-size: 0.9em; }
.sm-muted { color: var(--ink-2); }
.sm-faint { color: var(--ink-3); }
.sm-strong { color: var(--ink); font-weight: 700; }
.sm-link { color: var(--accent); font-weight: 700; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.sm-link:hover { color: var(--accent-ink); }
.sm-good { color: var(--accent-ink); }
.sm-bad { color: var(--danger); }
.sm-warn { color: var(--sand-ink); }
.sm-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Small capitals that open a section (SMTextStyle.Label). */
.sm-label {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-2); line-height: 1.3;
}
.sm-label.is-faint { color: var(--ink-3); font-weight: 600; }

/* ---------- Sidebar ---------- */

.sm-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--nav-w);
  display: flex; flex-direction: column;
  padding: var(--s-m) var(--s-s);
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto; scrollbar-width: none;
  transition: width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sm-sidebar::-webkit-scrollbar { display: none; }

.sm-brand { display: flex; align-items: center; gap: var(--s-s); padding: var(--s-xxs) var(--s-xxs) var(--s-xs); min-height: 52px; }
.sm-brand-mark { width: 40px; height: 40px; border-radius: 11px; display: block; }
.sm-brand-text { flex: 1; min-width: 0; line-height: 1.15; }
.sm-brand-name { font-size: 18px; font-weight: 800; letter-spacing: -0.2px; color: var(--ink); white-space: nowrap; }
.sm-brand-sub { margin-top: 3px; }

.sm-icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 999px; cursor: pointer;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
  transition: color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.sm-icon-btn:hover { color: var(--ink); background: var(--row-hover); }
.sm-icon-btn:active { transform: scale(0.94); }
.sm-icon-btn.is-small { width: 34px; height: 34px; }
.sm-collapse-btn svg { transition: transform 0.22s ease; }
.sm-drawer-close { display: none; }

.sm-nav { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s-m); }
.sm-nav-section { padding: var(--s-xl) var(--s-s) var(--s-xs); }
.sm-nav-section:first-child { padding-top: var(--s-xs); }

.sm-nav-link {
  position: relative;
  display: flex; align-items: center; gap: var(--s-s);
  min-height: 44px; padding: 0 var(--s-s);
  border-radius: var(--r-tile);
  font-size: 15.5px; font-weight: 500; color: var(--ink-2);
  transition: background 0.15s ease, color 0.15s ease;
}
.sm-nav-link svg { color: var(--ink-3); }
.sm-nav-link:hover { background: var(--row-hover); color: var(--ink); }
.sm-nav-link.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.sm-nav-link.is-active svg { color: var(--accent); }
.sm-nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sm-count {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--danger); color: var(--on-danger);
}

.sm-nav-footer { margin-top: auto; padding-top: var(--s-m); }
.sm-user {
  display: flex; align-items: center; gap: var(--s-s);
  padding: var(--s-s); border-radius: var(--r-tile);
  background: var(--canvas); border: 1px solid var(--line);
}
.sm-avatar {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 800; font-size: 16px;
}
.sm-user-text { flex: 1; min-width: 0; line-height: 1.2; }
.sm-user-name { font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-user-role { font-size: 13.5px; color: var(--ink-3); }
.sm-user form { margin: 0; display: flex; }

/* Collapsed sidebar: icons only. */
@media (min-width: 1024px) {
  html.sm-nav-collapsed { --nav-w: 84px; }
  html.sm-nav-collapsed .sm-brand { flex-direction: column; gap: var(--s-s); }
  html.sm-nav-collapsed .sm-brand-text,
  html.sm-nav-collapsed .sm-nav-text,
  html.sm-nav-collapsed .sm-user-text,
  html.sm-nav-collapsed .sm-nav-section > * { display: none; }
  html.sm-nav-collapsed .sm-nav-section { padding: var(--s-s) 0 0; border-top: 1px solid var(--line); margin: var(--s-s) var(--s-s) var(--s-xxs); }
  html.sm-nav-collapsed .sm-nav-section:first-child { border-top: 0; margin-top: 0; }
  html.sm-nav-collapsed .sm-nav-link { justify-content: center; padding: 0; }
  html.sm-nav-collapsed .sm-nav-link .sm-count { position: absolute; top: 2px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; }
  html.sm-nav-collapsed .sm-collapse-btn svg { transform: rotate(180deg); }
  html.sm-nav-collapsed .sm-user { flex-direction: column; padding: var(--s-xs); background: transparent; border-color: transparent; }
}

/* ---------- Main column ---------- */

.sm-main { margin-left: var(--nav-w); min-height: 100vh; transition: margin-left 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sm-page {
  container: page / inline-size;
  max-width: 1440px; margin: 0 auto;
  padding: var(--s-xl) var(--s-xxl) var(--s-xxxl);
}

.sm-topbar {
  display: flex; align-items: center; gap: var(--s-s);
  padding-bottom: var(--s-m);
  border-bottom: 1px solid var(--line);
}
.sm-crumbs { display: flex; align-items: center; gap: var(--s-xs); min-width: 0; font-size: 15px; color: var(--ink-3); }
.sm-crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.sm-crumbs .sep { color: var(--line-strong); }
.sm-crumbs .now { color: var(--accent-ink); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-spacer { flex: 1; }
.sm-date {
  display: inline-flex; align-items: center; gap: var(--s-xs);
  min-height: 40px; padding: 0 var(--s-m); border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}

/* Page header: one display title per page. */
.sm-head {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: var(--s-m) var(--s-xl);
  padding: var(--s-xl) 0 var(--s-l);
}
.sm-head-text { min-width: 0; }
.sm-title { font-size: 32px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.15; color: var(--ink); overflow-wrap: anywhere; }
.sm-subtitle { margin-top: 6px; font-size: 16px; color: var(--ink-2); }
.sm-actions { display: flex; align-items: center; gap: var(--s-xs); flex-wrap: wrap; }
.sm-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--s-s); font-size: 15px; font-weight: 700; color: var(--accent); }
.sm-back:hover { color: var(--accent-ink); }

.sm-section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s-s); margin: var(--s-xxl) 0 var(--s-s); }
.sm-head + .sm-section-title { margin-top: 0; }
.sm-stack { display: flex; flex-direction: column; gap: var(--s-m); }
.sm-stack.is-spaced { margin-top: var(--s-m); }

/* Mobile bar and drawer (below 1024). */
.sm-mobilebar { display: none; }
.sm-scrim { display: none; }
@media (max-width: 1023.98px) {
  .sm-sidebar { transform: translateX(-104%); width: min(300px, 86vw); box-shadow: var(--shadow-pop); }
  html.sm-nav-open .sm-sidebar { transform: none; }
  html.sm-nav-open .sm-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.32); }
  .sm-collapse-btn { display: none; }
  .sm-drawer-close { display: inline-grid; }
  .sm-main { margin-left: 0; }
  .sm-mobilebar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: var(--s-s);
    padding: var(--s-s) var(--s-l);
    background: color-mix(in srgb, var(--canvas) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .sm-mobilebar .sm-brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .sm-page { padding: var(--s-m) var(--s-l) var(--s-xxxl); }
  .sm-topbar .sm-date { display: none; }
}
@media (max-width: 640px) {
  .sm-title { font-size: 28px; }
}

/* ---------- Buttons and chips ---------- */

.sm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-xs);
  min-height: 44px; padding: 0 var(--s-l);
  border-radius: 999px; border: 1.5px solid transparent;
  font-size: 15.5px; font-weight: 700; line-height: 1.2; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.sm-btn:active { transform: scale(0.97); }
.sm-btn.is-primary { background: var(--accent); color: var(--on-accent); }
.sm-btn.is-primary:hover { filter: brightness(1.08); }
.sm-btn.is-secondary { background: var(--accent-soft); color: var(--accent-ink); }
.sm-btn.is-secondary:hover { filter: brightness(0.97); }
.sm-btn.is-outline { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.sm-btn.is-outline:hover { background: var(--row-hover); }
.sm-btn.is-danger { background: var(--danger-soft); color: var(--danger); }
.sm-btn.is-danger:hover { filter: brightness(0.97); }
.sm-btn.is-quiet { background: transparent; color: var(--accent); min-height: 36px; padding: 0 var(--s-xs); }
.sm-btn.is-quiet:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.sm-btn.is-quiet.is-danger-text { color: var(--danger); }
.sm-btn.is-small { min-height: 36px; padding: 0 14px; font-size: 14.5px; }
.sm-btn.is-block { width: 100%; }
.sm-app form.button_to { display: inline-flex; margin: 0; }

.sm-chips { display: flex; align-items: center; gap: var(--s-xs); flex-wrap: wrap; }
.sm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 var(--s-m);
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap;
  cursor: pointer; list-style: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.sm-chip::-webkit-details-marker { display: none; }
.sm-chip:hover { border-color: var(--line-strong); }
.sm-chip:active { transform: scale(0.97); }
.sm-chip.is-selected { background: var(--ink); border-color: var(--ink); color: var(--canvas); }

/* A popover from a chip or an icon button (details/summary, no script). */
.sm-pop { position: relative; }
.sm-pop > summary { list-style: none; }
.sm-pop > summary::-webkit-details-marker { display: none; }
.sm-pop-panel {
  position: absolute; z-index: 50; top: calc(100% + var(--s-xs)); right: 0;
  width: min(360px, calc(100vw - 32px));
  padding: var(--s-l); border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
}
.sm-pop-panel.is-list { padding: var(--s-xs); width: min(420px, calc(100vw - 32px)); max-height: min(560px, 70vh); overflow-y: auto; }
.sm-pop-title { padding: var(--s-xs) var(--s-s) var(--s-xs); }

/* ---------- Cards and the tray ---------- */

.sm-card {
  background: var(--surface); border-radius: var(--r-card);
  box-shadow: var(--shadow); border: 1px solid var(--card-border);
  padding: var(--s-l);
}
.sm-card.is-flush { padding: 0; overflow: hidden; }
.sm-card-text { margin: var(--s-xs) 0 var(--s-m); font-size: 15.5px; color: var(--ink-2); }

.sm-tray {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--tray); border-radius: var(--r-card);
  padding: var(--tray-pad);
  box-shadow: inset 0 0 0 1px var(--tray-edge);
}
.sm-tray-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-s);
  padding: var(--s-xs) var(--s-s) var(--s-xs);
  min-height: 36px;
}
.sm-tray-head a.sm-label:hover { color: var(--accent); }
.sm-paper {
  flex: 1; min-width: 0;
  background: var(--tray-paper); border-radius: var(--r-tray-paper);
  border: 1px solid var(--paper-edge);
  padding: var(--s-m) var(--s-l);
}
.sm-paper.is-flush { padding: 0; overflow: hidden; }
.sm-tray-foot {
  display: flex; align-items: center; gap: var(--s-xs);
  padding: var(--s-xs) var(--s-s) var(--s-xxs);
  font-size: 14px; color: var(--ink-2); min-height: 36px;
}

/* ---------- Dashboard ---------- */

/* Five across on a wide page, three over two in the middle, then two, then one. */
.sm-kpis { display: grid; gap: var(--s-m); grid-template-columns: minmax(0, 1fr); }
@container page (min-width: 481px) and (max-width: 759.98px) {
  .sm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@container page (min-width: 760px) and (max-width: 1179.98px) {
  .sm-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .sm-kpis > * { grid-column: span 2; }
  .sm-kpis > :nth-child(n + 4) { grid-column: span 3; }
}
@container page (min-width: 1180px) {
  .sm-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.sm-kpi-figure { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-s); margin-top: var(--s-s); }
.sm-kpi-num {
  display: block; min-width: 0;
  font-size: 30px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.05;
  font-variant-numeric: tabular-nums; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sm-kpi-unit { font-size: 16px; font-weight: 700; color: var(--ink-2); margin-left: 3px; letter-spacing: 0; }
.sm-kpi-note { font-size: 14px; line-height: 1.35; color: var(--ink-3); margin-top: var(--s-xs); }

.sm-spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; flex: none; }
.sm-spark-col { width: 4px; border-radius: 2px; background: var(--line); }
.sm-spark-col.is-hot { background: var(--accent); }

.sm-delta { display: inline-flex; align-items: center; gap: var(--s-xs); font-size: 14px; font-weight: 700; white-space: nowrap; color: var(--ink-3); }
.sm-delta-icon {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px;
  background: var(--tray-paper); border: 1px solid var(--paper-edge); color: var(--ink-3);
}
.sm-delta.is-good { color: var(--accent-ink); }
.sm-delta.is-good .sm-delta-icon { background: var(--sage-bg); border-color: transparent; color: var(--accent-ink); }
.sm-delta.is-bad { color: var(--danger); }
.sm-delta.is-bad .sm-delta-icon { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.sm-delta-rest { font-weight: 500; color: var(--ink-3); }

.sm-grid { display: grid; gap: var(--s-m); margin-top: var(--s-m); grid-template-columns: minmax(0, 1fr); }
@container page (min-width: 900px) {
  .sm-grid.is-wide-narrow { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .sm-grid.is-halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-grid.is-thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container page (min-width: 900px) {
  .sm-grid.is-quarters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@container page (min-width: 480px) and (max-width: 899.98px) {
  .sm-grid.is-quarters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.sm-grid.is-first { margin-top: 0; }
.sm-label + .sm-big { margin-top: var(--s-xs); }
@container page (min-width: 720px) and (max-width: 899.98px) {
  .sm-grid.is-thirds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-grid.is-thirds > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .sm-grid.is-halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.sm-total { font-size: 15px; color: var(--ink-2); }
.sm-total b { margin-left: 6px; font-size: 19px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.sm-legend { display: flex; flex-wrap: wrap; gap: var(--s-xs) var(--s-m); margin: var(--s-s) 0 var(--s-xs); }
.sm-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.sm-tray-head .sm-legend { margin: 0; }
.sm-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sm-chart { margin-top: var(--s-xs); }

/* Meters: a labelled rate with a capsule bar. */
.sm-meters { display: flex; flex-direction: column; gap: var(--s-m); }
.sm-meter-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-s); font-size: 15px; color: var(--ink-2); }
.sm-meter-row b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.sm-meter-row .sm-meter-name { color: var(--ink); font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-meter-row a.sm-meter-name:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.sm-meter-row > span:last-child { flex: none; }
.sm-meter-hint { font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }
.sm-bar { display: block; margin-top: 7px; height: 8px; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.sm-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.sm-bar.is-warn > i { background: #B07F1E; }
.sm-bar.is-bad > i { background: var(--danger); }
.sm-bar.is-none > i { background: var(--line-strong); }

/* Summary panels: a big figure over quiet rows. */
.sm-big { font-size: 34px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.sm-big.sm-bad { color: var(--danger); }
.sm-big.sm-good { color: var(--accent-ink); }
.sm-big.sm-warn { color: var(--sand-ink); }
.sm-list-body .sm-bar { max-width: 440px; }
.sm-big-note { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); }
.sm-rows { margin-top: var(--s-s); }
.sm-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-s);
  padding: 11px 0; border-top: 1px solid var(--line);
  font-size: 15px; color: var(--ink-2);
}
.sm-row b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.sm-row-key { display: inline-flex; align-items: center; gap: var(--s-xs); min-width: 0; }
.sm-dot { width: 9px; height: 9px; border-radius: 999px; flex: none; background: var(--line-strong); }

/* Lists of things to open. */
.sm-list { list-style: none; margin: 0; padding: 0; }
.sm-list-item { border-top: 1px solid var(--line); }
.sm-list-item:first-child { border-top: 0; }
.sm-list-link {
  display: flex; align-items: center; gap: var(--s-m);
  padding: 14px var(--s-l);
  transition: background 0.15s ease;
}
a.sm-list-link:hover { background: var(--row-hover); }
.sm-list-body { flex: 1; min-width: 0; }
.sm-list-title { display: block; font-size: 16px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-list-meta { margin-top: 3px; font-size: 14px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 2px var(--s-s); }
.sm-list-chevron { color: var(--ink-3); }

.sm-score {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: var(--r-tile);
  font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--surface-muted); color: var(--ink-2);
}
.sm-score.is-good { background: var(--sage-bg); color: var(--sage-ink); }
.sm-score.is-warn { background: var(--sand-bg); color: var(--sand-ink); }
.sm-score.is-bad { background: var(--danger-soft); color: var(--danger); }
.sm-score.is-large { width: 64px; height: 64px; font-size: 24px; }

/* ---------- Tags, notices, tables ---------- */

.sm-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-badge);
  font-size: 13px; font-weight: 700; line-height: 1.35; white-space: nowrap;
  background: var(--surface-muted); color: var(--ink-2);
}
.sm-tag.is-sage { background: var(--sage-bg); color: var(--sage-ink); }
.sm-tag.is-sand { background: var(--sand-bg); color: var(--sand-ink); }
.sm-tag.is-clay { background: var(--clay-bg); color: var(--clay-ink); }
.sm-tag.is-sky { background: var(--sky-bg); color: var(--sky-ink); }
.sm-tag.is-slate { background: var(--slate-bg); color: var(--slate-ink); }
.sm-tag.is-moss { background: var(--moss-bg); color: var(--moss-ink); }
.sm-tag.is-danger { background: var(--danger-soft); color: var(--danger); }

.sm-notice {
  display: flex; align-items: flex-start; gap: var(--s-s);
  padding: 14px var(--s-m); border-radius: var(--r-tile);
  font-size: 15.5px; line-height: 1.45;
  background: var(--sky-bg); color: var(--sky-ink);
}
.sm-notice > svg { margin-top: 1px; }
.sm-notice-body { flex: 1; min-width: 0; }
.sm-notice-body strong { font-weight: 800; }
.sm-notice.is-success { background: var(--accent-soft); color: var(--accent-ink); }
.sm-notice.is-danger { background: var(--danger-soft); color: var(--danger); }
.sm-notice.is-warn { background: var(--sand-bg); color: var(--sand-ink); }
.sm-notice-close {
  display: grid; place-items: center; width: 28px; height: 28px; margin: -3px -6px -3px 0;
  border-radius: 999px; border: 0; background: transparent; color: inherit; cursor: pointer; opacity: 0.75;
}
.sm-notice-close:hover { opacity: 1; background: rgba(127, 127, 127, 0.14); }
.sm-flash { display: flex; flex-direction: column; gap: var(--s-xs); margin-top: var(--s-m); }
.sm-flash:not(:has(.sm-notice)) { display: none; }
.sm-flash .sm-notice { transition: opacity 0.3s ease, transform 0.3s ease; }
.sm-flash .sm-notice.is-leaving { opacity: 0; transform: translateY(-6px); }

.sm-table-wrap { position: relative; overflow-x: auto; } /* contains visually hidden headers */
.sm-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
.sm-table th {
  padding: 14px var(--s-l) 12px; text-align: left; vertical-align: bottom;
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.sm-table td { padding: 14px var(--s-l); color: var(--ink-2); border-bottom: 1px solid var(--line); vertical-align: middle; }
.sm-table tbody tr:last-child td { border-bottom: 0; }
.sm-table tbody tr:hover td { background: var(--row-hover); }
.sm-table td.is-key { color: var(--ink); font-weight: 700; }
.sm-table td.is-num, .sm-table th.is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sm-table td.is-nowrap { white-space: nowrap; }
.sm-table .sm-table-sub { display: block; margin-top: 2px; font-size: 13.5px; font-weight: 400; color: var(--ink-3); }

/* ---------- Placement split ---------- */

.sm-split { display: flex; height: 40px; border-radius: 999px; overflow: hidden; background: var(--surface-muted); }
.sm-split > span {
  display: flex; align-items: center; justify-content: center; min-width: 0;
  font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden;
}
.sm-split .is-inbox { background: var(--accent); color: var(--on-accent); }
.sm-split .is-spam { background: var(--danger); color: var(--on-danger); }

/* ---------- Alerts bell ---------- */

.sm-bell { position: relative; }
.sm-bell > summary { cursor: pointer; }
.sm-bell .sm-count { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 11.5px; box-shadow: 0 0 0 2px var(--canvas); }
.sm-bell[open] > summary { color: var(--ink); border-color: var(--line-strong); }
.sm-alert-item { display: flex; gap: var(--s-s); padding: var(--s-s); border-radius: var(--r-tile); }
.sm-alert-item + .sm-alert-item { border-top: 1px solid var(--line); border-radius: 0; }
.sm-alert-item p { font-size: 15px; color: var(--ink); line-height: 1.4; }
.sm-alert-item time { display: block; margin-top: 3px; font-size: 13.5px; color: var(--ink-3); }
.sm-pop-foot { padding: var(--s-xs) var(--s-s) var(--s-xxs); border-top: 1px solid var(--line); }

.sm-alert-card { display: flex; align-items: flex-start; gap: var(--s-m); }
.sm-alert-card.is-done { opacity: 0.6; }
.sm-alert-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-tile); flex: none; }
.sm-alert-icon.is-critical { background: var(--danger-soft); color: var(--danger); }
.sm-alert-icon.is-warning { background: var(--sand-bg); color: var(--sand-ink); }
.sm-alert-icon.is-info { background: var(--sky-bg); color: var(--sky-ink); }
.sm-alert-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-xs); margin-bottom: 6px; }

/* ---------- Forms ---------- */

.sm-form { display: flex; flex-direction: column; gap: var(--s-l); }
.sm-form-card { max-width: 600px; }
.sm-field label, .sm-field-label { display: block; margin-bottom: var(--s-xs); font-size: 15px; font-weight: 700; color: var(--ink); }
.sm-field-hint { margin-top: 6px; font-size: 14px; color: var(--ink-3); }
.sm-input,
.sm-app .sm-form input[type="text"], .sm-app .sm-form input[type="password"], .sm-app .sm-form input[type="email"],
.sm-app .sm-form input[type="date"], .sm-app .sm-form input[type="datetime-local"], .sm-app .sm-form input[type="search"],
.sm-app .sm-form select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: var(--r-tile); border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sm-input::placeholder, .sm-form input::placeholder { color: var(--ink-3); opacity: 1; }
.sm-input:focus, .sm-form input:focus, .sm-form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.sm-form-row { display: grid; gap: var(--s-m); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.sm-check { display: flex; align-items: center; gap: var(--s-s); font-size: 16px; color: var(--ink); cursor: pointer; }
.sm-check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.sm-form-actions { display: flex; align-items: center; gap: var(--s-s); flex-wrap: wrap; padding-top: var(--s-xxs); }

.sm-search { display: flex; gap: var(--s-s); flex-wrap: wrap; }
.sm-search .sm-input { flex: 1 1 280px; min-height: 52px; font-size: 17px; padding-left: 46px; }
.sm-search-field { position: relative; flex: 1 1 280px; display: flex; }
.sm-search-field svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.sm-search .sm-btn { min-height: 52px; }

/* Filters above a table, and paging under it. */
.sm-filters { display: flex; flex-wrap: wrap; gap: var(--s-s); padding: var(--s-m) var(--s-l); border-bottom: 1px solid var(--line); }
.sm-filters .sm-input { flex: 1 1 160px; width: auto; min-height: 44px; font-size: 15px; }
.sm-filters .sm-input[type="search"] { flex-basis: 260px; }
.sm-filters .sm-btn { min-height: 44px; }
.sm-pager { display: flex; justify-content: space-between; gap: var(--s-s); padding: var(--s-s) var(--s-l); border-top: 1px solid var(--line); }

/* A folder's sync state: a dot, a word and when. */
.sm-status { display: inline-flex; align-items: flex-start; gap: var(--s-xs); color: var(--ink); }
.sm-status .sm-dot { margin-top: 6px; }
.sm-status b { font-weight: 700; }
.sm-status.is-live .sm-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sm-status.is-idle .sm-dot { background: var(--sand-ink); }
.sm-status.is-bad { color: var(--danger); cursor: help; }
.sm-status.is-bad .sm-dot { background: var(--danger); }
.sm-actions { display: flex; flex-wrap: wrap; gap: var(--s-xs); justify-content: flex-end; }

/* ---------- Empty states ---------- */

.sm-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-xs); padding: var(--s-xxl) var(--s-l); }
.sm-empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-tile); background: var(--accent-soft); color: var(--accent); margin-bottom: var(--s-xs); }
.sm-empty h3 { font-size: 18px; font-weight: 800; color: var(--ink); }
.sm-empty p { max-width: 440px; font-size: 15.5px; color: var(--ink-2); }
.sm-empty.is-compact { padding: var(--s-xl) var(--s-m); }

/* ---------- Sign in ---------- */

.sm-login { min-height: 100vh; display: grid; place-items: center; padding: var(--s-xl) var(--s-l); }
.sm-login-card { width: min(440px, 100%); padding: var(--s-xxl); }
.sm-login-mark { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto var(--s-l); display: block; box-shadow: var(--shadow); }
.sm-login h1 { text-align: center; font-size: 28px; font-weight: 800; letter-spacing: -0.4px; }
.sm-login-sub { text-align: center; margin: 6px 0 var(--s-xl); font-size: 16px; color: var(--ink-2); }
.sm-login .sm-flash { margin: 0 0 var(--s-l); }

@media (prefers-reduced-motion: reduce) {
  .sm-app *, .sm-app *::before, .sm-app *::after { transition: none !important; animation: none !important; }
}
