/* ==========================================================================
   Dwarpal (Dattamsha Data Labs) - base design system
   --------------------------------------------------------------------------
   Token-driven. Every colour, space and radius is a custom property on
   :root, so brand tokens can be swapped in one place without touching a
   component rule.

   This file styles the sign-in and error pages on its own, and is the base
   the two signed-in shells build on: pl-web.css (shared web components),
   portal.css and console.css load after it and override it inside .pl-web,
   .pl-portal and .pl-admin.

   The palette is Dattamsha v2 (dattamsha.co.in): warm cream grounds, ink
   text, Sangam teal for links and brand surfaces, kesar (Phala orange) for
   the one call to action, logo cyan for accents, and raat navy for dark
   surfaces. The legacy token names (--pine, --teal, --mint, --lime) are kept
   so no component rule has to change; read them as the roles below.
   ========================================================================== */

/* ---- Brand ------------------------------------------------------------
   The Dattamsha hexes behind the four legacy role names.

     --pine  #1c1a17  ink           headings, primary text
     --teal  #0a5c63  sangam deep   links, secondary brand surfaces
     --mint  #25abce  logo cyan     accents, on-dark highlights
     --lime  #e8731c  kesar         primary calls to action (ink text)
   --------------------------------------------------------------------- */
:root {
  --pine:  #1c1a17;
  --teal:  #0a5c63;
  --mint:  #25abce;
  --lime:  #e8731c;

  /* Dattamsha's own names, for new rules. */
  --dm-ground: #fbf6ea;
  --dm-surface: #f4ecd9;
  --dm-surface-raised: #fffdf7;
  --dm-ink: #1c1a17;
  --dm-text: #4a4541;
  --dm-muted: #6e665d;
  --dm-rule: #e2d6bd;
  --dm-rule-strong: #cdbf9f;
  --dm-sangam: #0e7c86;
  --dm-sangam-deep: #0a5c63;
  --dm-sangam-tint: #ccded6;
  --dm-kesar: #e8731c;
  --dm-kesar-deep: #824010;
  --dm-kesar-tint: #f7dcc1;
  --dm-logo-cyan: #25abce;
  --dm-logo-grey: #424242;
  --dm-margdarshak: #283593;
  --dm-raat: #141833;
  --dm-raat-surface: #1c2246;
  --dm-raat-raised: #262d57;

  /* The Sangam scale, for surfaces and dividers. */
  --pine-900: #1c1a17;
  --pine-800: #1c2246;
  --pine-700: #0a5c63;
  --pine-600: #0e7c86;
  --pine-500: #138994;
  --pine-400: #1f9fb4;
  --pine-300: var(--mint);
  --pine-200: #9fd3e2;
  --pine-100: #ccded6;
  --pine-050: #eef3ee;

  /* Kesar tints, for soft highlights. */
  --lime-600: #824010;
  --lime-500: #cf6416;
  --lime-300: #f0904a;
  --lime-100: #f7dcc1;
  --lime-050: #fcf0e3;

  /* Warm neutrals from the Dattamsha ground and ink. */
  --ink-900: #1c1a17;
  --ink-800: #2a2622;
  --ink-700: #3a3531;
  --ink-600: #4a4541;
  --ink-500: #6b635a;  /* muted text: clears 4.5:1 on white and on the ground */
  --ink-400: #a39a8c;
  --ink-300: #cdbf9f;
  --ink-200: #e2d6bd;
  --ink-100: #ece3cf;
  --ink-050: #f8f1e2;

  --amber-600: #824010;
  --amber-100: #f7dcc1;
  --red-600: #a22121;
  --red-100: #f0cdc3;
  /* "Info" uses Sangam. Kesar and Sandesh red are kept for warning and
     danger, where a status colour carries real meaning. */

  /* ---- Semantic ------------------------------------------------------- */
  /* Cream ground, near-white cards with a hairline, as on dattamsha.co.in. */
  --bg-page: #fbf6ea;
  --bg-surface: #fffdf7;
  --bg-raised: #fffdf7;
  --bg-subtle: #f4ecd9;
  --bg-inverse: #141833;

  --text-primary: var(--pine);
  --text-secondary: var(--ink-600);
  --text-muted: var(--ink-500);
  --text-inverse: #fbf6ea;
  --text-brand: var(--teal);

  --border-subtle: var(--ink-100);
  --border-default: var(--ink-200);
  --border-strong: var(--ink-300);
  --border-focus: #283593;

  --accent: var(--lime);
  --accent-ink: var(--pine);
  --accent-hover: var(--lime-500);
  --accent-soft: var(--pine-050);

  /* ---- Scale ---------------------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Dattamsha radii: 6 / 8 / 12, pills at 999. */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(28, 26, 23, .05), 0 1px 1px rgba(28, 26, 23, .04);
  --shadow-md: 0 1px 2px rgba(28, 26, 23, .05), 0 8px 24px -12px rgba(28, 26, 23, .22);
  --shadow-lg: 0 2px 4px rgba(28, 26, 23, .06), 0 24px 48px -16px rgba(28, 26, 23, .28);

  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-devanagari: "Noto Serif Devanagari", "DM Sans", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --header-height: 68px;
  --content-max: 1280px;

  /* The dotted-grid motif. */
  --dot: rgba(28, 26, 23, 0.10);

  /* ---- Categorical slots ----------------------------------------------
     Six Dattamsha product colours, used wherever the UI must tell like
     things apart: resource types, roles, KPI cards. Identity is carried by
     the SOLID value; -soft is the product tint, -ink its text-safe tone.
     Every solid/on pair clears WCAG AA 4.5:1.                            */
  --slot-1: #141833;  --slot-1-on: #fbf6ea;
  --slot-1-soft: #e3e1ea;  --slot-1-ink: #141833;  --slot-1-line: #c5c3d6;
  --slot-2: #0a5c63;  --slot-2-on: #fbf6ea;
  --slot-2-soft: #ccded6;  --slot-2-ink: #0a5c63;  --slot-2-line: #a9c9c3;
  --slot-3: #283593;  --slot-3-on: #fbf6ea;
  --slot-3-soft: #d1cfd9;  --slot-3-ink: #283593;  --slot-3-line: #b4b1c6;
  --slot-4: #305f18;  --slot-4-on: #fbf6ea;
  --slot-4-soft: #d5dec2;  --slot-4-ink: #305f18;  --slot-4-line: #b9c79f;
  --slot-5: #25abce;  --slot-5-on: #1c1a17;
  --slot-5-soft: #d7edf3;  --slot-5-ink: #136a80;  --slot-5-line: #a8d8e6;
  --slot-6: #e8731c;  --slot-6-on: #1c1a17;
  --slot-6-soft: #f7dcc1;  --slot-6-ink: #824010;  --slot-6-line: #efc199;

  /* ---- Gradients -------------------------------------------------------
     Raat navy into Sangam teal, logo cyan, and kesar - no colour the
     brand does not own.                                                   */
  --grad-brand:  linear-gradient(135deg, #141833 0%, #0a5c63 70%, #0e7c86 100%);
  --grad-deep:   linear-gradient(135deg, #1c2246 0%, #0e7c86 100%);
  --grad-jade:   linear-gradient(135deg, #0a5c63 0%, #138994 100%);
  --grad-mint:   linear-gradient(135deg, #138994 0%, #25abce 100%);
  /* Both ends light enough to carry ink text at 4.5:1. */
  --grad-mint-bright: linear-gradient(135deg, #5cc0db 0%, #a6dceb 100%);
  --grad-lime:   linear-gradient(135deg, #e8731c 0%, #f0904a 100%);
  --grad-wash:   linear-gradient(180deg, #f8f1e2 0%, #fffdf7 100%);

  /* Glow behind heroes and hover states. */
  --glow-lime: rgba(232, 115, 28, 0.22);
  --glow-mint: rgba(37, 171, 206, 0.20);
}

/* ---- Typeface ---------------------------------------------------------
   The Dattamsha faces, self-hosted so the CSP can keep font-src 'self'
   (all SIL Open Font License, see fonts/OFL-Dattamsha.txt):
   DM Sans for text, Fraunces for display, Noto Serif Devanagari for the
   Sanskrit product name.
   --------------------------------------------------------------------- */
@font-face {
  font-family: "DM Sans";
  src: url("../../fonts/dm-sans.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../../fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Serif Devanagari";
  src: url("../../fonts/noto-serif-devanagari.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CF4, U+1CF7-1CF9, U+200C-200D, U+20A8, U+20B9,
    U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B0A;
}

/* Wordmark lockup (_wordmark.svg): the owl, "Dattamsha" and "DATA LABS". */
.dm-lockup { display: inline-flex; align-items: center; gap: .4em; color: inherit; line-height: 1; vertical-align: middle; }
.dm-lockup__mark { display: block; flex-shrink: 0; width: 1.5em; height: 1.5em; border-radius: 22%; }
.dm-lockup__name { font-family: var(--font-display); font-weight: 400; font-size: 1em; letter-spacing: -.01em; white-space: nowrap; }
.dm-lockup__labs { font-family: var(--font-sans); font-weight: 600; font-size: .4em; letter-spacing: .18em;
  text-transform: uppercase; color: #25abce; white-space: nowrap; align-self: flex-end; margin-bottom: .3em; }
.dm-deva { font-family: var(--font-devanagari); font-weight: 400; }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Proportional figures make a column of numbers wobble; every count,
     percentage and timestamp in this app sits in a column. */
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;   /* the brand sets display type tight */
  color: var(--text-primary);
}
h1 { font-size: 32px; }
h2 { font-size: 22px; letter-spacing: -0.02em; }
h3 { font-size: 17px; letter-spacing: -0.015em; }
h4 { font-size: 14px; letter-spacing: -0.01em; }
p  { margin: 0 0 var(--space-3); }

a { color: var(--text-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Visible focus everywhere - never removed, only restyled. */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -48px; left: var(--space-4);
  z-index: 100; padding: var(--space-2) var(--space-4);
  background: var(--bg-surface); color: var(--text-brand);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--space-3); }

/* ---- Layout ------------------------------------------------------------ */
.layout { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--space-5); }

/* ---- Page head ---------------------------------------------------------
   One header pattern on every in-app page. An eyebrow says where you are, a
   title says what this is, actions sit on the right. No dark panel: the
   masthead is the only heavy band on the page, and stacking a second one
   under it made every screen feel top-loaded.                             */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-5); margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}
.page-head__eyebrow {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--slot-4-ink); margin: 0 0 var(--space-2);
}
.page-head__eyebrow::before {
  content: ""; width: 18px; height: 2px; border-radius: var(--radius-full);
  background: var(--grad-mint);
}
.page-head__title { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.page-head__subtitle {
  margin: var(--space-2) 0 0; color: var(--text-secondary); font-size: 14px;
  max-width: 68ch;
}
.page-head__actions {
  display: flex; gap: var(--space-2); flex-shrink: 0; flex-wrap: wrap;
  padding-top: var(--space-2);
}

/* ---- Admin shell ---------------------------------------------------------
   The Admin Panel is an application, not a page with a menu: a full-height
   brand sidebar that holds the navigation and the person signed in, and a
   slim top bar that says where you are. The sidebar never collapses.

   Contrast is measured against the lightest point of the sidebar sweep
   (#161c43): group labels at 60% white clear 5.2:1, links at 78% clear
   7.6:1, mint icons 5.6:1. See scripts/check_contrast.py.                 */
.admin {
  display: grid; grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  /* The sidebar is sticky and one viewport tall, so on a long page the
     column below it would show the page colour when printed or captured.
     Painting the column itself keeps it solid all the way down. */
  background: linear-gradient(90deg, #161c43 0 264px, var(--bg-page) 264px);
}
.admin-nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  color: #fff;
  background:
    radial-gradient(120% 45% at 0% 100%, rgba(37, 171, 206, .10), transparent 65%),
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .05) 1px, transparent 0) 0 0 / 22px 22px,
    linear-gradient(180deg, #1c1a17 0%, #161c43 100%);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255,.2) transparent;
}
.admin-nav__brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 22px 22px 20px; color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.admin-nav__brand:hover { text-decoration: none; }
.admin-nav__brand .masthead__wordmark { height: 22px; }
.admin-nav__product {
  display: flex; flex-direction: column; line-height: 1.2;
  padding-left: var(--space-3); border-left: 1px solid rgba(255, 255, 255, .18);
}
.admin-nav__product-name { font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, .85); }
.admin-nav__product-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--lime);
}

.admin-nav__menu { flex: 1; padding: var(--space-4) 14px; }
.admin-nav__group { margin-bottom: 18px; }
.admin-nav__label {
  margin: 0 0 6px; padding: 0 var(--space-3);
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255, 255, 255, .6);
}
.admin-nav__link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3); margin-bottom: 2px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .78);
  transition: background .15s ease, color .15s ease;
}
.admin-nav__link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.admin-nav__link:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.admin-nav__icon { display: inline-flex; color: var(--mint); flex-shrink: 0; }
/* Lime is the brand's call-to-action colour; here it marks where you are. */
.admin-nav__link.is-active {
  background: var(--lime); color: var(--pine); font-weight: 700;
  box-shadow: 0 8px 20px -10px rgba(232, 115, 28, .7);
}
.admin-nav__link.is-active .admin-nav__icon { color: var(--pine); }
.admin-nav__count {
  margin-left: auto; min-width: 20px; padding: 1px 7px;
  border-radius: var(--radius-full); background: var(--lime); color: var(--pine);
  font-size: 11px; font-weight: 700; text-align: center;
}
.admin-nav__link.is-active .admin-nav__count { background: var(--pine); color: var(--lime); }

