/* ==========================================================================
   Use Case Library — shared design system
   Light theme is the default token set; dark theme overrides via
   [data-theme="dark"] on <html>, toggled and persisted by theme.js.
   ========================================================================== */

:root {
  /* Insulet corporate purple + Omnipod Mango accents */
  --color-primary: #743DBC;
  --color-primary-light: #8B5CF6;
  --color-accent: #F5A623;
  --sidebar-bg: linear-gradient(180deg, #3B1A6E, #743DBC);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-active: rgba(245, 166, 35, 0.22);

  --color-success: #16a34a;
  --color-success-light: #f0fdf4;
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;
  --color-warning: #F5A623;
  --color-warning-light: #fff8eb;
  --color-info: #743DBC;
  --color-info-light: #f3eefc;

  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-faint: #94a3b8;
  --color-border: #e8e0f2;
  --color-border-strong: #d4c4ea;
  --color-bg: #f7f4fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f6f1fc;
  --color-input-bg: #ffffff;
  --color-overlay: rgba(59, 26, 110, 0.45);

  /* Background brand watermark strength — lower on light backgrounds, where the
     mark's own dark card reads more strongly against the page. */
  --watermark-opacity: 0.035;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 12px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(59, 26, 110, 0.06);
  --shadow-md: 0 6px 20px rgba(59, 26, 110, 0.08);
  --shadow-lg: 0 20px 45px rgba(59, 26, 110, 0.14);

  --font-sans: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --color-primary-rgb: 116, 61, 188;

  color-scheme: light;
}

html[data-theme="dark"] {
  --color-primary: #8B5CF6;
  --color-primary-light: #9F7AEA;
  --color-accent: #A78BFA;
  --sidebar-bg: linear-gradient(180deg, #2A0052, #42107A);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-active: rgba(255, 255, 255, 0.15);

  --color-success: #4ade80;
  --color-success-light: rgba(74, 222, 128, 0.12);
  --color-danger: #f87171;
  --color-danger-light: rgba(248, 113, 113, 0.12);
  --color-warning: #fbbf24;
  --color-warning-light: rgba(251, 191, 36, 0.12);
  --color-info: #A78BFA;
  --color-info-light: rgba(167, 139, 250, 0.12);

  --color-text: #FFFFFF;
  --color-text-muted: #D8CCFF;
  --color-text-faint: #B9A5E8;
  --color-border: #5A2D91;
  --color-border-strong: #6C3AAF;
  --color-bg: #2A0052;
  --color-surface: #3B0A6D;
  --color-surface-alt: #42107A;
  --color-input-bg: #4A157D;
  --color-overlay: rgba(20, 4, 40, 0.65);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  --watermark-opacity: 0.06;
  --color-primary-rgb: 139, 92, 246;

  color-scheme: dark;
}

/* Respect OS preference only when the visitor hasn't made an explicit choice. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-primary: #8B5CF6;
    --color-primary-light: #9F7AEA;
    --color-accent: #A78BFA;
    --sidebar-bg: linear-gradient(180deg, #2A0052, #42107A);
    --sidebar-hover: rgba(255, 255, 255, 0.12);
    --sidebar-active: rgba(255, 255, 255, 0.15);

    --color-success: #4ade80;
    --color-success-light: rgba(74, 222, 128, 0.12);
    --color-danger: #f87171;
    --color-danger-light: rgba(248, 113, 113, 0.12);
    --color-warning: #fbbf24;
    --color-warning-light: rgba(251, 191, 36, 0.12);
    --color-info: #A78BFA;
    --color-info-light: rgba(167, 139, 250, 0.12);

    --color-text: #FFFFFF;
    --color-text-muted: #D8CCFF;
    --color-text-faint: #B9A5E8;
    --color-border: #5A2D91;
    --color-border-strong: #6C3AAF;
    --color-bg: #2A0052;
    --color-surface: #3B0A6D;
    --color-surface-alt: #42107A;
    --color-input-bg: #4A157D;
    --color-overlay: rgba(20, 4, 40, 0.65);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

    --watermark-opacity: 0.06;
    --color-primary-rgb: 139, 92, 246;

    color-scheme: dark;
  }

  html:not([data-theme="light"]):not([data-theme="dark"]) body,
  html:not([data-theme="light"]):not([data-theme="dark"]) main {
    background: linear-gradient(180deg, #2A0052, #42107A);
  }
}

* {
  box-sizing: border-box;
}

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

html {
  /* Avoid a flash of default color before theme.js applies the stored choice. */
  background: var(--color-bg);
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

/* Dark theme: soft purple gradient page background (--color-bg itself stays a
   solid color, since it also doubles as a border-color in a few places, and
   a gradient there would be invalid CSS). Applied to both body AND main:
   main sits on top of body and covers the entire content area once the
   sidebar's 280px margin is accounted for, so body's own background is
   barely visible in practice — main needs the actual gradient too. */
html[data-theme="dark"] body,
html[data-theme="dark"] main {
  background: linear-gradient(180deg, #2A0052, #42107A);
}

*,
*::before,
*::after {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

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

a:hover {
  text-decoration: underline;
}

::selection {
  background: var(--color-primary);
  color: #fff;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-faint);
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Sidebar Navigation ---------- */
body {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 280px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

.sidebar-collapsed {
  width: 80px;
}

/* Auto-expand on hover when collapsed */
.sidebar-collapsed:hover,
.sidebar-collapsed.sidebar-expanded-temp {
  width: 280px;
  z-index: 50;
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.sidebar-collapsed .sidebar-header {
  padding: 16px;
  justify-content: center;
}

.sidebar-collapsed .brand-text {
  display: none;
}

.sidebar-collapsed .brand-compact {
  display: inline-flex;
}

.sidebar-collapsed:hover .brand-text,
.sidebar-collapsed.sidebar-expanded-temp .brand-text {
  display: flex;
}

.sidebar-collapsed:hover .brand-compact,
.sidebar-collapsed.sidebar-expanded-temp .brand-compact {
  display: none;
}

.sidebar-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  top: 16px;
  right: 8px;
  background: rgba(255, 255, 255, 0.15);
}

.sidebar-collapsed .sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-header .brand-mark {
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff !important;
  text-decoration: none !important;
  white-space: nowrap;
  min-width: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  line-height: 1.05;
}

.brand-compact {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #F3C777;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-org {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #F5A623;
  text-transform: uppercase;
}

.brand-product {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
}

.sidebar-collapsed .brand-mark {
  width: 32px;
  height: 32px;
}

.nav-links {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  padding: 10px 16px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.25s ease;
  border-left: 4px solid transparent;
  margin: 0 8px;
  border-radius: 8px;
  position: relative;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  padding-left: 18px;
}

.nav-link.active {
  background: var(--sidebar-active);
  border-left-color: var(--color-accent);
  color: #fff;
  font-weight: 600;
}

.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 12px;
  margin: 0 4px;
}

/* When sidebar expands on hover, adjust nav-link styling */
.sidebar-collapsed.sidebar-expanded-temp .nav-link,
.sidebar-collapsed:hover .nav-link {
  justify-content: flex-start;
  padding: 10px 16px;
  margin: 0 8px;
}

.sidebar-collapsed .nav-label {
  display: none;
}

/* Show text when sidebar is expanded (temporarily or permanently) */
.sidebar-collapsed.sidebar-expanded-temp .nav-label {
  display: inline;
}

.sidebar-collapsed:hover .nav-label {
  display: inline;
}

/* Show tooltip only when sidebar is truly collapsed (no hover) */
.sidebar-collapsed:not(:hover) .nav-link:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 70px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

.nav-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: all 0.25s ease;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  stroke-width: 2.2;
}

.nav-user {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-meta {
  font-size: 12px;
  line-height: 1.3;
}

.user-meta .name {
  font-weight: 600;
  color: #fff;
}

.user-meta .role {
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.sidebar-collapsed .user-meta {
  display: none;
}

.sidebar-collapsed:hover .user-meta {
  display: block;
}

.sidebar-collapsed .nav-user-actions {
  position: absolute;
  bottom: 16px;
  right: 8px;
  flex-direction: column;
}

.btn-logout {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 6px;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.nav-user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.theme-toggle {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 6px;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ---------- Main Content Area ---------- */
main {
  flex: 1;
  margin-left: 280px;
  transition: margin-left 0.3s ease;
  background: var(--color-bg);
}

body.sidebar-collapsed main {
  margin-left: 80px;
}

/* Adjust main content when collapsed sidebar is hovered */
body.sidebar-collapsed .sidebar:hover~main {
  margin-left: 280px;
}

/* Alternative: using adjacent sibling selector if sidebar is not sibling */
.sidebar.sidebar-collapsed:hover {
  width: 280px;
}

body.sidebar-collapsed .sidebar:hover~main,
body.sidebar-collapsed:has(.sidebar:hover) main {
  margin-left: 280px;
}

/* ---------- Breadcrumb Navigation ---------- */
.breadcrumb-container {
  padding: 12px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 35;
}

.breadcrumb-item {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.breadcrumb-item:hover {
  color: var(--color-primary);
}

.breadcrumb-item.active {
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 17px;
  line-height: 1;
}

.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.theme-toggle .icon-dark {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-light {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-dark {
  display: block;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  font-family: inherit;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary);
  filter: brightness(1.12);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn-success {
  background: var(--color-success);
  color: #06240f;
}

html[data-theme="dark"] .btn-success {
  color: #06240f;
}

.btn-success:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn-outline {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

.card-header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--color-border);
}

.card-header h1,
.card-header h2 {
  margin: 0 0 4px;
}

.card-header p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

.card-body {
  padding: 28px;
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 24px;
  margin-top: 1em;
}

.form-row-3 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 24px;
}

.form-row-4 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 24px;
  align-items: start;
}

.form-row-2 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 24px;
  align-items: start;
}

.form-row-2-1 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px 24px;
  align-items: start;
}

.form-section {
  grid-column: 1 / -1;
  margin: 8px 0 -4px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
}

.form-section:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.form-section h3 {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--color-primary);
  margin: 0 0 2px;
  font-weight: 700;
}

.form-section .hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.field label .required,
.field legend .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.field .field-hint {
  font-size: 11px;
  line-height: 1.35;
  color: var(--color-text-muted);
  margin-top: -2px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-input-bg);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-faint);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

input.invalid,
select.invalid,
textarea.invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px var(--color-danger-light);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: .6;
  cursor: not-allowed;
  background: var(--color-surface-alt);
}

.error-text {
  font-size: 12px;
  color: var(--color-danger);
  min-height: 15px;
  display: none;
}

.error-text.show {
  display: block;
}

.toggle-group {
  display: flex;
  gap: 10px;
}

.toggle-option {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-muted);
  transition: all .15s;
  user-select: none;
}

.toggle-option:hover {
  border-color: var(--color-primary);
}

.toggle-option.selected {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.toggle-option.selected.yes {
  background: var(--color-success-light);
  border-color: var(--color-success);
  color: var(--color-success);
}

.toggle-option.selected.no {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
  color: var(--color-text-muted);
}

.conditional-block {
  grid-column: 1 / -1;
  display: none;
  gap: 20px 24px;
  grid-template-columns: repeat(2, 1fr);
  padding: 18px;
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
}

.conditional-block.show {
  display: grid;
}

.pct-wrap {
  position: relative;
}

.pct-wrap input {
  padding-right: 34px;
}

.pct-wrap::after {
  content: '%';
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 14px;
  pointer-events: none;
}

/* ---------- Badges / status pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-pending {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-approved {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-rejected {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-role {
  background: var(--color-primary);
  color: #fff;
}

.badge-role.admin {
  background: var(--color-danger);
  color: #fff;
}

.badge-role.reviewer {
  background: var(--color-warning);
  color: #000;
}

.badge-role.submitter {
  background: var(--color-primary);
  color: #fff;
}

.badge-status-dot {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-status-dot.inactive {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* ---------- Alerts / toasts ---------- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  display: none;
}

.alert.show {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error {
  background: var(--color-danger-light);
  border-color: color-mix(in srgb, var(--color-danger) 35%, transparent);
  color: var(--color-danger);
}

.alert-success {
  background: var(--color-success-light);
  border-color: color-mix(in srgb, var(--color-success) 35%, transparent);
  color: var(--color-success);
}

.alert-info {
  background: var(--color-info-light);
  border-color: color-mix(in srgb, var(--color-info) 35%, transparent);
  color: var(--color-info);
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 280px;
  max-width: 380px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slide-in .2s ease;
}

@keyframes slide-in {
  from {
    transform: translateX(30px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-success {
  background: #16a34a;
}

.toast-error {
  background: #dc2626;
}

.toast-info {
  background: var(--color-primary-dark);
}

/* ---------- Login page ---------- */
.auth-shell {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(63, 0, 110, 0.16), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(255, 216, 77, 0.12), transparent 45%),
    var(--color-bg);
  overflow: hidden;
  z-index: 9999;
}

.auth-shell::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(90vw, 1000px);
  height: min(90vw, 1000px);
  transform: translate(-50%, -50%);
  background: url('/static/images/watermark.png') center / contain no-repeat;
  opacity: var(--watermark-opacity, 0.035);
  filter: grayscale(0.35) saturate(1.15);
  pointer-events: none;
  z-index: 0;
}

.auth-shell>* {
  position: relative;
  z-index: 1;
}

.auth-theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--color-border);
  padding: 44px 40px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  text-align: center;
}

