/* =========================================================================
   Components. Class names match what the templates already use, so the whole
   application picks up the new look without every page being rewritten.
   ========================================================================= */

/* ---- cards ---------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.card > h3, .card-head h3 { font-size: var(--text-sm); font-weight: 620; letter-spacing: 0.005em; }
.card > h3 { margin-bottom: var(--sp-3); }
.card-head {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.card-head .spacer { margin-left: auto; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { margin: 0; }
.card-foot {
  margin: var(--sp-3) calc(var(--sp-4) * -1) calc(var(--sp-4) * -1);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
}
.card-flush .card-foot { margin: 0; }

/* Interactive cards lift on hover. Small movement, quick curve -- enough to
   read as clickable without feeling springy. */
.card-link { display: block; color: inherit; }
.card-link:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* ---- grids ---------------------------------------------------------- */
.grid   { display: grid; gap: var(--sp-4); }
/* Panels size to their content. Without this, grid stretches every card to
   the tallest in the row, so a panel holding two rows stands a screen tall
   beside a full one. Stat rows keep the default stretch, because there the
   uniform height is the point. */
.grid-2 { align-items: start; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); }

/* ---- statistics ----------------------------------------------------- */
.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
/* A hairline of colour to carry the status without shouting it. */
.stat-card::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--brand); opacity: 0.8;
}
.stat-card.is-danger::after { background: var(--danger); }
.stat-card.is-warn::after   { background: var(--warn); }
.stat-card.is-ok::after     { background: var(--ok); }
.stat-card.is-quiet::after  { background: var(--border-strong); }

.stat {
  font-size: var(--text-stat);
  font-weight: 660;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-card.is-danger .stat { color: var(--danger); }
.stat-card.is-warn   .stat { color: var(--warn); }
.stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: var(--sp-1);
}
.stat-note { font-size: var(--text-xs); color: var(--text-subtle); margin-top: var(--sp-2); }

/* ---- tables --------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-sunken);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr { transition: background-color var(--dur-fast) var(--ease); }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: 0; }
/* Bare tables inside a card panel: no sticky head, tighter. */
.card table.plain thead th { position: static; background: none; }
table.plain td, table.plain th { padding: var(--sp-2) 0; }
table.plain tbody tr:hover { background: none; }
.cell-strong { font-weight: 560; color: var(--text); }

/* ---- pills / badges ------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 0.3em;
  padding: 0.14rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-ok      { background: var(--ok-wash);     color: var(--ok); }
.pill-warn    { background: var(--warn-wash);   color: var(--warn); }
.pill-danger  { background: var(--danger-wash); color: var(--danger); }
.pill-info    { background: var(--info-wash);   color: var(--info); }
.pill-brand   { background: var(--brand-wash);  color: var(--brand); }
.pill-muted   { background: var(--surface-sunken); color: var(--text-muted); border-color: var(--border); }
.pill-dot::before {
  content: ""; width: 0.4em; height: 0.4em; border-radius: 50%;
  background: currentColor; flex: none;
}

/* ---- buttons -------------------------------------------------------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--text-on-brand);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 560;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
button:hover, .btn:hover { background: var(--brand-hover); text-decoration: none; color: var(--text-on-brand); }
/* Press feedback: the button moves under the cursor, which is the cue that
   distinguishes a real control from a picture of one. */
button:active, .btn:active { transform: translateY(1px); box-shadow: none; }
button:disabled, .btn.is-disabled {
  opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;
}