.admin-nav__foot { padding: 14px; border-top: 1px solid rgba(255, 255, 255, .08); }

.admin-nav__me {
  display: flex; align-items: center; gap: var(--space-3);
  margin-top: var(--space-2); padding: 10px var(--space-3);
  border-radius: var(--radius-lg); background: rgba(2, 6, 33, .35);
}
.admin-nav__me form { margin: 0; }
.admin-nav__who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.admin-nav__name {
  font-size: 13px; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-nav__role { font-size: 11px; color: rgba(255, 255, 255, .72); }
.admin-nav__out {
  display: inline-flex; padding: 6px; cursor: pointer;
  border: 0; border-radius: var(--radius-md);
  background: transparent; color: rgba(255, 255, 255, .78);
}
.admin-nav__out:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  height: 60px; padding: 0 var(--space-6);
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.crumbs {
  display: flex; align-items: center; gap: var(--space-2); min-width: 0;
  font-size: 13px; color: var(--ink-600);
}
.crumbs a { color: var(--ink-600); }
.crumbs a:hover { color: var(--pine); }
.crumbs__sep { color: var(--ink-300); }
.crumbs__here {
  color: var(--pine); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-top__right { display: flex; align-items: center; gap: var(--space-4); flex-shrink: 0; }

.admin-content {
  flex: 1; width: 100%; max-width: 1360px;
  padding: var(--space-6) var(--space-6) var(--space-8);
}

/* ---- Filter bar ----------------------------------------------------------
   A GET form: a filtered catalogue is a shareable URL and works with
   JavaScript off. portal.js only makes it instant.                        */
.filters {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
}
.filters__search { position: relative; flex: 1 1 260px; min-width: 0; }
.filters__divider {
  width: 1px; align-self: stretch; background: var(--border-subtle);
  margin: 0 var(--space-1);
}
.filters__menus { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.filters__icon {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--ink-400); pointer-events: none; display: inline-flex;
}
.filters__input {
  width: 100%; padding: var(--space-3) var(--space-4) var(--space-3) 40px;
  font-family: inherit; font-size: 13px; color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid transparent; border-radius: var(--radius-full);
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
/* --ink-500 on the tinted field is 4.44:1, a hair under AA. The next step
   down clears it and still reads as placeholder rather than value. */
.filters__input::placeholder { color: var(--ink-600); }
.filters__input:focus {
  outline: none; background: var(--bg-surface);
  border-color: var(--teal); box-shadow: 0 0 0 3px var(--pine-100);
}

/* A select styled as a pill. The native control is kept - it is
   keyboard-accessible and touch-friendly for free - and only the chrome
   changes. The caret is a background image so no extra markup is needed. */
.picker {
  appearance: none; -webkit-appearance: none;
  padding: var(--space-2) 34px var(--space-2) var(--space-4);
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--ink-600);
  background-color: var(--bg-surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-500) 50%),
                    linear-gradient(135deg, var(--ink-500) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--border-default); border-radius: var(--radius-full);
  cursor: pointer;
}
.picker:hover { border-color: var(--border-strong); color: var(--pine); }
.picker:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* ---- Catalogue group ---------------------------------------------------- */
.catalogue-group { margin-bottom: var(--space-4); }
.catalogue-group {
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.catalogue-group__head {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.catalogue-group__icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--radius-lg);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad-brand); color: #fff;
}
.catalogue-group__text { flex: 1; min-width: 0; }
.catalogue-group__all {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: 12px; font-weight: 600; color: var(--pine); white-space: nowrap;
}
.catalogue-group__all:hover { text-decoration: none; color: var(--teal); }
.catalogue-group__title { margin: 0; font-size: 15px; font-weight: 600; }
.catalogue-group__desc { margin: 2px 0 0; font-size: 12px; color: var(--ink-600); }
.catalogue-group__count {
  flex-shrink: 0; padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full); background: var(--bg-subtle);
  font-size: 11px; font-weight: 600; color: var(--ink-600);
}