.auth-logo .brand-mark {
  width: 100px;
  height: 100px;
  border-radius: 24px;
  box-shadow: 0 12px 32px rgba(63, 0, 110, 0.35);
}

.auth-logo h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.auth-logo p {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

.auth-footer {
  margin-top: 22px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

.auth-footer-byline {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--color-text-faint, var(--color-text-muted));
}

.demo-hint {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.demo-hint code {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- MFA setup (login page) ---------- */
.auth-card--wide {
  max-width: 480px;
}

.mfa-intro {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.mfa-intro-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mfa-intro p {
  margin: 0;
  font-size: 13.5px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.mfa-step {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
}

.mfa-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.mfa-step-body {
  flex: 1;
  min-width: 0;
}

.mfa-step-body h3 {
  margin: 0 0 3px;
  font-size: 14.5px;
}

.mfa-step-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.mfa-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.mfa-qr-wrap svg {
  display: block;
  width: 168px;
  height: 168px;
}

.mfa-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  text-decoration: underline;
}

.mfa-manual-key {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.mfa-manual-key code {
  display: block;
  font-size: 14px;
  letter-spacing: 1px;
  word-break: break-all;
  margin-bottom: 6px;
}

.mfa-backup-callout {
  padding: 14px;
  background: var(--color-warning-light);
  border: 1px solid color-mix(in srgb, var(--color-warning) 35%, transparent);
  border-radius: var(--radius-md);
}

.mfa-backup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  margin-top: 10px;
  color: var(--color-text);
}

.mfa-copy-btn {
  margin-top: 12px;
  font-size: 12px;
  padding: 6px 12px;
}

/* ---------- Page shell ---------- */
.page {
  padding: 32px 0 64px;
  position: relative;
}

/* Large, faint, fixed brand watermark behind the authenticated app pages.
   Applied via body.watermarked so it sits behind the navbar + content without
   affecting layout or scrolling with the page. */
body.watermarked::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(65vw, 820px);
  height: min(65vw, 820px);
  transform: translate(-50%, -50%);
  background: url('/static/images/watermark.png') center / contain no-repeat;
  opacity: var(--watermark-opacity, 0.035);
  filter: grayscale(0.35) saturate(1.15);
  pointer-events: none;
  z-index: 0;
}

/* :not(...) exclusions so this doesn't clobber position:fixed on modals,
   toasts, and other fixed-position overlays that are direct children of
   <body> — they need to stay fixed to the viewport, not be pulled into
   normal flow. */
body.watermarked>*:not(.modal-overlay):not(.toast-container):not(.chat-fab) {
  position: relative;
  z-index: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}

.page-header h1 {
  margin: 1em 0 4px;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  font-weight: 700;
}

.page-header p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

.page-header .actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------- Export dropdown ---------- */
.export-dropdown {
  position: relative;
}

.export-dropdown .caret {
  font-size: 10px;
  margin-left: 2px;
}

.export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 60;
}

.export-menu.show {
  display: block;
}

.export-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  font-family: inherit;
}

.export-menu-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.export-menu-item:disabled {
  opacity: .5;
  cursor: wait;
}

.export-menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 4px;
}

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  font-weight: 600;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.02em;
}

