/* ==========================================================================
   RD SEO Tools: design system C, "Charcoal and green" (spec 2026-10-02, section 6)
   Loaded on every page. On the Tools pages and Grid Map it comes AFTER style.css,
   so the legacy variables below win over style.css's own :root values.
   1 Tokens  2 Legacy variables  3 Shell base  4 Sidebar  5 Switcher and popover
   6 Main, top bar, page  7 Type helpers  8 Buttons, links, inputs
   9 Tiles, panels, tables  10 Chips, badges, notices, empty states
   11 Dialog  12 Sign-in pages  13 Narrow screens
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --rd-side: #232628;
  --rd-side-raised: #2E3336;
  --rd-side-active: #34383B;
  --rd-side-text: #ECEDEA;
  --rd-side-muted: #A6AAA4;
  --rd-side-label: #8C918A;
  --rd-side-line: #3A3F42;
  --rd-side-edge: #43494D;
  --rd-lime: #AED143;

  --rd-ground: #F6F6F4;
  --rd-surface: #FFFFFF;
  --rd-surface-subtle: #FAFAF8;
  --rd-border: #E4E5E1;
  --rd-hairline: #EEEFEB;
  --rd-text: #1E2123;
  --rd-muted: #5D6265;
  --rd-separator: #707570;
  --rd-faint: #696E69;
  --rd-brand: #00804A;
  --rd-link: #00704A;
  --rd-control-border: #CFD2CC;

  --rd-error-text: #9B2C24;
  --rd-error-bg: #FBEAE8;
  --rd-error-border: #F0C7C2;
  --rd-warning-text: #7A4A00;
  --rd-warning-bg: #FDF3DC;
  --rd-warning-border: #F0D9A6;
  --rd-success-text: #155C33;
  --rd-success-bg: #E1F3E7;
  --rd-success-border: #BFE2CB;
  --rd-info-text: #1F4E79;
  --rd-info-bg: #E7F0F8;
  --rd-info-border: #C5D9EC;

  /* Rank zones (spec 6.3): chip background / border / text, and map-bubble outline. */
  --rd-chip-top3-bg: #E1F3E7;
  --rd-chip-top3-border: #BFE2CB;
  --rd-chip-top3-text: #155C33;
  --rd-chip-mid-bg: #EFC36A;
  --rd-chip-mid-border: #D9A743;
  --rd-chip-mid-text: #4F3100;
  --rd-chip-low-bg: #B3372F;
  --rd-chip-low-border: #B3372F;
  --rd-chip-low-text: #FFFFFF;
  --rd-chip-none-bg: #FFFFFF;
  --rd-chip-none-border: #CFD2CC;
  --rd-chip-none-text: #5D6265;
  --rd-bubble-top3: #155C33;
  --rd-bubble-mid: #4F3100;
  --rd-bubble-low: #7A231D;
  --rd-bubble-none: #5D6265;

  --rd-font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --rd-font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --rd-radius: 12px;
  --rd-radius-sm: 6px;
  --rd-radius-btn: 10px;
  --rd-shadow-btn: 0 1px 2px rgba(0, 64, 37, 0.2);
  --rd-shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
  --rd-focus: #00804A;
  --rd-sidebar-w: 248px;
}

/* 2. Legacy variables (spec 6.6): style.css and the Tools / Grid Map templates
   read these; re-pointing them reskins the legacy content without rewriting it. */
:root {
  --bg: var(--rd-ground);
  --bg-surface: var(--rd-surface);
  --bg-card: var(--rd-surface);
  --bg-hover: var(--rd-hairline);
  --border: var(--rd-border);
  --border-lt: var(--rd-control-border);
  --txt: var(--rd-text);
  --text-primary: var(--rd-text);
  --txt-2: var(--rd-muted);
  --text-secondary: var(--rd-muted);
  --text-muted: var(--rd-muted);
  --txt-3: var(--rd-faint);
  --accent: var(--rd-brand);
  --accent-bg: rgba(0, 128, 74, 0.08);
  --accent-2: var(--rd-link);
  --green: var(--rd-success-text);
  --success: var(--rd-success-text);
  --green-bg: var(--rd-success-bg);
  --red: var(--rd-error-text);
  --danger: var(--rd-error-text);
  --red-bg: var(--rd-error-bg);
  --yellow: var(--rd-warning-text);
  --yellow-bg: var(--rd-warning-bg);
  --blue: var(--rd-info-text);
  --blue-bg: var(--rd-info-bg);
  --head: var(--rd-font);
  --body: var(--rd-font);
  --mono: var(--rd-font-mono);
  --r: 12px;
  --radius: 12px;
  --r-sm: 6px;
  --radius-sm: 6px;
  --shadow: none;
}
/* Spec 6.7: a contrast failure the re-pointing causes is fixed here. The Batch pages'
   "Clear Sheet" button is a style.css .btn-sm (fill var(--accent), now #00804A) with
   inline text colour var(--danger) (#9B2C24): 1.5:1. The error-notice fill gives 6.49:1;
   the id outranks .btn-sm:hover, so hover keeps it too. */