/* ---- Application card ----------------------------------------------------
   One component for held, pending and unavailable. Equal heights from the
   grid, so a row of cards lines up whatever the description length.      */
.app-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}
.app-card {
  position: relative; display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .18s ease, transform .18s ease;
}
/* The whole card is the target; the footer repeats the action visibly. */
.app-card__hit { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.app-card__hit:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.app-card:has(.app-card__hit:hover),
.app-card:has(.app-card__hit:focus-visible) {
  border-color: var(--slot-4-line); box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.app-card:has(.app-card__hit:hover) .app-card__open .icon { transform: translateX(3px); }
/* Lift the content above the hit area, but let clicks fall through to it -
   except on the pin, which is its own control.

   :not(.app-card__pin) matters: without it this rule's `position: relative`
   beats the pin's absolute positioning and the star drops into the flow
   below the footer. */
.app-card > *:not(.app-card__hit):not(.app-card__pin) {
  position: relative; z-index: 2; pointer-events: none;
}
.app-card__pin { z-index: 3; pointer-events: auto; }

.app-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.app-card__icon {
  width: 38px; height: 38px; border-radius: var(--radius-lg); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad-brand); color: #fff;
}
.app-card--application .app-card__icon { background: var(--grad-jade); }
.app-card--dashboard .app-card__icon { background: var(--grad-mint-bright); color: var(--pine); }
.app-card__badges { display: flex; gap: var(--space-1); flex-wrap: wrap; justify-content: flex-end; }
.app-card__name { margin: 0; font-size: 14px; font-weight: 600; }
.app-card__desc {
  margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-600); flex: 1;
}
.app-card__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2); margin-top: auto; padding-top: var(--space-3);
}
.app-card__when {
  display: flex; align-items: center; gap: var(--space-2);
  margin: 0; padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: 11px; color: var(--ink-600);
}
.app-card__when .icon { color: var(--ink-400); flex-shrink: 0; }
.app-card__type {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--slot-3-ink);
}
/* A span, not a button: the whole card is already the link, and a nested
   interactive element would be a second tab stop to the same place. */
.app-card__open { pointer-events: none; }
.app-card__open .icon { transition: transform .15s ease; }

.app-card__pin { margin: 0; display: inline-flex; }

/* Three states, told apart by more than colour: the badge says which. */
.app-card--pending { border-style: dashed; border-color: #f0d5a8; }
.app-card--none { background: var(--bg-subtle); }
.app-card--none .app-card__icon { background: var(--ink-200); color: var(--ink-600); }

/* ---- Launchpad on tablet and phone -------------------------------------
   The rail stacks under the catalogue rather than squeezing it, and the
   hero collapses to a single column.                                     */
@media (max-width: 1024px) {
  .launcher { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
}
@media (max-width: 760px) {
  .filters { flex-direction: column; align-items: stretch; }
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .catalogue-group__head { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
}

@media (max-width: 960px) {
  /* The sidebar becomes a band across the top. Its navigation stays in
     view as a scrolling row - it is never hidden behind a toggle. */
  .admin { grid-template-columns: minmax(0, 1fr); background: var(--bg-page); }
  .admin-nav { position: static; height: auto; overflow: visible; }
  .admin-nav__brand { padding: var(--space-4); }
  .admin-nav__menu {
    display: flex; gap: var(--space-1); overflow-x: auto;
    padding: 0 var(--space-3) var(--space-3); scrollbar-width: none;
  }
  .admin-nav__menu::-webkit-scrollbar { display: none; }
  .admin-nav__group { display: flex; gap: var(--space-1); margin: 0; }
  .admin-nav__label { display: none; }
  .admin-nav__link { white-space: nowrap; margin: 0; }
  .admin-nav__foot { display: none; }
  .admin-top { position: static; padding: 0 var(--space-4); }
  .admin-content { padding: var(--space-5) var(--space-4) var(--space-7); }
  .page-head { flex-direction: column; gap: var(--space-3); }
  .page-head__actions { padding-top: 0; }
}

/* The wordmark is inlined SVG so it inherits the surrounding colour. */
.masthead__wordmark { height: 22px; width: auto; display: block; color: #fff; }

/* ---- Avatar / user menu ------------------------------------------------ */

.avatar {
  width: 34px; height: 34px; border-radius: var(--radius-full);
  background: var(--grad-mint-bright); color: var(--pine);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0; letter-spacing: 0.02em;
}

/* ---- Cards ------------------------------------------------------------- */
.card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}
.card__header {
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
}
.card__title { margin: 0; font-size: 15px; font-weight: 600; }
/* A line under a card title, for the rule a reader needs before the table. */
.card__hint { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.card__body { padding: var(--space-5); }
.card__footer {
  padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex; gap: var(--space-2); justify-content: flex-end;
}

/* ---- Launcher layout ---------------------------------------------------
   The groups hold one or two applications each, so a full-width grid was
   always mostly empty. A rail takes that space and puts something useful
   in it.                                                                  */
.launcher {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-5); align-items: start;
}
.launcher__main { min-width: 0; }
.rail { position: sticky; top: calc(var(--header-height) + var(--space-5)); }
.rail__card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.rail__head {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, var(--pine) 0%, var(--teal) 100%);
  color: #fff;
}
.rail__title { margin: 0; font-size: 14px; font-weight: 600; color: #fff; flex: 1; }
.rail__link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: #fff;
}
.rail__link:hover { text-decoration: none; opacity: .85; }
.rail__note { font-size: 11px; color: rgba(255, 255, 255,.75); }
.rail__body { padding: var(--space-3) var(--space-4) var(--space-4); }
.rail__empty { padding: var(--space-5); font-size: 13px; color: var(--ink-600); }

/* One trending application. The bar is a share of the leader's launches,
   so the eye ranks them without reading the numbers. */
.trend {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-lg); color: inherit;
}
a.trend:hover { background: var(--slot-5-soft); text-decoration: none; }
.trend__rank {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink-100); color: var(--ink-600);
  font-size: 11px; font-weight: 700;
}
.trend:first-child .trend__rank { background: var(--slot-6); color: var(--slot-6-on); }
.trend__body { min-width: 0; flex: 1; }
.trend__name {
  display: block; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trend__meta { display: block; font-size: 11px; color: var(--ink-600); margin-top: 1px; }
/* The bar is an SVG, not a div with a width: its length is data, and the
   CSP forbids the inline style that would carry it. Same approach as the
   adoption meter on the usage page. */
.trend__bar { display: block; width: 100%; height: 4px; margin-top: 6px; }
.trend__track { fill: var(--ink-100); }
.trend__fill { fill: var(--mint); }
.trend:first-child .trend__fill { fill: var(--slot-4); }

@media (max-width: 1024px) {
  /* Below this the rail would squeeze the cards to one column. */
  .launcher { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
}

/* ---- Favourite pin -----------------------------------------------------
   The star on an application card is its own form - a form cannot sit
   inside the card's link - so it is a button of its own.                  */

.pin__btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border-radius: var(--radius-full); cursor: pointer;
  background: var(--bg-surface); color: var(--ink-400);
  border: 1px solid var(--border-default);
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.pin__btn:hover { color: var(--slot-4-ink); border-color: var(--slot-4-line); }
.pin__btn .icon { fill: none; }
/* Pinned: the star fills, so the state is a shape and not only a colour. */
.pin__btn.is-on {
  color: var(--slot-6-ink); border-color: var(--slot-6-line); background: var(--slot-6-soft);
}
.pin__btn.is-on .icon { fill: currentColor; }

/* ---- Favourites rail ---------------------------------------------------- */
/* Pine to jade rather than jade to mint: white has to stay readable across
   the whole sweep, and mint at the right end takes it to 2.1:1. */
.rail__head--accent {
  background: linear-gradient(135deg, var(--pine) 0%, var(--slot-4) 100%);
  color: #fff;
}
.fav {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg);
  color: inherit;
}
.fav:hover { background: var(--slot-5-soft); text-decoration: none; }
.fav { padding: var(--space-3); border-bottom: 1px solid var(--border-subtle); border-radius: 0; }
.fav:last-child { border-bottom: 0; }
.fav__icon {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--radius-lg);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--slot-5-soft); color: var(--slot-4-ink);
}
.fav__name { font-size: 13px; }
.fav__role {
  font-size: 11px; color: var(--ink-600); letter-spacing: .04em;
  font-family: var(--font-sans); text-transform: uppercase; font-weight: 600;
}
.fav__body { min-width: 0; flex: 1; }
.fav__name {
  display: block; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fav__role {
  display: block; font-size: 11px; color: var(--ink-600);
  font-family: var(--font-mono); letter-spacing: .03em;
}
.fav .icon { color: var(--ink-400); flex-shrink: 0; }

/* A trending application the viewer cannot open yet. */
.trend--locked .trend__rank { background: var(--ink-050); color: var(--ink-500); }
.trend__ask { color: var(--slot-4-ink); font-weight: 600; }
.trend--locked .trend__fill { fill: var(--ink-300); }

/* ---- Application cards -------------------------------------------------
   One card per application or dashboard. Type colour lives on the icon
   chip; the card itself stays white so a wall of them reads as a set.    */
.app-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
/* A 4px rule in the card's own colour, always on. Tinting the three card
   types differently does not work with this palette - every pale mix of
   pine, teal and jade lands within a few points of the same grey-green
   (#ece3cd / #ede3ce / #e2efea). So the card takes one soft green wash and
   the saturated bar and icon carry the type. */

/* ---- Cards coloured by resource type -----------------------------------
   The class comes straight from the data, so a new type in the enum needs
   one rule here and no template change.                                   */

/* The tint darkens the top of the card, where --ink-500 muted text drops
   under 4.5:1. Everything inside a tinted card steps one shade darker. */
/* The card already carries colour; the footer rule should not fight it. */

/* ---- Badges ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.is-success { background: var(--pine-050); color: var(--pine-700); border-color: var(--pine-200); }
.badge.is-brand   { background: var(--lime-100); color: var(--lime-600); border-color: var(--lime-300); }
.badge.is-warning { background: var(--amber-100); color: var(--amber-600); border-color: #f0d5a8; }
.badge.is-danger  { background: var(--red-100);   color: var(--red-600);   border-color: #f1c4c0; }
.badge.is-info    { background: var(--slot-2-soft); color: var(--slot-2-ink); border-color: var(--slot-2-line); }
.badge.is-muted   { background: var(--ink-100);   color: var(--ink-600);   border-color: var(--ink-200); }
.badge--role {
  background: var(--pine); color: var(--mint); border-color: var(--pine);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em;
}
/* ---- Role colours -------------------------------------------------------
   A role badge takes one of the six brand slots, picked from a hash of the
   role code (see the `color_slot` filter). Role names are data, so nothing
   here may name one; the hash just guarantees the same role always gets the
   same colour on every page.                                              */
.badge--role.slot-1 { background: var(--slot-1); color: var(--slot-1-on); border-color: var(--slot-1); }
.badge--role.slot-2 { background: var(--slot-2); color: var(--slot-2-on); border-color: var(--slot-2); }
.badge--role.slot-3 { background: var(--slot-3); color: var(--slot-3-on); border-color: var(--slot-3); }
.badge--role.slot-4 { background: var(--slot-4); color: var(--slot-4-on); border-color: var(--slot-4); }
.badge--role.slot-5 { background: var(--slot-5); color: var(--slot-5-on); border-color: var(--slot-5); }
.badge--role.slot-6 { background: var(--slot-6); color: var(--slot-6-on); border-color: var(--slot-6); }

/* ---- Resource-type badges ----------------------------------------------
   The same three steps the launcher tiles use, so a row in the admin table
   and a tile on the launcher agree about what a portal looks like. The
   modifier comes from resource_type, which is data - adding a type means
   adding one rule here, not editing a template.                           */
.badge--type { text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
.badge--type.is-portal {
  background: var(--slot-1-soft); color: var(--slot-1-ink); border-color: var(--slot-1-line);
}
.badge--type.is-application {
  background: var(--slot-3-soft); color: var(--slot-3-ink); border-color: var(--slot-3-line);
}
.badge--type.is-dashboard {
  background: var(--slot-5-soft); color: var(--slot-5-ink); border-color: var(--slot-5-line);
}

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); min-height: 42px;
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  border-radius: var(--radius-full);          /* brand buttons are pills */
  border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--pine); color: #fff; box-shadow: var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) { background: var(--teal); }