.stat-card.total .value {
  color: var(--color-primary);
}

.stat-card.pending .value {
  color: var(--color-warning);
}

.stat-card.approved .value {
  color: var(--color-success);
}

.stat-card.rejected .value {
  color: var(--color-danger);
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.filter-bar .field {
  min-width: 170px;
  flex: 1;
}

.filter-bar .field.search {
  flex: 2;
  min-width: 240px;
}

.filter-bar .actions {
  display: flex;
  gap: 10px;
}

/* ---------- Table ---------- */
/* Fully fluid, percentage-based columns — the table always fits its
   container's width, so no horizontal scrollbar ever appears on desktop. */
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

table.data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 14px;
}

/* Proposals table columns */
.data-table col.col-code {
  width: 12%;
}

.data-table col.col-name {
  width: 22%;
}

.data-table col.col-submitter {
  width: 22%;
}

.data-table col.col-lob {
  width: 15%;
}

.data-table col.col-status {
  width: 12%;
}

.data-table col.col-submitted {
  width: 14%;
}

.data-table col.col-actions {
  width: 18%;
}

/* Admin users table columns */
.data-table col.col-user {
  width: 28%;
}

.data-table col.col-role {
  width: 12%;
}

.data-table col.col-user-status {
  width: 10%;
}

.data-table col.col-mfa {
  width: 11%;
}