.page-batch #btn-clear-all,
.page-batch-gmb #btn-clear-all { background: var(--rd-error-bg); }

/* 3. Shell base -------------------------------------------------------------
   Body type sits in :where() (zero specificity): on the Tools pages style.css's own
   body rule still governs the legacy content. The frame (sections 4 to 6) sets its
   own type on rd- classes, so style.css's *, body, a and select rules cannot change it. */
:where(.rd-shell, .rd-auth) {
  margin: 0;
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--rd-text);
  background: var(--rd-ground);
  -webkit-font-smoothing: antialiased;
}
/* A page that loads style.css keeps its 16px body size for the legacy content. */
html:has(link[href*="style.css"]) :where(.rd-shell) { font-size: 16px; }
:where(.rd-shell, .rd-auth) *,
:where(.rd-shell, .rd-auth) *::before,
:where(.rd-shell, .rd-auth) *::after { box-sizing: border-box; }
:where(.rd-shell, .rd-auth) [hidden] { display: none !important; }
:where(.rd-shell, .rd-auth) :focus-visible { outline: 2px solid var(--rd-focus); outline-offset: 2px; }

.rd-shell {
  display: flex;
  height: auto;            /* style.css sets html, body { height: 100% } */
  min-height: 100vh;
  margin: 0;
}
.rd-icon { flex: none; }   /* every icon() svg: an icon never shrinks in a flex row */

/* 4. Sidebar ---------------------------------------------------------------- */
.rd-sidebar {
  --rd-focus: var(--rd-lime);
  position: sticky;
  top: 0;
  z-index: 1100;           /* above Leaflet's panes (400) and controls (1000) */
  align-self: flex-start;
  flex: 0 0 var(--rd-sidebar-w);
  width: var(--rd-sidebar-w);
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  background: var(--rd-side);
  color: var(--rd-side-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
  text-align: left;
}
.rd-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 20px 20px 18px;
  color: var(--rd-side-text);
  font-size: 15px;
  line-height: 20px;
  font-weight: 800;
  letter-spacing: -0.015em;
  text-decoration: none;
}
.rd-brand img {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
}

.rd-nav { margin: 24px 0 0; padding: 0 12px; }
.rd-nav--tools { margin: 22px 0 0; }
.rd-nav:last-of-type { margin-bottom: 32px; }   /* the last section (Team) keeps the gap above the user bar */
.rd-nav ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rd-nav--tools ul { gap: 0; }
.rd-nav li { margin: 0; padding: 0; }
.rd-nav__label {
  margin: 0;
  padding: 0 12px 6px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rd-side-label);
}
.rd-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border-radius: var(--rd-radius-sm);
  color: var(--rd-side-text);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  text-decoration: none;
}
.rd-nav__item svg { flex: none; color: var(--rd-side-muted); }
.rd-nav--tools .rd-nav__item { color: var(--rd-side-muted); font-weight: 500; }
.rd-nav--tools .rd-nav__item svg { margin: 0 1px; color: var(--rd-side-label); }
.rd-nav a.rd-nav__item:not(.rd-nav__item--active):not([aria-current="page"]):hover {
  background: var(--rd-side-raised);
  color: var(--rd-side-text);
}
.rd-nav .rd-nav__item--active,
.rd-nav .rd-nav__item[aria-current="page"] {
  background: var(--rd-side-active);
  color: #FFFFFF;
  font-weight: 700;
}
.rd-nav .rd-nav__item--active svg,
.rd-nav .rd-nav__item[aria-current="page"] svg { color: var(--rd-lime); }
.rd-nav .rd-nav__item--disabled { color: var(--rd-side-label); cursor: default; }
.rd-nav .rd-nav__item--disabled svg { color: var(--rd-side-label); }
.rd-soon {
  margin-left: auto;
  padding: 1px 7px;
  border: 1px solid var(--rd-side-line);
  border-radius: 999px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rd-side-muted);
}