/* The one loud action on a page - "Request access", "Sign in". Used
   sparingly; a page with two of these has none. */
.btn--accent {
  background: var(--grad-lime); color: var(--pine);
  box-shadow: 0 1px 2px rgba(28, 26, 23, .06), 0 6px 16px -8px rgba(144, 80, 31, .8);
}
.btn--accent:hover:not(:disabled) { background: var(--lime-300); }
.btn--secondary {
  background: var(--bg-surface); color: var(--text-primary);
  border-color: var(--border-default); box-shadow: var(--shadow-sm);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--bg-subtle); border-color: var(--border-strong);
}
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled) { background: var(--ink-100); color: var(--text-primary); }
.btn--danger { background: var(--red-600); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #8a1c14; }
.btn--sm { min-height: 34px; padding: var(--space-2) var(--space-4); font-size: 13px; }
.btn--block { width: 100%; }

/* ---- Forms ------------------------------------------------------------- */
.form-grid { display: grid; gap: var(--space-4); }
/* Grid items default to min-width:auto. A card holding a long unbreakable
   value - a URL, an LDAP DN - then refused to shrink and pushed the
   configuration page sideways between 980 and 1000px. */
.form-grid > * { min-width: 0; }
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.field__label .req { color: var(--red-600); margin-left: 2px; }
.field__help { font-size: 12px; color: var(--text-muted); }
.field__error { font-size: 12px; color: var(--red-600); font-weight: 500; }

/* Checkboxes: a row, so the label is part of the hit area. */
.checkbox {
  display: flex; align-items: flex-start; gap: var(--space-3);
  font-size: 13px; cursor: pointer;
}
.checkbox input {
  width: 16px; height: 16px; margin: 2px 0 0; flex-shrink: 0;
  accent-color: var(--pine); cursor: pointer;
}

.input, .select, .textarea {
  width: 100%; padding: var(--space-2) var(--space-3); min-height: 38px;
  font-family: inherit; font-size: 14px; color: var(--text-primary);
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--pine-100);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }

/* Identity fields the user must not be able to change. */
.input[readonly], .input:disabled, .select:disabled {
  background: var(--ink-050); color: var(--text-secondary); cursor: not-allowed;
}
.field--locked .field__label::after {
  content: "from SSO"; margin-left: var(--space-2);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); background: var(--ink-100);
  padding: 1px var(--space-2); border-radius: var(--radius-sm);
}

.filter-bar {
  display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap;
  padding: var(--space-4) var(--space-5); background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
}
.filter-bar .field { min-width: 170px; gap: 6px; }
/* The search box takes the spare width; the menus stay their own size. */
.filter-bar .field:first-child { flex: 1 1 260px; }
.filter-bar .field__label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-600);
}
/* Pill fields on a tint - the same treatment as the launcher's search, so
   filtering looks the same everywhere in the portal. */
.filter-bar .input, .filter-bar .select {
  min-height: 38px; padding: var(--space-2) var(--space-4); font-size: 13px;
  background-color: var(--bg-subtle); border-color: transparent;
  border-radius: var(--radius-full);
}
.filter-bar .input:focus, .filter-bar .select:focus {
  background-color: var(--bg-surface); border-color: var(--teal);
}
.filter-bar .btn { min-height: 38px; padding: var(--space-2) var(--space-5); font-size: 13px; }

/* A filter bar directly above its results reads as that panel's header:
   join the two into one card instead of two boxes with a gap. */
.filter-bar:has(+ .table-wrap) {
  margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.filter-bar + .table-wrap {
  border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0;
}

/* ---- Tables ------------------------------------------------------------ */
.table-wrap {
  /* position: relative makes this the containing block for the absolutely
     positioned .visually-hidden labels in the header row. Without it their
     containing block is .container, so they escape this scroller, sit at the
     table's full width and drag the whole page sideways on a phone. */
  position: relative;
  overflow-x: auto; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--pine-700);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--slot-5-line);
  background: linear-gradient(180deg, var(--slot-5-soft) 0%, var(--bg-subtle) 100%);
  white-space: nowrap;
}
.table td { padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-subtle); }
/* Not display:flex. A flex <td> stops being a table cell, so its height and
   its bottom border no longer line up with the rest of the row - the border
   visibly steps at the last column. Inline layout keeps the row intact. */
.table__actions { text-align: right; white-space: nowrap; }
.table__actions > * + * { margin-left: var(--space-2); }
.table__actions form { display: inline-block; margin: 0; }
.table__mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.table__primary { font-weight: 600; color: var(--text-primary); }
.table__sub { font-size: 12px; color: var(--text-muted); }