.data-table col.col-last-login {
  width: 17%;
}

.data-table col.col-created {
  width: 14%;
}

.data-table col.col-admin-actions {
  width: 8%;
}

.data-table thead th {
  text-align: left;
  padding: 13px 16px;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
}

.data-table thead th:hover {
  color: var(--color-primary);
}

.data-table thead th.no-sort {
  cursor: default;
}

.data-table thead th.no-sort:hover {
  color: var(--color-text-muted);
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background-color 0.15s ease;
}

.data-table tbody tr.clickable-row {
  cursor: pointer;
}

.data-table tbody tr:nth-child(even) {
  background: var(--color-surface-alt);
}

.data-table tbody tr:hover {
  background: rgba(var(--color-primary-rgb), 0.06);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody td[data-label="Actions"],
.data-table tbody td[data-label="Status"],
.data-table tbody td[data-label="Submitter"] {
  overflow: visible;
  white-space: normal;
}

/* Admin users table specific styles */
.data-table tbody td[data-label="Role"],
.data-table tbody td[data-label="MFA"],
.data-table tbody td[data-label="Status"] {
  overflow: visible;
  white-space: nowrap;
  padding: 12px 14px;
}

.data-table tbody td[data-label="Last Login"],
.data-table tbody td[data-label="Created"] {
  font-size: 13px;
}

.data-table tbody td[data-label="User"] {
  overflow: visible;
  white-space: normal;
}

.code-cell {
  font-weight: 700;
  color: var(--color-primary-dark);
  font-size: 13px;
  letter-spacing: .01em;
}

.name-cell {
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submitter-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.submitter-name {
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submitter-email {
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
}

/* Action buttons are icon-only: the text stays in the DOM for screen readers
   (and each button carries a title/aria-label for a hover tooltip). */
.row-actions .btn {
  flex-shrink: 0;
}

/* Only icon-bearing actions collapse to a square; text-only buttons in a
   row (e.g. Activate / Deactivate on the users page) keep their labels. */
.row-actions .btn:has(.btn-icon) {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.row-actions .btn:has(.btn-icon) .btn-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
  flex-wrap: wrap;
  gap: 10px;
}

.pagination .pages {
  display: flex;
  gap: 6px;
}

.pagination button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  padding: 6px 11px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.pagination button:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.pagination button.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.pagination button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  /* Header and footer (incl. action buttons) always stay visible; only the
     body scrolls — a long form (e.g. the reject flow's rationale textarea)
     must never be able to push the Save/Confirm button below the fold with
     no visible way to reach it. */
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px 26px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}

.modal-close:hover {
  color: var(--color-danger);
}

.modal-body {
  padding: 22px 26px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  padding: 18px 26px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 22px;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-item .dt-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-item .dt-value {
  font-size: 14px;
  color: var(--color-text);
  white-space: pre-wrap;
  line-height: 1.55;
}

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audit-list li {
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border-radius: 8px;
  font-size: 13px;
}

.audit-list .audit-meta {
  color: var(--color-text-muted);
  font-size: 12px;
  margin-top: 3px;
}

/* ---------- Rejection flow: step indicator + AI draft review ---------- */
.reject-steps {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.reject-step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-faint);
}

.reject-step b {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.reject-step.active {
  color: var(--color-primary);
}

.reject-step.active b {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.reject-step-sep {
  width: 26px;
  height: 1px;
  background: var(--color-border);
}

.draft-banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  border: 1px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
  color: var(--color-text);
  font-size: 13px;
  line-height: 1.6;
}

.draft-banner-icon {
  color: var(--color-primary);
  font-size: 15px;
  line-height: 1.4;
  flex-shrink: 0;
}

#reject-final {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.draft-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ---------- Admin: user management ---------- */
.role-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.role-option {
  padding: 12px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  user-select: none;
}

.role-option .role-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--color-text);
}

.role-option .role-desc {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.role-option:hover {
  border-color: var(--color-primary);
}

.role-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.role-option.selected .role-title {
  color: var(--color-primary);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 42px;
}

.password-toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 6px;
}

.password-toggle-btn:hover {
  color: var(--color-primary);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell .avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.user-cell .u-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--color-text);
}