.rd-userbar {
  display: flex;
  flex-wrap: wrap;          /* a name too long to share the row puts Sign out on a second row */
  align-items: center;
  gap: 10px;
  margin: auto 12px 0;
  padding: 14px 0 16px 4px;
  border-top: 1px solid var(--rd-side-active);
}
.rd-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--rd-side-active);
  color: #FFFFFF;
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.03em;
}
/* The name may use the whole row beside the avatar (100% less the 34px avatar and the
   10px gap) before it is cut off; past what fits beside Sign out, Sign out wraps. */
.rd-userbar__text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  max-width: calc(100% - 44px);
}
.rd-userbar__name {
  overflow: hidden;
  font-size: 14px;
  line-height: 18px;
  font-weight: 700;
  color: var(--rd-side-text);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rd-userbar__role { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--rd-side-muted); }
.rd-signout { flex: none; margin: 0; }
.rd-signout button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: 0;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--rd-side-edge);
  border-radius: var(--rd-radius-sm);
  color: var(--rd-side-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.rd-signout button:hover { background: var(--rd-side-raised); }
.rd-signout button svg { color: var(--rd-side-muted); }

.rd-menu-btn {
  display: none;            /* shown below 900px (section 13) */
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 1px solid var(--rd-side-edge);
  border-radius: var(--rd-radius-sm);
  color: var(--rd-side-text);
  cursor: pointer;
}

/* 5. Client switcher and popover --------------------------------------------- */
.rd-switcher { position: relative; margin: 0; padding: 0 12px; }
#rd-switcher-btn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  margin: 0;
  padding: 11px 10px 11px 13px;
  background: var(--rd-side-raised);
  border: 1px solid var(--rd-side-edge);
  border-radius: var(--rd-radius-sm);
  color: var(--rd-side-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  cursor: pointer;
}
#rd-switcher-btn:hover,
#rd-switcher-btn[aria-expanded="true"] { border-color: var(--rd-side-label); }
#rd-switcher-btn > svg {
  box-sizing: content-box;
  grid-column: 2;
  grid-row: 1 / span 3;
  padding: 4px;
  border-radius: var(--rd-radius-sm);
  background: var(--rd-side-line);
  color: var(--rd-side-text);
}
.rd-switcher__label,
.rd-switcher__name,
.rd-switcher__meta { display: block; grid-column: 1; min-width: 0; }
.rd-switcher__label {
  font-size: 11px;
  line-height: 14px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--rd-lime);
}
.rd-switcher__name {
  margin-top: 3px;
  overflow: hidden;
  font-size: 15px;
  line-height: 20px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--rd-side-text);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rd-switcher__meta { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--rd-side-muted); }