/* ---- Access tree ------------------------------------------------------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: var(--space-5); padding-left: var(--space-4); border-left: 1px solid var(--border-default); }
.tree__item { padding: var(--space-1) 0; }
.tree__row {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3); border-radius: var(--radius-md);
  border: 1px solid transparent;
}
.tree__row:hover { background: var(--ink-050); border-color: var(--border-subtle); }
.tree__row.is-granted { background: var(--pine-050); border-color: var(--mint); }
.tree__main { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 200px; }
.tree__name { font-weight: 600; font-size: 13px; }
.tree__code { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.tree__controls { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.tree__controls .select, .tree__controls .input { min-height: 32px; font-size: 13px; padding: var(--space-1) var(--space-2); }
.tree__controls .select { min-width: 150px; }

/* ---- Alerts / flashes -------------------------------------------------- */
.flash-stack { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  border: 1px solid; font-size: 13px;
}
.alert__icon { flex-shrink: 0; margin-top: 1px; }
.alert__body { flex: 1; }
.alert--success { background: var(--pine-050); border-color: var(--pine-200); color: var(--pine-800); }
.alert--warning { background: var(--amber-100); border-color: #f0d5a8; color: var(--amber-600); }
.alert--error   { background: var(--red-100);  border-color: #f1c4c0; color: var(--red-600); }
.alert--info    { background: var(--slot-2-soft); border-color: var(--slot-2-line); color: var(--slot-2-ink); }

/* ---- Empty states ------------------------------------------------------ */
.empty {
  text-align: center; padding: var(--space-8) var(--space-5);
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.empty__icon {
  width: 64px; height: 64px; margin: 0 auto var(--space-5);
  border-radius: var(--radius-full); background: var(--grad-brand);
  color: var(--mint); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(28, 26, 23, .18);
}
.empty__title { font-size: 17px; font-weight: 600; margin-bottom: var(--space-2); }
.empty__text { color: var(--text-secondary); max-width: 460px; margin: 0 auto var(--space-5); font-size: 14px; }

/* ---- Toolbar and segmented control -------------------------------------
   Report controls in one row above the data, as the chart guidance calls
   for: range on the left, actions on the right.                          */
.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
}
.segmented__btn {
  padding: var(--space-2) var(--space-4); border: 0; cursor: pointer;
  border-radius: var(--radius-full); background: transparent;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--ink-600);
}
.segmented__btn:hover { color: var(--pine); }
.segmented__btn.is-on {
  background: var(--bg-surface); color: var(--pine); box-shadow: var(--shadow-sm);
}

/* A sortable column header. The active one keeps an arrow, so the sort is
   visible without relying on colour. */
.th-sort {
  display: inline-flex; align-items: center; gap: 4px;
  color: inherit; font: inherit;
}
.th-sort:hover { color: var(--pine); text-decoration: none; }
.th-sort.is-on { color: var(--pine); }
.th-sort .icon { transform: rotate(90deg); }

/* ---- Admin dashboard ----------------------------------------------------
   The base for the dashboard's two lists, the request queue and the recent
   changes timeline. console.css restyles both.                               */
.admin .page-head__eyebrow { display: none; }   /* the breadcrumb says it */

.dash-split {
  display: grid; gap: var(--space-5); align-items: start;
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
}

/* The request queue: one row per request, the decision one click away. */
.queue { list-style: none; margin: 0; padding: 0; }
.queue__row {
  display: grid; align-items: center; gap: var(--space-3);
  grid-template-columns: auto minmax(0, 1.3fr) minmax(0, 1fr) auto auto;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}
.queue__row:hover { background: var(--bg-subtle); }
.queue__who, .queue__what { display: flex; flex-direction: column; min-width: 0; }
.queue__name, .queue__resource {
  font-size: 13px; font-weight: 600; color: var(--pine);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.queue__sub {
  font-size: 11px; color: var(--ink-600);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.quiet { display: flex; align-items: center; gap: var(--space-3); font-size: 13px; color: var(--ink-600); }
.quiet__icon { color: var(--slot-5-ink); display: inline-flex; }

/* Recent changes: a timeline, one sentence per event. */
.timeline { list-style: none; margin: 0; padding: var(--space-3) var(--space-5) var(--space-4); }
.timeline__item { position: relative; display: flex; gap: var(--space-3); padding: var(--space-2) 0; }
.timeline__item:not(:last-child)::after {
  content: ""; position: absolute; left: 15px; top: 38px; bottom: -6px;
  width: 2px; background: var(--border-subtle); border-radius: 1px;
}
.timeline__dot {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--slot-2-soft); color: var(--slot-2-ink);
}
.timeline__item--good .timeline__dot { background: var(--slot-5-soft); color: var(--slot-5-ink); }
.timeline__item--warn .timeline__dot { background: var(--amber-100); color: var(--amber-600); }
.timeline__item--bad .timeline__dot { background: var(--red-100); color: var(--red-600); }
.timeline__body { min-width: 0; padding-top: 5px; }
.timeline__text { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-700); }
.timeline__text strong { color: var(--pine); font-weight: 600; }
.timeline__repeat {
  margin-left: var(--space-1); padding: 0 6px; border-radius: var(--radius-full);
  background: var(--ink-050); font-size: 11px; font-weight: 700; color: var(--ink-600);
}
.timeline__when { margin: 2px 0 0; font-size: 11px; color: var(--ink-600); }

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

@media (max-width: 640px) {
  .queue__row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .queue__what, .queue__row .badge { display: none; }
}

/* Quick picks on Who has access: people waiting on a decision. */
.people-picks {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.person-pick {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); color: inherit;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  background: var(--bg-surface);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.person-pick:hover {
  text-decoration: none; border-color: var(--slot-4-line);
  box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.person-pick .icon { color: var(--ink-400); margin-left: auto; }
.person-pick__who { display: flex; flex-direction: column; min-width: 0; }
.person-pick__name { font-size: 13px; font-weight: 600; color: var(--pine); }
.person-pick__sub {
  font-size: 11px; color: var(--ink-600);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- KPI card ----------------------------------------------------------
   Value, movement against the same window before, and the shape of it. The
   card is white; the colour is in the icon chip and the delta, so a row of
   five reads as a set rather than five competing panels.                  */
.kpi-grid {
  display: grid; gap: var(--space-4); margin-bottom: var(--space-6);
  /* 176px lets all five sit on one row in the console's content column; at
     200px the fifth wrapped and sat alone. */
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
}
.kpi {
  position: relative; overflow: visible;
  display: flex; flex-direction: column;
  padding: var(--space-5) var(--space-5) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi__top {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3);
}
.kpi__label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-600);
}
.kpi__icon {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--slot-1-soft); color: var(--slot-1-ink);
}
.kpi--c1 .kpi__icon { background: var(--slot-1); color: var(--slot-1-on); }
.kpi--c2 .kpi__icon { background: var(--slot-2); color: var(--slot-2-on); }
.kpi--c3 .kpi__icon { background: var(--slot-4); color: var(--slot-4-on); }
.kpi--c4 .kpi__icon { background: var(--slot-5); color: var(--slot-5-on); }
.kpi--c5 .kpi__icon { background: var(--slot-6); color: var(--slot-6-on); }
.kpi__value {
  font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -.03em;
  color: var(--pine);
}
.kpi__foot {
  display: flex; align-items: center; gap: var(--space-2);
  margin-top: var(--space-3); flex-wrap: wrap;
}
.kpi__compare { font-size: 11px; color: var(--ink-600); }
/* One line: "Active users" wrapped at five-up and carried the info button
   onto a second line under the icon. */
.kpi__label {
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap; letter-spacing: .05em; min-width: 0;
}
.kpi__info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0; cursor: help;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default); background: var(--bg-surface);
  font-family: Georgia, serif; font-size: 10px; font-style: italic; font-weight: 700;
  color: var(--ink-600);
}
.kpi__info:hover, .kpi__info:focus-visible { border-color: var(--teal); color: var(--pine); }
/* The tooltip: hidden until its button is hovered or focused, so keyboard
   users get it as well as mouse users. */
