/* =============================================================
   CSA Demo Platform — stylesheet
   ============================================================= */

[hidden] { display: none !important; }

:root {
  --c-bg:         #f5f7fb;
  --c-card:       #ffffff;
  --c-border:     #e4e8ef;
  --c-text:       #1b2230;
  --c-muted:      #6b7388;
  --c-primary:    #2d5bff;
  --c-primary-d:  #1f44c7;
  --c-danger:     #d64545;
  --c-warn:       #d48806;
  --c-info:       #2b7cdb;
  --c-success:    #1e9e4f;

  --c-high:       #d64545;
  --c-medium:     #d48806;
  --c-low:        #1e9e4f;

  --radius:       8px;
  --shadow:       0 1px 3px rgba(17, 23, 41, .06), 0 1px 2px rgba(17, 23, 41, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a           { color: var(--c-primary); text-decoration: none; }
a:hover     { text-decoration: underline; }
h1, h2, h3  { margin: 0 0 .4em; font-weight: 600; }
h1          { font-size: 1.6rem; }
h2          { font-size: 1.2rem; }
h3          { font-size: 1.0rem; }
code        { background: #eef1f7; padding: 1px 5px; border-radius: 4px; font-size: .85em; }
hr          { border: none; border-top: 1px solid var(--c-border); margin: 16px 0; }
.muted      { color: var(--c-muted); }
.small      { font-size: .85em; }
.wrap       { white-space: pre-wrap; max-width: 400px; }
.truncate   { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml         { margin-left: 6px; }
.inline     { display: inline; }

/* ------------- Topbar ------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow);
}
.brand-link        { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 600; }
.brand-link:hover  { text-decoration: none; }
.brand-mark {
  background: var(--c-primary);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: .9em;
  letter-spacing: .5px;
}
.brand-name        { font-size: .95em; }
.mainnav           { display: flex; gap: 4px; margin-left: 20px; }
.mainnav a {
  padding: 8px 12px;
  color: var(--c-muted);
  border-radius: 6px;
}
.mainnav a:hover   { background: #eef1f7; color: var(--c-text); text-decoration: none; }
.userbox           { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name         { font-weight: 600; }

/* ------------- Container ------------- */
.container         { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ------------- Footer ------------- */
.foot              { margin-top: 60px; padding: 16px 0; border-top: 1px solid var(--c-border); background: #fff; }

/* ------------- Cards ------------- */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head         { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2      { margin: 0; }

/* ------------- Page head ------------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.page-head h1      { margin: 0; }
.page-head p       { margin: 4px 0 0; }
.page-actions      { display: flex; gap: 8px; align-items: center; }

/* ------------- Grid ------------- */
.grid              { display: grid; gap: 12px; margin-bottom: 16px; }
.grid-3            { grid-template-columns: repeat(3, 1fr); }
.grid-5            { grid-template-columns: repeat(5, 1fr); }
.grid-6            { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-5, .grid-6 { grid-template-columns: 1fr 1fr; }
}

/* ------------- Stat tiles ------------- */
.stat {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
}
.stat-n            { font-size: 1.8rem; font-weight: 700; color: var(--c-primary); }
.stat-l            { color: var(--c-muted); font-size: .85em; margin-top: 2px; }
.stat-link         { display: block; margin-top: 8px; font-size: .85em; }
.stat-sm .stat-n   { font-size: 1.3rem; }

.progress          { margin-top: 8px; background: #eef1f7; border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar      { background: var(--c-success); height: 100%; }

/* ------------- Tables ------------- */
.table             { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.table th          { font-size: .78em; text-transform: uppercase; letter-spacing: .4px; color: var(--c-muted); background: #fafbfd; }
.table tr:hover td { background: #fafbfd; }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: .9em; }
.table-centered th, .table-centered td { text-align: center; vertical-align: middle; padding: 1px 12px; }
.section-row       { background: #f0f3f9; }
.section-row td    { font-weight: 600; color: var(--c-muted); font-size: .85em; letter-spacing: .4px; text-transform: uppercase; }
.row-actions       { white-space: nowrap; }

/* ------------- Forms ------------- */
.form              { display: flex; flex-direction: column; gap: 14px; }
.form label        { display: flex; flex-direction: column; gap: 4px; font-size: .9em; font-weight: 600; color: var(--c-text); }
.form label small  { font-weight: 400; }
.form input,
.form select,
.form textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: #fff;
  color: var(--c-text);
  width: 100%;
  box-sizing: border-box;
}
/* Top-level textareas in a column-flex .form sit directly under the
   form (not inside a label) — make them span the full available width
   too. */
.form > textarea,
.form > input,
.form > select { width: 100%; box-sizing: border-box; }
.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(45, 91, 255, .15);
}
.form textarea     { resize: vertical; font-family: inherit; }
.form-row          { display: flex; gap: 14px; }
.form-row > label  { flex: 1; }
.form-actions      { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-card         { max-width: none; }

.inline-generator  { background: #fafbfd; padding: 10px 14px; border-radius: 6px; border: 1px dashed var(--c-border); margin-bottom: 14px; }

/* ------------- Buttons ------------- */
.btn {
  display: inline-block;
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-text);
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  font-size: .9em;
}
.btn:hover         { background: #f6f8fc; text-decoration: none; }
.btn-sm            { padding: 5px 10px; font-size: .82em; }
.btn-primary       { background: var(--c-primary); color: white; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-d); border-color: var(--c-primary-d); color: white; }
.btn-danger        { background: #fff; color: var(--c-danger); border-color: #f1c6c6; }
.btn-danger:hover  { background: var(--c-danger); color: white; border-color: var(--c-danger); }
.btn-ghost         { background: transparent; border-color: transparent; color: var(--c-muted); }
.btn-ghost:hover   { background: #eef1f7; color: var(--c-text); }
.btn.block         { width: 100%; }
.btn[disabled]     { opacity: .5; cursor: not-allowed; }

/* ------------- Tabs ------------- */
.tabs              { display: flex; gap: 2px; border-bottom: 1px solid var(--c-border); margin-bottom: 16px; }
.tab {
  padding: 9px 14px;
  color: var(--c-muted);
  border-bottom: 2px solid transparent;
  font-weight: 500;
  font-size: .9em;
}
.tab:hover         { color: var(--c-text); text-decoration: none; }
.tab.active        { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ------------- Badges ------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .75em;
  font-weight: 600;
  line-height: 1.5;
  text-transform: capitalize;
  background: #eef1f7;
  color: var(--c-muted);
}
/* Legacy tier badges (kept for backwards compat — driven by currentUser.role) */
.badge-role-admin     { background: #fde8e8; color: #b02a2a; }
.badge-role-manager   { background: #fff3cd; color: #8a6400; }
.badge-role-user      { background: #e2ecff; color: #1f44c7; }

/* 11-role named badges (slug-based class names). Colour groups follow
   the tier mapping in middleware/auth.js so the visual language
   matches the access model. */
.badge-role-validation-lead,
.badge-role-compliance-manager,
.badge-role-system-owner,
.badge-role-qa-reviewer,
.badge-role-bp-owner,
.badge-role-product-owner {
  background: #fff3cd; color: #8a6400;        /* manager tier — amber */
}
.badge-role-tester,
.badge-role-business-user,
.badge-role-developer {
  background: #e2ecff; color: #1f44c7;        /* user tier — blue */
}
.badge-role-auditor {
  background: #eef1f7; color: var(--c-muted); /* read-only — neutral grey */
}
.badge-role-general-user {
  background: #f1f3f5; color: #6c757d; /* JIT no-access baseline — dimmed grey */
}

.badge-gxp-direct     { background: #fde8e8; color: #b02a2a; }
.badge-gxp-indirect   { background: #fff3cd; color: #8a6400; }
.badge-gxp-none       { background: #e6f6ec; color: #1e7e3f; }

.badge-status-active  { background: #e6f6ec; color: #1e7e3f; }
.badge-status-on_hold { background: #fff3cd; color: #8a6400; }
.badge-status-retired { background: #eef1f7; color: var(--c-muted); }

.badge-risk-critical  {
  background: #7f1d1d; color: #fee2e2;
  animation: badgePulse 1.8s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(127, 29, 29, .55); }
  50%      { box-shadow: 0 0 0 6px rgba(127, 29, 29, 0); }
}
.badge-risk-high      { background: #fde8e8; color: #b02a2a; }
.badge-risk-medium    { background: #fff3cd; color: #8a6400; }
.badge-risk-low       { background: #e6f6ec; color: #1e7e3f; }

.badge-priority-high  { background: #fde8e8; color: #b02a2a; }
.badge-priority-medium{ background: #fff3cd; color: #8a6400; }
.badge-priority-low   { background: #eef1f7; color: var(--c-muted); }

.badge-type-unscripted       { background: #e2ecff; color: #1f44c7; }
.badge-type-scripted         { background: #e6f6ec; color: #1e7e3f; }
.badge-type-robust_scripted  { background: #fff3cd; color: #8a6400; }
.badge-type-ad_hoc           { background: #eef1f7; color: var(--c-muted); }

.badge-teststatus-draft   { background: #eef1f7; color: var(--c-muted); }
.badge-teststatus-ready   { background: #e2ecff; color: #1f44c7; }
.badge-teststatus-passed  { background: #e6f6ec; color: #1e7e3f; }
.badge-teststatus-failed  { background: #fde8e8; color: #b02a2a; }
.badge-teststatus-blocked     { background: #fff3cd; color: #8a6400; }
.badge-teststatus-in_progress { background: #e2ecff; color: #1f44c7; }

.badge-cfr-compliant      { background: #e6f6ec; color: #1e7e3f; }
.badge-cfr-in_progress    { background: #fff3cd; color: #8a6400; }
.badge-cfr-non_compliant  { background: #fde8e8; color: #b02a2a; }
.badge-cfr-not_applicable { background: #eef1f7; color: var(--c-muted); }
.badge-cfr-not_assessed   { background: #e2ecff; color: #1f44c7; }

/* ------------- Flash messages ------------- */
.flash             { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid transparent; }
.flash-success     { background: #e6f6ec; color: #1e7e3f; border-color: #c7ecd5; }
.flash-error       { background: #fde8e8; color: #b02a2a; border-color: #f4c3c3; }
.flash-warn        { background: #fff3cd; color: #8a6400; border-color: #ffe49a; }
.flash-info        { background: #e2ecff; color: #1f44c7; border-color: #c3d4ff; }

/* ------------- Toast (floating flash) -------------
   Success/info/warn confirmations float top-right so they're visible
   regardless of scroll position (e.g. after saving a long matrix). */
.app-toast-wrap    { position: fixed; top: 74px; right: 24px; z-index: 4000; display: flex; flex-direction: column; gap: 10px; max-width: 380px; pointer-events: none; }
.app-toast         { pointer-events: auto; position: relative; padding: 12px 38px 12px 14px; border-radius: 8px; border: 1px solid transparent; box-shadow: 0 8px 28px rgba(16,24,40,.18); font-size: .85rem; line-height: 1.45; opacity: 0; transform: translateX(24px); animation: appToastIn .28s cubic-bezier(.2,.8,.3,1) forwards, appToastOut .45s ease 5s forwards; }
.app-toast-close   { position: absolute; top: 5px; right: 7px; border: none; background: none; cursor: pointer; font-size: 1rem; line-height: 1; color: inherit; opacity: .5; padding: 2px 5px; }
.app-toast-close:hover { opacity: 1; }
@keyframes appToastIn  { to { opacity: 1; transform: translateX(0); } }
@keyframes appToastOut { to { opacity: 0; transform: translateX(24px); visibility: hidden; } }

/* ------------- Auth ------------- */
.auth-wrap         { max-width: 420px; margin: 40px auto; }
.auth-card h1      { text-align: center; }

/* ============================================================
   Dashboard — colourful tiles, hover lift, stacked progress
   ============================================================ */

.btn,
.card,
.stat,
.kpi,
.table tr {
  transition: transform .18s ease, box-shadow .18s ease,
              background-color .18s ease, border-color .18s ease, color .18s ease;
}

.btn:hover            { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(17,23,41,.08); }
.btn-primary:hover    { box-shadow: 0 6px 14px rgba(45,91,255,.30); }
.btn-danger:hover     { box-shadow: 0 6px 14px rgba(214,69,69,.28); }
.card:hover           { box-shadow: 0 6px 18px rgba(17,23,41,.08); }

.stat                  { overflow: hidden; color: inherit; cursor: default; }
a.stat                 { cursor: pointer; }
a.stat:hover           { text-decoration: none; }
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--c-primary); opacity: .9;
}
.stat:hover            { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(17,23,41,.10); }
.stat .stat-n          { background-image: linear-gradient(135deg, var(--c-primary), var(--c-primary-d));
                         -webkit-background-clip: text; background-clip: text; color: transparent; }

.stat--blue::before    { background: linear-gradient(180deg, #3b6dff, #1f44c7); }
.stat--blue   .stat-n  { background-image: linear-gradient(135deg, #3b6dff, #1f44c7); }
.stat--green::before   { background: linear-gradient(180deg, #2bb673, #1e7e3f); }
.stat--green  .stat-n  { background-image: linear-gradient(135deg, #2bb673, #1e7e3f); }
.stat--purple::before  { background: linear-gradient(180deg, #8a5cf6, #5e35b1); }
.stat--purple .stat-n  { background-image: linear-gradient(135deg, #8a5cf6, #5e35b1); }
.stat--orange::before  { background: linear-gradient(180deg, #ff9e3d, #d4720b); }
.stat--orange .stat-n  { background-image: linear-gradient(135deg, #ff9e3d, #d4720b); }
.stat--pink::before    { background: linear-gradient(180deg, #ff5e8a, #c8235b); }
.stat--pink   .stat-n  { background-image: linear-gradient(135deg, #ff5e8a, #c8235b); }
.stat--teal::before    { background: linear-gradient(180deg, #2bbfbf, #0e8a8a); }
.stat--teal   .stat-n  { background-image: linear-gradient(135deg, #2bbfbf, #0e8a8a); }

.kpi {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.kpi:hover             { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(17,23,41,.10); }
.kpi-head              { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-title             { font-size: .8em; text-transform: uppercase; letter-spacing: .5px; color: var(--c-muted); font-weight: 600; }
.kpi-pct               { font-size: 1.6rem; font-weight: 700; }
.kpi-pct.green         { color: #1e9e4f; }
.kpi-pct.amber         { color: #d48806; }
.kpi-pct.red           { color: #d64545; }
.kpi-pct.blue          { color: #1f44c7; }
.kpi-sub               { font-size: .82em; color: var(--c-muted); }

.legend                { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: .78em; color: var(--c-muted); }
.legend .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: 1px;
}

.progress-stack {
  display: flex; height: 10px; border-radius: 6px; overflow: hidden;
  background: #eef1f7; border: 1px solid var(--c-border);
}
.progress-stack > span { display: block; height: 100%; transition: width .4s ease; }

.seg-passed     { background: linear-gradient(180deg,#2bb673,#1e7e3f); }
.seg-failed     { background: linear-gradient(180deg,#ef5b5b,#b02a2a); }
.seg-blocked    { background: linear-gradient(180deg,#ffb454,#d48806); }
.seg-ready      { background: linear-gradient(180deg,#5b8aff,#1f44c7); }
.seg-draft      { background: linear-gradient(180deg,#c5cad6,#8a92a3); }

.seg-high       { background: linear-gradient(180deg,#ef5b5b,#b02a2a); }
.seg-medium     { background: linear-gradient(180deg,#ffb454,#d48806); }
.seg-low        { background: linear-gradient(180deg,#2bb673,#1e7e3f); }

.seg-compliant      { background: linear-gradient(180deg,#2bb673,#1e7e3f); }
.seg-in_progress    { background: linear-gradient(180deg,#5b8aff,#1f44c7); }
.seg-non_compliant  { background: linear-gradient(180deg,#ef5b5b,#b02a2a); }
.seg-not_applicable { background: linear-gradient(180deg,#c5cad6,#8a92a3); }
.seg-not_assessed   { background: #eef1f7; }

.dot.seg-passed     { background: #1e9e4f; }
.dot.seg-failed     { background: #d64545; }
.dot.seg-blocked    { background: #d48806; }
.dot.seg-ready      { background: #1f44c7; }
.dot.seg-draft      { background: #8a92a3; }
.dot.seg-high       { background: #d64545; }
.dot.seg-medium     { background: #d48806; }
.dot.seg-low        { background: #1e9e4f; }
.dot.seg-compliant      { background: #1e9e4f; }
.dot.seg-in_progress    { background: #1f44c7; }
.dot.seg-non_compliant  { background: #d64545; }
.dot.seg-not_applicable { background: #8a92a3; }
.dot.seg-not_assessed   { background: #d0d5e0; }

@keyframes kpiFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stat, .kpi             { animation: kpiFadeIn .35s ease both; }

.btn-ghost:hover        { background: #eef1f7; color: var(--c-text); }

/* =============================================================
   App shell — sidebar + topbar layout
   ============================================================= */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.app-sidebar {
  width: 240px; min-width: 240px;
  background: #fff; border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.app-brand {
  padding: 18px 20px; border-bottom: 1px solid var(--c-border);
}
.app-brand-link {
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
  transition: background 0.15s;
}
.app-brand-link:hover { background: rgba(0,0,0,0.03); }
.app-brand-logo {
  display: block;
  width: 75%;
  height: auto;
  object-fit: contain;
}
.app-brand-tag {
  font-size: 11px; font-weight: 700; color: var(--c-primary);
  letter-spacing: 1.5px;
}
.app-brand-sub { color: var(--c-muted); font-size: 13px; margin-top: 2px; }
.app-tenant-chip {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  color: var(--c-primary-d);
  background: #eef4ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
}

/* =============================================================
   System Details — tab bar + lifecycle split
   ============================================================= */
.sys-tab-bar {
  display: flex; gap: 4px;
  margin: 4px 0 18px;
  border-bottom: 1px solid var(--c-border);
}
.sys-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  color: var(--c-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s, border-color .15s, background .15s;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  margin-bottom: -1px;
}
.sys-tab:hover {
  color: var(--c-text);
  background: #f8fafc;
}
.sys-tab.active {
  color: var(--c-primary-d);
  border-bottom-color: var(--c-primary);
  background: #fff;
}
.sys-tab:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}
.sys-tab-count {
  display: inline-block;
  padding: 1px 7px;
  background: #eef4ff;
  color: var(--c-primary-d);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.sys-tab.active .sys-tab-count {
  background: var(--c-primary);
  color: #fff;
}

.sys-tab-panel { animation: tabFadeIn .2s ease-out; }
@keyframes tabFadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* Buttons that look like links — used in the Releases table to
   jump straight to a specific release in the lifecycle tab. */
.link-button {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--c-primary);
  font: inherit;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }

/* ---------- Two-column lifecycle layout ---------- */
.lc-split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) {
  .lc-split { grid-template-columns: 1fr; }
}

.lc-split-releases {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 12px;
  position: sticky;
  top: 72px; /* clears the app-topbar */
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  box-shadow: var(--shadow);
}
@media (max-width: 900px) {
  .lc-split-releases { position: static; max-height: none; }
}
.lc-split-releases-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--c-muted);
  padding: 4px 8px 10px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 8px;
}

.lc-release-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
@media (max-width: 900px) {
  /* On narrow viewports collapse the rail to a horizontal scroll. */
  .lc-release-list {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .lc-release-btn { min-width: 220px; flex: 0 0 auto; }
}

.lc-release-btn {
  appearance: none;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background .15s, border-color .15s, transform .15s;
  font: inherit;
  color: var(--c-text);
}
.lc-release-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.lc-release-btn.active {
  background: #eef4ff;
  border-color: #bfdbfe;
  box-shadow: 0 0 0 2px rgba(45, 91, 255, .12);
}
.lc-release-btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

.lc-release-btn-row {
  display: flex; justify-content: space-between; align-items: center;
}
.lc-release-name {
  font-weight: 600; font-size: 14px;
}
.lc-release-pct {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--c-muted);
  font-weight: 600;
}
.lc-release-btn.active .lc-release-pct { color: var(--c-primary-d); }
.lc-release-progress {
  height: 4px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}
.lc-release-progress-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: 999px;
  transition: width .25s ease;
}
.lc-release-progress-fill.green { background: var(--c-success); }
.lc-release-progress-fill.amber { background: var(--c-warn); }
.lc-release-progress-fill.blue  { background: var(--c-primary); }
.lc-release-btn-meta {
  font-size: 11px;
  color: var(--c-muted);
}

.lc-add-release-btn {
  display: block;
  margin-top: 10px;
  text-align: center;
}

.lc-split-phases > .lc-phases-pane[hidden] { display: none; }

/* =============================================================
   Release status pills (in the lifecycle release selector)
   ============================================================= */
.lc-release-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  letter-spacing: .5px; text-transform: uppercase;
}
.lc-release-status.lc-status-live        { background: #d1fae5; color: #047857; }
.lc-release-status.lc-status-in_progress { background: #dbeafe; color: var(--c-primary-d); }
.lc-release-status.lc-status-retired     { background: #f1f5f9; color: #64748b; }

/* =============================================================
   Electronic signature — sign form + signature history
   ============================================================= */
.sign-card { margin-top: 18px; border-left: 4px solid var(--c-primary); }

.sign-callout {
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
}
.sign-callout-done   { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.sign-callout-locked { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.sign-callout-block  { background: #f0f9ff; color: #075985; border: 1px solid #bae6fd; }

/* Meaning badges in the signature-history table */
.sig-meaning {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1.2px;
  font-weight: 700;
}
.sig-author    { background: #f1f5f9; color: var(--c-muted); }
.sig-reviewer  { background: #dbeafe; color: var(--c-primary-d); }
.sig-approver  { background: #d1fae5; color: #047857; }

/* CRA status badge (re-used by other status pills) */
.sig-status {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1.2px;
  font-weight: 700;
  margin-left: 8px;
}
.sig-status.sig-status-draft     { background: #f1f5f9; color: var(--c-muted); }
.sig-status.sig-status-in_review { background: #dbeafe; color: var(--c-primary-d); }
.sig-status.sig-status-approved  { background: #d1fae5; color: #047857; }

/* Reset browser default styling so the disabled wrapper around an
   approved doc form looks identical to an editable one (other than
   the grayed-out inputs). */
.doc-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.doc-fieldset[disabled] input,
.doc-fieldset[disabled] textarea,
.doc-fieldset[disabled] select {
  background: #f8fafc;
  color: var(--c-muted);
  cursor: not-allowed;
}

/* =============================================================
   Lifecycle chart (Overview tab)
   ============================================================= */
.lc-chart {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .lc-chart { grid-template-columns: 1fr; }
}

.lc-chart-donut {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 8px;
}
.lc-chart-donut-meta {
  text-align: center;
  font-size: 13px;
  width: 100%;
}
.lc-chart-donut-meta .lc-release-status { margin-left: 6px; }
.lc-chart-legend {
  list-style: none; padding: 8px 0 0; margin: 0;
  font-size: 12px;
  text-align: left;
  border-top: 1px solid var(--c-border);
  margin-top: 8px;
}
.lc-chart-legend li {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0;
}

.lc-chart-matrix {
  display: flex; flex-direction: column; gap: 4px;
}
.lc-chart-matrix-head, .lc-chart-matrix-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) repeat(7, 1fr) 110px;
  align-items: center;
  gap: 4px;
}
.lc-chart-matrix-head {
  font-size: 10px; color: var(--c-muted); letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 4px 6px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 2px;
}
.lc-chart-matrix-head > div { text-align: center; }
.lc-chart-matrix-head > div:first-child { text-align: left; }

.lc-chart-matrix-row { padding: 6px; border-radius: 6px; }
.lc-chart-matrix-row:hover { background: #f8fafc; }

.lc-chart-name {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.lc-chart-name .link-button strong { font-size: 13px; }

.lc-chart-cell {
  display: grid; place-items: center;
  height: 26px; border-radius: 6px;
  font-weight: 700; font-size: 13px;
}
.lc-chart-cell.done    { background: #d1fae5; color: #047857; }
.lc-chart-cell.active  { background: #dbeafe; color: var(--c-primary-d); }
.lc-chart-cell.pending { background: #f1f5f9; color: #94a3b8; }
.lc-chart-cell.locked  {
  background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 4px, #f1f5f9 4px, #f1f5f9 8px);
  color: #94a3b8;
}

.lc-chart-progress { display: flex; align-items: center; gap: 6px; }
.lc-chart-progress .progress {
  flex: 1; background: #f1f5f9; height: 6px; border-radius: 999px; overflow: hidden;
}
.lc-chart-progress .progress .fill {
  height: 100%; background: var(--c-primary); border-radius: 999px;
  transition: width .25s ease;
}
.lc-chart-progress .progress.green .fill { background: var(--c-success); }
.lc-chart-progress .progress.amber .fill { background: var(--c-warn); }
.lc-chart-progress .progress.blue  .fill { background: var(--c-primary); }
.lc-chart-progress .pct { font-size: 11px; color: var(--c-muted); width: 32px; text-align: right; font-variant-numeric: tabular-nums; }
.app-nav { flex: 1; padding: 12px; overflow-y: auto; }
.app-nav-item, .app-nav-static {
  display: block; padding: 8px 12px; border-radius: 6px;
  color: #334155; font-size: 14px; font-weight: 500;
}
.app-nav-item:hover  { background: #f1f5f9; text-decoration: none; }
.app-nav-item.active { background: #eef4ff; color: var(--c-primary-d); }
.app-nav-static      { color: #94a3b8; font-weight: 400; cursor: default; }
.app-nav-section {
  padding: 18px 12px 4px; font-size: 11px; font-weight: 700;
  color: #94a3b8; letter-spacing: 1.5px; text-transform: uppercase;
}
.app-nav-section.prominent {
  font-size: 12px; font-weight: 800; color: #475569;
  letter-spacing: 0.8px; padding-top: 20px;
}
.app-nav-item.prominent {
  font-size: 12px; font-weight: 800; color: #475569;
  letter-spacing: 0.8px; text-transform: uppercase;
}
.app-nav-sub { padding-left: 32px; }
.app-brand-foot {
  padding: 14px 20px; border-top: 1px solid var(--c-border);
  color: #94a3b8; font-size: 11px;
}

.app-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.app-topbar {
  height: 56px; padding: 0 24px; background: #fff;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.app-topbar-user    { color: var(--c-muted); }
.app-topbar-user strong { color: var(--c-text); }
.app-topbar-actions { display: flex; align-items: center; gap: 10px; }
.role-tag {
  margin-left: 8px; font-size: 11px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 1.2px;
}
.role-tag-admin   { color: var(--c-danger); }
.role-tag-manager { color: var(--c-warn); }
.role-tag-user    { color: var(--c-muted); }

.app-content { padding: 24px 32px; flex: 1; max-width: 1400px; width: 100%; }
.app-content.app-content--wide { max-width: none; }

/* Auth pages (login / register) use a centered card and no sidebar */
.auth-main {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
/* Redirect flash (e.g. "Please sign in to continue") sits above the card,
   matched to its width — not floating beside it. */
.auth-main > .flash { width: 100%; max-width: 420px; margin-bottom: 0; }

/* =============================================================
   Lifecycle stepper (system detail page)
   ============================================================= */
.lc-stepper {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.lc-step {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 6px;
  padding: 12px 6px; border-radius: 8px;
  border: 1px solid var(--c-border); background: #fff;
  color: var(--c-text);
  font-size: 12px; font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.lc-step:hover { background: #f8fafc; text-decoration: none; }
.lc-step .lc-step-dot {
  width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center;
  background: #eef2f7; color: #94a3b8;
  font-weight: 700; font-size: 13px;
}
.lc-step.done   .lc-step-dot { background: #d1fae5; color: #047857; }
.lc-step.done   { border-color: #a7f3d0; }
.lc-step.active .lc-step-dot { background: #dbeafe; color: var(--c-primary-d); }
.lc-step.active { border-color: #bfdbfe; }
.lc-step.pending .lc-step-dot { background: #f1f5f9; color: #94a3b8; }
/* Locked = prerequisite phase not yet approved. Visually muted and
   non-interactive (route also blocks the action). */
.lc-step.locked {
  opacity: .55;
  cursor: not-allowed;
  background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 6px, #f3f4f6 6px, #f3f4f6 12px);
}
.lc-step.locked:hover { background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 6px, #f3f4f6 6px, #f3f4f6 12px); }
.lc-step.locked .lc-step-dot { background: #e5e7eb; color: #9ca3af; }
.lc-step.locked .lc-step-dot::after { content: '🔒'; font-size: 11px; margin-left: 2px; }
.lc-step .lc-step-sub { color: var(--c-muted); font-size: 11px; }

/* =============================================================
   Lifecycle phase grid (two-row: phase names + deliverables)
   ============================================================= */
.lc-phase-grid {
  display: grid;
  /* column count set dynamically via inline style: 90px repeat(N, 1fr) */
  gap: 8px;
  overflow-x: auto;
  margin-top: 4px;
}
.lc-pg-label {
  background: #0f2d4a;
  color: #fff;
  border-radius: 8px;
  padding: 14px 8px;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.lc-pg-phase {
  /* background applied via inline style (per-phase color) */
  color: #000;
  border-radius: 8px;
  padding: 14px 10px;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.lc-pg-phase.done   { filter: brightness(0.88); }
.lc-pg-phase.active { outline: 2px solid rgba(0,0,0,0.25); outline-offset: -2px; }
.lc-pg-dot { font-size: 15px; }
.lc-pg-deliverables {
  /* background applied via inline style (per-phase color) */
  color: #000;
  border-radius: 8px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.lc-pg-deliverables.done   { filter: brightness(0.88); }
.lc-pg-deliverables.active { outline: 2px solid rgba(0,0,0,0.25); outline-offset: -2px; }
.lc-pg-link {
  color: #000;
  text-decoration: none;
  line-height: 1.4;
}
.lc-pg-link:hover { color: #000; text-decoration: underline; }

.sys-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.sys-meta-item .label {
  display: block; font-size: 11px; color: var(--c-muted);
  letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 2px;
}
.sys-meta-item .value { font-weight: 500; }
.env-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eef4ff; color: var(--c-primary-d);
  font-size: 11px; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; margin-right: 4px;
}
.breadcrumbs {
  font-size: 12px; color: var(--c-muted); margin-bottom: 6px;
}
.breadcrumbs a:hover { color: var(--c-text); }
.breadcrumbs .sep { margin: 0 6px; color: #cbd5e1; }
.entity-id-tag {
  /* Match the Entity Name (h1) styling exactly — no box, same font,
     size, weight and colour as the heading it sits beside. */
  display: inline; padding: 0; border-radius: 0; background: none;
  color: inherit; font: inherit;
}

/* =============================================================
   Dashboard 2.0 — hero, charts, lifecycle matrix
   ============================================================= */
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.mono   { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.right  { text-align: right; }

/* Hero */
.hero {
  background: linear-gradient(135deg, #1f3fa3 0%, #4f46e5 100%);
  color: #fff;
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(31, 63, 163, .18);
}
.hero h1 { color: #fff; margin: 6px 0 4px; font-size: 1.6rem; }
.hero-tag {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  color: rgba(255,255,255,.85);
}
.hero-sub { color: rgba(255,255,255,.85); margin: 0 0 16px; }
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.hero-stat {
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  padding: 10px 14px;
}
.hero-stat .v { font-size: 1.4rem; font-weight: 600; }
.hero-stat .l { font-size: 11px; color: rgba(255,255,255,.78); letter-spacing: 1.2px; text-transform: uppercase; }

/* Stat ring cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 16px 18px;
  display: block;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  border-left: 4px solid #cbd5e1;
}
.stat-card:hover { text-decoration: none; transform: translateY(-1px); transition: transform .15s; }
.stat-card .stat-label { color: var(--c-muted); font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 600; margin-top: 4px; }
.tone-ring-amber  { border-left-color: var(--c-warn); }
.tone-ring-green  { border-left-color: var(--c-success); }
.tone-ring-red    { border-left-color: var(--c-danger); }
.tone-ring-blue   { border-left-color: var(--c-primary); }

/* Chart grid */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.chart-card { padding: 18px 20px; }
.chart-wide { grid-column: span 2; }
@media (max-width: 900px) { .chart-wide { grid-column: span 1; } }
.chart-title { font-weight: 600; font-size: 1rem; color: var(--c-text); }
.chart-sub   { color: var(--c-muted); font-size: 12px; margin-bottom: 12px; }
.chart-row   { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.chart-donut { flex: 0 0 auto; }

.chart-legend {
  list-style: none; padding: 0; margin: 0; flex: 1; min-width: 140px;
}
.chart-legend li {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; font-size: 13px;
}
.swatch {
  width: 10px; height: 10px; border-radius: 3px;
  display: inline-block;
}

/* Bar chart */
.chart-bars { display: flex; flex-direction: column; gap: 6px; }
.chart-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 32px;
  align-items: center; gap: 8px;
  font-size: 13px;
}
.chart-bar-label { color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-track {
  background: #f1f5f9; height: 10px; border-radius: 999px; overflow: hidden;
}
.chart-bar-fill  { height: 100%; border-radius: 999px; transition: width .3s ease; }
.chart-bar-value { text-align: right; color: var(--c-muted); font-variant-numeric: tabular-nums; }

/* Activity feed */
.activity { list-style: none; padding: 0; margin: 0; }
.activity-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid #f1f5f9;
}
.activity-row:last-child { border-bottom: 0; }
.badge-action {
  background: #eef4ff; color: var(--c-primary-d);
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
}

/* Lifecycle matrix */
.lc-matrix { display: flex; flex-direction: column; gap: 4px; }
.lc-matrix-head, .lc-matrix-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(7, 1fr) 120px;
  align-items: center;
  gap: 6px;
}
.lc-matrix-head {
  font-size: 11px; color: var(--c-muted); letter-spacing: 1.2px;
  text-transform: uppercase; padding: 4px 8px;
  border-bottom: 1px solid var(--c-border); margin-bottom: 4px;
}
.lc-matrix-head > div { text-align: center; }
.lc-matrix-head > div:first-child { text-align: left; }
.lc-matrix-row {
  padding: 8px; border-radius: 6px;
}
.lc-matrix-row:hover { background: #f8fafc; }
.lc-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lc-name a { font-weight: 500; color: var(--c-text); }
.lc-name a:hover { color: var(--c-primary); }

.lc-cell-wrap {
  display: grid; place-items: center;
  height: 28px; border-radius: 6px;
  font-weight: 700; font-size: 13px;
  text-decoration: none;
}
.lc-cell-wrap.done    { background: #d1fae5; color: #047857; }
.lc-cell-wrap.active  { background: #dbeafe; color: var(--c-primary-d); }
.lc-cell-wrap.pending { background: #f1f5f9; color: #94a3b8; }
.lc-cell-wrap.locked  { background: #f1f5f9; color: #cbd5e1; cursor: not-allowed; }

.lc-progress-mini { display: flex; align-items: center; gap: 8px; }
.lc-progress-mini .progress {
  flex: 1; background: #f1f5f9; height: 8px; border-radius: 999px; overflow: hidden;
}
.lc-progress-mini .progress .fill {
  height: 100%; background: var(--c-primary); border-radius: 999px; transition: width .3s ease;
}
.lc-progress-mini .progress.green .fill { background: var(--c-success); }
.lc-progress-mini .progress.amber .fill { background: var(--c-warn); }
.lc-progress-mini .progress.blue  .fill { background: var(--c-primary); }
.lc-progress-mini .pct { font-size: 12px; color: var(--c-muted); width: 36px; text-align: right; }

/* =============================================================
   Topbar widgets — search launcher, tenant switcher, AI button
   ============================================================= */
.app-topbar { gap: 12px; }

.search-launcher {
  flex: 1; max-width: 480px; min-width: 200px;
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px;
  background: #f1f5f9; color: var(--c-muted);
  border: 1px solid var(--c-border); border-radius: 8px;
  cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s;
}
.search-launcher:hover { background: #eef4ff; border-color: #bfdbfe; }
.search-launcher-icon  { font-size: 14px; color: #94a3b8; }
.search-launcher-text  { flex: 1; text-align: left; color: var(--c-muted); }
.search-launcher-shortcut { display: flex; gap: 4px; }
.search-launcher kbd, .search-overlay kbd, .ai-panel kbd {
  background: #fff; border: 1px solid var(--c-border); border-bottom-width: 2px;
  border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px; padding: 1px 5px; color: var(--c-muted);
}

.tenant-switch {
  height: 34px; padding: 0 8px;
  background: #fff; color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: 8px;
  font-size: 13px;
}

.btn-ai {
  background: linear-gradient(135deg, #6d28d9 0%, #2563eb 100%);
  color: #fff; border: 0;
  padding: 6px 12px; border-radius: 8px;
  font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-ai:hover { filter: brightness(1.08); }

/* =============================================================
   Search overlay (Ctrl/Cmd+K)
   ============================================================= */
.search-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 96px;
}
.search-overlay[hidden] { display: none; }
.search-overlay-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}
.search-overlay-panel {
  position: relative;
  width: min(640px, calc(100vw - 32px));
  background: #fff; border-radius: 14px;
  box-shadow: 0 16px 56px rgba(15, 23, 42, .22);
  overflow: hidden;
}
.search-overlay-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
}
.search-overlay-icon { font-size: 18px; color: var(--c-muted); }
.search-overlay-input-wrap input {
  flex: 1; border: 0; outline: 0; font-size: 16px;
  background: transparent; color: var(--c-text);
}
.search-overlay-shortcut { display: flex; gap: 4px; }
.search-overlay-results {
  max-height: 60vh; overflow-y: auto; padding: 6px 0;
}
.search-overlay-empty {
  padding: 24px; text-align: center; color: var(--c-muted); font-size: 13px;
}

/* ── Search group headers ────────────────────────────────────── */
.search-group-hdr {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 18px 3px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: #94a3b8;
  border-top: 1px solid #f1f5f9;
}
.search-group-hdr:first-child { border-top: none; }
.search-group-ct {
  background: #f1f5f9; color: #64748b;
  font-size: 9px; padding: 1px 5px; border-radius: 8px;
}

.search-result {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px;
  padding: 8px 18px; color: var(--c-text);
  text-decoration: none; cursor: pointer;
}
.search-result:hover, .search-result.active { background: #eef4ff; text-decoration: none; }
.search-result-type {
  font-size: 13px; font-weight: 600;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; flex-shrink: 0;
}
/* Type colors */
.search-result-type.type-nav            { background: #f1f5f9; color: #475569; }
.search-result-type.type-system         { background: #ede9fe; color: #5b21b6; }
.search-result-type.type-release        { background: #dcfce7; color: #15803d; }
.search-result-type.type-requirement    { background: #dbeafe; color: #1d4ed8; }
.search-result-type.type-defect         { background: #fee2e2; color: #b91c1c; }
.search-result-type.type-test-case      { background: #d1fae5; color: #065f46; }
.search-result-type.type-test-cycle     { background: #e0f2fe; color: #0369a1; }
.search-result-type.type-change-request { background: #fff7ed; color: #c2410c; }
.search-result-type.type-document       { background: #fef3c7; color: #92400e; }
.search-result-type.type-cra            { background: #fef9c3; color: #713f12; }
.search-result-label  { font-weight: 500; font-size: 13px; }
.search-result-sub    {
  color: var(--c-muted); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 260px;
}

.search-overlay-foot {
  border-top: 1px solid var(--c-border);
  padding: 8px 18px; font-size: 11px; color: var(--c-muted);
  display: flex; gap: 12px;
}

/* =============================================================
   AI Assistant slide-in panel
   ============================================================= */
/* ── AI Assistant floating chat widget ── */
/* ── Notification bell ── */
.notif-wrap { position: relative; display: inline-flex; }
.notif-bell {
  position: relative; background: none; border: none; cursor: pointer;
  color: #64748b; padding: 7px; border-radius: 8px;
  display: inline-flex; align-items: center; transition: background .12s, color .12s;
}
.notif-bell:hover { background: #f1f5f9; color: #334155; }
.notif-badge {
  position: absolute; top: 1px; right: 1px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #ef4444; color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  border: 2px solid #fff;
}
.notif-badge[hidden] { display: none; }
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-height: 440px; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15,23,42,.16), 0 2px 8px rgba(15,23,42,.08);
  z-index: 200; display: flex; flex-direction: column; overflow: hidden;
}
.notif-dropdown[hidden] { display: none; }
.notif-dropdown-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #f3f4f6;
  font-size: .82rem; font-weight: 700; color: #374151;
}
.notif-readall {
  background: none; border: none; cursor: pointer;
  font-size: .72rem; color: #6366f1; font-weight: 600; padding: 2px 4px;
}
.notif-readall:hover { text-decoration: underline; }
.notif-dropdown-list { flex: 1; overflow-y: auto; }
.notif-dropdown-list::-webkit-scrollbar { width: 4px; }
.notif-dropdown-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.notif-empty { padding: 28px 16px; text-align: center; color: #9ca3af; font-size: .82rem; }
.notif-item {
  display: block; width: 100%; text-align: left; box-sizing: border-box;
  padding: 11px 16px; border: none; border-bottom: 1px solid #f3f4f6;
  background: none; cursor: pointer; text-decoration: none;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #f5f3ff; }
.notif-item.unread:hover { background: #ede9fe; }
.notif-item-title { font-size: .8rem; font-weight: 600; color: #111827; margin-bottom: 2px; }
.notif-item-msg { font-size: .75rem; color: #6b7280; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item-time { font-size: .68rem; color: #9ca3af; margin-top: 3px; }
.notif-dropdown-foot {
  display: block; text-align: center; padding: 10px;
  font-size: .78rem; font-weight: 600; color: #6366f1;
  border-top: 1px solid #f3f4f6; text-decoration: none;
}
.notif-dropdown-foot:hover { background: #f8fafc; }

/* ---- Active automation runs (cross-screen live indicator) ---- */
.autorun-wrap { position: relative; display: inline-flex; }
.autorun-wrap[hidden] { display: none; }
.autorun-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: #eef2ff; border: 1px solid #c7d2fe; color: #4338ca;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  font-size: .76rem; font-weight: 600; transition: background .12s, border-color .12s;
}
.autorun-pill:hover { background: #e0e7ff; border-color: #a5b4fc; }
.autorun-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #c7d2fe; border-top-color: #4f46e5;
  animation: autorun-spin .8s linear infinite; flex: none;
}
@keyframes autorun-spin { to { transform: rotate(360deg); } }
.autorun-count {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #4f46e5; color: #fff; font-size: 10px; font-weight: 700;
  line-height: 16px; text-align: center;
}
.autorun-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-height: 460px; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15,23,42,.16), 0 2px 8px rgba(15,23,42,.08);
  z-index: 200; display: flex; flex-direction: column; overflow: hidden;
}
.autorun-dropdown[hidden] { display: none; }
.autorun-dropdown-head {
  padding: 12px 16px; border-bottom: 1px solid #f3f4f6;
  font-size: .82rem; font-weight: 700; color: #374151;
}
.autorun-dropdown-list { flex: 1; overflow-y: auto; }
.autorun-dropdown-list::-webkit-scrollbar { width: 4px; }
.autorun-dropdown-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.autorun-empty { padding: 28px 16px; text-align: center; color: #9ca3af; font-size: .82rem; }
.autorun-item {
  display: block; padding: 11px 16px; border-bottom: 1px solid #f3f4f6;
  text-decoration: none; color: inherit;
}
.autorun-item:hover { background: #f8fafc; }
.autorun-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.autorun-item-ref { font-size: .8rem; font-weight: 700; color: #111827; }
.autorun-item-tally { font-size: .72rem; color: #6b7280; white-space: nowrap; }
.autorun-item-title { font-size: .73rem; color: #6b7280; line-height: 1.4; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.autorun-bar { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.autorun-bar > span { display: block; height: 100%; background: #4f46e5; border-radius: 999px; transition: width .4s ease; }
.autorun-item-step { font-size: .7rem; color: #4338ca; margin-top: 5px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.autorun-dropdown-foot {
  display: block; text-align: center; padding: 10px;
  font-size: .78rem; font-weight: 600; color: #6366f1;
  border-top: 1px solid #f3f4f6; text-decoration: none;
}
.autorun-dropdown-foot:hover { background: #f8fafc; }

/* ---- Per-cycle live execution badges (test-cycle list rows) ---- */
.cycle-exec-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.cycle-exec-badges:empty { display: none; }
.exec-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.3;
}
.exec-badge[hidden] { display: none; }
.exec-badge b { font-weight: 800; }
.exec-badge-auto   { background: #eef2ff; border: 1px solid #c7d2fe; color: #4338ca; }   /* automated = indigo */
.exec-badge-manual { background: #fffbeb; border: 1px solid #fde68a; color: #b45309; }   /* manual = amber */
.exec-spinner {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #c7d2fe; border-top-color: #4f46e5;
  animation: autorun-spin .8s linear infinite; flex: none;
}

/* Run-finished toast (fired when a run completes while you're on another screen) */
.autorun-toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.autorun-toast {
  pointer-events: auto; min-width: 260px; max-width: 360px;
  background: #fff; border: 1px solid #e5e7eb; border-left-width: 4px;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.18);
  padding: 12px 14px; font-size: .82rem; color: #1f2937; text-decoration: none;
  display: block; animation: autorun-toast-in .25s ease;
}
.autorun-toast.pass  { border-left-color: #16a34a; }
.autorun-toast.fail  { border-left-color: #dc2626; }
.autorun-toast.error { border-left-color: #d97706; }
.autorun-toast-title { font-weight: 700; margin-bottom: 2px; }
.autorun-toast-sub { font-size: .74rem; color: #6b7280; }
@keyframes autorun-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ai-panel {
  position: fixed; inset: 0; z-index: 95;
  pointer-events: none;
}
.ai-panel[hidden] { display: none; }
.ai-panel-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .18);
  pointer-events: auto;
}
.ai-panel-body {
  position: absolute; bottom: 24px; right: 24px;
  width: 340px; height: 480px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(15,23,42,.18), 0 2px 8px rgba(15,23,42,.08);
  display: flex; flex-direction: column; overflow: hidden;
  animation: aiPopUp .25s cubic-bezier(.34,1.46,.64,1);
  pointer-events: auto;
}
@keyframes aiPopUp {
  from { transform: scale(.88) translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
/* Header */
.ai-panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px 0;
  background: linear-gradient(135deg, #5b21b6 0%, #4f46e5 100%);
  flex-shrink: 0;
  flex-direction: column;
}
/* Head row */
.ai-panel-head > * { align-self: flex-start; }
.ai-panel-head {
  flex-direction: row;
  padding: 10px 14px 0;
}
/* Tabs row inside header */
.ai-panel-head-tabs {
  display: flex; gap: 2px; margin-top: 4px; margin-bottom: 0;
}
.ai-tab-btn {
  background: none; border: none; color: rgba(255,255,255,.6);
  font-size: 11.5px; font-weight: 600; padding: 3px 9px 6px;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  letter-spacing: .02em;
}
.ai-tab-btn:hover { color: rgba(255,255,255,.9); }
.ai-tab-btn.active { color: #fff; border-bottom-color: #a78bfa; }
/* Tab sections */
.ai-tab-section { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.ai-tab-section[hidden] { display: none; }
/* Conversation bar */
.ai-conv-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px 5px 12px;
  background: #f0f0f8; border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.ai-conv-title {
  flex: 1; font-size: 11px; font-weight: 600; color: #4b5563;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-conv-action {
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: #6b7280; padding: 3px 6px; border-radius: 4px;
  transition: background .12s, color .12s; white-space: nowrap;
}
.ai-conv-action:hover { background: #e0e7ff; color: #4f46e5; }
.ai-conv-bookmark-btn.bookmarked { color: #f59e0b; }
/* History tab */
.ai-history-toolbar {
  display: flex; align-items: center;
  padding: 8px 12px 6px;
  border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
}
.ai-history-label { font-size: 11px; font-weight: 700; color: #374151; letter-spacing: .04em; text-transform: uppercase; flex: 1; }
.ai-history-list {
  flex: 1; overflow-y: auto; padding: 6px 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.ai-history-list::-webkit-scrollbar { width: 4px; }
.ai-history-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.ai-history-empty { font-size: 12px; color: #9ca3af; text-align: center; padding: 24px 0; }
.ai-history-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.ai-history-item:hover { background: #f5f3ff; border-color: #e0e7ff; }
.ai-history-item.active { background: #ede9fe; border-color: #c4b5fd; }
.ai-history-item-icon {
  font-size: 14px; flex-shrink: 0; width: 20px; text-align: center;
}
.ai-history-item-body { flex: 1; min-width: 0; }
.ai-history-item-title {
  font-size: 11.5px; font-weight: 600; color: #1f2937;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-history-item-meta {
  font-size: 10px; color: #9ca3af; margin-top: 1px;
}
.ai-history-item-bmark {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: #d1d5db; padding: 2px 4px; border-radius: 4px;
  flex-shrink: 0; transition: color .12s;
}
.ai-history-item-bmark:hover { color: #f59e0b; }
.ai-history-item-bmark.on { color: #f59e0b; }
.ai-history-item-del {
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: #d1d5db; padding: 2px 4px; border-radius: 4px;
  flex-shrink: 0; opacity: 0; transition: opacity .12s, color .12s;
}
.ai-history-item:hover .ai-history-item-del { opacity: 1; }
.ai-history-item-del:hover { color: #ef4444; }
.ai-panel-head-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; flex-shrink: 0;
}
.ai-panel-head-info { flex: 1; min-width: 0; }
.ai-panel-head-title {
  font-size: .82rem; font-weight: 700; color: #fff; line-height: 1.2;
}
.ai-panel-head-sub {
  font-size: .67rem; color: rgba(255,255,255,.65); margin-top: 1px;
}
.ai-panel-close {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.6); font-size: .75rem; line-height: 1;
  padding: 5px 6px; border-radius: 6px;
  transition: color .12s, background .12s;
}
.ai-panel-close:hover { color: #fff; background: rgba(255,255,255,.15); }
/* Message area */
.ai-panel-body-inner {
  flex: 1; overflow-y: auto;
  padding: 12px 12px 6px;
  display: flex; flex-direction: column; gap: 8px;
  background: #f8f9fb;
}
.ai-panel-body-inner::-webkit-scrollbar { width: 4px; }
.ai-panel-body-inner::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
/* Messages */
.ai-message {
  padding: 8px 11px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.55;
  max-width: 88%; word-wrap: break-word;
}
.ai-message-bot {
  background: #fff; color: var(--c-text);
  border: 1px solid #e8ecf2; border-bottom-left-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.ai-message-user {
  background: linear-gradient(135deg, #5b21b6, #4f46e5);
  color: #fff; border-bottom-right-radius: 3px;
  align-self: flex-end;
}
.ai-message-bot p  { margin: 0 0 5px; }
.ai-message-bot p:last-child { margin-bottom: 0; }
.ai-message-bot ul { margin: 4px 0 5px; padding-left: 15px; }
.ai-message-bot li { margin: 2px 0; }
/* SOP source tag */
.ai-sop-source {
  font-size: 10.5px; color: #6366f1;
  padding: 4px 8px; background: #eef2ff;
  border: 1px solid #c7d2fe; border-radius: 6px; line-height: 1.4;
}
/* Typing indicator */
.ai-typing { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.ai-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #a5b4fc;
  animation: aiTypingDot 1.2s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiTypingDot {
  0%,60%,100% { transform: translateY(0);   opacity: .45; }
  30%         { transform: translateY(-5px); opacity: 1;  }
}
/* Input row */
.ai-input-row {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 12px;
  border-top: 1px solid #e8ecf2; background: #fff; flex-shrink: 0;
}
.ai-input-row input {
  flex: 1; height: 32px; padding: 0 10px;
  border: 1px solid #e2e8f0; border-radius: 20px;
  font-size: 12.5px; background: #f8f9fb;
  transition: border-color .15s, background .15s;
}
.ai-input-row input:focus { outline: none; border-color: #6d28d9; background: #fff; }
.ai-send-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #5b21b6, #4f46e5);
  color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .15s, transform .12s;
}
.ai-send-btn:hover  { opacity: .88; transform: scale(1.06); }
.ai-send-btn:active { transform: scale(.94); }
.xsmall { font-size: 11px; }

/* =============================================================
   Admin hub
   ============================================================= */
.admin-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 7px;
  margin-bottom: 20px;
}
.admin-tile {
  display: flex; flex-direction: column; gap: 3px;
  padding: 9px 10px;
  background: #fff;
  border: 1px solid var(--c-border); border-radius: 8px;
  box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
  transition: transform .15s, border-color .15s;
}
.admin-tile:hover { transform: translateY(-1px); border-color: #bfdbfe; text-decoration: none; }
.admin-tile-head  { display: flex; align-items: center; gap: 6px; }
.admin-tile-head h2 { margin: 0; font-size: .76rem; font-weight: 600; line-height: 1.2; }
.admin-tile-icon  {
  font-size: 12px; line-height: 1; overflow: hidden;
  display: grid; place-items: center;
  width: 22px; height: 22px; flex-shrink: 0;
  background: #eef4ff; border-radius: 5px;
}
.admin-tile-stat  {
  margin-top: 1px; color: var(--c-muted); font-size: .67rem;
}
.admin-tile-stat strong { color: var(--c-text); font-size: .76rem; font-weight: 600; margin-right: 2px; }
.admin-tile-badge {
  display: inline-block; padding: 1px 7px; border-radius: 99px;
  font-size: .65rem; font-weight: 700; letter-spacing: .02em;
}
.admin-tile-badge-on  { background: #dcfce7; color: #15803d; }
.admin-tile-badge-off { background: #f1f5f9; color: #64748b; }
.admin-tile-badge-warn { background: #fef9c3; color: #92400e; }

.admin-soon-card .badge { vertical-align: middle; }

/* Roles matrix */
.roles-matrix .role-col { text-align: center; width: 100px; }
.roles-matrix .roles-group-row td {
  background: #f8fafc; color: var(--c-muted);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  padding: 8px 12px;
}
.role-yes { color: var(--c-success); font-weight: 700; font-size: 16px; }
.role-no  { color: #cbd5e1; }

.inline-checkbox {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; cursor: pointer;
}
.inline-checkbox input[type=checkbox] { width: auto; margin: 0; }

/* =============================================================
   Defects — filter pills
   ============================================================= */
.defect-filters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 14px;
}
.defect-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--c-text);
  text-decoration: none;
}
.defect-filter:hover  { background: #f1f5f9; text-decoration: none; }
.defect-filter.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.defect-filter-count {
  background: rgba(255,255,255,.25);
  color: inherit;
  font-variant-numeric: tabular-nums;
  padding: 0 6px; border-radius: 999px;
  font-size: 11px;
}
.defect-filter:not(.active) .defect-filter-count {
  background: #f1f5f9; color: var(--c-muted);
}
.defect-filter-warning {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  background: #fee2e2; color: #7f1d1d;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  margin-left: 6px;
}

/* =============================================================
   Users — multi-role checkbox group
   ============================================================= */
.role-fieldset {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 12px;
}
.role-fieldset legend {
  font-size: .85rem; color: var(--c-muted);
  padding: 0 6px;
}
.role-check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #f1f5f9;
}
.role-check:first-of-type { border-top: 0; }
.role-check input[type=checkbox] { width: auto; margin-top: 4px; }
.role-check > span { display: flex; flex-direction: column; gap: 4px; }

/* =============================================================
   Requirements deep-dive — class badges, hierarchy, comments
   ============================================================= */
.req-class-urs        { background: #ede9fe; color: #5b21b6; }   /* user requirements */

.req-hierarchy-indent {
  display: inline-block;
  margin-left: calc(var(--lvl, 0) * 16px);
  color: var(--c-muted);
  font-size: 12px;
  margin-right: 4px;
}

/* =============================================================
   DMS card — version + retention + revision history
   ============================================================= */
.dms-card { border-left: 4px solid var(--c-primary); }
.dms-retention {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 13px;
}
.dms-retention-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-left: 6px;
}
.dms-retention-ok       { background: #d1fae5; color: #047857; }
.dms-retention-warn     { background: #fff3cd; color: #8a6400; }
.dms-retention-expired  { background: #fee2e2; color: #7f1d1d; }
.dms-history summary    { cursor: pointer; padding: 6px 0; }

/* Comment timeline */
.req-comment-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.req-comment {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 10px 12px;
}
.req-comment-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
  font-size: 13px;
}
.req-comment-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-text);
}

/* Tier grouping inside the user form. */
.role-tier {
  padding: 8px 0;
  border-top: 1px dashed var(--c-border);
}
.role-tier:first-of-type { border-top: 0; }
.role-tier-head {
  padding: 4px 0 6px;
  display: flex; align-items: baseline; gap: 6px;
}
.role-tier-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--c-muted);
}
.role-tier .role-check { border-top: 0; padding: 4px 0; }

/* ============================================================
   Global application error dialog (views/partials/error-modal.ejs).
   Sits above every other layer (overlays, AI panel, OnlyOffice
   saving-overlay, inactivity modal) so a failure is always visible.
   ============================================================ */
.app-error-modal { position: fixed; inset: 0; z-index: 200000; display: flex;
  align-items: center; justify-content: center; padding: 20px; }
.app-error-modal[hidden] { display: none; }
.app-error-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .55);
  backdrop-filter: blur(1px); }
.app-error-dialog { position: relative; width: 100%; max-width: 440px; background: #fff;
  border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); padding: 26px 26px 22px;
  text-align: center; animation: appErrPop .16s ease-out; }
@keyframes appErrPop { from { transform: translateY(8px) scale(.98); opacity: 0; }
  to { transform: none; opacity: 1; } }
.app-error-icon { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fdecec; color: var(--c-danger, #d64545); }
.app-error-title { margin: 0 0 8px; font-size: 1.12rem; font-weight: 700; color: var(--c-text, #1b2230); }
.app-error-message { margin: 0; font-size: .92rem; line-height: 1.6; color: var(--c-muted, #6b7388);
  white-space: pre-wrap; word-break: break-word; }
.app-error-ref { margin: 12px 0 0; font-size: .72rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #9aa1b2; background: #f6f7fa; border: 1px solid var(--c-border, #e4e8ef);
  border-radius: 6px; padding: 5px 8px; display: inline-block; }
.app-error-actions { margin-top: 20px; display: flex; justify-content: center; gap: 10px; }
.app-error-close-btn { min-width: 120px; }
body.app-error-open { overflow: hidden; }

/* ============================================================
   Generic centered dialog (.modal-backdrop / .modal-box).
   Used by the Archive / Initialize-from-archive / Import-from-archive
   modals (release-management, systems/show, requirements, doc-archive).
   Views toggle visibility with inline display:none ↔ display:flex.
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100000;
  /* display is toggled inline (none ↔ flex) by each view's JS */
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(17, 24, 39, .55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.modal-box {
  position: relative; width: 100%; max-width: 480px;
  background: #fff; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  max-height: calc(100vh - 40px); overflow: auto;
  animation: modalPop .16s ease-out;
}
@keyframes modalPop {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--c-border, #e4e8ef);
}
.modal-title { margin: 0; font-size: 1.02rem; font-weight: 700; color: var(--c-text, #1b2230); }
.modal-close {
  background: none; border: none; cursor: pointer; line-height: 1;
  font-size: 1.15rem; color: var(--c-muted, #6b7388); padding: 4px 6px; border-radius: 6px;
}
.modal-close:hover { background: #f1f5f9; color: var(--c-text, #1b2230); }
.modal-body { padding: 18px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--c-border, #e4e8ef);
}
body.modal-open { overflow: hidden; }

/* ------------- Toggle switch ------------- */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .toggle-track {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd5e1; border-radius: 999px; transition: background .15s;
}
.toggle-switch .toggle-track::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.toggle-switch input:checked + .toggle-track { background: var(--c-success, #16a34a); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); }
.toggle-switch input:focus-visible + .toggle-track { outline: 2px solid var(--c-primary, #4f46e5); outline-offset: 2px; }