.user-cell .u-email {
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.dot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.dot-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
}

.dot-status.inactive::before {
  background: var(--color-text-faint);
}

.dot-status.inactive {
  color: var(--color-text-muted);
}

/* ---------- Tabs (shared: Configuration page, proposal form's Risk Screening tab) ---------- */
.config-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.config-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.config-tab-btn:hover {
  color: var(--color-text);
}

.config-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.config-tab-panel {
  display: none;
}

.config-tab-panel.active {
  display: block;
}

/* ==========================================================================
   AI Proposal Analysis page
   ========================================================================== */
.analysis-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.analysis-sidebar {
  position: sticky;
  top: 84px;
  overflow: hidden;
}

.analysis-main>.card {
  margin-bottom: 18px;
}

.analysis-main>.card:last-child {
  margin-bottom: 0;
}

.proposal-list {
  max-height: 60vh;
  overflow-y: auto;
  border-top: 1px solid var(--color-border);
}

.list-placeholder {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13.5px;
}

.proposal-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-left: 3px solid transparent;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.proposal-item:hover {
  background: var(--color-surface-alt);
}

.proposal-item.active {
  background: var(--color-primary-light);
  border-left-color: var(--color-primary);
}

.pi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.pi-code {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--color-primary-dark);
}

.pi-customer {
  font-size: 13.5px;
  color: var(--color-text);
  margin-bottom: 6px;
}