.rd-popover {
  --rd-focus: var(--rd-lime);
  position: absolute;
  top: calc(100% + 6px);
  left: 12px;
  right: 12px;
  z-index: 30;
  max-height: min(440px, calc(100vh - 170px));
  overflow-y: auto;
  margin: 0;
  padding: 0;
  background: var(--rd-side-raised);
  border: 1px solid var(--rd-side-edge);
  border-radius: var(--rd-radius);
  box-shadow: var(--rd-shadow-pop);   /* one of the two shadows the spec allows */
  color: var(--rd-side-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
}
.rd-popover__search {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 10px;
  background: var(--rd-side-raised);
  border-bottom: 1px solid var(--rd-side-line);
}
.rd-popover__search svg {
  position: absolute;
  left: 21px;
  color: var(--rd-side-muted);
  pointer-events: none;
}
.rd-popover__search input {
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 10px 0 36px;
  background: var(--rd-side);
  border: 1px solid var(--rd-side-edge);
  border-radius: var(--rd-radius-sm);
  color: var(--rd-side-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
}
.rd-popover__search input::placeholder { color: var(--rd-side-muted); opacity: 1; }
.rd-popover__search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.rd-popover__group { margin: 0; padding: 6px; }
.rd-popover__group + .rd-popover__group { border-top: 1px solid var(--rd-side-line); }
.rd-popover__group ul { margin: 0; padding: 0; list-style: none; }
.rd-popover__group li { margin: 0; padding: 0; }
.rd-popover__heading {
  margin: 0;
  padding: 6px 8px 4px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rd-side-muted);
}
.rd-popover__item {
  display: block;
  min-height: 44px;
  margin: 0;
  padding: 12px 10px;
  overflow: hidden;
  border-radius: var(--rd-radius-sm);
  color: var(--rd-side-text);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: none;
}
.rd-popover__item[aria-current="true"],
.rd-popover__item[aria-current="page"] { font-weight: 800; box-shadow: inset 3px 0 0 var(--rd-lime); }
.rd-popover__item:hover,
.rd-popover__item:focus-visible { background: var(--rd-side-active); color: #FFFFFF; }
.rd-popover__item:focus-visible { outline-offset: -2px; }
.rd-popover__empty {
  margin: 0;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 20px;
  color: var(--rd-side-muted);
}
.rd-popover__foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 6px;
  background: var(--rd-side-raised);
  border-top: 1px solid var(--rd-side-line);
}
.rd-popover__foot a,
.rd-popover__foot button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: 0;
  padding: 0 10px;
  background: transparent;
  border: 0;
  border-radius: var(--rd-radius-sm);
  color: var(--rd-side-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.rd-popover__foot a:hover,
.rd-popover__foot button:hover { background: var(--rd-side-active); color: #FFFFFF; }
.rd-popover__foot svg { flex: none; color: var(--rd-lime); }

/* 6. Main column, top bar, page ---------------------------------------------- */
.rd-main {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-width: 0;
  margin: 0;
}
.rd-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 68px;
  margin: 0;
  padding: 0 28px;
  background: var(--rd-surface);
  border-bottom: 1px solid var(--rd-border);
  color: var(--rd-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
}
.rd-breadcrumb { min-width: 0; margin: 0; }
.rd-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rd-breadcrumb li { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; }
.rd-breadcrumb__sep { color: var(--rd-separator); }   /* the "/" span starting each crumb after the first */
.rd-breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--rd-muted);
  font-weight: 500;
  text-decoration: none;
}
.rd-breadcrumb a:hover,
.rd-breadcrumb a:focus-visible { color: var(--rd-text); text-decoration: underline; text-underline-offset: 3px; }
.rd-breadcrumb [aria-current="page"] { color: var(--rd-text); font-weight: 700; }
.rd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; }
.rd-page {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  margin: 0;
  padding: 28px;
}

/* 7. Type helpers -------------------------------------------------------------- */
.rd-h1 {
  margin: 0;
  font-family: var(--rd-font);
  font-size: 28px;
  line-height: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--rd-text);
}
.rd-h2 {
  margin: 0;
  font-family: var(--rd-font);
  font-size: 17px;
  line-height: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rd-text);
}
.rd-meta { margin: 6px 0 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--rd-muted); }
.rd-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0;
}
.rd-mono {
  font-family: var(--rd-font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.rd-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 8. Buttons, links, inputs ---------------------------------------------------- */
.rd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 0 16px 0 14px;
  border: 1px solid transparent;
  border-radius: var(--rd-radius-sm);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.rd-btn svg { flex: none; }
.rd-btn:disabled,
.rd-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.rd-btn--primary {           /* the main action: design B's button, spec 6.5 */
  height: 44px;
  padding: 0 18px;
  background: var(--rd-brand);
  border-color: transparent;
  border-radius: var(--rd-radius-btn);
  box-shadow: var(--rd-shadow-btn);
  color: #FFFFFF;
}
.rd-btn--primary:hover { background: var(--rd-link); color: #FFFFFF; }
.rd-btn--secondary {
  background: var(--rd-surface);
  border-color: var(--rd-control-border);
  color: var(--rd-text);
}
.rd-btn--secondary:hover { background: var(--rd-surface-subtle); color: var(--rd-text); }
.rd-btn--secondary svg { color: var(--rd-muted); }
.rd-btn--danger {
  background: var(--rd-error-bg);
  border-color: var(--rd-error-border);
  color: var(--rd-error-text);
}
.rd-btn--danger:hover { border-color: var(--rd-error-text); color: var(--rd-error-text); }

.rd-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--rd-link);
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  text-decoration: none;
}
.rd-link:hover,
.rd-link:focus-visible { color: var(--rd-link); text-decoration: underline; text-underline-offset: 3px; }

.rd-field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.rd-field label { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--rd-muted); }
.rd-input {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  background: var(--rd-surface);
  border: 1px solid var(--rd-control-border);
  border-radius: var(--rd-radius-sm);
  color: var(--rd-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
}
.rd-input::placeholder { color: var(--rd-muted); opacity: 1; }
.rd-input:focus-visible { outline: 2px solid var(--rd-focus); outline-offset: 1px; }
.rd-search { position: relative; display: block; width: 100%; max-width: 360px; margin: 0; }
.rd-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: var(--rd-muted);
  pointer-events: none;
}
.rd-search .rd-input { padding-left: 40px; }

