:root {
  --ink: #161616;
  --muted: #636363;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --paper: #ffffff;
  --wash: #f3f4f6;
  --primary: #d40924;
  --positive: #176b4b;
  --positive-strong: #11553b;
  --positive-tint: #e2f2e8;
  --amber: #b45309;
  --amber-100: #fef3c7;
  --blue: #175cd3;
  --blue-100: #e8f1ff;
  --shadow-sm: 0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;
  --shadow-xl: 0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;
}

* { box-sizing: border-box; }

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 200ms ease;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 18px; height: 18px; flex: none; display: block; }

.mobilebar {
  display: none;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 56px;
  padding: 6px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.menu-btn {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: -8px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-lg);
  color: var(--ink);
  cursor: pointer;
}
.menu-btn:hover { background: var(--wash); }
.mobilebar-brand { display: flex; align-items: center; gap: 9px; font-size: 15px; color: var(--ink); }
.mobilebar-brand .brand-mark { width: 30px; height: 30px; font-size: 12px; }

.sidebar {
  background: var(--paper);
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: clamp(10px, 1.8vh, 16px) 12px;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.3vh, 12px);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}
.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 9999px;
  transition: background 150ms ease;
}
.sidebar:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.35);
}
.sidebar-head { display: flex; align-items: center; gap: 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  flex: 1;
  min-width: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xl);
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 14px;
  flex: none;
}

.brand-text { min-width: 0; }
.brand strong { display: block; font-size: 14px; line-height: 1.2; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--muted); font-size: 11px; }

.sidebar-toggle, .sidebar-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
  cursor: pointer;
}
.sidebar-toggle:hover, .sidebar-close:hover { background: var(--wash); color: var(--ink); }
.sidebar-close { display: none; }
.sidebar-toggle svg { transition: transform 200ms ease; }

.sidebar-profile { position: relative; }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  color: var(--ink);
  font: inherit;
  text-align: left;
  user-select: none;
}
.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.profile-text { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.profile-text strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-text small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip-link:focus {
  left: 10px;
  top: 10px;
  z-index: 200;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}
#main:focus { outline: none; }

.nav { display: grid; gap: 2px; }
.nav-label {
  margin: 12px 0 4px;
  padding: 0 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted);
}
.nav-label:first-child { margin-top: 0; }

.nav-group {
  display: grid;
  gap: 1px;
  margin-top: clamp(2px, 0.4vh, 4px);
}
.nav-group-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: clamp(5px, 0.8vh, 8px) 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-lg);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  color: #374151;
  text-align: left;
  cursor: pointer;
  min-height: clamp(32px, 3.8vh, 36px);
  transition: background 120ms ease, color 120ms ease;
}
.nav-group-trigger:hover {
  background: var(--wash);
  color: var(--ink);
}
.nav-group-trigger .ico {
  color: #6b7280;
}
.nav-group-trigger .label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-group-trigger .chevron {
  width: 15px;
  height: 15px;
  flex: none;
  margin-left: auto;
  color: #9ca3af;
  transition: transform 200ms ease;
  transform: rotate(-90deg);
}
.nav-group.is-open > .nav-group-trigger .chevron,
.nav-group-trigger[aria-expanded="true"] .chevron {
  transform: rotate(0deg);
}
.nav-group.is-open > .nav-group-trigger,
.nav-group-trigger[aria-expanded="true"] {
  color: var(--ink);
}
.nav-group:has([aria-current="page"]) > .nav-group-trigger {
  font-weight: 700;
  color: var(--ink);
}
.nav-group:has([aria-current="page"]) > .nav-group-trigger .ico {
  color: var(--primary);
}

.nav-group-header {
  display: flex;
  align-items: center;
  border-radius: var(--radius-lg);
  min-height: clamp(32px, 3.8vh, 36px);
  transition: background 120ms ease, color 120ms ease;
  position: relative;
}
.nav-group-header:hover {
  background: var(--wash);
}
.nav-group-header.is-active,
.nav-group-header:has(.nav-group-link[aria-current="page"]) {
  background: var(--primary);
  color: #fff;
}
.nav-group-link {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: clamp(5px, 0.8vh, 8px) 4px clamp(5px, 0.8vh, 8px) 10px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  color: #374151;
  text-decoration: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  min-height: clamp(32px, 3.8vh, 36px);
  transition: color 120ms ease;
}
.nav-group-link:hover {
  text-decoration: none;
  color: var(--ink);
}
.nav-group-link .ico {
  color: #6b7280;
}
.nav-group-link .label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-group-header.is-active .nav-group-link,
.nav-group-link[aria-current="page"] {
  color: #fff !important;
}
.nav-group-header.is-active .nav-group-link .ico,
.nav-group-link[aria-current="page"] .ico {
  color: #fff !important;
}
.nav-group-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: clamp(32px, 3.8vh, 36px);
  background: transparent;
  border: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  cursor: pointer;
  color: #9ca3af;
  padding: 0;
  flex: none;
  transition: color 120ms ease, background 120ms ease;
}
.nav-group-toggle:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
}
.nav-group-header.is-active .nav-group-toggle {
  color: rgba(255, 255, 255, 0.85);
}
.nav-group-header.is-active .nav-group-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}
.nav-group-toggle .chevron {
  width: 15px;
  height: 15px;
  flex: none;
  transition: transform 200ms ease;
  transform: rotate(-90deg);
}
.nav-group.is-open > .nav-group-header .nav-group-toggle .chevron,
.nav-group-toggle[aria-expanded="true"] .chevron {
  transform: rotate(0deg);
}
.nav-group:has([aria-current="page"]) > .nav-group-header .nav-group-link {
  font-weight: 700;
  color: var(--ink);
}
.nav-group:has([aria-current="page"]) > .nav-group-header .nav-group-link .ico {
  color: var(--primary);
}
.nav-group:has(.nav-group-link[aria-current="page"]) > .nav-group-header .nav-group-link {
  color: #fff !important;
}
.nav-group:has(.nav-group-link[aria-current="page"]) > .nav-group-header .nav-group-link .ico {
  color: #fff !important;
}

.nav-group-items {
  display: grid;
  gap: 1px;
  margin-left: 17px;
  padding-left: 8px;
  border-left: 1.5px solid var(--line);
}
.nav-group-items[hidden] {
  display: none !important;
}
.nav-group-items a, .nav-group-items .nav-item {
  font-size: 13px;
  color: #4b5563;
  min-height: clamp(28px, 3.4vh, 32px);
  padding: clamp(4px, 0.6vh, 6px) 8px;
  border-radius: 6px;
}
.nav-group-items a:hover {
  color: var(--ink);
  background: var(--wash);
}
.sub-dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: 0.45;
  margin: 0 5px 0 2px;
  flex: none;
  transition: opacity 120ms ease, transform 120ms ease;
}
.nav-group-items a:hover .sub-dot {
  opacity: 0.9;
  transform: scale(1.2);
}
.nav-group-items a[aria-current="page"] .sub-dot {
  opacity: 1;
  background: #fff;
  transform: scale(1.2);
}

.nav a, .nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  padding: clamp(5px, 0.8vh, 8px) 10px;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 13.5px;
  color: #374151;
  min-height: clamp(32px, 3.8vh, 36px);
}
.nav a .ico, .nav-item .ico { color: #6b7280; }
.nav a:hover { background: var(--wash); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--primary); color: #fff; }
.nav a[aria-current="page"] .ico { color: #fff; }
.nav-item { color: var(--muted); }
.soon {
  margin-left: auto;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--wash);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 1px 6px;
}
.nav-soon { display: grid; gap: 2px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

.admin-link {
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  padding: clamp(5px, 0.7vh, 7px) 10px;
  border-radius: var(--radius-lg);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  min-height: clamp(30px, 3.6vh, 34px);
}
.admin-link:hover { background: var(--wash); color: var(--ink); text-decoration: none; }
.admin-link[aria-current="page"] { background: var(--primary); color: #fff; }
.admin-link[aria-current="page"] .ico { color: #fff; }
.admin-link[aria-current="page"]:hover { background: var(--primary); color: #fff; text-decoration: none; }

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: clamp(6px, 1vh, 10px);
  border-top: 1px solid var(--line);
  padding-top: clamp(8px, 1.2vh, 12px);
}
.sidebar-foot-links { display: grid; gap: 2px; }
.logout-form button {
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  border-radius: var(--radius-lg);
  padding: clamp(5px, 0.7vh, 7px) 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  min-height: clamp(30px, 3.6vh, 34px);
}
.logout-form button:hover { background: var(--wash); color: var(--ink); }

.sidebar-backdrop { display: none; }

.nav a:focus-visible, .nav-group-trigger:focus-visible, .nav-group-link:focus-visible, .nav-group-toggle:focus-visible, .admin-link:focus-visible, .logout-form button:focus-visible,
.sidebar-toggle:focus-visible, .sidebar-close:focus-visible, .menu-btn:focus-visible, .brand:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.nav a[aria-current="page"]:focus-visible, .nav-group-link[aria-current="page"]:focus-visible, .admin-link[aria-current="page"]:focus-visible { outline-color: var(--ink); outline-offset: -3px; }

.main { padding: clamp(16px, 2.8vw, 36px) clamp(14px, 3.2vw, 44px) 56px; min-width: 0; width: 100%; max-width: 1600px; margin: 0 auto; }

/* ── Console Navigation Bar (Back Button + GitHub-style Slash Breadcrumbs) ── */
.console-nav-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 4px 0;
  min-height: 40px;
  position: relative;
  z-index: 90;
}
.console-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.console-nav-left::-webkit-scrollbar { display: none; }
.console-nav-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.console-nav-divider {
  display: inline-block;
  width: 1px;
  height: 14px;
  background: #cbd5e1;
  margin: 0 4px;
  flex-shrink: 0;
  opacity: 0.7;
}

.console-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 6px);
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 130ms ease;
  white-space: nowrap;
}
.console-back-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  transform: translateX(-1px);
}
.console-back-btn .ico {
  width: 13px;
  height: 13px;
  opacity: 0.8;
}