.kpi__tip {
  position: absolute; z-index: 20; left: var(--space-4); right: var(--space-4);
  top: 44px;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  background: var(--pine); color: #fff;
  font-size: 11px; line-height: 1.45; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-2px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
  pointer-events: none;
}
.kpi:has(.kpi__info:hover) .kpi__tip,
.kpi:has(.kpi__info:focus-visible) .kpi__tip {
  opacity: 1; visibility: visible; transform: none;
}
.kpi__spark { width: 100%; height: 28px; margin-top: var(--space-3); display: block; }
.kpi__spark-line { fill: none; stroke: var(--slot-4); stroke-width: 1.5;
  stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.kpi__spark-area { fill: var(--slot-5-soft); stroke: none; }

/* ---- Delta ---------------------------------------------------------------
   Direction is carried by the arrow's rotation and by the word, never by
   colour alone - the same reason the status column has a label.          */
.delta {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.delta .icon { transition: none; }
.delta--up { background: var(--slot-5-soft); color: var(--slot-5-ink); }
.delta--up .icon { transform: rotate(-45deg); }
.delta--down { background: var(--red-100); color: var(--red-600); }
.delta--down .icon { transform: rotate(45deg); }
.delta--flat { background: var(--ink-050); color: var(--ink-600); }
.delta--new { background: var(--slot-6-soft); color: var(--slot-6-ink); }

/* ---- Funnel ------------------------------------------------------------- */
.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.funnel__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-3);
}
.funnel__label { font-size: 13px; font-weight: 600; cursor: help; }
.funnel__count { font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.funnel__bar { display: block; width: 100%; height: 8px; margin: 6px 0; }
.funnel__track { fill: var(--ink-100); }
.funnel__fill { fill: var(--slot-4); }
.funnel__step:first-child .funnel__fill { fill: var(--slot-1); }
.funnel__step:last-child .funnel__fill { fill: var(--slot-5); }
.funnel__meta {
  display: flex; gap: var(--space-3); flex-wrap: wrap;
  font-size: 11px; color: var(--ink-600);
}
.funnel__drop { color: var(--amber-600); font-weight: 600; }

/* ---- Insight ------------------------------------------------------------ */
.insight-grid {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.insight {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4); border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
}
.insight__icon {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
}
.insight--good { border-color: var(--slot-5-line); }
.insight--good .insight__icon { background: var(--slot-5-soft); color: var(--slot-5-ink); }
.insight--warn { border-color: #f0d5a8; }
.insight--warn .insight__icon { background: var(--amber-100); color: var(--amber-600); }
.insight__title { margin: 0; font-size: 13px; font-weight: 600; }
.insight__body { margin: 2px 0 0; font-size: 12px; color: var(--ink-600); }

/* ---- Analytics layout --------------------------------------------------- */
.analytics-split {
  display: grid; gap: var(--space-5);
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  margin-bottom: var(--space-5);
  align-items: stretch;
}
.analytics-split > .card { display: flex; flex-direction: column; }
.analytics-split > .card > .card__body {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
}
@media (max-width: 1100px) {
  .analytics-split { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Analytics on tablet and phone -------------------------------------
   The workspace is dense by design. On a narrow screen the split panels
   stack, the KPI row becomes two-up, and the dense tables keep their own
   scroller rather than squashing.                                        */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi__value { font-size: 26px; }
  .toolbar { width: 100%; justify-content: space-between; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .insight-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Definition lists -------------------------------------------------- */
.dl { display: grid; grid-template-columns: minmax(150px, auto) 1fr; gap: var(--space-3) var(--space-5); margin: 0; }
.dl dt { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
/* min-width:0 and anywhere-wrapping, so a URL or DN breaks instead of
   widening the page. */
.dl dd { margin: 0; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }

/* ---- Pagination -------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); flex-wrap: wrap; }
.pagination__info { font-size: 13px; color: var(--text-muted); }
.pagination__links { display: flex; gap: var(--space-1); }
.pagination__link {
  min-width: 32px; height: 32px; padding: 0 var(--space-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-secondary);
}
.pagination__link:hover { background: var(--bg-subtle); text-decoration: none; }
.pagination__link.is-active { background: var(--pine); border-color: var(--pine); color: #fff; }

/* ---- Auth pages --------------------------------------------------------
   Sign-in is the one screen every person meets and the only one with no
   navigation to carry the brand, so it gets the full treatment: a gradient
   mesh built from the four corporate hexes, with a single frosted card
   floating on it.

   Every colour below is pine, teal, mint or lime at some alpha over a deep
   base - the mesh cannot drift outside the palette. The card is dark enough
   that white text clears AA over the brightest part of the mesh, with or
   without backdrop-filter; scripts/check_contrast.py records the measured
   worst case.                                                              */
.auth-shell {
  position: relative; overflow: hidden;
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--space-6) var(--space-5);
  background-color: #111634;
}

/* The mesh: four soft blobs plus the dotted motif, painted on pseudo
   elements so the card never inherits the blur. */
.auth-shell::before {
  content: ""; position: absolute; inset: -10%;
  background-image:
    radial-gradient(44% 48% at 16% 18%, rgba(37, 171, 206, .58), transparent 64%),
    radial-gradient(42% 46% at 86% 14%, rgba(0, 110, 120, .92), transparent 62%),
    radial-gradient(48% 52% at 82% 86%, rgba(232, 115, 28, .30), transparent 62%),
    radial-gradient(40% 44% at 12% 88%, rgba(26, 150, 161, .72), transparent 62%),
    radial-gradient(46% 48% at 50% 46%, rgba(16, 121, 131, .85), transparent 72%),
    radial-gradient(30% 32% at 62% 34%, rgba(37, 171, 206, .30), transparent 70%);
  filter: blur(14px);
  pointer-events: none;
}
.auth-shell::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .07) 1px, transparent 0);
  background-size: 26px 26px;
  pointer-events: none;
}

/* ---- The card ---- */
.auth-glass {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  padding: var(--space-7) var(--space-6) var(--space-5);
  text-align: center; color: var(--text-inverse);
  border-radius: var(--radius-xl);
  /* Dark enough on its own: the blur is an enhancement, never the thing
     that makes the text readable. */
  background: rgba(12, 15, 36, .46);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 24px 60px rgba(2, 6, 33, .45),
              inset 0 1px 0 rgba(255, 255, 255, .10);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
}
/* Without backdrop-filter the mesh shows straight through, so the fill has
   to carry the contrast by itself. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .auth-glass { background: rgba(13, 17, 39, .92); }
}
/* A mint-to-lime hairline across the top edge, the one bright note. */
.auth-glass::before {
  content: ""; position: absolute; top: 0; left: 18%; right: 18%; height: 2px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, transparent, var(--mint), var(--lime), transparent);
}

.auth-glass__logo {
  display: flex; justify-content: center; color: #fff; margin-bottom: var(--space-6);
}
.auth-glass__logo .masthead__wordmark { height: 26px; }
.auth-glass__eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase;
  color: #5cbcd7; margin: 0 0 var(--space-2);
}
.auth-glass__title { font-family: var(--font-display); font-weight: 400; font-size: 26px; margin: 0 0 var(--space-2); color: #fff; }
/* A card with no subtitle keeps the same gap before its form. */
.auth-glass__title--alone { margin-bottom: var(--space-6); }
.auth-glass__subtitle {
  font-size: 13px; color: rgba(255, 255, 255, .82); margin: 0 auto var(--space-6);
  max-width: 34ch;
}
.auth-glass__foot {
  margin: var(--space-6) 0 0; padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: 12px; color: rgba(255, 255, 255, .82);
}
.auth-glass .auth-note { color: rgba(255, 255, 255, .82); }
.auth-glass .auth-note a { color: var(--lime); }

/* Sign-in keeps the lime action it shipped with: in the app .btn--primary
   is now pine, and that change must not reach this page. */
.auth-shell .btn--primary {
  background: var(--grad-lime); color: var(--pine);
  box-shadow: 0 2px 10px rgba(144, 80, 31, .35);
}
.auth-shell .btn--primary:hover:not(:disabled) {
  background: var(--lime-300); box-shadow: 0 4px 16px rgba(144, 80, 31, .45);
}
.auth-glass .field { text-align: left; }
.auth-glass .alert { text-align: left; }

/* ---- The book ----------------------------------------------------------
   Two pages hinged at a spine, tipped towards the reader so the book reads
   as part-open rather than laid flat. The rotation is small on purpose:
   past about 14deg the text on each page starts to soften, and this is a
   page people have to read and type into.

   Both pages are the same glass as .auth-glass, so the contrast measured
   for that card holds here too.                                           */
.book {
  position: relative; z-index: 1;
  width: 100%; max-width: 1000px;
  display: grid; grid-template-columns: 1fr 1fr;
  perspective: 2400px;
  perspective-origin: 50% 45%;
}
.book__page {
  position: relative;
  padding: var(--space-7) var(--space-6);
  color: var(--text-inverse);
  background: rgba(12, 15, 36, .46);
  border: 1px solid rgba(255, 255, 255, .18);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .book__page { background: rgba(12, 15, 36, .92); }
}
.book__page--left {
  transform-origin: right center;
  transform: rotateY(16deg);
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  border-right: 0;
  /* Stacked offsets on the outer edge read as the thickness of the paper. */
  box-shadow: -4px 0 0 rgba(255, 255, 255, .05),
              -8px 0 0 rgba(255, 255, 255, .035),
              -12px 0 0 rgba(255, 255, 255, .02),
              -30px 30px 70px rgba(1, 5, 30, .50);
}
.book__page--right {
  transform-origin: left center;
  transform: rotateY(-16deg);
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  border-left: 0;
  box-shadow: 4px 0 0 rgba(255, 255, 255, .05),
              8px 0 0 rgba(255, 255, 255, .035),
              12px 0 0 rgba(255, 255, 255, .02),
              30px 30px 70px rgba(1, 5, 30, .50);
}
/* The gutter: each page darkens towards the fold, the way a real one does. */
.book__page::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 34%;
  pointer-events: none; border-radius: inherit;
}
.book__page--left::after {
  right: 0; background: linear-gradient(to right, transparent, rgba(1, 4, 24, .72));
}
.book__page--right::after {
  left: 0; background: linear-gradient(to left, transparent, rgba(1, 4, 24, .72));
}
/* Content rides above the gutter wash. */
.book__inner { position: relative; z-index: 1; }
/* ---- Controls on a dark surface ----------------------------------------
   Every text and form helper in this stylesheet is built for a white page.
   Dropped onto the book or the glass card, --ink-500 body text lands near
   1.5:1 and a .textarea renders as a white slab. These overrides cover both
   surfaces at once so the two cannot drift apart.                          */