/* 9. Tiles, panels, tables ----------------------------------------------------- */
.rd-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--rd-border);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
}
.rd-tile { flex: 1 1 200px; min-width: 0; margin: 0; padding: 18px 20px; background: var(--rd-surface); }
.rd-tile__label { margin: 0; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--rd-muted); }
.rd-tile__value {
  margin: 10px 0 0;
  overflow-wrap: anywhere;
  font-family: var(--rd-font-mono);
  font-size: 30px;
  line-height: 36px;
  font-weight: 500;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--rd-text);
}
.rd-tile__context { margin: 6px 0 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--rd-muted); }

.rd-panel {
  margin: 0;
  padding: 20px;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
}
.rd-panel > :first-child { margin-top: 0; }
.rd-panel > :last-child { margin-bottom: 0; }

.rd-table-wrap {
  margin: 0;
  position: relative;      /* contains the absolutely positioned rd-visually-hidden header labels, so they scroll with the table instead of widening the page */
  overflow-x: auto;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
}
.rd-panel .rd-table-wrap { border: 0; border-radius: 0; }
.rd-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  color: var(--rd-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
}
.rd-table th,
.rd-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rd-hairline);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;     /* narrow screens scroll the .rd-table-wrap instead of squeezing */
}
.rd-table thead th {
  padding-top: 11px;
  padding-bottom: 11px;
  background: var(--rd-surface-subtle);
  border-bottom-color: var(--rd-border);
  color: var(--rd-muted);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  white-space: nowrap;
}
.rd-table tbody th { font-weight: 600; }
.rd-table th:first-child,
.rd-table td:first-child { padding-left: 20px; }
.rd-table th:last-child,
.rd-table td:last-child { padding-right: 20px; }
.rd-table tbody tr:last-child > * { border-bottom: 0; }
.rd-table .rd-num { text-align: right; }
.rd-table .rd-mono { font-size: 14px; }
.rd-table .rd-link,
.rd-table .rd-btn { margin: -12px 0; }

/* 10. Chips, badges, notices, empty states ------------------------------------- */
.rd-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-family: var(--rd-font-mono);
  font-size: 13px;
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rd-chip--top3 { background: var(--rd-chip-top3-bg); border-color: var(--rd-chip-top3-border); color: var(--rd-chip-top3-text); }
.rd-chip--mid { background: var(--rd-chip-mid-bg); border-color: var(--rd-chip-mid-border); color: var(--rd-chip-mid-text); }
.rd-chip--low { background: var(--rd-chip-low-bg); border-color: var(--rd-chip-low-border); color: var(--rd-chip-low-text); }
.rd-chip--none { background: var(--rd-chip-none-bg); border-color: var(--rd-chip-none-border); color: var(--rd-chip-none-text); }

.rd-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin: 0;
  padding: 0 10px;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: 12px;
  color: var(--rd-muted);
  font-family: var(--rd-font);
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
}
.rd-badge--running { background: var(--rd-info-bg); border-color: var(--rd-info-border); color: var(--rd-info-text); }
.rd-badge--done { background: var(--rd-success-bg); border-color: var(--rd-success-border); color: var(--rd-success-text); }

.rd-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 12px;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid;
  border-radius: var(--rd-radius);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}
.rd-notice a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -12px 0;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rd-notice--info { background: var(--rd-info-bg); border-color: var(--rd-info-border); color: var(--rd-info-text); }
.rd-notice--success { background: var(--rd-success-bg); border-color: var(--rd-success-border); color: var(--rd-success-text); }
.rd-notice--warning { background: var(--rd-warning-bg); border-color: var(--rd-warning-border); color: var(--rd-warning-text); }
.rd-notice--error { background: var(--rd-error-bg); border-color: var(--rd-error-border); color: var(--rd-error-text); }
/* An empty notice slot leaves the flex flow (so it adds no gap to .rd-page or a dialog
   panel) but stays rendered, so its aria-live still announces what rdNotice puts in it. */