.console-breadcrumbs {
  display: flex;
  align-items: center;
  min-width: 0;
}
.breadcrumb-trail {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.breadcrumb-trail li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bc-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 120ms ease;
}
.bc-link:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}
.bc-home-ico {
  width: 13px;
  height: 13px;
  opacity: 0.7;
}
.bc-sep {
  color: #9ca3af;
  font-size: 12px;
  user-select: none;
  font-weight: 400;
}
.bc-current {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Standardized Context Filter Controls (Branch, Period & Window Buttons) ── */
.context-filter-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}
.actions-divider {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--line-strong);
  margin: 0 2px;
  flex-shrink: 0;
}
.filter-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 34px;
  min-height: 34px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.filter-pill .pill-ico {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.filter-pill.branch-pill .pill-ico {
  color: var(--primary);
  opacity: 0.88;
}
.filter-pill.is-static,
.filter-pill.static {
  padding: 0 11px;
  gap: 6px;
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
  cursor: default;
}
.filter-pill .static-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.filter-pill.is-interactive {
  padding: 0;
  cursor: pointer;
}
.filter-pill.is-interactive:hover {
  background: var(--wash);
  border-color: #94a3b8;
}
.filter-pill.is-interactive:focus-within {
  background: var(--paper);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}
.filter-pill.is-interactive .pill-ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
}
.filter-pill.is-interactive .pill-chevron {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
  transition: color 140ms ease, transform 140ms ease;
}
.filter-pill.is-interactive:hover .pill-chevron,
.filter-pill.is-interactive:focus-within .pill-chevron {
  color: var(--ink);
}
.filter-pill select.filter-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 0 28px 0 30px;
  border: 0 !important;
  border-radius: inherit;
  outline: none !important;
  box-shadow: none !important;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 32px;
  cursor: pointer;
}
.filter-pill select.filter-select option {
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 12px;
}

/* ── Standardized Action Bar Dropdown Menu (e.g. Export CSV) ── */
.action-menu-wrap {
  position: relative;
  display: inline-flex;
}
.action-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-xl);
  z-index: 60;
}
.action-dropdown-menu.is-open {
  display: block;
}
.action-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.action-dropdown-item:hover {
  background: var(--wash);
  color: var(--ink);
  text-decoration: none;
}

/* ── Compact In-Page Section Anchor Strip ── */
.clinical-anchor-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.clinical-anchor-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 6px 0 4px;
}
.clinical-anchor-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: var(--radius-lg);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.clinical-anchor-pill:hover {
  background: var(--wash);
  color: var(--ink);
  border-color: var(--line);
  text-decoration: none;
}

/* ── QI Portfolio Filter Tabs ── */
.btn-tab {
  background: transparent;
  transition: all 0.15s ease;
}
.btn-tab.active {
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  color: var(--ink);
}