.pi-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pi-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.pi-none {
  font-size: 12px;
  color: var(--color-text-faint);
  font-style: italic;
}

/* Inputs under assessment */
.criteria-grid {
  display: grid;
  gap: 14px;
}

.criteria-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.criteria-value {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* Verdict banner */
.verdict-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  border-left-width: 5px;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.verdict-card.go {
  border-left-color: var(--color-success);
}

.verdict-card.conditional {
  border-left-color: var(--color-warning);
}

.verdict-card.nogo {
  border-left-color: var(--color-danger);
}

.verdict-decision {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.verdict-card.go .verdict-decision {
  color: var(--color-success);
}

.verdict-card.conditional .verdict-decision {
  color: var(--color-warning);
}

.verdict-card.nogo .verdict-decision {
  color: var(--color-danger);
}

.verdict-sub {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.verdict-score {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-shrink: 0;
}

.vs-num {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.vs-den {
  font-size: 14px;
  color: var(--color-text-muted);
  font-weight: 600;
}

.decision-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.decision-chip.go {
  background: var(--color-success-light);
  color: var(--color-success);
}

.decision-chip.conditional {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.decision-chip.nogo {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* AI-vs-conventional callout */
.ai-fit-card {
  border-left: 4px solid var(--color-accent);
}

.ai-fit-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.verdict-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.verdict-chip.ai-essential {
  background: var(--color-success-light);
  color: var(--color-success);
}

.verdict-chip.ai-beneficial {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.verdict-chip.ai-hybrid {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.verdict-chip.ai-conventional {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
}

.verdict-chip.ai-unsuitable {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.ai-fit-blurb {
  font-size: 13px;
  color: var(--color-text-muted);
}

.ai-fit-text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.65;
}

.ai-fit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Score bars */
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 11px;
}

.score-row:last-child {
  margin-bottom: 0;
}

.score-label {
  flex: 0 0 210px;
  font-size: 13px;
  font-weight: 600;
}

.inverse-hint {
  font-weight: 500;
  color: var(--color-text-faint);
  font-size: 11.5px;
}

.score-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--color-surface-alt);
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
}

.score-fill.good {
  background: var(--color-success);
}

.score-fill.mid {
  background: var(--color-warning);
}

.score-fill.bad {
  background: var(--color-danger);
}

.score-fill.neutral {
  background: var(--color-border-strong);
}

.score-num {
  flex: 0 0 34px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

.score-pill {
  display: inline-block;
  min-width: 38px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.score-pill.good {
  background: var(--color-success-light);
  color: var(--color-success);
}

.score-pill.mid {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.score-pill.bad {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.score-pill.neutral {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

/* Report tables read as prose, not a fixed-width data grid. */
table.report-table {
  table-layout: auto;
  min-width: 720px;
}

.report-table tbody td {
  white-space: normal;
  overflow: visible;
  font-size: 13px;
  line-height: 1.55;
  vertical-align: top;
}

.report-table thead th {
  cursor: default;
}

/* Report body bits */
.report-para {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}

.report-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.report-list li {
  font-size: 13.5px;
  line-height: 1.65;
  margin-bottom: 5px;
}

.muted-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--color-text-faint);
  font-style: italic;
}

.mini-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.mini-label.good-label {
  color: var(--color-success);
}

.mini-label.bad-label {
  color: var(--color-danger);
}

.mini-value {
  font-size: 13.5px;
  line-height: 1.6;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 22px;
}

.estimate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.estimate-item {
  padding: 12px 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.estimate-value {
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.phase-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.phase-list li {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-primary);
  font-size: 13.5px;
}

.phase-duration {
  color: var(--color-text-muted);
  font-size: 12.5px;
  margin-left: 8px;
}

.phase-outcome {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-top: 3px;
  line-height: 1.55;
}

.final-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.final-value {
  font-size: 15px;
  font-weight: 700;
  margin-top: 3px;
}

.analysis-provenance {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--color-text-faint);
  line-height: 1.6;
}

/* ---------- Button icons ---------- */
.btn-icon {
  flex-shrink: 0;
  display: block;
}

.btn .btn-icon {
  margin-right: -1px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* ---- Tablet / small laptop ---- */
@media (max-width: 1024px) {
  .container {
    padding: 0 18px;
  }

  .navbar-inner {
    padding: 10px 18px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }

  .stat-card {
    padding: 15px 16px;
  }

  .stat-card .value {
    font-size: 24px;
  }

  .auth-shell {
    padding: 20px;
  }

  .auth-card {
    max-width: 420px;
    padding: 40px 36px;
  }

  .auth-logo .brand-mark {
    width: 96px;
    height: 96px;
  }

  .auth-logo h1 {
    font-size: 24px;
  }
}

/* ---- Tablet portrait ---- */
@media (max-width: 860px) {

  .form-grid,
  .form-row-3,
  .form-row-4,
  .form-row-2,
  .form-row-2-1,
  .conditional-block,
  .detail-grid,
  .role-select-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .navbar-inner {
    flex-wrap: wrap;
    gap: 10px;
  }

  .nav-links {
    width: 100%;
    order: 3;
    justify-content: flex-start;
  }

  .navbar-utility {
    margin-left: auto;
  }

  .page-header {
    align-items: stretch;
  }

  .page-header .actions {
    width: 100%;
  }

  .page-header .actions .btn {
    flex: 1;
    justify-content: center;
  }

  .filter-bar .field,
  .filter-bar .field.search {
    flex: 1 1 100%;
    min-width: 0;
  }

  .filter-bar .actions {
    width: 100%;
  }

  .filter-bar .actions .btn {
    flex: 1;
  }

  .modal {
    max-width: none !important;
  }

  /* --- Data table reflows into cards from tablet-portrait down: no horizontal
     scrolling anywhere below desktop width. --- */
  .table-wrap {
    overflow-x: visible;
    overflow-y: visible;
  }

  .data-table thead {
    display: none;
  }

  .data-table col {
    width: auto !important;
  }

  table.data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .data-table tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin: 0 0 14px;
    background: var(--color-surface);
  }

  .data-table tbody tr:hover {
    background: var(--color-surface);
  }

  .data-table tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--color-border);
    text-align: right;
    min-height: auto;
    overflow: visible;
    white-space: normal;
  }

  .data-table tbody tr td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .data-table tbody td::before {
    content: attr(data-label);
    flex-shrink: 0;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    min-width: 100px;
  }

  .data-table tbody td:not([data-label])::before {
    content: none;
  }

  .data-table tbody td[data-label="Actions"] {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    padding-top: 12px;
    padding-bottom: 0;
    text-align: right;
  }

  .data-table tbody td[data-label="Actions"]::before {
    content: "Actions";
    margin-bottom: 10px;
    width: 100%;
    text-align: left;
  }

  .row-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 3px;
    width: 100%;
  }

  .row-actions .btn {
    flex: 0 1 auto;
    padding: 7px 12px;
    font-size: 12px;
  }

  .row-actions .btn:has(.btn-icon) {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }

  .data-table tbody td {
    padding: 12px 14px;
  }

  .data-table tbody td[data-label="User"],
  .data-table tbody td[data-label="Submitter"] {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
  }

  .user-cell {
    gap: 8px;
  }

  .user-cell .u-email {
    font-size: 11.5px;
    word-break: break-all;
  }

  .submitter-cell {
    gap: 3px;
  }

  .submitter-name,
  .submitter-email,
  .name-cell {
    white-space: normal;
    word-break: break-word;
  }

  /* Analysis page: sidebar sits above the report instead of beside it. */
  .analysis-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .analysis-sidebar {
    position: static;
  }

  .proposal-list {
    max-height: 320px;
  }

  .ai-fit-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .estimate-grid,
  .final-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- Phone ---- */
@media (max-width: 640px) {
  .container {
    padding: 0 14px;
  }

  .page {
    padding: 20px 0 48px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .card-body,
  .card-header {
    padding: 18px 16px;
  }

  .auth-shell {
    padding: 16px;
  }

  .auth-card {
    max-width: 100%;
    padding: 32px 24px;
  }

  .auth-logo .brand-mark {
    width: 80px;
    height: 80px;
    border-radius: 18px;
  }

  .auth-logo h1 {
    font-size: 22px;
  }

  .auth-logo p {
    font-size: 13px;
  }

  .auth-card--wide {
    max-width: 100%;
  }

  .mfa-qr-wrap svg {
    width: 140px;
    height: 140px;
  }

  .mfa-backup-grid {
    grid-template-columns: 1fr;
  }

  .mfa-step {
    flex-direction: column;
    gap: 10px;
  }

  .mfa-step-num {
    width: 24px;
    height: 24px;
    font-size: 12px;
    margin-top: 0;
  }

  body {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-direction: row;
  }

  .sidebar-header {
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
    padding: 12px 16px;
  }

  .sidebar-header .brand {
    font-size: 14px;
  }

  .brand-org {
    font-size: 9px;
    letter-spacing: 0.14em;
  }

  .brand-product {
    font-size: 15px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .nav-links {
    flex-direction: row;
    padding: 0;
    margin: 0 auto;
    flex: 1;
  }

  .nav-link {
    margin: 0;
    padding: 8px 10px;
    font-size: 12px;
  }

  .nav-link span {
    display: inline;
  }

  .nav-user {
    border-top: none;
    padding: 8px 12px;
  }

  main {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
  }

  .stat-card {
    padding: 13px 14px;
  }

  .stat-card .label {
    font-size: 11px;
  }

  .stat-card .value {
    font-size: 21px;
  }

  .filter-bar {
    padding: 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .filter-bar .field {
    min-width: 140px;
  }

  .filter-bar .field.search {
    flex: 1 1 100%;
    min-width: 0;
  }

  .filter-bar .actions {
    width: 100%;
    gap: 8px;
  }

  .filter-bar .actions .btn {
    flex: 1;
  }

  .empty-state {
    padding: 40px 16px;
  }

  .pagination {
    padding: 14px;
    justify-content: center;
    gap: 12px;
  }

  .pagination .pages {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* --- Modals become near-full-screen sheets --- */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-height: 94vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .modal-footer {
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .export-menu {
    right: auto;
    left: 0;
    min-width: 200px;
  }

  /* Reject flow */
  .reject-steps {
    gap: 7px;
  }

  .reject-step {
    font-size: 11.5px;
  }

  .reject-step-sep {
    width: 16px;
  }

  #reject-final {
    font-size: 12.5px;
  }

  .draft-actions {
    flex-wrap: wrap;
  }

  /* LLM Config: the per-provider cards reuse .modal-footer for their actions. */
  .llm-card .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .llm-card .modal-footer .btn {
    width: 100%;
  }

  .role-select-grid {
    gap: 8px;
  }

  .toast-container {
    top: auto;
    bottom: 14px;
    left: 14px;
    right: 14px;
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  /* Analysis page on a phone */
  .verdict-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 18px;
  }

  .verdict-decision {
    font-size: 16px;
  }

  .vs-num {
    font-size: 32px;
  }

  .score-row {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .score-label {
    flex: 1 1 100%;
  }

  .estimate-grid,
  .final-grid {
    grid-template-columns: 1fr;
  }

  /* Report tables keep their own scroll rather than reflowing into cards —
     these are wide comparison grids, not per-record rows. */
  table.report-table {
    min-width: 640px;
  }

  .report-table thead {
    display: table-header-group;
  }

  .report-table,
  .report-table tbody,
  .report-table tr,
  .report-table td {
    display: revert;
    width: auto;
  }

  .report-table tbody tr {
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    background: none;
  }

  .report-table tbody td {
    display: table-cell;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    padding: 10px 12px;
  }

  .report-table tbody td::before {
    content: none;
  }
}

/* ---- Small phone ---- */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page-header .actions {
    flex-direction: column;
  }

  .page-header .actions .btn,
  .page-header .actions .export-dropdown {
    width: 100%;
  }

  .page-header .actions .export-dropdown .btn {
    width: 100%;
  }

  .auth-shell {
    padding: 12px;
  }

  .auth-card {
    max-width: 100%;
    padding: 28px 20px;
  }

  .auth-logo {
    margin-bottom: 20px;
  }

  .auth-logo .brand-mark {
    width: 70px;
    height: 70px;
    border-radius: 16px;
  }

  .auth-logo h1 {
    font-size: 20px;
  }

  .auth-logo p {
    font-size: 12px;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"] {
    padding: 13px 12px;
    font-size: 16px;
  }

  .btn {
    padding: 12px 16px;
    font-size: 14px;
    min-height: 44px;
  }

  .btn-block {
    margin-bottom: 10px;
  }

  .field {
    gap: 5px;
    margin-bottom: 14px;
  }

  .field label {
    font-size: 12px;
  }

  .auth-footer {
    font-size: 12px;
    margin-top: 16px;
  }

  .demo-hint {
    font-size: 11.5px;
    padding: 10px 12px;
  }
}