.btn-plain {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-plain:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text-subtle); }
.btn-danger { background: var(--danger); color: var(--text-on-danger); }
.btn-danger:hover {
  background: var(--danger); filter: brightness(1.08); color: var(--text-on-danger);
}
.btn-ghost { background: transparent; box-shadow: none; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm { padding: 0.24rem 0.55rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.6rem 1.2rem; font-size: var(--text-base); }
.btn-block { width: 100%; }
.actions { margin-top: var(--sp-5); display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }

/* ---- toolbar -------------------------------------------------------- */
.toolbar {
  display: flex; gap: var(--sp-3); align-items: center;
  margin-bottom: var(--sp-4); flex-wrap: wrap;
}
.toolbar input[type=text], .toolbar input[type=search] { max-width: 24rem; }
.search-field { position: relative; flex: 1 1 18rem; max-width: 24rem; }
.search-field .icon {
  position: absolute; left: 0.65rem; top: 50%; transform: translateY(-50%);
  width: 1rem; height: 1rem; color: var(--text-subtle); pointer-events: none;
}
.search-field input { padding-left: 2.1rem !important; max-width: none !important; }

/* ---- forms ---------------------------------------------------------- */
label { display: block; font-size: var(--text-sm); font-weight: 580; margin: var(--sp-4) 0 var(--sp-1); }
.field, input[type=text], input[type=email], input[type=search], input[type=password],
input[type=date], input[type=datetime-local], input[type=number], input[type=tel],
input[type=file], select, textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
textarea { min-height: 8rem; resize: vertical; line-height: 1.6; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
.helptext { display: block; font-size: var(--text-xs); color: var(--text-subtle); margin-top: var(--sp-1); }
.errorlist {
  color: var(--danger); font-size: var(--text-xs); font-weight: 500;
  margin: var(--sp-1) 0 0; padding-left: 1.1rem;
}
fieldset { border: 0; padding: 0; margin: 0 0 var(--sp-5); }
legend {
  padding: 0; font-size: var(--text-xs); font-weight: 620;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
}
.form-narrow { max-width: 34rem; }

/* ---- messages / banners --------------------------------------------- */
.msg {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-3);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}
.msg-success { background: var(--ok-wash);     color: var(--ok);     border-color: var(--ok); }
.msg-error   { background: var(--danger-wash); color: var(--danger); border-color: var(--danger); }
.msg-warning { background: var(--warn-wash);   color: var(--warn);   border-color: var(--warn); }
.msg-info    { background: var(--info-wash);   color: var(--info);   border-color: var(--info); }

.banner {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  background: var(--warn-wash);
  color: var(--text);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-4);
}
.banner-danger { border-left-color: var(--danger); background: var(--danger-wash); }
.banner-info   { border-left-color: var(--info);   background: var(--info-wash); }
.banner strong { font-weight: 620; }
.banner ul { margin: var(--sp-2) 0 0; padding-left: 1.2rem; }

/* ---- empty states ---------------------------------------------------
   A blank table looks broken; a blank table that says why looks finished. */
.empty {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-muted);
}
.empty .icon { width: 2rem; height: 2rem; color: var(--text-subtle); margin-bottom: var(--sp-3); }
.empty h3 { font-size: var(--text-base); color: var(--text); margin-bottom: var(--sp-1); }
.empty p { font-size: var(--text-sm); max-width: 28rem; margin: 0 auto var(--sp-4); }

/* ---- people --------------------------------------------------------- */
.avatar, .avatar-lg {
  object-fit: cover;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: inline-grid;
  place-items: center;
  color: var(--text-subtle);
  font-weight: 600;
  font-size: var(--text-xs);
  flex: none;
  overflow: hidden;
}
.avatar { width: 2.25rem; height: 2.25rem; border-radius: 50%; }
.avatar-lg { width: 6rem; height: 6rem; border-radius: var(--radius); font-size: var(--text-lg); }
.person { display: flex; align-items: center; gap: var(--sp-3); }
.person-name { font-weight: 560; }
.person-meta { font-size: var(--text-xs); color: var(--text-muted); }

/* ---- misc ----------------------------------------------------------- */
.meter {
  height: 6px; border-radius: var(--radius-pill);
  background: var(--surface-sunken); overflow: hidden;
}
.meter > span {
  display: block; height: 100%; border-radius: inherit;
  background: var(--brand);
  transition: width var(--dur-slow) var(--ease-out);
}
.meter.is-warn > span   { background: var(--warn); }
.meter.is-danger > span { background: var(--danger); }