.book__page .text-muted,
.book__page .auth-note,
.book__page .field__help,
.auth-glass .text-muted,
.auth-glass .auth-note,
.auth-glass .field__help { color: rgba(255, 255, 255, .82); }
/* :not(.btn) matters. A bare `a` selector here also catches the primary
   action, which is an <a> on these pages - lime text on the lime pill, about
   1:1. */
.book__page a:not(.btn),
.auth-glass a:not(.btn) { color: var(--lime); }
.book__page .field__label,
.auth-glass .field__label { color: rgba(255, 255, 255, .92); }
.book__page .input, .book__page .textarea, .book__page .select,
.auth-glass .input, .auth-glass .textarea, .auth-glass .select {
  background: rgba(255, 255, 255, .08); color: #fff;
  border-color: rgba(255, 255, 255, .22);
}
.book__page .input::placeholder, .book__page .textarea::placeholder,
.auth-glass .input::placeholder, .auth-glass .textarea::placeholder {
  color: rgba(255, 255, 255, .84);
}
.book__page .input:focus, .book__page .textarea:focus, .book__page .select:focus,
.auth-glass .input:focus, .auth-glass .textarea:focus, .auth-glass .select:focus {
  background: rgba(255, 255, 255, .14);
  border-color: var(--mint); box-shadow: 0 0 0 3px rgba(37, 171, 206, .25);
}
/* The spine itself. */
.book::after {
  content: ""; position: absolute; z-index: 2; pointer-events: none;
  top: 5%; bottom: 5%; left: 50%; width: 2px; transform: translateX(-1px);
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, transparent, var(--mint), var(--lime), transparent);
}