.rd-notice-area:empty { position: absolute; }

.rd-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 40px 24px;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  text-align: center;
}
.rd-panel .rd-empty { padding: 24px; border: 0; }
.rd-empty > svg {
  box-sizing: content-box;
  padding: 12px;
  border-radius: 50%;
  background: var(--rd-ground);
  color: var(--rd-muted);
}
.rd-empty > p {
  max-width: 44ch;
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--rd-text);
}

/* 11. Dialog (a native <dialog>, opened with rdOpenDialog) ---------------------- */
.rd-dialog {
  --rd-focus: var(--rd-brand);   /* the dialog may sit inside the sidebar's markup */
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;            /* style.css's * reset would otherwise pin it top-left */
  padding: 0;
  overflow-y: auto;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  color: var(--rd-text);
  font-family: var(--rd-font);
  font-size: 14px;
  line-height: 20px;
}
.rd-dialog::backdrop { background: rgba(30, 33, 35, 0.55); }
.rd-dialog__panel { display: flex; flex-direction: column; gap: 16px; margin: 0; padding: 24px; }
.rd-dialog__panel p { margin: 0; }
.rd-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin: 4px 0 0; }

/* 12. Sign-in pages (base_auth.html) -------------------------------------------- */
.rd-auth {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  min-height: 100vh;
  margin: 0;
}
.rd-auth__brand {
  --rd-focus: var(--rd-lime);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  margin: 0;
  padding: 48px 40px;
  background: var(--rd-side);
  color: var(--rd-side-text);
}
.rd-auth__brand img {
  display: block;
  width: 72px;
  height: 72px;
}
.rd-auth__brand p { margin: 0; font-size: 15px; line-height: 22px; font-weight: 500; color: var(--rd-side-muted); }
.rd-auth__brand p:first-of-type {
  font-size: 24px;
  line-height: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rd-side-text);
}
.rd-auth__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: center;
  justify-self: center;
  width: min(400px, calc(100% - 32px));
  margin: 48px 0;
  padding: 0;
}
.rd-auth__form form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.rd-auth__form form .rd-btn--primary { width: 100%; }
.rd-auth__form label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--rd-text);
  font-size: 14px;
  font-weight: 500;
}
.rd-auth__form input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--rd-brand); }

/* 13. Narrow screens (spec 5.5): the sidebar folds into a top bar ----------------- */
@media (max-width: 900px) {
  .rd-shell { flex-direction: column; }
  .rd-sidebar {
    position: relative;
    top: auto;
    align-self: stretch;
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 10px 16px;
  }
  .rd-brand { order: 0; min-height: 44px; padding: 0; }
  .rd-brand > :not(img) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .rd-switcher { position: static; order: 1; flex: 1 1 0; min-width: 0; padding: 0; }
  #rd-switcher-btn { min-height: 48px; padding: 6px 8px 6px 12px; }
  .rd-switcher__meta { display: none; }
  .rd-popover { top: calc(100% - 4px); left: 16px; right: 16px; max-height: min(440px, calc(100vh - 90px)); }
  .rd-menu-btn { display: inline-flex; order: 2; }
  .rd-nav,
  .rd-userbar { display: none; order: 3; flex: 1 1 100%; }
  .rd-nav { margin: 8px 0 0; padding: 0; }
  .rd-userbar { order: 4; margin: 8px 0 0; }
  .rd-menu-open .rd-nav { display: block; }
  .rd-menu-open .rd-userbar { display: flex; }
  .rd-topbar { min-height: 60px; padding: 8px 16px; }
  .rd-page { padding: 20px 16px; }
  .rd-tiles { flex-direction: column; }
  .rd-tile { flex-basis: auto; }

  .rd-auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .rd-auth__brand { flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; padding: 16px; }
  .rd-auth__brand img { width: 40px; height: 40px; }
  .rd-auth__brand p:not(:first-of-type) { display: none; }
  .rd-auth__brand p:first-of-type { font-size: 17px; line-height: 24px; }
  .rd-auth__form { align-self: start; margin: 32px 0; }
}