.divider-label {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--text-xs); font-weight: 620; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin: var(--sp-4) 0 var(--sp-2);
}
.divider-label::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.divider-label:first-child { margin-top: 0; }

/* Timeline, used by the engagement history. */
.timeline { list-style: none; margin: 0; padding: 0 0 0 var(--sp-5); position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 0.5rem; bottom: 0.5rem;
  border-left: 1px solid var(--border);
}
.timeline > li { position: relative; padding-bottom: var(--sp-4); }
.timeline > li::before {
  content: ""; position: absolute; left: calc(var(--sp-5) * -1); top: 0.45rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand);
}
.timeline > li.is-quiet::before { border-color: var(--border-strong); }

/* ---- user menu / theme picker --------------------------------------- */
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + var(--sp-2)); z-index: 40;
  min-width: 15rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-2);
}
.menu-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}
.menu-head-text { min-width: 0; }
.menu-head .who-name, .menu-head .who-role {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-head .avatar-lg { width: 2.6rem; height: 2.6rem; font-size: var(--text-sm); }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  padding: 0.4rem var(--sp-3);
  border-radius: var(--radius-sm);
  background: none; border: 0; box-shadow: none;
  color: var(--text);
  font-size: var(--text-sm); font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.menu-item.is-active { color: var(--brand); font-weight: 600; }
.menu-item .check { margin-left: auto; opacity: 0; }
.menu-item.is-active .check { opacity: 1; }
.swatch {
  width: 1.5rem; height: 1.5rem; flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.who { display: flex; align-items: center; gap: var(--sp-3); }
.who-name { font-size: var(--text-sm); font-weight: 560; line-height: 1.2; }
.who-role { font-size: var(--text-xs); color: var(--text-muted); }

/* ---- icons ----------------------------------------------------------
   One size, inheriting currentColor so icons theme with their container. */
.icon {
  width: 1.15rem; height: 1.15rem;
  flex: none;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
}

/* ---- signed-out pages -----------------------------------------------
   Login and MFA. Centred card on the brand gradient -- the one screen where
   a little presentation is warranted, because it is the only one anybody
   outside the firm would ever be shown. */
.auth-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  /* place-content rather than place-items: the logo and the card are two
     grid rows, and centring each one *within its own row* is what put half
     the page between them. This centres the pair. */
  place-content: center;
  justify-items: center;
  padding: var(--sp-5);
  max-width: none;
  background:
    radial-gradient(70rem 40rem at 15% -10%, var(--brand-wash) 0%, transparent 60%),
    radial-gradient(50rem 34rem at 110% 110%, var(--info-wash) 0%, transparent 55%),
    var(--canvas);
}
.auth-card {
  width: 100%;
  max-width: 25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  animation: rise var(--dur-slow) var(--ease-out) both;
}
.auth-card .brand { padding: 0 0 var(--sp-5); color: var(--text); }
.auth-card .brand-sub { color: var(--text-muted); }
.auth-card h1 { font-size: var(--text-md); }
.auth-card .actions { margin-top: var(--sp-5); }
.auth-foot {
  margin-top: var(--sp-5); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--text-subtle);
}

/* ---- row actions ----------------------------------------------------
   The worklist's per-row controls. Nowrap keeps a row one line tall; the
   table gives the column the width it asks for. */
.row-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}
.row-actions select { width: auto; padding: 0.2rem 0.4rem; font-size: var(--text-xs); }

/* A <details> used as a popover: no JavaScript, and it closes on Escape and
   on a second click for free. */
.disclosure { position: relative; }
.disclosure > summary { list-style: none; cursor: pointer; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: ""; width: 0; height: 0; margin-left: 0.15rem;
  border: 0.25em solid transparent; border-top-color: currentColor;
  transform: translateY(0.12em);
}
.disclosure[open] > summary { background: var(--surface-hover); color: var(--text); }
.disclosure > .menu-panel { display: block; }
.disclosure:not([open]) > .menu-panel { display: none; }

.auth-corner { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 30; }
.auth-corner .menu-panel { transform-origin: top right; }