/* ── Modern KPI Summary UI ── */
.kpi-section {
  position: relative;
}
.kpi-health-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  margin-bottom: 16px;
}
.kpi-health-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.kpi-health-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}
.kpi-health-pill.green { background: var(--positive-tint); color: var(--positive-strong); }
.kpi-health-pill.amber { background: var(--amber-100); color: var(--amber); }
.kpi-health-pill.red { background: #fee2e2; color: #b91c1c; }
.kpi-health-pill.none { background: #f1f5f9; color: var(--muted); }

.kpi-filter-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.kpi-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 120ms ease;
}
.kpi-tab-btn:hover {
  background: var(--wash);
  color: var(--ink);
}
.kpi-tab-btn.active {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.kpi-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.kpi-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}
.kpi-card.status-green { border-top: 3.5px solid var(--positive); }
.kpi-card.status-amber { border-top: 3.5px solid var(--amber); }
.kpi-card.status-red { border-top: 3.5px solid var(--primary); }
.kpi-card.status-none { border-top: 3.5px solid #cbd5e1; }

.kpi-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.kpi-cat-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.kpi-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.kpi-status-tag.green { background: var(--positive-tint); color: var(--positive-strong); }
.kpi-status-tag.amber { background: var(--amber-100); color: var(--amber); }
.kpi-status-tag.red { background: #fee2e2; color: #b91c1c; }
.kpi-status-tag.none { background: #f1f5f9; color: var(--muted); }

.kpi-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-metric-val {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.kpi-metric-val.val-green { color: var(--positive-strong); }
.kpi-metric-val.val-amber { color: var(--amber); }
.kpi-metric-val.val-red { color: var(--primary); }
.kpi-metric-val.val-none { color: #94a3b8; font-size: 17px; font-weight: 600; }

.kpi-name-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.kpi-target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.kpi-variance-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}
.kpi-variance-badge.pos { background: #dcfce7; color: #15803d; }
.kpi-variance-badge.neg { background: #fee2e2; color: #b91c1c; }

.kpi-card-footer {
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}
.kpi-source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  background: #eff6ff;
  padding: 2px 7px;
  border-radius: 4px;
  transition: all 120ms ease;
  font-size: 11px;
}
.kpi-source-link:hover {
  background: #dbeafe;
  color: #1d4ed8;
  text-decoration: none;
}
.kpi-source-link.manual {
  color: #4b5563;
  background: #f3f4f6;
}
.kpi-source-link.manual:hover {
  background: #e5e7eb;
  color: #111827;
}

.kpi-info-trigger {
  background: none;
  border: 0;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  border-radius: 50%;
  transition: color 120ms ease;
}
.kpi-info-trigger:hover {
  color: var(--ink);
}

/* ── KPI Calculation Reference Drawer / Modal ── */
.kpi-guide-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.kpi-guide-modal[hidden] { display: none !important; }
.kpi-guide-box {
  background: var(--paper);
  border-radius: var(--radius-2xl);
  max-width: 860px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.kpi-guide-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-guide-body {
  padding: 20px;
  overflow-y: auto;
}

/* ── Pharmacy Compact Side-by-side Overview Cards ── */
.pharmacy-compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 860px) {
  .pharmacy-compact-grid { grid-template-columns: 1fr; }
}
.compact-stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0 8px;
}
.compact-stat-box {
  flex: 1 1 110px;
  background: var(--wash);
  border-radius: var(--radius-lg);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.compact-stat-val {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}
.compact-stat-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.compact-alert-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: var(--radius-lg);
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}
.compact-alert-banner.good { background: var(--positive-tint); color: var(--positive-strong); }
.compact-alert-banner.warn { background: var(--amber-100); color: var(--amber); }
.compact-alert-banner.alert { background: #fee2e2; color: #b91c1c; }

/* ── DDA Unified Card Styles ── */
.dda-unified-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.dda-drug-pill-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: thin;
}
.dda-drug-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: all 120ms ease;
}
.dda-drug-pill:hover {
  background: #e2e8f0;
  text-decoration: none;
}
.dda-drug-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}
.dda-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}

/* ── Spreadsheet Interactive Data Grid (Expiries Tracker & Bulk Entry) ── */
.excel-grid-card {
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.excel-summary-ribbon {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.ribbon-stat-item {
  flex: 1 1 120px;
  background: var(--wash);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.ribbon-stat-val {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}
.ribbon-stat-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
}
.grid-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}
.grid-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.grid-search-input {
  max-width: 260px;
  min-width: 180px;
  padding: 6px 10px 6px 12px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
}
.grid-filter-pill-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--wash);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}
.grid-filter-btn {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 120ms ease;
  text-decoration: none;
}
.grid-filter-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
}
.grid-filter-btn.active {
  background: #ffffff;
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.editable-grid-wrap {
  position: relative;
  max-height: 62vh;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  background: #ffffff;
}
.editable-grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.editable-grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 10px;
  border-bottom: 2px solid var(--line);
  border-right: 1px solid #f1f5f9;
  white-space: nowrap;
}
.editable-grid-table tbody tr {
  transition: background 80ms ease;
}
.editable-grid-table tbody tr:hover {
  background: rgba(241, 245, 249, 0.6);
}
.editable-grid-table tbody tr.is-dirty {
  background: #fffdf5;
  border-left: 3px solid var(--amber);
}
.editable-grid-table tbody tr.is-new {
  background: #f4fbf7;
  border-left: 3px solid var(--positive-strong);
}
.editable-grid-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #f8fafc;
  vertical-align: middle;
}
.cell-input {
  width: 100%;
  padding: 5px 7px;
  font-size: 12px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-family: inherit;
  transition: all 120ms ease;
  box-sizing: border-box;
}
.cell-input:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}
.cell-input:focus {
  outline: none;
  border-color: var(--blue);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(23, 92, 211, 0.15);
}
.cell-input.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.grid-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.grid-status-badge.expired { background: #fee2e2; color: #b91c1c; }
.grid-status-badge.critical { background: #fef3c7; color: #b45309; }
.grid-status-badge.warning { background: #fef9c3; color: #854d0e; }
.grid-status-badge.ok { background: #ecfdf5; color: #047857; }

/* ── DDA Multi-Medicine & Inline Entry Styles ── */
.dda-inline-entry-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.dda-inline-entry-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  align-items: flex-end;
}
.dda-stockcard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.dda-all-cards-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}


.page-header-deck {
  display: contents;
}
.page-header-deck.is-sticky {
  display: block;
  position: sticky;
  top: 0;
  z-index: 45;
  background: rgba(243, 244, 246, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin: -6px -10px 18px;
  padding: 8px 10px 10px;
  border: 1px solid transparent;
  border-top: 0;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.page-header-deck.is-sticky.is-stuck {
  background: rgba(255, 255, 255, 0.97);
  border-color: var(--line);
  box-shadow: 0 8px 20px -10px rgba(15, 23, 42, 0.12);
}
.page-header-deck.is-sticky .topbar {
  margin-bottom: 12px;
}
.page-header-deck.is-sticky.is-stuck .perf-subtitle {
  display: none;
}

.clinical-tabs-bar-shell {
  padding: 0;
  margin: 0;
}
.clinical-cluster-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius-xl, 12px);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.cluster-tab-btn {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.25;
  color: var(--muted, #636363);
  border-radius: var(--radius-lg, 8px);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 130ms ease, color 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}
.cluster-tab-btn:hover {
  background: var(--wash, #f3f4f6);
  color: var(--ink, #161616);
}
.cluster-tab-btn:focus-visible {
  outline: 2px solid var(--primary, #d40924);
  outline-offset: -2px;
}
.cluster-tab-btn.is-active {
  background: var(--paper, #ffffff);
  color: var(--primary, #d40924);
  font-weight: 700;
  border-color: var(--line-strong, #d1d5db);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.cluster-tab-btn.cluster-tab-all:not(.is-active) {
  background: rgba(243, 244, 246, 0.55);
  border-color: rgba(209, 213, 219, 0.55);
}
.cluster-tab-btn.cluster-tab-all:not(.is-active):hover {
  background: var(--wash, #f3f4f6);
  border-color: var(--line-strong, #d1d5db);
}
@media (max-width: 640px) {
  .clinical-cluster-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cluster-tab-btn {
    padding: 6px 8px;
    font-size: 12px;
  }
  .cluster-tab-btn.cluster-tab-all {
    grid-column: 1 / -1;
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 42px;
  margin-bottom: 20px;
}
.topbar > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}
.topbar h1 { margin: 0; font-size: clamp(22px, 2.6vw, 28px); line-height: 1.2; letter-spacing: -0.03em; overflow-wrap: break-word; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ── Global Header Search Bar & Widget (Lively, Sleek & Inviting) ── */
.global-search-widget,
.topbar-search {
  position: relative;
  width: clamp(290px, 31vw, 390px);
  max-width: 100%;
  transition: width 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.global-search-widget:focus-within,
.topbar-search:focus-within {
  width: clamp(330px, 36vw, 440px);
}
.global-search-form {
  position: relative;
  width: 100%;
  margin: 0;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 38px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px -1px rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  cursor: text;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.search-input-wrap:hover {
  border-color: rgba(212, 9, 36, 0.35);
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(212, 9, 36, 0.05);
}
.search-input-wrap:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(212, 9, 36, 0.12), 0 6px 16px -4px rgba(15, 23, 42, 0.08);
}
.search-icon-badge {
  position: absolute;
  left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(212, 9, 36, 0.08);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  transition: background 150ms ease, color 150ms ease;
}
.search-input-wrap:hover .search-icon-badge {
  background: rgba(212, 9, 36, 0.14);
}
.search-input-wrap:focus-within .search-icon-badge {
  background: var(--primary);
  color: #ffffff;
}
.search-icon-badge .search-icon {
  width: 14px;
  height: 14px;
  color: currentColor;
  pointer-events: none;
}
.topbar-search .ico {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: #64748b;
  pointer-events: none;
  transition: color 140ms ease;
  z-index: 2;
}
.topbar-search:focus-within .ico {
  color: var(--primary);
}
.global-search-input,
.topbar-search-input {
  width: 100%;
  height: 100%;
  padding: 0 68px 0 39px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
  border-radius: var(--radius-full);
  -webkit-appearance: none;
}
.global-search-input::placeholder,
.topbar-search-input::placeholder {
  color: #64748b;
  font-size: 12.5px;
}
.search-input-wrap.is-rotator-ready .global-search-input:placeholder-shown:not(:focus)::placeholder {
  color: transparent;
}
.search-prompt-rotator {
  display: none;
  align-items: center;
  position: absolute;
  left: 39px;
  right: 68px;
  top: 0;
  bottom: 0;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  z-index: 1;
}
.search-input-wrap.is-rotator-ready .global-search-input:placeholder-shown:not(:focus) ~ .search-prompt-rotator {
  display: flex;
}
.search-prompt-text {
  font-size: 12.5px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 190ms ease, transform 190ms ease;
}
.search-prompt-text.is-changing {
  opacity: 0;
  transform: translateY(-4px);
}
.search-input-affixes {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
}
.search-kbd-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2.5px 5.5px;
  border-radius: 5px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 0 #cbd5e1;
  color: #475569;
  font-size: 10px;
  font-family: inherit;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}
.search-kbd-shortcut kbd {
  font-family: inherit;
  font-size: 9.5px;
}
.search-input-wrap:focus-within .search-kbd-shortcut {
  display: none;
}
.search-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: #e2e8f0;
  color: #475569;
  border-radius: 50%;
  cursor: pointer;
  transition: all 120ms ease;
}
.search-clear-btn:hover {
  background: #cbd5e1;
  color: var(--ink);
}
.search-clear-btn .ico {
  width: 10px;
  height: 10px;
}
.search-spinner {
  display: none;
  width: 15px;
  height: 15px;
  color: var(--primary);
  animation: searchSpin 0.75s linear infinite;
}
.search-spinner.htmx-request {
  display: inline-flex;
}
@keyframes searchSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spinner-svg {
  width: 100%;
  height: 100%;
}
.global-search-input::-webkit-search-cancel-button,
.topbar-search-input::-webkit-search-cancel-button {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.topbar-actions .btn.small {
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  gap: 6px;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.topbar-actions .btn.secondary.small {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.topbar-actions .btn.secondary.small:hover {
  background: var(--wash);
  border-color: #94a3b8;
}
.topbar-actions .btn.small .ico {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.topbar-actions .btn-chip {
  height: 34px;
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: var(--radius-lg);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 10px 15px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.92); text-decoration: none; }
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--wash); }
.btn.danger { background: var(--paper); color: var(--primary); border-color: var(--primary); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: var(--radius-lg); }

.up { color: var(--positive); }
.down { color: var(--primary); }
.same { color: var(--muted); }

.grid { display: grid; gap: clamp(12px, 1.6vw, 18px); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: clamp(14px, 1.8vw, 22px);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card .grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card h2, .card h3 { margin: 0 0 4px; letter-spacing: -0.02em; overflow-wrap: break-word; }
.card h2 { font-size: 19px; }
.card h3 { font-size: 16px; }
.card .muted { color: var(--muted); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-head > div:first-child { min-width: 0; flex: 1 1 200px; }

.hero {
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: var(--radius-xl);
  padding: clamp(16px, 2.5vw, 26px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: clamp(16px, 2.2vw, 24px);
  align-items: center;
  overflow: hidden;
  min-width: 0;
}

.hero h2 { color: #fff; font-size: clamp(22px, 3.2vw, 38px); letter-spacing: -0.04em; margin: 0; }
.hero p { color: #fff; margin: 6px 0 0; }
.hero .muted { color: #fff; }
.hero-score { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero-score .number { font-size: clamp(38px, 6vw, 68px); font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.hero-meta { display: grid; gap: 10px; }
.hero-meta .metric { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid rgba(255,255,255,0.16); padding-bottom: 9px; }
.hero-meta .metric span:first-child { color: #fff; }
.hero-meta .metric strong { color: #fff; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--wash);
  color: var(--muted);
}
.badge.excellent { background: var(--positive-tint); color: var(--positive-strong); }
.badge.good { background: var(--blue-100); color: var(--blue); }
.badge.needs-improvement { background: var(--amber-100); color: var(--amber); }
.badge.poor { background: var(--wash); color: var(--primary); }
.badge.not-assessed, .badge.na { background: var(--wash); color: var(--muted); }
.badge.open { background: var(--wash); color: var(--primary); }
.badge.in-progress { background: var(--amber-100); color: var(--amber); }
.badge.done { background: var(--blue-100); color: var(--blue); }
.badge.verified { background: var(--positive-tint); color: var(--positive-strong); }
.badge.warn { background: var(--amber-100); color: var(--amber); }

.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-box { background: var(--wash); border-radius: var(--radius-xl); padding: 14px; }
.metric-box .value { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.metric-box .label { font-size: 12px; color: var(--muted); }

/* Card Title Link with Subtle Arrow */
.card-title-link {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 120ms ease;
}
.card-title-link:hover {
  color: var(--primary);
  text-decoration: none;
}
.card-title-link .arrow {
  font-size: 0.9em;
  color: var(--muted);
  transition: transform 150ms ease, color 150ms ease;
}
.card-title-link:hover .arrow {
  color: var(--primary);
  transform: translateX(3px);
}

/* Stat Grid: Clean typography without nested box borders */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 12px 0;
}
.stat-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.card > .stat-grid:first-child {
  margin-top: 0;
}
.card > .stat-grid:last-child {
  margin-bottom: 0;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-val {
  font-size: clamp(18px, 1.6vw, 22px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-val .curr {
  font-size: 0.65em;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
  margin-right: 2px;
}
.stat-val .unit {
  font-size: 0.7em;
  font-weight: 600;
  color: var(--muted);
  margin-left: 1px;
}
.stat-lbl {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quality Hero Stat Row */
.stat-hero {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.stat-val-lg {
  font-size: clamp(28px, 2.8vw, 36px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat-hero-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-hero-meta strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.stat-hero-meta .meta-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action Chips: Sleek, non-boxy button chips */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--wash);
}
.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-decoration: none;
  min-height: 28px;
  transition: all 120ms ease;
  user-select: none;
  white-space: nowrap;
}
.btn-chip:hover {
  background: #e5e7eb;
  color: var(--ink);
  text-decoration: none;
  border-color: #d1d5db;
}
.btn-chip.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-chip.primary:hover {
  filter: brightness(0.92);
  color: #fff;
}
.btn-chip.disabled {
  opacity: 0.6;
  cursor: default;
  background: transparent;
  border-style: dashed;
}
.btn-chip.disabled:hover {
  background: transparent;
  color: #374151;
}

.badge.small {
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}

/* Needs Attention list */
.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.attention-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.attention-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.attention-list li:first-child {
  padding-top: 0;
}
.attention-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.attention-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.attention-title:hover {
  color: var(--primary);
  text-decoration: underline;
}
.attention-sub {
  font-size: 11.5px;
  color: var(--muted);
}
.attention-list .empty-state {
  padding: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 9999px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
tbody tr:hover { background: #f9fafb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; }
.activity-table td { font-size: 13.5px; padding: 9px 10px; }
.claims-table td { font-size: 13px; }

.progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--line);
  overflow: hidden;
  min-width: 80px;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #a7f3d0);
}

.list { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; }
.list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; padding-bottom: 0; }
.list .title { font-weight: 650; }
.list .sub { color: var(--muted); font-size: 12px; }

.empty {
  text-align: center;
  padding: 56px 22px;
  color: var(--muted);
}
.empty h2 { color: var(--ink); }

.alert {
  border-radius: var(--radius-xl);
  padding: 12px 15px;
  margin-bottom: 16px;
  background: var(--blue-100);
  color: var(--blue);
  border: 1px solid #c7dcff;
}
.alert.error { background: var(--wash); color: var(--primary); border-color: var(--primary); }
.alert.success { background: var(--positive-tint); color: var(--positive-strong); border-color: #bfe3cc; }
.alert.warning { background: var(--amber-100); color: var(--amber); border-color: #f4daa0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-field { display: grid; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-weight: 650; font-size: 13px; }
.form-field .help { color: var(--muted); font-size: 12px; }
.input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
}
.input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
textarea { resize: vertical; }
.checkbox { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
.errorlist { color: var(--primary); margin: 0; padding-left: 18px; font-size: 13px; }

.criterion-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  background: var(--paper);
  display: grid;
  gap: 12px;
}
.criterion-card.has-error { border-color: var(--primary); }
.criterion-top { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.criterion-ref { font-size: 12px; font-weight: 800; color: var(--primary); letter-spacing: 0.04em; }
.criterion-text { margin: 3px 0 0; }
.criterion-note { background: var(--wash); border-left: 3px solid var(--line-strong); padding: 8px 10px; border-radius: 0 8px 8px 0; color: var(--muted); font-size: 13px; }
.criterion-controls { display: grid; gap: 10px; }
.score-options { display: flex; gap: 8px; flex-wrap: wrap; }
.score-option { position: relative; cursor: pointer; }
.score-option input { position: absolute; opacity: 0; pointer-events: none; }
.score-option span {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  font-weight: 700;
  background: var(--paper);
}
.score-option span small { font-weight: 500; margin-left: 5px; color: var(--muted); }
.score-option input:checked + span { border-color: var(--primary); background: var(--paper); color: var(--primary); }
.score-option input:focus-visible + span { outline: 2px solid var(--primary); }
.score-option.na input:checked + span { border-color: var(--line-strong); background: var(--wash); color: var(--muted); }
.criterion-comment { display: flex; gap: 10px; align-items: flex-start; }
.criterion-comment textarea { min-height: 42px; }
.saved-note { color: var(--positive); font-size: 12px; font-weight: 650; }
.error-note { color: var(--primary); font-size: 13px; }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 24px 0 12px;
}
.section-head h2 { margin: 0; font-size: 18px; }
.section-head .summary { color: var(--muted); font-size: 13px; }
.criteria-stack { display: grid; gap: 10px; }

.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr); gap: 18px; align-items: start; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--primary);
  padding: 24px;
}
.auth-card { width: min(430px, 100%); background: var(--paper); border-radius: var(--radius-2xl); padding: 30px; box-shadow: var(--shadow-xl); }
.auth-card h1 { margin: 0 0 6px; letter-spacing: -0.03em; }
.auth-card p { color: var(--muted); margin: 0 0 22px; }
.auth-card .form-field { margin-bottom: 14px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }

.mobile-more { display: none; }

@media (min-width: 1024px) {
  html[data-sidebar="collapsed"] .app-shell { grid-template-columns: 64px minmax(0, 1fr); }
  html[data-sidebar="collapsed"] .sidebar {
    width: 64px;
    padding-left: 10px;
    padding-right: 10px;
    z-index: 110;
    overflow: visible;
    transition: width 180ms ease, padding 180ms ease, box-shadow 180ms ease;
  }
  html[data-sidebar="collapsed"] .sidebar.is-peek {
    width: 264px;
    padding-left: 14px;
    padding-right: 14px;
    box-shadow: var(--shadow-xl);
  }
  html[data-sidebar="collapsed"] .sidebar-head { flex-direction: column; }
  html[data-sidebar="collapsed"] .brand { flex: none; justify-content: center; }
  html[data-sidebar="collapsed"] .brand-text { display: none; }
  html[data-sidebar="collapsed"] .sidebar-toggle svg { transform: rotate(180deg); }
  html[data-sidebar="collapsed"] .nav-label { display: none; }
  html[data-sidebar="collapsed"] .nav-soon { display: none; }
  html[data-sidebar="collapsed"] .nav a { justify-content: center; padding-left: 4px; padding-right: 4px; }
  html[data-sidebar="collapsed"] .nav-group-trigger { justify-content: center; padding-left: 4px; padding-right: 4px; }
  html[data-sidebar="collapsed"] .nav-group-trigger .chevron,
  html[data-sidebar="collapsed"] .nav-group-trigger .soon { display: none; }
  html[data-sidebar="collapsed"] .nav-group-header { justify-content: center; }
  html[data-sidebar="collapsed"] .nav-group-toggle { display: none; }
  html[data-sidebar="collapsed"] .nav-group-link { justify-content: center; padding-left: 4px; padding-right: 4px; width: 100%; border-radius: var(--radius-lg); }
  html[data-sidebar="collapsed"] .nav-group-items { margin-left: 0; padding-left: 0; border-left: 0; }
  html[data-sidebar="collapsed"]:not(.is-peek) .nav-group-items { display: none !important; }
  html[data-sidebar="collapsed"] .logout-form button { justify-content: center; padding-left: 4px; padding-right: 4px; }
  html[data-sidebar="collapsed"] .admin-link { justify-content: center; padding-left: 4px; padding-right: 4px; }
  html[data-sidebar="collapsed"] .sidebar .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  html[data-sidebar="collapsed"] .profile-chip {
    justify-content: center;
    padding: 6px;
    background: transparent;
    border-color: transparent;
  }
  html[data-sidebar="collapsed"] .profile-text { display: none; }

  /* peek restores full-width content inside the overflowing rail */
  html[data-sidebar="collapsed"] .sidebar.is-peek .sidebar-head { flex-direction: row; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .brand { flex: 1; justify-content: flex-start; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .brand-text { display: block; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-label { display: block; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-soon { display: grid; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav a,
  html[data-sidebar="collapsed"] .sidebar.is-peek .admin-link,
  html[data-sidebar="collapsed"] .sidebar.is-peek .logout-form button {
    justify-content: flex-start;
    padding-left: 11px;
    padding-right: 11px;
  }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-group-trigger {
    justify-content: flex-start;
    padding-left: 11px;
    padding-right: 11px;
  }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-group-trigger .chevron { display: block; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-group-header { justify-content: flex-start; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-group-toggle { display: grid; }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-group-link { justify-content: flex-start; padding-left: 11px; width: auto; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
  html[data-sidebar="collapsed"] .sidebar.is-peek .nav-group-items {
    margin-left: 18px;
    padding-left: 8px;
    border-left: 1.5px solid var(--line);
  }
  html[data-sidebar="collapsed"] .sidebar.is-peek .label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
  }
  html[data-sidebar="collapsed"] .sidebar.is-peek .profile-chip {
    justify-content: flex-start;
    padding: 8px 10px;
    background: var(--paper);
    border-color: var(--line);
  }
  html[data-sidebar="collapsed"] .sidebar.is-peek .profile-text { display: grid; }
}

/* Compact sidebar heights for short viewports (1366x768, 1280x800, 13" laptops) */
@media (max-height: 760px) and (min-width: 1024px) {
  .sidebar {
    padding: 8px 10px;
    gap: 5px;
  }
  .brand-mark { width: 30px; height: 30px; font-size: 12px; }
  .brand strong { font-size: 13px; }
  .brand small { font-size: 10px; }
  .sidebar-toggle { width: 28px; height: 28px; }
  .profile-chip { padding: 5px 8px; gap: 8px; }
  .avatar { width: 28px; height: 28px; font-size: 11px; }
  .profile-text strong { font-size: 12px; }
  .profile-text small { font-size: 10px; }
  .nav-label { margin: 6px 0 2px; font-size: 10px; }
  .nav-group { gap: 0; margin-top: 1px; }
  .nav-group-trigger {
    padding: 4px 8px;
    min-height: 28px;
    font-size: 12.5px;
    gap: 7px;
  }
  .nav-group-trigger .ico { width: 14px; height: 14px; }
  .nav-group-trigger .chevron { width: 13px; height: 13px; }
  .nav-group-header { min-height: 28px; }
  .nav-group-link {
    padding: 4px 4px 4px 8px;
    min-height: 28px;
    font-size: 12.5px;
    gap: 7px;
  }
  .nav-group-link .ico { width: 14px; height: 14px; }
  .nav-group-toggle { width: 28px; min-height: 28px; }
  .nav-group-toggle .chevron { width: 13px; height: 13px; }
  .nav-group-items {
    margin-left: 14px;
    padding: 2px 0 2px 6px;
    gap: 1px;
  }
  .nav-group-items a, .nav-group-items .nav-item {
    padding: 3px 8px;
    min-height: 25px;
    font-size: 12px;
    gap: 7px;
  }
  .nav a, .nav-item {
    padding: 4px 8px;
    min-height: 28px;
    font-size: 12.5px;
    gap: 7px;
  }
  .nav a .ico, .nav-item .ico { width: 14px; height: 14px; }
  .nav-soon { margin-top: 6px; padding-top: 6px; gap: 1px; }
  .sidebar-foot { gap: 5px; padding-top: 6px; }
  .admin-link {
    padding: 4px 8px;
    min-height: 27px;
    font-size: 12px;
    gap: 7px;
  }
  .admin-link .ico { width: 14px; height: 14px; }
  .logout-form button {
    padding: 4px 8px;
    min-height: 27px;
    font-size: 12px;
    gap: 7px;
  }
  .logout-form button .ico { width: 14px; height: 14px; }
}

@media (max-width: 1023.98px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; transition: none; }
  .mobilebar {
    display: flex;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .menu-btn { display: grid; }
  .sidebar-toggle { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: min(300px, 86vw);
    z-index: 120;
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: var(--shadow-xl);
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    transition: transform 200ms ease, visibility 0s linear 200ms;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 200ms ease;
  }
  .sidebar-close { display: grid; }
  .nav a, .nav-item { min-height: 44px; }
  .nav-group-trigger { min-height: 44px; }
  .nav-group-header { min-height: 44px; }
  .nav-group-link { min-height: 44px; }
  .nav-group-toggle { width: 44px; min-height: 44px; }
  .nav-group-items a, .nav-group-items .nav-item { min-height: 42px; }
  .admin-link { min-height: 44px; }

  .sidebar-backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 110;
  }
  body.nav-open { overflow: hidden; }

  .hero { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .page-header-deck.is-sticky { top: 56px; }
}

@media (max-width: 900px) {
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .grid.three, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .main { padding: 18px 14px 40px; }
  .console-nav-strip { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .console-nav-left { width: 100%; }
  .console-nav-right { width: 100%; }
  .global-search-widget, .global-search-widget:focus-within, .topbar-search, .topbar-search:focus-within { width: 100%; }
  .search-input-wrap { height: 40px; }
  .global-search-input, .topbar-search-input { height: 40px; font-size: 13.5px; padding: 0 38px 0 40px; }
  .search-prompt-rotator { left: 40px; right: 38px; }
  .search-prompt-text { font-size: 13px; }
  .search-kbd-shortcut { display: none; }
  .topbar-search .ico { left: 12px; width: 16px; height: 16px; }
  .search-dropdown { width: 100%; max-width: 100%; right: 0; left: 0; }
  .topbar { flex-direction: column; gap: 12px; align-items: stretch; min-height: 0; }
  .page-header-deck.is-sticky { margin: -4px -6px 14px; padding: 6px 6px 8px; }
  .page-header-deck.is-sticky .topbar { gap: 8px; margin-bottom: 8px; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .topbar-actions .actions-divider { display: none; }
  .topbar-actions .btn:not(.small) { flex: 1 1 calc(50% - 6px); justify-content: center; }

  .card form .flex, form.card .flex {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px !important;
    width: 100%;
  }
  .card form .flex .form-field, form.card .flex .form-field {
    min-width: 0 !important;
    width: 100% !important;
  }
  .card form .flex .form-field:has(input[type="search"]),
  .card form .flex .form-field:has(input[type="text"]),
  .card form .flex .form-field.full {
    grid-column: 1 / -1;
  }
  .card form .flex > div:has(.btn), form.card .flex > div:has(.btn) {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
  }
  .card form .flex > div:has(.btn) .btn, form.card .flex > div:has(.btn) .btn {
    flex: 1;
    justify-content: center;
  }

  .grid.three, .grid.four, .form-grid, .metric-row, .card .grid.two { grid-template-columns: 1fr; }
  .criterion-top { flex-direction: column; gap: 8px; }
  .criterion-comment { flex-direction: column; }
  .criterion-comment textarea { width: 100%; }
  .btn:not(.small):not(.btn-chip) { min-height: 44px; }
  .btn.small { min-height: 32px; padding: 4px 10px; font-size: 12px; }
  .input, select, textarea { font-size: 16px; min-height: 44px; }
  .score-option span { min-height: 44px; }
  .list li { flex-wrap: wrap; align-items: flex-start; }
  .list li > div:first-child { min-width: 0; flex: 1 1 60%; }

  .card { padding: 13px 14px; border-radius: var(--radius-lg); }
  .card-head { margin-bottom: 10px; gap: 8px; }
  .card-head h2 { font-size: 16px; }
  .card-head .muted { font-size: 11.5px; }
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px 12px;
    margin: 8px 0;
  }
  .stat-val { font-size: 18px; }
  .stat-lbl { font-size: 11px; }
  .stat-hero { gap: 8px; padding-bottom: 8px; margin-bottom: 8px; }
  .stat-val-lg { font-size: 26px; }
  .card-actions { margin-top: 10px; padding-top: 8px; gap: 5px; }
  .btn-chip { padding: 4px 8px; font-size: 11.5px; min-height: 28px; }
  .attention-list li { padding: 8px 0; }
  .attention-title { font-size: 13px; }
  .attention-sub { font-size: 11px; }

  .table-wrap.table-scroll table { min-width: 580px; }

  .table-wrap:not(.table-scroll) thead { display: none; }
  .table-wrap:not(.table-scroll),
  .table-wrap:not(.table-scroll) tbody,
  .table-wrap:not(.table-scroll) tr,
  .table-wrap:not(.table-scroll) td { display: block; width: 100%; }
  .table-wrap:not(.table-scroll) tr {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: 10px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  }
  .table-wrap:not(.table-scroll) tr:last-child { margin-bottom: 0; }
  .table-wrap:not(.table-scroll) td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: normal;
    min-height: 32px;
  }
  .table-wrap:not(.table-scroll) td:last-child { border-bottom: 0; }
  .table-wrap:not(.table-scroll) td[data-label]::before {
    content: attr(data-label);
    font-weight: 650;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex: none;
    margin-right: 12px;
  }
  .table-wrap:not(.table-scroll) td:not([data-label])::before { display: none; }
  .table-wrap:not(.table-scroll) td.num { text-align: right; }
  .table-wrap:not(.table-scroll) td.num::before { margin-right: auto; }
  .table-wrap:not(.table-scroll) td.actions { justify-content: flex-end; }
  .table-wrap:not(.table-scroll) td.actions::before { display: none; }
  .table-wrap:not(.table-scroll) td:empty { display: none; }

  .hide-mobile { display: none !important; }
  .activity-table td { font-size: 12px; padding: 7px 8px; }
  .claims-table td { font-size: 12px; padding: 5px 6px; }
  [data-mobile-hide] { display: none !important; }
  [data-mobile-hide].mobile-shown { display: revert !important; }
  .mobile-shown .grid.two { display: grid !important; grid-template-columns: 1fr; }
  .mobile-shown .split { display: grid !important; grid-template-columns: 1fr; }
  .mobile-more { display: none; }
  .mobile-more.show {
    display: flex;
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .main { padding: 14px 10px 32px; }
  th, td { padding: 8px 7px; font-size: 13px; }
  .card { padding: 10px 12px; }
  .card-head h2 { font-size: 15px; }
  .card-head .muted { font-size: 11px; }
  .stat-val { font-size: 16.5px; }
  .stat-lbl { font-size: 10.5px; }
  .stat-val-lg { font-size: 24px; }
  .card-actions { margin-top: 8px; padding-top: 6px; gap: 4px; }
  .btn-chip { padding: 3px 7px; font-size: 11px; min-height: 26px; }
  .metric-box { padding: 10px; }
  .metric-box .value { font-size: 18px; }
  .table-wrap tr { padding: 8px 10px; }
  .hero-score .number { font-size: 32px; }
  .topbar h1 { font-size: 20px; }
  .topbar-actions { width: 100%; gap: 6px; }
  .topbar-actions .btn { flex: 1 1 100%; justify-content: center; }
  .topbar-actions .btn.small { flex: 1 1 calc(50% - 4px); min-height: 32px; font-size: 12px; }
  .card form .flex, form.card .flex { grid-template-columns: 1fr !important; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .metric-row { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell, .sidebar, .sidebar-toggle svg, .nav-group-trigger .chevron { transition: none !important; }
}

/* ── Power Search Dropdown & Interactive Flyout (Sleek & Minimalist) ── */
.search-dropdown[hidden] {
  display: none !important;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 420px;
  max-width: min(420px, calc(100vw - 24px));
  z-index: 150;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
  animation: dropdownAnim 140ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 4px 0;
}
@keyframes dropdownAnim {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.search-dropdown::-webkit-scrollbar { width: 4px; }
.search-dropdown::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: var(--radius-full); }

/* Result group */
.search-group {
  display: flex;
  flex-direction: column;
}
.search-group + .search-group {
  border-top: 1px solid #f1f5f9;
  margin-top: 3px;
  padding-top: 3px;
}

/* Group header row */
.search-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  background: transparent;
}
.search-group-header .ico {
  width: 12px;
  height: 12px;
  color: #64748b;
  flex: none;
}
.search-group-title {
  font-weight: 700;
}
.search-group-count {
  font-size: 9.5px;
  font-weight: 600;
  color: #94a3b8;
}
.search-primary-label {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(212, 9, 36, 0.07);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Individual result row */
.search-hit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin: 1px 6px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  transition: background 100ms ease;
  position: relative;
}
.search-hit:hover,
.search-hit.is-selected,
.search-hit:focus-visible {
  background: #f8fafc;
  text-decoration: none;
  outline: none;
}
.search-hit.is-selected {
  background: #f1f5f9;
}
.search-hit-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.search-hit-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-hit:hover .search-hit-title,
.search-hit.is-selected .search-hit-title {
  color: var(--primary);
}
.search-hit-sub {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-hit-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 9.5px !important;
  padding: 1px 6px !important;
  font-weight: 600 !important;
}
.search-hit-arrow {
  width: 12px;
  height: 12px;
  color: #cbd5e1;
  flex: none;
  opacity: 0;
  transition: opacity 100ms ease, transform 100ms ease;
}
.search-hit:hover .search-hit-arrow,
.search-hit.is-selected .search-hit-arrow {
  opacity: 1;
  transform: translateX(1px);
  color: var(--primary);
}

/* Footer row */
.search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  background: #fafafa;
  font-size: 11px;
  margin-top: 4px;
}
.search-footer-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #94a3b8;
}
.search-footer-hint kbd {
  padding: 1px 3px;
  border-radius: 3px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  font-size: 9px;
  color: #64748b;
}
.search-see-all {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.search-see-all:hover {
  text-decoration: underline;
}

/* Empty state */
.search-empty {
  padding: 18px 14px;
  text-align: center;
}
.search-empty-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.search-empty-sub {
  font-size: 11px;
  color: #64748b;
  margin-top: 3px;
}

/* Zero-state quick guide & workspace jumpstart */
.search-zero-dropdown {
  padding: 0;
}
.search-zero-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 14px 9px;
  background: linear-gradient(180deg, #fffafa 0%, #ffffff 100%);
  border-bottom: 1px solid #f1f5f9;
}
.search-zero-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.search-zero-sub {
  font-size: 11px;
  color: #64748b;
}
.search-zero-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}
.search-zero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 2px 10px 8px;
}
.search-quick-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
  background: #fcfcfd;
  color: var(--ink);
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.search-quick-card:hover,
.search-quick-card.is-selected,
.search-quick-card:focus-visible {
  background: #fff5f5;
  border-color: rgba(212, 9, 36, 0.24);
  text-decoration: none;
  outline: none;
}
.search-quick-card.is-current {
  border-color: rgba(212, 9, 36, 0.18);
  background: #fffafa;
}
.search-quick-ico {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}
.search-quick-ico .ico {
  width: 14px;
  height: 14px;
}
.search-quick-card:hover .search-quick-ico,
.search-quick-card.is-selected .search-quick-ico,
.search-quick-card.is-current .search-quick-ico {
  background: rgba(212, 9, 36, 0.1);
  color: var(--primary);
}
.search-quick-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.search-quick-meta strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.search-quick-card:hover .search-quick-meta strong,
.search-quick-card.is-selected .search-quick-meta strong {
  color: var(--primary);
}
.search-quick-meta small {
  font-size: 10.5px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 400px) {
  .search-zero-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Full Results Page Hub Styles ── */
.search-page-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 10px;
}
.search-page-input-card {
  padding: 16px 20px;
}
.search-page-form {
  margin: 0;
}
.search-page-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-page-input-wrapper {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}
.search-page-input-wrapper .ico {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-page-input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 42px;
  font-size: 14.5px;
  border-radius: var(--radius-lg);
}
.search-page-ctx-select {
  height: 44px;
  font-size: 13.5px;
  min-width: 170px;
  border-radius: var(--radius-lg);
}
.search-filter-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.search-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 140ms ease;
}
.search-tab-btn .ico {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
.search-tab-btn:hover {
  background: var(--wash);
  border-color: var(--line-strong);
}
.search-tab-btn.is-active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}
.search-tab-btn.is-active .ico {
  color: #ffffff;
}
.search-tab-btn .tab-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
}
.search-tab-btn.is-active .tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}
.search-page-results {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.search-page-group-card {
  padding: 0;
  overflow: hidden;
}
.search-group-card-head {
  padding: 14px 20px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.group-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.group-title-wrap .group-ico {
  width: 18px;
  height: 18px;
  color: var(--primary);
}
.group-title-wrap h2 {
  font-size: 16px;
  margin: 0;
}
.search-page-cards-list {
  display: grid;
  grid-template-columns: 1fr;
}
.search-page-hit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: all 120ms ease;
}
.search-page-hit-card:last-child {
  border-bottom: none;
}
.search-page-hit-card:hover {
  background: var(--wash);
}
.hit-card-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.hit-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hit-card-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}
.search-page-hit-card:hover .hit-card-title {
  color: var(--primary);
}
.hit-card-sub {
  font-size: 13px;
  color: var(--muted);
}
.hit-card-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
  transition: all 120ms ease;
}
.hit-card-action .ico {
  width: 15px;
  height: 15px;
}
.search-page-hit-card:hover .hit-card-action {
  color: var(--primary);
  transform: translateX(3px);
}
.search-empty-card {
  padding: 48px 24px;
}
.search-empty-ico-lg {
  width: 48px;
  height: 48px;
  color: #94a3b8;
  margin: 0 auto 16px;
  display: block;
}
.search-suggestions-box {
  margin-top: 24px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 22px;
}
.search-suggestions-box h3 {
  margin: 0 0 10px;
  font-size: 14px;
}
.search-suggestions-box ul {
  margin: 0;
  padding-left: 20px;
}
.search-suggestions-box li {
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
}
.search-suggestions-box code {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink);
  font-size: 12px;
}


/* ==========================================================================
   Clinical Safety & Risk Management Module
   ========================================================================== */

/* Safety Module Grids: Single Card for Heatmap, 2-Column Grid for Adverse Events & Registers */
.safety-submodules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 960px) {
  .safety-submodules-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* Clean Neutral Card Header Forward Links (No Reddish Color) */
.card-jump-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  background: var(--wash);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.card-jump-link:hover {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  text-decoration: none;
}
.card-jump-link svg {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}
.card-jump-link:hover svg {
  color: var(--ink);
  transform: translate(1px, -1px);
}

/* Registers compact list: clean divided rows without nested cards */
.registers-compact-list {
  display: flex;
  flex-direction: column;
}
.register-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: background 0.15s ease;
  gap: 16px;
}
.register-row-item:last-child {
  border-bottom: none;
}
.register-row-item:hover {
  background: var(--wash);
  text-decoration: none;
}
.register-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.register-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--wash);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink);
}
.register-row-item:hover .register-item-icon {
  background: var(--paper);
  border-color: var(--line-strong);
}
.register-item-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.register-item-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}
.register-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .register-row-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
  }
  .register-item-right {
    width: 100%;
    justify-content: space-between;
    padding-top: 6px;
    border-top: 1px dashed var(--line);
  }
}

/* 6-Month Adverse Events Trend Bar Chart (Cohesive Palette) */
.trend-chart-container {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  height: 145px;
  padding: 12px 6px 8px 6px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 10px;
}
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}
.trend-col-bar-wrap {
  width: 100%;
  max-width: 38px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 5px 5px 0 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}
.trend-col:hover .trend-col-bar-wrap {
  filter: brightness(0.92);
  transform: translateY(-2px);
}
.trend-seg {
  width: 100%;
  transition: height 0.3s ease;
}

/* Harmonized clinical palette: cohesive, restrained, high-contrast */
.trend-seg-med { background: #c92a2a; }      /* Clinical crimson for medication errors */
.trend-seg-near { background: #475569; }     /* Slate steel for near-misses (prevented) */
.trend-seg-needle { background: #b45309; }   /* Warm ochre for needlestick */
.trend-seg-emerg { background: #1d4ed8; }    /* Navy blue for emergencies */
.trend-seg-sentinel { background: #701a24; } /* Deep wine for sentinel events */
.trend-seg-other { background: #94a3b8; }    /* Neutral slate for other */

.trend-col-val {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.trend-col-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
}
.trend-col.is-current .trend-col-lbl {
  color: var(--primary);
  font-weight: 750;
}
.trend-col.is-current .trend-col-bar-wrap {
  box-shadow: 0 0 0 2px var(--primary);
}

/* Legend items */
.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11.5px;
  color: var(--muted);
  padding-top: 2px;
}
.trend-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.trend-legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

/* 5x5 Risk Heat Map Matrix */
.risk-matrix-card {
  overflow: hidden;
}
.risk-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  table-layout: fixed;
}
.risk-matrix-table th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  padding: 4px 2px;
  letter-spacing: 0.03em;
}
.risk-matrix-table th.axis-col-hdr {
  font-size: 11px;
  color: var(--ink);
  font-weight: 700;
  background: var(--wash);
  border-radius: 4px;
  padding: 5px 2px;
}
.risk-matrix-table th.axis-row-hdr {
  text-align: right;
  padding-right: 8px;
  width: 78px;
  white-space: nowrap;
  font-size: 11px;
  color: var(--ink);
  font-weight: 700;
}
.risk-matrix-table td.risk-cell {
  height: 48px;
  text-align: center;
  vertical-align: middle;
  border-radius: 6px;
  padding: 2px 4px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}
.risk-matrix-table td.risk-cell:hover {
  transform: scale(1.04);
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}
.risk-matrix-table td.risk-cell.is-selected {
  outline: 3px solid #1e293b;
  outline-offset: -1px;
  box-shadow: 0 0 0 4px rgba(30, 41, 59, 0.2);
}

/* Risk Cell Color Bands */
.risk-critical {
  background: #fef2f2 !important;
  border: 1.5px solid #fca5a5 !important;
  color: #991b1b !important;
}
.risk-high {
  background: #fff7ed !important;
  border: 1.5px solid #fdba74 !important;
  color: #9a3412 !important;
}
.risk-medium {
  background: #fefce8 !important;
  border: 1.5px solid #fde047 !important;
  color: #854d0e !important;
}
.risk-low {
  background: #f0fdf4 !important;
  border: 1.5px solid #bbf7d0 !important;
  color: #166534 !important;
}

/* Inside cell content */
.risk-cell-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1;
}
.risk-cell.has-risks.risk-critical .risk-cell-count {
  background: #dc2626;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.35);
}
.risk-cell.has-risks.risk-high .risk-cell-count {
  background: #ea580c;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(234, 88, 12, 0.35);
}
.risk-cell.has-risks.risk-medium .risk-cell-count {
  background: #ca8a04;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(202, 138, 4, 0.35);
}
.risk-cell.has-risks.risk-low .risk-cell-count {
  background: #16a34a;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(22, 163, 74, 0.35);
}
.risk-cell:not(.has-risks) .risk-cell-count {
  display: none;
}
.risk-cell-score {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.65;
  display: block;
}
.risk-cell:not(.has-risks) .risk-cell-score {
  font-size: 11px;
  font-weight: 650;
  opacity: 0.55;
}

/* Compact & Responsive Heatmap Legend Bar */
.risk-legend-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
@media (max-width: 640px) {
  .risk-legend-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
}
@media (max-width: 380px) {
  .risk-legend-bar {
    grid-template-columns: 1fr;
  }
}
.risk-legend-pill {
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 28px;
  white-space: nowrap;
}
.risk-legend-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}
.risk-legend-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
}
.risk-legend-count {
  font-weight: 750;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  line-height: 1.2;
  flex-shrink: 0;
}

/* Clean Status Dot Indicators */
.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.risk-dot-critical { background: #dc2626; box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2); }
.risk-dot-high { background: #ea580c; box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.2); }
.risk-dot-medium { background: #ca8a04; box-shadow: 0 0 0 2px rgba(202, 138, 4, 0.2); }
.risk-dot-low { background: #16a34a; box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2); }

/* Sticky Tab Navigation Header */
.safety-tab-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 6px;
  border-radius: 10px;
  margin-bottom: 16px;
  overflow-x: auto;
  position: sticky;
  top: 8px;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.safety-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.safety-tab-btn:hover {
  color: var(--ink);
  background: var(--wash);
}
.safety-tab-btn.is-active {
  color: var(--paper);
  background: var(--primary);
  box-shadow: 0 2px 4px rgba(212, 9, 36, 0.22);
}
.safety-tab-btn svg {
  flex-shrink: 0;
}
.safety-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 750;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
}
.safety-tab-btn.is-active .safety-tab-badge {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

/* Streamlined Rapid Continuous Entry Box */
.rapid-entry-card {
  background: #fcfdfe;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.rapid-entry-card:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(212, 9, 36, 0.06);
}
.rapid-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
  flex-wrap: wrap;
}
.rapid-entry-title {
  font-size: 12.5px;
  font-weight: 750;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.rapid-form-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.rapid-form-row.secondary {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.live-calc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 750;
  transition: all 0.2s ease;
}

/* Action & Status Badges */
.badge.badge-critical { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; font-weight: 700; }
.badge.badge-high { background: #fff7ed; color: #ea580c; border: 1px solid #fdba74; font-weight: 700; }
.badge.badge-medium { background: #fefce8; color: #ca8a04; border: 1px solid #fde047; font-weight: 700; }
.badge.badge-low { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; font-weight: 700; }

.flash-saved {
  animation: flash-green 1.4s ease-out;
}
@keyframes flash-green {
  0% { background-color: #bbf7d0; }
  100% { background-color: transparent; }
}


/* ==========================================================================
   Minimalist Home Workspace (/) — Work Queue & Editorial Ledger
   Uses strictly existing :root brand tokens.
   ========================================================================== */

.home-subline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13.5px;
  color: var(--muted);
  margin: 4px 0 0;
}
.home-sep {
  opacity: 0.6;
  user-select: none;
}

.home-layout {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Primary surface: Prioritised work queue */
.home-queue {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.home-queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.home-queue-heading-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.home-queue-heading-group h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.home-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--wash);
  color: var(--ink);
}
.home-count-pill.is-urgent {
  background: var(--primary);
  color: var(--paper);
}

.home-urgent-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-left: 2px;
}

.home-filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.home-filter-bar::-webkit-scrollbar {
  display: none;
}

.home-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.home-filter-btn:hover {
  background: var(--wash);
  color: var(--ink);
}
.home-filter-btn.is-active {
  background: var(--wash);
  border-color: var(--line-strong);
  color: var(--ink);
}
.home-filter-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.home-filter-num {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.home-queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.home-queue-item {
  border-bottom: 1px solid var(--line);
}
.home-queue-item:last-child {
  border-bottom: 0;
}
.home-queue-item.is-collapsed,
.home-queue-item[hidden] {
  display: none !important;
}

.home-queue-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  color: var(--ink);
  text-decoration: none;
  transition: background 120ms ease;
}
.home-queue-link:hover {
  background: var(--wash);
  text-decoration: none;
}
.home-queue-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--wash);
}

.home-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.home-status-dot.urgent {
  background: var(--primary);
}
.home-status-dot.warning {
  background: var(--amber);
}
.home-status-dot.review {
  background: var(--blue);
}
.home-status-dot.clear {
  background: var(--positive);
}

.home-queue-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.home-queue-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.home-queue-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  transition: color 120ms ease;
}
.home-queue-link:hover .home-queue-title {
  color: var(--primary);
}

.home-yours-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 700;
  background: var(--wash);
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.home-queue-detail {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
}

.home-queue-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.home-queue-mod {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  min-width: 56px;
  text-align: right;
}
.home-queue-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  min-width: 132px;
  justify-content: flex-end;
  transition: color 120ms ease;
}
.home-queue-link:hover .home-queue-cta {
  color: var(--primary);
}
.home-arrow {
  display: inline-block;
  transition: transform 140ms ease;
}
.home-queue-link:hover .home-arrow {
  transform: translateX(3px);
}

.home-queue-foot {
  border-top: 1px solid var(--line);
  padding: 6px 20px;
  background: var(--paper);
}
.home-more-btn {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 6px 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: color 120ms ease;
}
.home-more-btn:hover {
  color: var(--primary);
}
.home-more-btn:focus-visible {
  outline: 2px solid var(--primary);
  border-radius: var(--radius-lg);
}

/* Zero-inbox calm status bar */
.home-clear-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.home-clear-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.home-clear-left strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.3;
}
.home-clear-sub {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

.home-quiet-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 120ms ease;
}
.home-quiet-link:hover {
  color: var(--primary);
  text-decoration: none;
}

/* Quiet between-sections brief for clean modules (zero-card editorial note) */

.home-clean-section {

  display: flex;

  align-items: center;

  gap: 10px;

  margin: -10px 0 -4px;

  padding: 6px 14px;

  border-left: 2px solid var(--positive);

}

.home-clean-copy {

  margin: 0;

  font-size: 13px;

  line-height: 1.45;

  color: var(--muted);

}

.home-clean-copy strong {

  font-weight: 650;

  color: var(--ink);

}



/* Secondary section: Cardless hairline-divided workspace ledger */
.home-workspaces {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.home-section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}
.home-section-bar h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.home-ledger {
  border-top: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
}
.home-ws-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.15fr) minmax(260px, 1.85fr) auto;
  align-items: center;
  gap: 20px;
  padding: 15px 10px;
  border-bottom: 1px solid var(--line-strong);
  transition: background 120ms ease;
}
.home-ws-row:hover {
  background: var(--paper);
}

.home-ws-primary {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.home-ws-primary:hover {
  text-decoration: none;
}
.home-ws-primary .ico {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 120ms ease;
}
.home-ws-row:hover .home-ws-primary .ico {
  color: var(--primary);
}
.home-ws-primary strong {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  transition: color 120ms ease;
}
.home-ws-primary:hover strong {
  color: var(--primary);
}
.home-ws-primary small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.home-ws-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}
.home-ws-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.home-ws-stat strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.home-ws-stat strong.down {
  color: var(--primary);
}
.home-ws-stat strong.muted {
  color: var(--muted);
}
.home-curr {
  font-size: 0.72em;
  font-weight: 600;
  color: var(--muted);
  margin-right: 2px;
}
.home-ws-stat span {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-ws-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.home-ws-nav a {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 120ms ease;
}
.home-ws-nav a:hover {
  color: var(--ink);
  text-decoration: none;
}
.home-ws-nav a.home-ws-open {
  color: var(--ink);
  padding-left: 12px;
  border-left: 1px solid var(--line-strong);
}
.home-ws-nav a.home-ws-open:hover {
  color: var(--primary);
}

@media (max-width: 960px) {
  .home-ws-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px 8px;
  }
  .home-ws-nav {
    justify-content: flex-start;
    padding-top: 8px;
    border-top: 1px dashed var(--line-strong);
  }
}

@media (max-width: 640px) {
  .home-layout {
    gap: 22px;
  }
  .home-queue-head {
    padding: 12px 14px;
  }
  .home-queue-link {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 10px;
    padding: 12px 14px;
  }
  .home-queue-right {
    grid-column: 2;
    justify-content: space-between;
    width: 100%;
    margin-top: 2px;
  }
  .home-queue-mod {
    text-align: left;
    min-width: 0;
  }
  .home-queue-cta {
    min-width: 0;
  }
  .home-clear-strip {
    padding: 12px 14px;
  }
}

.profile-avatar-wrap {
  display: flex;
  text-decoration: none;
  color: inherit;
}
.profile-name-link {
  text-decoration: none;
  color: inherit;
  min-width: 0;
  display: block;
}
.profile-name-link strong {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  color: var(--ink);
  transition: color 0.15s ease;
}
.profile-name-link:hover strong {
  color: var(--primary);
}
.profile-actions-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1.2;
  margin-top: 2px;
}
.profile-sublink {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}
.profile-sublink:hover {
  color: var(--primary);
  text-decoration: underline;
}
.profile-subsep {
  color: #94a3b8;
  font-size: 11px;
}

/* ============================================================
   Authentication & registration shell
   ============================================================ */
.auth-stage {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  background:
    radial-gradient(circle at 12% 8%, rgba(212, 9, 36, 0.06), transparent 34%),
    radial-gradient(circle at 88% 92%, rgba(23, 92, 211, 0.06), transparent 30%),
    #f7f8fa;
  padding: 32px 18px 20px;
}
.auth-panel-wrap { display: grid; place-items: center; width: 100%; }
.auth-panel {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 60px -28px rgba(15, 23, 42, 0.28), 0 8px 20px -14px rgba(15, 23, 42, 0.18);
  padding: 30px 32px 26px;
}
.auth-panel.is-wide { width: min(620px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth-brand .mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; letter-spacing: 0.02em; flex: none;
}
.auth-brand strong { display: block; font-size: 15px; line-height: 1.2; color: var(--ink); }
.auth-brand span { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); letter-spacing: 0.01em; }
.auth-heading { margin: 0 0 5px; font-size: 22px; line-height: 1.25; letter-spacing: -0.03em; color: var(--ink); }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.auth-alert {
  border-radius: 9px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5;
  margin-bottom: 16px; border: 1px solid transparent;
}
.auth-alert.is-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.auth-alert.is-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.auth-alert.is-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.auth-alert.is-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.auth-form .form-field { margin-bottom: 14px; }
.auth-form label { display: block; font-size: 12.5px; font-weight: 650; color: #334155; margin-bottom: 5px; }
.auth-form .label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.auth-form .label-row label { margin-bottom: 0; }
.auth-form .input,
.auth-form select {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fff; color: var(--ink); font-size: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.auth-form .input:focus,
.auth-form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(212, 9, 36, 0.11); }
.auth-form .field-help { display: block; margin-top: 5px; font-size: 11px; color: var(--muted); }
.auth-form .field-error { display: block; margin-top: 5px; font-size: 11.5px; font-weight: 600; color: #b91c1c; }
.auth-form .grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.auth-form .pw-wrap { position: relative; }
.auth-form .pw-wrap .input { padding-right: 58px; }
.auth-form .pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); font-size: 11px;
  font-weight: 700; cursor: pointer; padding: 5px 7px; border-radius: 5px;
}
.auth-form .pw-toggle:hover { background: var(--wash); color: var(--ink); }
.auth-submit {
  width: 100%; margin-top: 18px; border: 0; border-radius: 8px; background: var(--primary);
  color: #fff; font-size: 14px; font-weight: 700; padding: 11px 16px; cursor: pointer;
  transition: background 140ms ease;
}
.auth-submit:hover { background: #bb0300; }
.auth-submit:focus-visible { outline: 3px solid rgba(212, 9, 36, 0.25); outline-offset: 2px; }
.auth-social-form { margin: 0 0 4px; }
.auth-social-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; min-height: 44px; padding: 10px 16px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fff; color: #1f2937; font-size: 14px;
  font-weight: 650; cursor: pointer; transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.auth-social-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.auth-social-btn:focus-visible { outline: 3px solid rgba(66, 133, 244, 0.22); outline-offset: 2px; }
.auth-or {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 18px;
  color: #94a3b8; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-links { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; font-size: 12.5px; }
.auth-links a { color: var(--primary); font-weight: 600; }
.auth-divider { margin: 20px 0 16px; border-top: 1px solid var(--line); }
.auth-note { text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.auth-note a { color: var(--primary); font-weight: 600; }
.auth-legal { text-align: center; font-size: 11px; color: #94a3b8; padding: 22px 12px 4px; }
.auth-policy {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; margin-bottom: 16px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  font-size: 11.5px; color: #475569; line-height: 1.5;
}
.auth-policy svg { flex: none; color: #64748b; margin-top: 1px; }
.auth-details { margin: 4px 0 16px; }
.auth-details summary {
  cursor: pointer; list-style: none; font-size: 12px; font-weight: 650; color: #475569;
  padding: 8px 11px; border: 1px dashed var(--line-strong); border-radius: 8px;
  text-align: center; user-select: none;
}
.auth-details summary::-webkit-details-marker { display: none; }
.auth-details summary:hover { background: #f8fafc; color: var(--ink); }
.auth-details[open] summary { border-style: solid; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.auth-details .details-body { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; padding: 14px 12px 2px; background: #fcfcfd; }
.auth-icon-state {
  width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; background: #f1f5f9; color: #475569;
}
.auth-icon-state.is-success { background: #ecfdf5; color: #047857; }
.auth-icon-state.is-error { background: #fef2f2; color: #b91c1c; }
.auth-icon-state.is-warning { background: #fffbeb; color: #b45309; }
.auth-centered { text-align: center; }
.auth-centered .auth-sub { margin-left: auto; margin-right: auto; max-width: 360px; }
.auth-badge-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0 2px; }
.auth-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: #f8fafc; font-size: 10.5px; font-weight: 600; color: #475569; }
@media (max-width: 520px) {
  .auth-stage { padding: 18px 12px 12px; }
  .auth-panel { padding: 24px 20px 20px; border-radius: 12px; }
  .auth-heading { font-size: 20px; }
}