/* ═══ Shell pages (Task 9) ════════════════════════════════════════════════════
   Classes the new pages and the auth pages use that Task 8's component set
   above does not define. Colours are spec §6.2 tokens; type follows spec §6.4. */
.rd-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.rd-section { display: flex; flex-direction: column; gap: 12px; }
.rd-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rd-table-none { margin: 0; padding: 16px 20px; font-size: 14px; line-height: 20px; color: #5D6265; }
.rd-branches { list-style: none; margin: 0; padding: 0; }
.rd-branches > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 12px 20px;
  border-bottom: 1px solid #EEEFEB; }
.rd-branches > li:last-child { border-bottom: 0; }
.rd-branches__label { font-weight: 700; color: #1E2123; }
.rd-branches__address { flex: 1 1 240px; color: #5D6265; }
.rd-branches__tag { font-size: 13px; line-height: 18px; font-weight: 600; color: #155C33; }

.rd-hint { font-size: 13px; line-height: 18px; color: #5D6265; }
.rd-dialog__text { margin: 0; font-size: 14px; line-height: 20px; color: #5D6265; }
.rd-dialog__text strong { color: #1E2123; }

.rd-auth__foot { margin: 0; font-size: 14px; line-height: 20px; color: #5D6265; }
.rd-strength { height: 4px; border-radius: 2px; background: #EEEFEB; overflow: hidden; }
.rd-strength__bar { height: 100%; width: 0; transition: width 0.2s ease; }

/* ── Team > Spend: period switch, chart cards, area chart, bar list ───────── */
.rd-spend-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 16px; }
.rd-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--rd-radius-btn); background: var(--rd-hairline); }
.rd-seg a { padding: 6px 12px; border-radius: 8px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--rd-muted); text-decoration: none; }
.rd-seg a:hover { color: var(--rd-text); }
.rd-seg a[aria-current="page"] { background: var(--rd-surface); color: var(--rd-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.rd-spend-range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--rd-muted); }
.rd-spend-range .rd-input { width: auto; min-width: 0; }
.rd-chart-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; margin: 16px 0 24px; }
.rd-chart-card { padding: 18px 20px; }
.rd-chart-card__title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 700; color: var(--rd-text); }
.rd-chart-card .rd-meta { margin-top: 2px; font-size: 13px; }
.rd-chart { position: relative; margin-top: 12px; min-height: 220px; }
.rd-chart svg { display: block; overflow: visible; }
.rd-chart svg:focus-visible { outline: 2px solid var(--rd-focus); outline-offset: 2px; }
.rd-chart__grid { stroke: var(--rd-hairline); stroke-width: 1; }
.rd-chart__axis { fill: var(--rd-muted); font-family: var(--rd-font); font-size: 12px; }
.rd-chart__line { fill: none; stroke: var(--rd-text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.rd-chart__cross { stroke: var(--rd-separator); stroke-width: 1; }
.rd-chart__dot { fill: var(--rd-text); stroke: var(--rd-surface); stroke-width: 2; }
.rd-chart-table { margin-top: 12px; font-size: 13px; color: var(--rd-muted); }
.rd-chart-table summary { cursor: pointer; }
.rd-chart-table .rd-table { margin-top: 8px; }
.rd-hbars { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.rd-hbar { display: grid; grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr) auto; align-items: center; gap: 10px; border-radius: 6px; font-size: 13px; line-height: 18px; }
.rd-hbar:focus-visible { outline: 2px solid var(--rd-focus); outline-offset: 2px; }
.rd-hbar__name { overflow: hidden; color: var(--rd-text); text-overflow: ellipsis; white-space: nowrap; }
.rd-hbar__track { height: 20px; }
.rd-hbar__fill { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--rd-text); }
.rd-hbar:hover .rd-hbar__fill, .rd-hbar:focus-visible .rd-hbar__fill { opacity: 0.72; }
.rd-hbar__value { font-family: var(--rd-font-mono); color: var(--rd-text); }
.rd-tip { position: absolute; z-index: 30; display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--rd-border); border-radius: 8px; background: var(--rd-surface); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1); font-size: 12px; line-height: 16px; color: var(--rd-muted); white-space: nowrap; pointer-events: none; }
.rd-tip strong { font-family: var(--rd-font-mono); font-size: 14px; line-height: 20px; color: var(--rd-text); }
@media (max-width: 900px) {
  .rd-chart-grid { grid-template-columns: minmax(0, 1fr); }
}