/* =========================================================================
   Header controls and the account menu
   ========================================================================= */

/* Square icon-only button. Used for the navigation toggle, where a label
   would take more room than the control. */
.icon-btn {
  width: 2.25rem; height: 2.25rem;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* The one entry point to everything an account owns. Reads as a person
   rather than as a gear, because that is what is behind it. */
.account-trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.3rem 0.45rem;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: var(--text);
  max-width: 15rem;
}
.account-trigger:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text);
}
.account-trigger[aria-expanded="true"] {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.account-trigger .who { flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; }
.account-trigger .who-name,
.account-trigger .who-role {
  display: block; max-width: 9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-trigger .chev { width: 1rem; height: 1rem; color: var(--text-subtle); }

.menu-end .menu-panel { min-width: 17.5rem; }
/* Groups inside a panel, separated by a rule rather than by guesswork. */
.menu-section + .menu-section { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.menu-label {
  margin: var(--sp-1) 0 var(--sp-2);
  padding: 0 var(--sp-3);
  font-size: var(--text-xs); font-weight: 620;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-subtle);
}
.menu-hint {
  margin: var(--sp-2) 0 var(--sp-1);
  padding: 0 var(--sp-3);
  font-size: var(--text-xs);
  color: var(--text-subtle);
}
.menu-item .icon { color: var(--text-subtle); }
.menu-item:hover .icon { color: var(--text-muted); }

/* One row of theme swatches. Wraps rather than scrolls, so a fifth theme
   costs a line of height and no code. */
.swatch-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-3); }
.swatch-btn {
  padding: 3px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.swatch-btn:hover { background: var(--surface-hover); border-color: var(--border); }
.swatch-btn.is-active { border-color: var(--brand); background: var(--brand-wash); }
.swatch-btn .swatch { width: 1.35rem; height: 1.35rem; }

/* =========================================================================
   Settings
   ========================================================================= */

/* Tab strip. Underline rather than a segmented control: there are four of
   these and a segmented control would need to shrink the labels to fit. */
.tabs {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: var(--text-sm); font-weight: 560;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); text-decoration: none; border-bottom-color: var(--border-strong); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .icon { width: 1rem; height: 1rem; }

/* A main column with a narrower companion beside it. Collapses to one
   column before the two get too tight to read. */
.grid-sidebar { grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); align-items: start; }
/* The mirror of it: main content leads, the read-only summary follows. Used
   where the wide column is a form -- a form squeezed into 20rem wraps every
   label onto two lines. */
.grid-sidebar-end { grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); align-items: start; }
@media (max-width: 900px) {
  .grid-sidebar, .grid-sidebar-end { grid-template-columns: minmax(0, 1fr); }
}

/* A card heading with no rule under it, for short panels where the rule is
   more furniture than the content is worth. */
.card-head-plain {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.card-head-plain h3 { font-size: var(--text-sm); font-weight: 620; }

.avatar-xl { width: 7.5rem; height: 7.5rem; border-radius: var(--radius-lg); font-size: var(--text-xl); }
.avatar-editor { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); text-align: center; }
.avatar-editor .actions { justify-content: center; }

/* The native file input is unstyleable and says "No file chosen" in a
   system font. This hides it inside a label that is styled like the rest of
   the form, and keeps it keyboard-reachable because the label is the target. */
.file-drop {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  margin: 0;
  padding: var(--sp-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-sm); font-weight: 560;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.file-drop:hover { border-color: var(--brand); color: var(--brand); }
.file-drop:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--brand-wash); }
.file-drop input[type=file] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* Read-only facts, as a definition list. Label above value, because the
   labels here are long enough that a two-column layout wraps badly. */
.field-list { margin: 0; display: grid; gap: var(--sp-4); }
.field-list dt {
  font-size: var(--text-xs); font-weight: 620;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: var(--sp-1);
}
.field-list dd { margin: 0; font-size: var(--text-sm); }
.field-list .helptext { margin-top: var(--sp-1); }

/* Theme cards on the Appearance tab: a miniature of the layout rather than
   two dots, so the choice is made from something that looks like the thing. */