/* ---- The left page: what this is ---- */
.book__logo { display: flex; color: #fff; margin-bottom: var(--space-6); }
.book__logo .masthead__wordmark { height: 26px; }
.book__headline {
  font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.12; letter-spacing: -0.01em;
  margin: 0 0 var(--space-3); color: #fff;
}
.book__lede { margin: 0 0 var(--space-6); font-size: 14px; color: rgba(255, 255, 255, .82); }
.book__foot {
  margin: var(--space-6) 0 0; font-size: 11px; color: rgba(255, 255, 255, .82);
}
.book-points { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.book-point { display: flex; gap: var(--space-3); align-items: flex-start; }
.book-point__title { display: block; font-size: 13px; font-weight: 600; color: #fff; }
.book-point__text {
  display: block; font-size: 12px; color: rgba(255, 255, 255, .82); margin-top: 2px;
}

/* ---- The right page: the action ---- */
.book__page--right .book__inner {
  display: flex; flex-direction: column; justify-content: center; height: 100%;
}
.book__eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase;
  color: #8fd1e3; margin: 0 0 var(--space-2);
}
.book__title { font-family: var(--font-display); font-weight: 400; font-size: 28px; margin: 0 0 var(--space-2); color: #fff; }
.book__subtitle {
  font-size: 13px; color: rgba(255, 255, 255, .82); margin: 0 0 var(--space-5);
}
/* The way out for someone SSO will not let in. */
.book__help {
  margin: var(--space-5) 0 0; padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: 12px; color: rgba(255, 255, 255, .82);
}
.book__help a { color: var(--lime); }

@media (max-width: 860px) {
  /* Flat and stacked: a 3D fold on a narrow screen costs readable width and
     buys nothing. */
  .book { grid-template-columns: 1fr; perspective: none; max-width: 520px; }
  .book::after { display: none; }
  .book__page { transform: none; padding: var(--space-6) var(--space-5); }
  .book__page::after { display: none; }
  .book__page--left {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-right: 1px solid rgba(255, 255, 255, .18); border-bottom: 0;
    box-shadow: none;
  }
  .book__page--right {
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    border-left: 1px solid rgba(255, 255, 255, .18);
    box-shadow: 0 24px 60px rgba(1, 5, 30, .45);
  }
  .book__headline { font-size: 22px; }
  /* On a phone the form is the point of the screen; the sales copy is not. */
  .book-points, .book__foot { display: none; }
  .book__lede { margin-bottom: 0; }
}

@media (prefers-reduced-transparency: reduce) {
  .book__page { background: #0e1129; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Three short facts, side by side under the action. */
.auth-fact__icon {
  width: 32px; height: 32px; border-radius: var(--radius-md); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(13, 16, 39, .55); border: 1px solid rgba(255, 255, 255, .14);
  color: var(--mint);
}

@media (max-width: 560px) {
  .auth-shell { padding: var(--space-5) var(--space-4); align-items: flex-start; }
  .auth-glass { padding: var(--space-6) var(--space-5) var(--space-5); margin-top: var(--space-6); }
  .auth-glass__title { font-size: 21px; }
  /* Stacked in a column the three facts push the action off a short screen. */
}

@media (prefers-reduced-transparency: reduce) {
  .auth-glass { background: #0e1129; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---- Status / error pages ----------------------------------------------
   Sign-out and every error page: one white card on the grey canvas with
   the brand's faint dot grid, a lime bar along its top edge, a flat icon
   tile and the heading's last word in teal. Flat colours only - the mesh
   belongs to the sign-in page alone.                                      */
.status-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5);
  background-color: #f4ecd9;
  background-image: radial-gradient(circle at 1px 1px, rgba(28, 26, 23, .08) 1px, transparent 0);
  background-size: 24px 24px;
}
.status-card {
  position: relative; overflow: hidden;
  max-width: 460px; width: 100%; text-align: center; padding: 44px 40px 30px;
  background: var(--bg-surface); border: 1px solid #e9dfc8; border-radius: 24px;
  box-shadow: 0 1px 2px rgba(28, 26, 23, .05), 0 14px 32px -22px rgba(28, 26, 23, .35);
}
.status-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--pl-accent, var(--lime)); }
.status-card__icon {
  width: 60px; height: 60px; margin: 0 auto var(--space-5);
  border-radius: 18px; display: flex; align-items: center; justify-content: center;
}
.status-card__icon.is-danger  { background: var(--red-100);   color: var(--red-600); }
.status-card__icon.is-warning { background: var(--amber-100); color: var(--amber-600); }
.status-card__icon.is-info    { background: var(--pine); color: var(--lime); }
.status-card__code { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--teal); margin-bottom: var(--space-2); }
.status-card__title {
  margin-bottom: var(--space-4);
  font-family: var(--font-display); font-size: 28px; font-weight: 400;
  letter-spacing: -.01em; color: var(--pine);
}
.status-card__title em { font-style: normal; color: var(--teal); }
.status-card__title::after {
  content: ""; display: block; width: 40px; height: 4px; margin: 14px auto 0;
  border-radius: 4px; background: var(--pl-accent, var(--lime));
}
.status-card__text { color: var(--text-secondary); margin-bottom: var(--space-5); }
.status-card__actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }
.status-card .btn--primary { background: var(--lime); color: var(--pine); }
.status-card .btn--primary:hover:not(:disabled) { background: var(--lime-300); }
.status-card .btn--secondary { background: #fff; color: var(--pine); border: 1px solid #e3d8bf; }
.status-card__ref {
  margin-top: var(--space-5); padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  font-size: 12px; color: var(--text-muted); font-family: var(--font-mono);
}

/* ---- Utilities --------------------------------------------------------- */
.stack       { display: flex; flex-direction: column; gap: var(--space-4); }
.row         { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 12px; }
.mono        { font-family: var(--font-mono); font-size: 12px; }
.mt-3        { margin-top: var(--space-3); }
.mt-4        { margin-top: var(--space-4); }
.mb-4        { margin-bottom: var(--space-4); }
.mb-5        { margin-bottom: var(--space-5); }
.nowrap      { white-space: nowrap; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.secret-box {
  padding: var(--space-4); background: var(--ink-900); color: #7ecce2;
  border-radius: var(--radius-md); font-family: var(--font-mono); font-size: 13px;
  word-break: break-all; user-select: all;
}

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 900px) {
  .dl { grid-template-columns: 1fr; gap: var(--space-2); }
  .dl dd { margin-bottom: var(--space-3); }
}

@media (max-width: 640px) {
  .container { padding: 0 var(--space-4); }

  .page-head { flex-direction: column; align-items: stretch; }
  .app-grid { grid-template-columns: 1fr; }

  .tree .tree { margin-left: var(--space-3); padding-left: var(--space-3); }
  .tree__row { flex-direction: column; align-items: stretch; }
  .tree__controls .select { width: 100%; }
  .card__body, .card__header, .card__footer { padding: var(--space-4); }
}

@media print {
  .page-head__actions, .btn { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; border-color: #d5c7aa; }
}

/* Users who ask for less motion get none of it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Layout helpers used by the templates.

   Everything the markup needs lives here as a class: no `style` attribute is
   used anywhere in the application templates, which also keeps the CSP free
   of 'unsafe-inline' for styles.
   ========================================================================== */

/* ---- Card widths ------------------------------------------------------- */
.card--md { max-width: 760px; }
.card--lg { max-width: 860px; }

/* ---- Flush a table inside a card (the card already draws the border) --- */
.table-wrap--flush { border: none; border-radius: 0; }

/* ---- Form helpers ------------------------------------------------------ */
.field--grow { flex: 1; }
.textarea--short { min-height: 80px; }
.select--fixed { min-width: 160px; }

/* ---- Alerts used as a centred block on empty states -------------------- */
.alert--block {
  text-align: left; max-width: 520px;
  margin: 0 auto var(--space-5);
}

/* ---- Small text helpers ------------------------------------------------ */
.auth-note { text-align: center; margin: 0; }
.prewrap { white-space: pre-wrap; }
.m-0 { margin: 0; }

/* A resource's icon on a chip coloured by its type, matching the launcher:
   portals deepest, applications mid, dashboards brightest. */
.type-chip {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad-brand); color: #fff;
}
.type-chip--application { background: var(--grad-jade); }
.type-chip--dashboard { background: var(--grad-mint-bright); color: var(--pine); }

/* ---- Hierarchy indentation --------------------------------------------
   The resource tree can nest to MAX_DEPTH (8). Indentation is expressed as a
   depth class rather than a computed inline style, so the depth comes from
   the data while the spacing stays in CSS.                                  */
.tree-indent { display: flex; align-items: center; gap: var(--space-2); }
.tree-indent--sub { font-size: 12px; color: var(--text-muted); }

.depth-0 { padding-left: 0; }
.depth-1 { padding-left: 20px; }
.depth-2 { padding-left: 40px; }
.depth-3 { padding-left: 60px; }
.depth-4 { padding-left: 80px; }
.depth-5 { padding-left: 100px; }
.depth-6 { padding-left: 120px; }
.depth-7 { padding-left: 140px; }
.depth-8 { padding-left: 160px; }

/* The description line sits under the name, aligned past the 28px type
   chip and its 8px gap. */
.tree-indent--sub.depth-0 { padding-left: 36px; }
.tree-indent--sub.depth-1 { padding-left: 56px; }
.tree-indent--sub.depth-2 { padding-left: 76px; }
.tree-indent--sub.depth-3 { padding-left: 96px; }
.tree-indent--sub.depth-4 { padding-left: 116px; }
.tree-indent--sub.depth-5 { padding-left: 136px; }
.tree-indent--sub.depth-6 { padding-left: 156px; }
.tree-indent--sub.depth-7 { padding-left: 176px; }
.tree-indent--sub.depth-8 { padding-left: 196px; }

@media (max-width: 640px) {
  /* Deep indentation wastes the whole width on a phone. */
  [class*="depth-"] { padding-left: var(--space-3) !important; }
}

/* ---- Wordmark sizing per context --------------------------------------
   The SVG itself carries no width/height so it can be scaled by context.  */
.status-card .masthead__wordmark { height: 26px; color: var(--pine); }

/* ==========================================================================
   Charts
   --------------------------------------------------------------------------
   Chart colour is a separate job from UI colour, and the brand's UI hexes do
   not survive the palette checks as chart marks: #1c1a17 and #0a5c63 fall
   below the categorical chroma floor (they read as grey marks) and outside
   the lightness band, and #e8731c is far too light to sit on white.

   These tokens are steps on the brand teal hue (OKLCH ~194.8 deg) chosen by
   running the checks, not by eye:

     --chart-ink    #0a5c63  brand teal, 8.52:1 on white
     --chart-track  #64bbc3  same hue, 2.07:1 on white - clears the 2.0:1
                             ordinal light-end floor

   Validated as a one-hue ordinal ramp (monotone lightness, adjacent dL >= 0.06,
   light-end contrast, single hue) with scripts/validate_palette.py.
   ========================================================================== */
:root {
  --chart-ink: #0a5c63;
  --chart-track: #64bbc3;
  --chart-area: rgba(10, 92, 99, 0.10);
  --chart-grid: var(--ink-100);
  --chart-tick: var(--ink-500);
}

.chart { margin: 0; }
.chart__svg { display: block; width: 100%; overflow: visible; }

/* Grid and axes stay recessive - they are scaffolding, not data. */
.chart__grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart__tick {
  fill: var(--chart-tick); font-size: 11px;
  font-family: var(--font-sans); font-variant-numeric: tabular-nums;
}

.chart__area { fill: var(--chart-area); stroke: none; }
.chart__line {
  fill: none; stroke: var(--chart-ink); stroke-width: 2.25;
  stroke-linejoin: round; stroke-linecap: round;
}

/* Markers carry a surface ring so overlapping marks stay separable. */
.chart__dot {
  fill: var(--chart-ink); stroke: var(--bg-surface); stroke-width: 2;
  opacity: 0; transition: opacity .12s ease;
}
/* Only the peak and today carry a marker. Revealing all thirty whenever
   the pointer was anywhere over the chart turned the line into beads; the
   individual point still appears under the pointer, with its tooltip. */
.chart__dot.is-peak, .chart__dot.is-last { opacity: 1; }
.chart__dot:hover, .chart__dot:focus { opacity: 1; r: 5; }
.chart__peak {
  fill: var(--pine); font-size: 11px; font-weight: 700;
  font-family: var(--font-sans); font-variant-numeric: tabular-nums;
}

.chart__table { margin-top: var(--space-4); font-size: 13px; }
.chart__table summary {
  cursor: pointer; color: var(--text-brand); font-weight: 600;
  padding: var(--space-2) 0;
}
.chart__table summary:hover { text-decoration: underline; }

/* ---- Meter -------------------------------------------------------------
   The unfilled track is a lighter step of the same hue, so the bar reads as
   one measure rather than two competing series.                            */
.meter { display: flex; align-items: center; gap: var(--space-3); }
.meter svg { display: block; flex-shrink: 0; }
.meter__track { fill: var(--chart-track); opacity: 0.35; }
.meter__fill { fill: var(--chart-ink); }
.meter__label {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  font-variant-numeric: tabular-nums; min-width: 38px;
}

@media (max-width: 900px) {
  .meter { gap: var(--space-2); }
  .meter svg { width: 96px; }
}

/* ---- Icon dropdown -----------------------------------------------------
   A listbox that shows the glyph next to its name, because an <option>
   cannot contain an SVG. The native <select> stays in the DOM and is what
   submits; with JavaScript off it is simply left visible.                  */
.icon-select { position: relative; }

.icon-select__button {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 38px;
  padding: var(--space-1) var(--space-3);
  font-family: inherit; font-size: 14px; color: var(--text-primary);
  text-align: left; cursor: pointer;
  background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.icon-select__button:hover { border-color: var(--border-strong); }
.icon-select__button[aria-expanded="true"],
.icon-select__button:focus-visible {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--pine-100);
}

.icon-select__glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--pine);
}
.icon-select__text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Caret drawn in CSS so the button needs no extra markup. */
.icon-select__caret {
  width: 0; height: 0; flex-shrink: 0; margin-left: auto;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--ink-500);
}
.icon-select__button[aria-expanded="true"] .icon-select__caret {
  border-top: 0; border-bottom: 6px solid var(--pine);
}

.icon-select__list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 264px; overflow-y: auto;
  margin: 0; padding: var(--space-1); list-style: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.icon-select__option {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
}
.icon-select__option:hover { background: var(--ink-050); }
.icon-select__option:focus-visible,
.icon-select__option:focus {
  outline: none; background: var(--pine-050);
  box-shadow: inset 0 0 0 2px var(--teal);
}
.icon-select__option.is-selected { background: var(--pine-050); font-weight: 600; }
.icon-select__option.is-selected .icon-select__glyph {
  background: var(--pine); color: var(--mint);
}

/* Only hide the native select once the enhancement has actually run, so it
   stays usable with JavaScript off. display:none still submits its value -
   only `disabled` would drop it from the form. */
.icon-field.is-enhanced .select[data-icon-input] { display: none; }