/* Capped, because auto-fit with two items in a group would otherwise stretch
   each card to half the page and leave the content floating in it. */
.theme-grid {
  display: grid;
  gap: var(--sp-3);
  max-width: 44rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}
.theme-card {
  /* justify-content is reset explicitly: these are <button>s, and the base
     button rule centres its contents, which pushed the preview and the label
     into the middle of the card as one floating group. */
  display: flex; align-items: center; justify-content: flex-start; gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-align: left;
}
.theme-card:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.theme-card.is-active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.theme-preview {
  flex: none;
  width: 3.25rem; height: 2.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 5px;
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
}
.theme-preview-bar { display: block; height: 6px; border-radius: 2px; }
.theme-preview-line {
  display: block; height: 3px; border-radius: 2px;
  background: currentColor; opacity: 0.28;
}
.theme-preview-line.is-short { width: 60%; }
.theme-card-body { min-width: 0; }
/* .who-role is inline elsewhere, which here let the description run straight
   out of the card instead of wrapping inside it. */
.theme-card-body .who-role { display: block; white-space: normal; line-height: 1.4; }
.theme-card-name {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--text-sm); font-weight: 600;
}
.theme-card-name .check {
  width: 0.9rem; height: 0.9rem;
  color: var(--brand);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.theme-card.is-active .theme-card-name .check { opacity: 1; }

/* A disclosure that pushes the page down instead of floating over it, for
   a form that belongs in the flow rather than in a popover. */
.disclosure-block > .menu-panel,
.disclosure-block[open] > * { position: static; }
.disclosure-block { margin-top: var(--sp-3); }
.disclosure-block > summary::after { display: none; }

/* The full logo above the sign-in card. */
.auth-logo { display: block; margin: 0 auto var(--sp-5); }
.auth-logo img {
  display: block;
  width: 200px; height: auto;
  /* The artwork has an opaque white interior, so on a dark theme it needs a
     plate to sit on rather than appearing as a bare white rectangle. */
  background: var(--white);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow);
}

/* =========================================================================
   Dashboard
   ========================================================================= */

/* Greeting band. Not a card: it is orientation, not content, and putting a
   border round it makes it compete with the panels underneath. */
.hero {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.hero-text { min-width: 0; flex: 1 1 20rem; }
.hero-title {
  margin: 0;
  font-size: var(--text-hero);
  font-weight: 640;
  letter-spacing: -0.018em;
}
.hero-sub { margin: var(--sp-1) 0 0; font-size: var(--text-sm); color: var(--text-muted); }
.hero-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

/* Section headings between dashboard tiers. Quieter than an h2 elsewhere --
   they are separators, and three loud headings would out-shout the panels. */
.section-title {
  margin: var(--sp-6) 0 var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}

/* A wide primary panel with a narrower companion. Unlike .grid-2 this does
   not equalise the columns -- the feed is the page and the pipeline is a
   sidebar to it. */
.grid-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}

.card-body { padding: var(--sp-4); }

/* ---- attention feed -------------------------------------------------
   Rows, not a table: each one is a sentence plus an action, and a table
   would force the sentence into a column width that fits the shortest. */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover { background: var(--surface-hover); }
/* A colour bar at the leading edge carries the severity. Cheaper to scan
   than a badge, and it does not take a column. */
.feed-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--border-strong);
}
.feed-item.is-danger::before { background: var(--danger); }
.feed-item.is-warn::before   { background: var(--warn); }
.feed-item.is-ok::before     { background: var(--ok); }

.feed-icon {
  flex: none;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-sunken);
  color: var(--text-muted);
}
.feed-icon .icon { width: 1rem; height: 1rem; }
.feed-item.is-danger .feed-icon { background: var(--danger-wash); color: var(--danger); }
.feed-item.is-warn   .feed-icon { background: var(--warn-wash);   color: var(--warn); }
.feed-item.is-ok     .feed-icon { background: var(--ok-wash);     color: var(--ok); }

.feed-body { min-width: 0; flex: 1; }
.feed-kind {
  display: inline-block;
  margin-right: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}
.feed-text { font-size: var(--text-sm); font-weight: 500; }
.feed-meta { display: block; font-size: var(--text-xs); color: var(--text-subtle); }
.feed-action { flex: none; }

/* ---- renewal pipeline -----------------------------------------------
   One proportional bar. Segments are flex-grow, so the browser does the
   percentage arithmetic and a zero-count segment is simply not rendered. */
.pipeline {
  display: flex;
  gap: 2px;
  height: 0.6rem;
  margin: var(--sp-2) 0 var(--sp-4);
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--surface-sunken);
}
.pipeline-seg {
  min-width: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  animation: grow var(--dur-slow) var(--ease-out) both;
}
.pipeline-seg.is-danger { background: var(--danger); }
.pipeline-seg.is-warn   { background: var(--warn); }
.pipeline-seg.is-info   { background: var(--accent-cool); }
.pipeline-seg.is-ok     { background: var(--ok); }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.legend li { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--text-sm); }
.legend-dot {
  width: 0.55rem; height: 0.55rem; flex: none;
  border-radius: 50%;
  background: var(--border-strong);
}
.legend-dot.is-danger { background: var(--danger); }
.legend-dot.is-warn   { background: var(--warn); }
.legend-dot.is-info   { background: var(--accent-cool); }
.legend-dot.is-ok     { background: var(--ok); }
.legend-label { color: var(--text-muted); }
.legend-value { margin-left: auto; font-weight: 620; }

@media (max-width: 560px) {
  /* The action drops below the sentence rather than squeezing it to two
     words a line. */
  .feed-item { align-items: flex-start; flex-wrap: wrap; }
  .feed-action { margin-left: calc(2rem + var(--sp-3)); }
}

/* The quiet end of the pipeline ramp: present, counted, not urgent. */
.pipeline-seg.is-quiet { background: var(--border-strong); }
.legend-dot.is-quiet   { background: var(--border-strong); }

/* ---- portal settings: users and roles -------------------------------- */
/*
 * The permission matrix is the only genuinely new layout here. Everything
 * else reuses the card, table and pill primitives, because an IAM screen
 * that looks like a different application is one people distrust.
 */
/* A two-line cell -- name over email -- inside a flex .person or a table
   cell, where the spans would otherwise run together on one line. */
.person-text { display: flex; flex-direction: column; min-width: 0; }
td .person-name, td .person-meta { display: block; }
td .person-meta code { font-size: 0.92em; }

/* Deactivated accounts stay in the list, dimmed. Removing them would hide
   the fact that the account still exists, which is the thing you need to
   know when someone has left. */
tr.is-muted td { opacity: 0.55; }

.matrix { list-style: none; margin: 0; padding: 0; }
.matrix-row {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
}
.matrix-row:first-child { border-top: 0; padding-top: var(--sp-1); }
.matrix-label { min-width: 0; flex: 1 1 auto; }
.matrix-label label { margin: 0; font-weight: 500; }
.matrix-label .helptext { display: block; margin-top: var(--sp-1); }
/* Fixed so every control in a group lines up: a ragged right edge makes a
   sixteen-row matrix much harder to read down. */
.matrix-control { flex: 0 0 13rem; display: flex; justify-content: flex-end; }
.matrix-control select { width: 100%; }
.matrix-control input[type="checkbox"] { margin-inline-start: auto; }
.matrix-row.has-error { background: var(--danger-wash); border-radius: var(--radius-sm); }
.matrix-row.has-error .matrix-label { padding-inline-start: var(--sp-2); }

.field-sm { font-size: var(--text-sm); padding-block: var(--sp-1); }

@media (max-width: 560px) {
  /* The control drops under its label rather than squeezing the label to
     three words a line. */
  .matrix-row { flex-direction: column; gap: var(--sp-2); }
  .matrix-control { flex: 1 1 auto; width: 100%; justify-content: flex-start; }
  .matrix-control select { width: 100%; }
}
