/* ==========================================================================
   Swarelic AI — component system
   Task-management visual language: flat surfaces, hairline borders, dense
   typography, blue accent, no gradients, no shadows, no movement on hover.
   Sections:
     1. Design tokens
     2. Global base
     3. App shell (topbar / sidebar / main)
     4. Layout primitives
     5. Navigation
     6. Forms
     7. Buttons and actions
     8. Feedback
     9. Patterns
    10. App-specific components
    11. Bootstrap bridge
    12. Responsive
   ========================================================================== */

/* --- 1. Design tokens --------------------------------------------------- */
:root {
  --ui-bg: #e4eaf0;
  --ui-surface: #ffffff;
  --ui-surface-soft: #ffffff;
  --ui-surface-muted: #f4f9ff;
  --ui-border: #c9cfd6;
  --ui-border-strong: #b3bbc5;

  --ui-text: #111827;
  --ui-muted: #3f4855;
  --ui-soft: #5a6472;

  --ui-blue: #0269cb;
  --ui-blue-dark: #0257ad;
  --ui-blue-strong: #0269cb;
  --ui-header-bg: var(--ui-surface);
  --ui-blue-stronger: #0257ad;
  --ui-blue-soft: #dff0f5;
  --ui-azure: #05b3fd;

  --ui-green: #16954b;
  --ui-green-strong: #128543;
  --ui-green-light: #93da7b;
  --ui-green-soft: #e6f6df;
  --ui-red: #e54d58;
  --ui-red-strong: #c53742;
  --ui-red-soft: #fdefef;
  --ui-pink: #cf4eb7;
  --ui-pink-soft: #fbecf7;
  --ui-orange: #f18234;
  --ui-orange-strong: #bd560e;
  --ui-orange-soft: #fdeadb;
  --ui-purple: #8068d8;
  --ui-purple-soft: #f1effc;

  --ui-radius-sm: 10px;
  --ui-radius-md: 12px;
  --ui-radius-lg: 16px;
  --ui-radius-xs: 8px;
  --ui-border-soft: #e3e7ec;
  --ui-fill-soft: #f5f7fa;
  --ui-stroke: #8793a1;
  --ui-teal: #0b7468;
  --ui-teal-soft: #e1f3ef;
  --ui-purple-strong: #6446c8;
  --ui-pink-strong: #b3327f;

  --ui-sidebar-width: 300px;
  --ui-header-height: 72px;
  --ui-font: Urbanist, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Aliases kept for template inline styles that reference the older names. */
  --ui-primary: var(--ui-blue);
  --ui-primary-dark: var(--ui-blue-dark);
  --ui-primary-deep: var(--ui-blue-dark);
  --ui-primary-soft: var(--ui-blue-soft);
  --ui-secondary: var(--ui-blue-dark);
  --ui-success: var(--ui-green);
  --ui-warning: var(--ui-orange);
  --ui-danger: var(--ui-red);
  --ui-danger-dark: #b8323d;
  --ui-info: var(--ui-blue);
  --ui-page: var(--ui-bg);
  --ui-text-muted: var(--ui-muted);
  --ui-text-soft: var(--ui-soft);
  --ui-hover: #edf6ff;
  --ui-fill-muted: var(--ui-surface-muted);
  --ui-track: #cfd6de;
  --ui-shadow-sm: none;
  --ui-shadow-md: none;
  --ui-sidebar-width-alias: var(--ui-sidebar-width);
}

/* --- 2. Global base ----------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--ui-font);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -.005em;
}

button, input, select, textarea { font: inherit; }

a { color: var(--ui-blue-dark); text-decoration: none; }
a:hover { color: var(--ui-blue-dark); text-decoration: underline; }

:focus-visible { outline: 2px solid rgba(2,105,203,.55); outline-offset: 2px; }

a, button, input, select, textarea {
  transition: background-color .12s linear, border-color .12s linear, color .12s linear;
}

/* Flat by design: nothing lifts, scales or shifts on hover. */
.ui-card:hover, .ui-btn:hover, .ui-icon-button:hover, .ui-chip:hover,
.ui-list-item:hover, .sidebar-link:hover, .task-card:hover {
  transform: none;
  scale: none;
  translate: none;
}

h1, h2, h3, h4, h5, h6 { letter-spacing: -.02em; font-weight: 800; }

.mini-muted { color: var(--ui-muted); font-size: 15px; }

/* --- 3. App shell ------------------------------------------------------- */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1040;
  height: var(--ui-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: var(--ui-header-bg);
  color: var(--ui-text);
  border-bottom: 1px solid var(--ui-border-strong);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  color: var(--ui-text);
  text-decoration: none;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.app-brand:hover { color: var(--ui-text); text-decoration: none; }

.app-brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface-soft);
  color: var(--ui-text);
  overflow: hidden;
}

.app-brand-mark img { height: 26px; width: auto; }

.app-header-actions { display: flex; align-items: center; gap: 8px; }

.app-icon-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-muted);
}
.app-icon-btn:hover { background: var(--ui-surface-soft); border-color: var(--ui-border-strong); color: var(--ui-text); }

.app-header-search { position: relative; flex: 0 1 400px; min-width: 0; }
.app-header-search .ui-input { padding-left: 48px; min-height: 48px; }
.app-header-search .ui-input::placeholder { color: var(--ui-soft); }
.app-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ui-soft);
  pointer-events: none;
}

.app-header-user {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.app-header-user:hover { background: var(--ui-surface-soft); border-color: var(--ui-border-strong); text-decoration: none; }

.app-sidebar {
  position: fixed;
  top: var(--ui-header-height);
  bottom: 0;
  left: 0;
  z-index: 1035;
  width: var(--ui-sidebar-width);
  overflow-y: auto;
  padding: 16px 12px 40px;
  background: var(--ui-surface);
  color: var(--ui-muted);
  border-right: 1px solid var(--ui-border-strong);
  transition: transform .2s ease;
}
.app-sidebar.is-collapsed { transform: translateX(calc(-1 * var(--ui-sidebar-width))); }
.app-sidebar { scrollbar-width: none; -ms-overflow-style: none; }
.app-sidebar::-webkit-scrollbar { width: 0; height: 0; display: none; }

.sidebar-intro { padding: 8px 16px 16px; border-bottom: 1px solid var(--ui-border); margin-bottom: 12px; }
.sidebar-intro-title { color: var(--ui-text); font-weight: 800; font-size: 17px; }
.sidebar-intro-text { margin-top: 4px; color: var(--ui-muted); font-size: 13px; }

.sidebar-group { margin: 12px 0 20px; }
.sidebar-group-title {
  padding: 8px 16px 8px;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 40px;
  margin: 1px 0;
  padding: 6px 16px;
  border-radius: 12px;
  color: var(--ui-muted);
  text-decoration: none;
  font-size: 16px;
}
.sidebar-link:hover {
  background: var(--ui-blue-soft);
  color: var(--ui-blue-dark);
  text-decoration: none;
}
/* NAV-02: the active item is a hard left rule, not a filled pill. */
.sidebar-link.active {
  background: transparent;
  color: var(--ui-text);
  font-weight: 600;
  border-left: 2px solid var(--ui-blue-dark);
  border-radius: 0;
  padding-left: 14px;
  text-decoration: none;
}
.sidebar-link i { font-size: 20px; }

.app-main {
  margin-left: var(--ui-sidebar-width);
  padding: calc(var(--ui-header-height) + 24px) 28px 64px;
  background: var(--ui-bg);
  min-height: 100vh;
  transition: margin-left .2s ease;
}
.app-main.is-expanded { margin-left: 0; }

.app-module {
  padding: 24px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.app-module > :last-child { margin-bottom: 0; }

/* --- 4. Layout primitives ----------------------------------------------- */
.ui-container { width: min(100%, 1320px); margin-inline: auto; padding-inline: 20px; }

.ui-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.ui-col-4 { grid-column: span 4; }
.ui-col-6 { grid-column: span 6; }
.ui-col-8 { grid-column: span 8; }
.ui-col-12 { grid-column: span 12; }

.ui-stack { display: flex; }
.ui-stack-v { flex-direction: column; }
.ui-stack-h { flex-direction: row; align-items: center; }
.ui-gap-2 { gap: 8px; }
.ui-gap-3 { gap: 16px; }
.ui-gap-4 { gap: 24px; }

.ui-divider { border: 0; border-top: 1px solid var(--ui-border); margin: 16px 0; }
.ui-divider-v { width: 1px; align-self: stretch; background: var(--ui-border); }

.ui-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  overflow: hidden;
}
.ui-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-size: 18px;
  font-weight: 800;
}
.ui-card-body { padding: 20px; }
.ui-card-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-muted);
  font-size: 15px;
}

.ui-section {
  padding: 24px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-section h3 { margin: 0 0 8px; font-size: 20px; font-weight: 800; }
.ui-section p { margin: 0; color: var(--ui-muted); font-size: 16px; }

.ui-page { padding: 20px; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-page-title { margin: 0 0 8px; font-size: 27px; font-weight: 800; }
.ui-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.ui-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-header-nav, .ui-navbar-links { display: flex; align-items: center; gap: 20px; }
.ui-header-nav a, .ui-navbar-links a { color: var(--ui-muted); text-decoration: none; font-size: 16px; }
.ui-header-nav a:hover, .ui-navbar-links a:hover { color: var(--ui-blue-dark); }

.ui-sidebar {
  width: 330px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  overflow: hidden;
}
.ui-sidebar.collapsed { width: 90px; }
.ui-sidebar.collapsed .sidebar-text { display: none; }
.ui-sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--ui-border); background: var(--ui-surface); font-weight: 800; }
.ui-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 8px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--ui-muted);
  text-decoration: none;
  font-size: 16px;
}
.ui-sidebar-nav a:hover, .ui-sidebar-nav a.active { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

/* --- 5. Navigation ------------------------------------------------------ */
.ui-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-navbar-brand { color: var(--ui-text); text-decoration: none; font-weight: 800; }

.ui-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ui-muted);
  font-size: 16px;
}
.ui-breadcrumb li + li::before { content: "/"; margin-right: 8px; color: var(--ui-soft); }
.ui-breadcrumb a { color: var(--ui-blue-dark); text-decoration: none; }

.ui-tabs { display: flex; gap: 8px; padding: 0 4px; border-bottom: 1px solid var(--ui-border); }
.ui-tab {
  padding: 12px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--ui-muted);
  font-weight: 700;
  font-size: 16px;
}
.ui-tab:hover { background: var(--ui-blue-soft); color: var(--ui-text); }
.ui-tab.active { background: var(--ui-surface); color: var(--ui-text); border-bottom-color: var(--ui-blue); }

.ui-dropdown-menu { padding: 8px; border: 1px solid var(--ui-border-strong); border-radius: 12px; background: var(--ui-surface); }
.ui-dropdown-menu .dropdown-item { padding: 8px 16px; border-radius: 10px; font-size: 16px; }
.ui-dropdown-menu .dropdown-item:hover { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

.ui-pagination .page-link { min-width: 51px; text-align: center; color: var(--ui-muted); border-color: var(--ui-border); font-size: 16px; }
.ui-pagination .page-item.active .page-link { background: var(--ui-blue-strong); border-color: var(--ui-blue-strong); color: #fff; }

.ui-stepper { display: flex; align-items: flex-start; justify-content: space-between; }
.ui-step { position: relative; flex: 1; text-align: center; color: var(--ui-muted); font-size: 15px; }
.ui-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 22px;
  left: 55%;
  right: -45%;
  height: 1px;
  background: var(--ui-border-strong);
}
.ui-step-circle {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 50%;
  background: var(--ui-surface);
  font-weight: 800;
}
.ui-step-label { display: block; }
.ui-step.active { color: var(--ui-blue-dark); }
.ui-step.active .ui-step-circle { border-color: var(--ui-blue-strong); background: var(--ui-blue-strong); color: #fff; }
.ui-step.complete::after, .ui-step.done::after { background: var(--ui-blue); }
.ui-step.complete .ui-step-circle, .ui-step.done .ui-step-circle { border-color: var(--ui-blue-strong); background: var(--ui-blue-strong); color: #fff; }

.ui-link { color: var(--ui-blue-dark); text-decoration: none; font-weight: 700; }
.ui-link:hover { text-decoration: underline; }

.ui-anchor-nav { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border: 1px solid var(--ui-border); border-radius: 12px; background: var(--ui-surface-soft); }
.ui-anchor-nav a { padding: 8px 12px; border-radius: 10px; color: var(--ui-muted); text-decoration: none; font-size: 15px; }
.ui-anchor-nav a:hover { background: var(--ui-surface); color: var(--ui-blue-dark); }

.ui-mega-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; padding: 20px; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-mega-menu h6 { margin-bottom: 8px; color: var(--ui-soft); font-size: 15px; font-weight: 800; text-transform: uppercase; }
.ui-mega-menu a { display: block; padding: 8px 0; color: var(--ui-text); text-decoration: none; font-size: 16px; }
.ui-mega-menu a:hover { color: var(--ui-blue-dark); }

.ui-back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--ui-muted);
  font-weight: 700;
  font-size: 16px;
  padding: 0;
}
.ui-back-button:hover { color: var(--ui-blue-dark); }

/* --- 6. Forms ----------------------------------------------------------- */
.ui-form { display: grid; gap: 16px; }
.ui-form-group { display: grid; gap: 8px; }
.ui-label { display: block; margin-bottom: 8px; font-size: 16px; font-weight: 800; }
.ui-form-group > .ui-label { margin-bottom: 0; }
.ui-help { color: var(--ui-muted); font-size: 15px; }
.ui-error { color: #b8323d; font-size: 15px; font-weight: 700; }

.ui-input, .ui-textarea, .ui-select {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid #cbd1d8;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  outline: 0;
  font-size: 16px;
}
.ui-input:hover, .ui-textarea:hover, .ui-select:hover { border-color: #b7c0c9; }
.ui-input:focus, .ui-textarea:focus, .ui-select:focus {
  border-color: #05b3fd;
  outline: 2px solid #dff0f5;
  outline-offset: 0;
}
.ui-textarea { min-height: 132px; resize: vertical; }

/* Search field with the icon inside the control, matching the header search. */
.ui-search { position: relative; }
.ui-search .ui-input { padding-left: 44px; }
.ui-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ui-soft);
  pointer-events: none;
}

/* Tom Select controls sit beside kit fields, so they share their metrics. */
.ts-wrapper .ts-control {
  min-height: 54px;
  padding: 11px 14px;
  border: 1px solid #cbd1d8;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 16px;
}
.ts-wrapper.focus .ts-control { border-color: #05b3fd; box-shadow: 0 0 0 2px #dff0f5; }
.ts-wrapper .ts-control > .item {
  border-radius: 8px;
  background: var(--ui-blue-soft);
  color: var(--ui-blue-dark);
  font-weight: 700;
}
.ts-dropdown { border: 1px solid var(--ui-border-strong); border-radius: 12px; }
.ts-dropdown .active { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

/* Native select arrows sit hard against the edge and differ per browser.
   One chevron, same offset as the Bootstrap select below it. */
.ui-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%235a6472' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
}
.ui-select[multiple], .ui-select[size]:not([size="1"]) {
  padding-right: 16px;
  background-image: none;
}
.ui-input.is-invalid, .ui-select.is-invalid, .ui-textarea.is-invalid { border-color: var(--ui-red); }

.ui-check { display: inline-flex; align-items: flex-start; gap: 10px; font-size: 16px; }
.ui-check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--ui-blue); }
.ui-radio-group { display: grid; gap: 12px; }
.ui-input + .mini-muted,
.ui-select + .mini-muted,
.ui-textarea + .mini-muted,
.ui-radio-group + .mini-muted,
.action-card small.mini-muted { display: block; margin-top: 6px; }
.ui-radio { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.ui-radio input { width: 18px; height: 18px; accent-color: var(--ui-blue); }

.ui-switch { position: relative; width: 60px; height: 32px; display: inline-block; }
.ui-switch input { opacity: 0; width: 0; height: 0; }
.ui-switch-track { position: absolute; inset: 0; border-radius: 999px; background: #cfd6de; cursor: pointer; }
.ui-switch-track::after { content: ""; position: absolute; width: 24px; height: 24px; left: 4px; top: 4px; border-radius: 50%; background: #fff; transition: left .12s linear; }
.ui-switch input:checked + .ui-switch-track { background: var(--ui-blue); }
.ui-switch input:checked + .ui-switch-track::after { left: 32px; }

.ui-slider { width: 100%; accent-color: var(--ui-blue); }
.ui-slider-value { color: var(--ui-blue-dark); font-weight: 800; font-size: 16px; }

.ui-upload {
  padding: 32px 24px;
  border: 1px dashed var(--ui-border-strong);
  border-radius: 12px;
  background: var(--ui-surface-soft);
  text-align: center;
  cursor: pointer;
}
.ui-upload:hover, .ui-upload.dragging { border-color: var(--ui-blue); background: var(--ui-blue-soft); }
.ui-upload input { display: none; }
.ui-upload-icon { margin-bottom: 8px; color: var(--ui-blue-dark); font-size: 36px; }

/* --- 7. Buttons and actions --------------------------------------------- */
.ui-btn {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.ui-btn:hover { text-decoration: none; }
.ui-btn-primary { background: var(--ui-blue-strong); border-color: var(--ui-blue-strong); color: #fff; }
.ui-btn-primary:hover { background: var(--ui-blue-stronger); border-color: var(--ui-blue-stronger); color: #fff; }
.ui-btn-secondary { background: var(--ui-surface); border-color: #c9d0d7; color: #2b3441; }
.ui-btn-secondary:hover { background: var(--ui-blue-soft); border-color: #bac3cc; color: #2b3441; }
.ui-btn-danger { background: var(--ui-red-strong); border-color: var(--ui-red-strong); color: #fff; }
.ui-btn-danger:hover { background: #b8323d; border-color: #b8323d; color: #fff; }
.ui-btn-link { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--ui-blue-dark); }
.ui-btn:disabled, .ui-btn.disabled { opacity: .6; cursor: not-allowed; pointer-events: none; }
/* Compact buttons for dense chrome: toolbars, popovers, table rows. */
.ui-btn-sm { min-height: 32px; padding: 0 12px; gap: 6px; border-radius: var(--ui-radius-xs); font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.ui-btn-sm i { font-size: 14px; }

.ui-icon-button {
  width: 54px;
  height: 54px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d3d8dd;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-muted);
  cursor: pointer;
}
.ui-icon-button:hover { background: var(--ui-blue-soft); border-color: #bfc7cf; color: #1f2937; }
.ui-icon-button, .ui-icon-button:hover { text-decoration: none; }
.ui-icon-button[aria-expanded="true"] { background: var(--ui-blue-soft); border-color: transparent; color: var(--ui-blue-dark); }
.ui-icon-button-sm { width: 32px; height: 32px; border-radius: var(--ui-radius-xs); font-size: 16px; }
.ui-icon-button-xs { width: 26px; height: 26px; border-radius: 6px; font-size: 13px; }
.ui-icon-button-ghost { border-color: transparent; background: transparent; color: var(--ui-soft); }
.ui-icon-button-ghost:hover { border-color: transparent; background: var(--ui-fill-soft); color: var(--ui-text); }
.ui-card-header .ui-icon-button { width: 36px; height: 36px; border-radius: 10px; }

.ui-fab {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ui-blue-strong);
  border-radius: 20px;
  background: var(--ui-blue-strong);
  color: #fff;
  font-size: 24px;
}
.ui-fab:hover { background: var(--ui-blue-stronger); border-color: var(--ui-blue-stronger); }

.ui-button-group { display: inline-flex; }
.ui-button-group .ui-btn { margin-left: -1px; border-radius: 0; }
.ui-button-group .ui-btn:first-child { margin-left: 0; border-radius: 12px 0 0 12px; }
.ui-button-group .ui-btn:last-child { border-radius: 0 12px 12px 0; }

.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ui-surface);
  border-color: var(--ui-border-strong);
  color: #4b5563;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
  cursor: pointer;
}
.ui-chip:hover { background: var(--ui-blue-soft); color: #2b3441; }
.ui-chip.active { background: var(--ui-blue-soft); border-color: #b9dfeb; color: #0269cb; }
.ui-chip-green { background: var(--ui-green-soft); color: #107c3f; }
.ui-chip-pink { background: #faedf7; color: #9c3286; }
.ui-chip-orange { background: var(--ui-orange-soft); color: #9f4a0e; }
.ui-chip-purple { background: #f0eefb; color: #705bc1; }

/* Status pills. .ui-badge-count is the small red counter from the reference. */
.ui-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ui-surface);
  border-color: var(--ui-border-strong);
  color: #4b5563;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 800;
}
.ui-badge-primary { background: var(--ui-blue); border-color: var(--ui-blue); color: #fff; }
.ui-badge-info { background: var(--ui-blue); border-color: var(--ui-blue); color: #fff; }
.ui-badge-success { background: var(--ui-green-strong); border-color: var(--ui-green-strong); color: #fff; }
.ui-badge-warning { background: var(--ui-orange-strong); border-color: var(--ui-orange-strong); color: #fff; }
.ui-badge-danger { background: var(--ui-red-strong); border-color: var(--ui-red-strong); color: #fff; }
.ui-badge-neutral { background: var(--ui-muted); border-color: var(--ui-muted); color: #fff; }
.ui-badge-dark { background: var(--ui-text); border-color: var(--ui-text); color: #fff; }
.ui-badge-count {
  min-width: 28px;
  padding: 5px 8px;
  border-color: var(--ui-red-strong);
  background: var(--ui-red-strong);
  color: #fff;
}
/* Small soft pills: a tinted background and a strong text colour from the same hue. */
.ui-badge-sm { min-height: 22px; padding: 0 9px; gap: 5px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.ui-badge-soft-success { background: var(--ui-green-soft); border-color: transparent; color: var(--ui-green-strong); }
.ui-badge-soft-danger { background: var(--ui-red-soft); border-color: transparent; color: var(--ui-red-strong); }
.ui-badge-soft-warning { background: var(--ui-orange-soft); border-color: transparent; color: var(--ui-orange-strong); }
.ui-badge-soft-purple { background: var(--ui-purple-soft); border-color: transparent; color: var(--ui-purple-strong); }
.ui-badge-soft-neutral { background: var(--ui-fill-soft); border-color: transparent; color: var(--ui-soft); }

/* --- 8. Feedback -------------------------------------------------------- */
.ui-alert {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 16px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  font-size: 16px;
}
.ui-alert-info { border: 1px solid var(--ui-blue); }
.ui-alert-success { border: 1px solid var(--ui-green); }
.ui-alert-warning { border: 1px solid var(--ui-orange); }
.ui-alert-danger { border: 1px solid var(--ui-red); }

.ui-toast { width: 400px; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); overflow: hidden; }
.ui-toast-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px; border-bottom: 1px solid var(--ui-border); font-size: 16px; }
.ui-toast-body { padding: 16px; color: var(--ui-muted); font-size: 15px; }

.ui-snackbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px;
  border: 1px solid #222;
  border-radius: 12px;
  background: #202630;
  color: #fff;
  font-size: 16px;
}

.ui-progress { height: 12px; overflow: hidden; border-radius: 999px; background: #d5dce4; }
.ui-progress-bar { height: 100%; border-radius: inherit; background: var(--ui-blue); }

.ui-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #cfd6dc;
  border-top-color: var(--ui-blue);
  border-radius: 50%;
  animation: ui-spin .8s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

.ui-skeleton { background: #dde3e9; border-radius: 10px; }
.ui-skeleton-line { height: 16px; margin-bottom: 12px; }
.ui-skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; }

.ui-tooltip-demo { display: inline-flex; align-items: center; gap: 8px; color: var(--ui-muted); border-bottom: 1px dashed var(--ui-soft); cursor: help; font-size: 16px; }

.ui-modal-content { border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-drawer.offcanvas { width: min(600px, 92vw); }

.ui-empty-state {
  padding: 40px 28px;
  text-align: center;
  border: 1px solid #d3d8dd;
  border-radius: 12px;
  background: var(--ui-surface-soft);
}
.ui-empty-icon { color: var(--ui-soft); font-size: 44px; }
.ui-empty-state h4 { margin: 12px 0 8px; font-size: 22px; }
.ui-empty-state p { margin: 0 0 16px; color: var(--ui-muted); font-size: 15px; }

/* --- 9. Patterns -------------------------------------------------------- */
.ui-accordion .accordion-item { border-color: var(--ui-border); }
.ui-accordion .accordion-button { font-size: 16px; }
.ui-accordion .accordion-button:not(.collapsed) { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

.ui-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ui-blue-soft);
  color: var(--ui-text);
  font-size: 15px;
  font-weight: 800;
}
.ui-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ui-avatar-group { display: flex; }
.ui-avatar-group .ui-avatar + .ui-avatar { margin-left: -12px; }

.ui-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); overflow: hidden; }
.ui-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-size: 16px;
}
.ui-list-item:last-child { border-bottom: 0; }

.ui-table-wrap { overflow-x: auto; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-table { width: 100%; min-width: 860px; border-collapse: collapse; background: var(--ui-surface); font-size: 15px; }
.ui-table th { padding: 12px 16px; background: var(--ui-surface); border-bottom: 1px solid var(--ui-border-strong); color: #414b59; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; text-align: left; }
.ui-table td { padding: 16px 16px; border-top: 1px solid var(--ui-border); }
.ui-table tbody tr:hover { background: #f7fbff; }

.ui-tree { margin: 0; padding: 0; list-style: none; font-size: 16px; }
.ui-tree ul { margin: 8px 0 0 28px; padding-left: 20px; list-style: none; }
.ui-tree-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.ui-tree-toggle { width: 32px; height: 32px; border: 0; background: transparent; color: var(--ui-muted); }
/* Toolbar: a floating strip of compact controls. Dividers separate groups. */
.ui-toolbar { display: flex; align-items: center; gap: 2px; padding: 5px; background: var(--ui-surface); border: 1px solid var(--ui-border-soft); border-radius: var(--ui-radius-md); }
.ui-toolbar form { display: flex; margin: 0; }
.ui-toolbar-divider { align-self: stretch; width: 1px; margin: 6px 5px; background: var(--ui-border-soft); }

/* Popover: a panel that hangs from the control that opened it, aligned to either end. */
.ui-popover { position: absolute; top: calc(100% + 8px); z-index: 20; width: 380px; max-width: calc(100vw - 48px); max-height: min(640px, calc(100dvh - 240px));
  overflow-y: auto; padding: 14px 14px 16px 16px; background: var(--ui-surface); border: 1px solid var(--ui-border-soft); border-radius: var(--ui-radius-md); cursor: auto; }
.ui-popover[hidden] { display: none; }
.ui-popover-start { left: -1px; }
.ui-popover-end { right: -1px; }
.ui-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ui-panel-title { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.ui-panel-note { margin: 0 0 12px; font-size: 12.5px; line-height: 1.5; color: var(--ui-soft); }

/* Menu: a searchable list of grouped choices, opened from a button. */
.ui-menu { position: absolute; z-index: 40; display: flex; flex-direction: column; width: 320px; max-height: 420px;
  background: var(--ui-surface); border: 1px solid var(--ui-border-soft); border-radius: var(--ui-radius-md); overflow: hidden; }
.ui-menu[hidden] { display: none; }
.ui-menu-search { position: relative; margin: 8px; }
.ui-menu-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--ui-soft); pointer-events: none; }
.ui-menu-search .ui-input { min-height: 36px; padding: 6px 10px 6px 34px; border: 0; border-radius: var(--ui-radius-xs); background: var(--ui-fill-soft); font-size: 13.5px; }
.ui-menu-search .ui-input:focus { outline: 2px solid var(--ui-blue-soft); }
.ui-menu-list { overflow-y: auto; padding: 0 6px 8px; }
.ui-menu-group { margin-bottom: 4px; }
.ui-menu-group[hidden] { display: none; }
.ui-menu-title { display: flex; align-items: center; gap: 7px; margin: 8px 0 2px; padding: 0 10px; font-size: 12px; font-weight: 700; color: var(--ui-soft); }
.ui-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; background: none; border: 0; border-radius: var(--ui-radius-xs); text-align: left; color: var(--ui-text); cursor: pointer; }
.ui-menu-item[hidden] { display: none; }
.ui-menu-item:hover, .ui-menu-item:focus-visible { background: var(--ui-fill-soft); }
.ui-menu-item:focus-visible { outline: 2px solid var(--ui-blue); outline-offset: -2px; }
.ui-menu-item-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 28px; height: 28px; border-radius: var(--ui-radius-xs); background: var(--ui-blue-soft); color: var(--ui-blue-dark); font-size: 14px; line-height: 1; }
.ui-menu-item-text { flex: 1; min-width: 0; display: grid; }
.ui-menu-item-label { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.ui-menu-item-description { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ui-soft); }
.ui-menu-item-meta { flex-shrink: 0; font-size: 11px; font-weight: 600; color: var(--ui-soft); font-variant-numeric: tabular-nums; }
.ui-menu-empty { margin: 0; padding: 4px 16px 14px; font-size: 13px; color: var(--ui-soft); }

/* --- 10. App-specific components ---------------------------------------- */
.ui-stat {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  padding: 20px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-stat-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--ui-blue-soft);
  color: var(--ui-blue-dark);
  font-size: 26px;
}
.ui-stat-value { font-size: 32px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.ui-stat-label { color: var(--ui-muted); font-size: 15px; }

.task-card { padding: 16px; margin-bottom: 12px; border: 1px solid var(--ui-border); border-radius: 12px; background: var(--ui-surface); }
.task-card:hover { background: #f7fbff; border-color: #bec8d2; }
.task-card-title { margin: 12px 0 8px; font-size: 17px; font-weight: 800; line-height: 1.35; }
.task-card-desc { color: #566070; font-size: 14px; line-height: 1.45; }
.task-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #dadee2; }

.action-sheet .modal-dialog { display: flex; align-items: flex-end; min-height: calc(100% - 1rem); margin: .5rem; max-width: none; }
.action-sheet .modal-content { border-radius: 16px 16px 0 0; }

/* --- 11. Bootstrap bridge ----------------------------------------------- */
:root {
  --bs-primary: var(--ui-blue);
  --bs-primary-rgb: 2, 105, 203;
  --bs-body-font-family: var(--ui-font);
  --bs-body-color: var(--ui-text);
  --bs-body-bg: var(--ui-surface);
  --bs-border-color: var(--ui-border);
}
.modal-content, .offcanvas, .dropdown-menu, .toast { border-color: var(--ui-border-strong); }
.dropdown-menu { padding: 8px; border-radius: 12px; }
.dropdown-item { padding: 8px 16px; border-radius: 10px; font-size: 16px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }
.modal-header, .offcanvas-header { border-bottom-color: var(--ui-border); }
.modal-footer { border-top-color: var(--ui-border); }
.modal-title, .offcanvas-title { font-size: 22px; font-weight: 800; }
.form-check-input:checked { background-color: var(--ui-blue); border-color: var(--ui-blue); }
.accordion-button:not(.collapsed) { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }
.table > :not(caption) > * > * { padding: 16px 16px; }
.table { --bs-table-bg: var(--ui-surface); font-size: 15px; }

/* Bootstrap's .alert-dismissible reserves padding-right for the absolutely
   positioned close button; .ui-alert's shorthand padding overrides it. */
.ui-alert.alert-dismissible { padding-right: 48px; }

/* Bootstrap controls sit beside kit controls, so they share its metrics. */
.btn:not(.btn-close) {
  --bs-btn-padding-y: 10px;
  --bs-btn-padding-x: 20px;
  --bs-btn-font-size: 16px;
  --bs-btn-font-weight: 800;
  --bs-btn-border-radius: 12px;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-sm:not(.btn-close) {
  --bs-btn-padding-y: 6px;
  --bs-btn-padding-x: 14px;
  --bs-btn-font-size: 14px;
  min-height: 38px;
}
.btn-primary {
  --bs-btn-bg: var(--ui-blue-strong);
  --bs-btn-border-color: var(--ui-blue-strong);
  --bs-btn-hover-bg: var(--ui-blue-stronger);
  --bs-btn-hover-border-color: var(--ui-blue-stronger);
  --bs-btn-active-bg: var(--ui-blue-stronger);
  --bs-btn-active-border-color: var(--ui-blue-stronger);
}
.btn-outline-secondary {
  --bs-btn-color: #2b3441;
  --bs-btn-border-color: #c9d0d7;
  --bs-btn-hover-bg: #f6f8fa;
  --bs-btn-hover-border-color: #bac3cc;
  --bs-btn-hover-color: #2b3441;
}
.form-control, .form-select {
  min-height: 54px;
  padding: 12px 16px;
}
.form-select {
  padding-right: 42px;
  background-position: right 14px center;
  background-size: 16px 16px;
}
.form-control, .form-select {
  border-color: #cbd1d8;
  border-radius: 12px;
  font-size: 16px;
}
.form-control:focus, .form-select:focus {
  border-color: #05b3fd;
  box-shadow: 0 0 0 2px #dff0f5;
}
.card { border-color: var(--ui-border-strong); border-radius: 16px; }

/* --- 12. Responsive ----------------------------------------------------- */
@media (max-width: 850px) {
  .app-sidebar { transform: translateX(calc(-1 * var(--ui-sidebar-width))); }
  .app-sidebar.mobile-open { transform: translateX(0); }
  .app-main { margin-left: 0; padding-inline: 16px; }
  .app-header-search { display: none; }
  .ui-header-nav, .ui-navbar-links { display: none; }
  .ui-mega-menu { grid-template-columns: 1fr; }
  .ui-col-4, .ui-col-6, .ui-col-8 { grid-column: span 12; }
}

/* Field library: shared kit controls with a persistent right-hand drawer. */
.field-key { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.field-library #field-notice { margin: 0; }
.field-library #field-notice:not(:empty) { margin-bottom: 16px; }
.field-table tbody tr[data-field-row] { cursor: pointer; }
.field-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: max(34vw, 400px); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0; border: 0; border-left: 1px solid var(--ui-border-strong); border-radius: 0; background: var(--ui-surface); color: var(--ui-text); overflow-y: auto; }
.field-drawer[open] { display: flex; flex-direction: column; overflow: hidden; }
.field-drawer::backdrop { background: transparent; }
.field-drawer-header { flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.field-drawer-header > div { min-width: 0; overflow-wrap: anywhere; }
.field-drawer-header .ui-icon-button { flex-shrink: 0; }
.field-drawer #field-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.field-drawer-body { flex: 1; min-height: 0; overflow-y: auto; }
.field-drawer-footer { flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; color: var(--ui-text); }
.field-save-actions { display: flex; justify-content: flex-end; gap: 8px; }
.field-preview { font-size: 15px; }
.field-preview p { margin: 6px 0; }
.field-preview p strong { display: inline-block; min-width: 88px; }
.field-preview .ui-select { width: auto; }
.field-type-group { margin: 0 0 16px; }
.field-type-group legend { margin-bottom: 8px; }
.field-type-option { align-items: flex-start; padding: 12px; border: 1px solid var(--ui-border-strong); border-radius: 12px; cursor: pointer; }
.field-type-option:has(input:checked) { background: var(--ui-blue-soft); border-color: var(--ui-blue); }
.field-type-option:focus-within { outline: 2px solid var(--ui-blue); outline-offset: 2px; }
.field-type-option small { display: block; }
.field-type-option input { flex-shrink: 0; margin-top: 3px; }
.field-type-unavailable { opacity: .65; cursor: default; }
.field-archive-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--ui-border-strong); }
.field-errors ul { padding-left: 20px; margin: 4px 0; }
.field-usages { padding-left: 20px; margin: 12px 0; }
.field-usages li { margin-bottom: 8px; }
.field-usages .mini-muted { display: block; }
.field-saved { animation: field-saved-highlight 3s ease-out; }
@keyframes field-saved-highlight { from { background: var(--ui-blue-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .field-saved { animation: none; outline: 2px solid var(--ui-blue); outline-offset: -2px; } }
@media (max-width: 600px) { .field-drawer { width: 100vw; } }

/* WKF-02 · the workflow canvas. Flat: hairlines, a dot grid, no shadows.
   The canvas is the page: it fills the module, and everything else floats over it on kit
   toolbars and popovers, so the flow keeps the room. In-call steps are solid, background
   steps are dashed, as if already detached from the live call. Every colour here is a
   --ui-* token; this block only composes them and adds layout. */
.app-module > .workflow-detail { margin: -24px; }
.app-main:has(.workflow-detail) { padding-bottom: 24px; }
.wf-builder { --wf-cat: var(--ui-soft);
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - var(--ui-header-height) - 50px); min-height: 560px; background: var(--ui-surface); border-radius: 15px; overflow: hidden; }
.wf-builder[data-expanded="true"] { position: fixed; inset: 0; z-index: 1040; height: auto; min-height: 0; border-radius: 0; }
body.wf-expanded-open { overflow: hidden; }
.wf-canvas-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.wf-stage { position: relative; flex: 1; min-height: 0; container: wf-stage / inline-size; }
.wf-canvas { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab;
  background-color: var(--ui-fill-soft); background-image: radial-gradient(var(--ui-border) 1px, transparent 1px); background-size: 24px 24px; }
.wf-canvas.is-panning { cursor: grabbing; }
.wf-nodes, .wf-edges { position: absolute; inset: 0; transform-origin: 0 0; }
.wf-edges { width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.wf-edge { fill: none; stroke: var(--ui-stroke); stroke-width: 1.75; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.wf-edge.is-ran { stroke: var(--ui-green-strong); stroke-width: 2.5; }
.wf-edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.wf-edge-hit:hover + .wf-edge { stroke: var(--ui-red-strong); stroke-width: 2; stroke-dasharray: 5 4; }
.wf-builder[data-read-only="true"] .wf-edge-hit { cursor: inherit; }
.wf-builder[data-read-only="true"] .wf-edge-hit:hover + .wf-edge { stroke: var(--ui-stroke); stroke-width: 1.75; stroke-dasharray: none; }

/* One colour per step category, carried by --wf-cat into cards, menu entries, the inspector and the trace. */
.wf-builder [data-category="conversation"] { --wf-cat: var(--ui-blue-strong); }
.wf-builder [data-category="logic"] { --wf-cat: var(--ui-teal); }
.wf-builder [data-category="commit"] { --wf-cat: var(--ui-purple-strong); }
.wf-builder [data-category="delivery"] { --wf-cat: var(--ui-pink-strong); }
.wf-builder [data-category="external"] { --wf-cat: var(--ui-orange-strong); }
.wf-node { position: absolute; display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; width: 208px; padding: 11px 12px 10px;
  background: var(--ui-surface); border: 1px solid color-mix(in srgb, var(--wf-cat) 26%, var(--ui-track)); border-radius: var(--ui-radius-md); box-shadow: none; cursor: grab;
  transition: border-color .12s linear, outline-color .12s linear; }
.wf-node:hover { border-color: color-mix(in srgb, var(--wf-cat) 60%, var(--ui-track)); }
.wf-node[data-execution="background"] { border-style: dashed; }
.wf-node[data-problem="warning"] { border-color: var(--ui-orange-strong); }
.wf-node[data-problem="error"] { border-color: var(--ui-red-strong); }
.wf-node[data-ran="true"] { border-color: var(--ui-green-strong); outline: 3px solid color-mix(in srgb, var(--ui-green-strong) 22%, transparent); }
.wf-node.is-selected { border-color: var(--wf-cat); outline: 3px solid color-mix(in srgb, var(--wf-cat) 24%, transparent); }
.wf-builder[data-read-only="true"] .wf-node { cursor: pointer; }
.wf-canvas.is-dragging, .wf-canvas.is-dragging .wf-node { cursor: grabbing; }
.wf-node-header { display: contents; }
.wf-node-icon, .wf-inspector-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 28px; height: 28px; border-radius: var(--ui-radius-xs); background: var(--wf-cat); color: var(--ui-surface); font-size: 14px; line-height: 1; }
.wf-builder .ui-menu-item-icon { background: var(--wf-cat); color: var(--ui-surface); }
.wf-builder .ui-menu-title::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--wf-cat); }
.wf-node-icon { grid-row: 1 / span 2; width: 30px; height: 30px; font-size: 15px; }
.wf-node-title { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700;
  line-height: 1.3; letter-spacing: -.01em; color: var(--ui-text); }
.wf-node[data-problem] .wf-node-title { padding-right: 18px; }
.wf-node-flag { position: absolute; top: 10px; right: 10px; font-size: 14px; line-height: 1; color: var(--ui-red-strong); }
.wf-node[data-problem="warning"] .wf-node-flag { color: var(--ui-orange-strong); }
.wf-node-summary { grid-column: 2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
  margin-top: 1px; font-size: 12.5px; font-weight: 500; line-height: 1.4; color: var(--ui-soft); }
.wf-node-summary.is-missing { color: var(--ui-orange-strong); font-weight: 600; }
.wf-node-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 9px; font-size: 11.5px; font-weight: 600; color: var(--ui-soft); font-variant-numeric: tabular-nums; }
.wf-node-meta span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.wf-node-meta i { font-size: 11px; }
.wf-node[data-waits="true"] .wf-node-meta span:last-child { color: var(--wf-cat); }
.wf-port { position: absolute; width: 10px; height: 10px; background: var(--ui-surface); border: 1.5px solid var(--ui-track); border-radius: 50%; transform: translate(-50%, -50%); }
.wf-port-in { left: 0; top: 26px; }
.wf-port-out { left: 100%; cursor: crosshair; }
.wf-port-out:hover { background: var(--wf-cat); border-color: var(--wf-cat); }
/* The "+" at the end of a step: press it for the step menu, drag it onto a step that exists. */
.wf-port.wf-port-add { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0;
  font-size: 14px; line-height: 1; color: var(--ui-soft); background: var(--ui-surface); border: 1px solid var(--ui-track); border-radius: 50%; cursor: pointer; }
.wf-port.wf-port-add:hover, .wf-port.wf-port-add:focus-visible { background: var(--wf-cat); border-color: var(--wf-cat); color: var(--ui-surface); outline: none; }
.wf-port-tag { position: absolute; left: calc(100% + 14px); transform: translateY(-50%); min-height: 0; padding: 1px 7px; font-size: 10.5px; line-height: 14px; pointer-events: none; }
.wf-canvas-hint { position: absolute; left: 50%; bottom: 76px; z-index: 5; display: flex; align-items: center; gap: 8px; margin: 0; padding: 7px 14px;
  transform: translateX(-50%); background: var(--ui-surface); border: 1px solid var(--ui-border-soft); border-radius: 999px;
  font-size: 13px; color: var(--ui-soft); white-space: nowrap; pointer-events: none; }
.wf-canvas-hint[hidden] { display: none; }
.wf-canvas-hint i { color: var(--ui-blue-strong); }
.wf-readonly-note { transition: background-color .2s linear, border-color .2s linear, color .2s linear; }
.wf-readonly-note i { color: var(--ui-soft); }
.wf-readonly-note.is-flashing { background: var(--ui-blue-soft); border-color: var(--ui-blue-strong); color: var(--ui-blue-dark); }
.wf-readonly-note.is-flashing i { color: var(--ui-blue-dark); }

.wf-overlay { position: absolute; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px; pointer-events: none; }
.wf-overlay-top { top: 0; }
.wf-overlay-bottom { bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; }
.wf-overlay .ui-toolbar { position: relative; pointer-events: auto; }
.wf-stage .ui-popover { max-width: min(calc(100vw - 48px), calc(100cqw - 28px)); }
.wf-identity { flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; max-width: min(560px, 100%); padding: 10px 12px 10px 16px; }
.wf-identity-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.wf-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 800; line-height: 1.25; letter-spacing: -.02em; }
.wf-identity-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--ui-soft); }
.wf-version { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.wf-version i { font-size: 12px; }
.wf-version[data-version-state="live"] i { color: var(--ui-green-strong); }
.wf-version[data-version-state="draft"] i { color: var(--ui-blue-strong); }
.wf-version[data-version-state="past"] { color: var(--ui-orange-strong); }
[data-verdict] { cursor: pointer; }
[data-verdict]:disabled { cursor: default; }
[data-verdict][data-state="outstanding"]:hover, [data-verdict][aria-expanded="true"] { outline: 1px solid currentColor; outline-offset: -1px; }
.wf-save-state { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; color: var(--ui-soft); }
.wf-save-state[data-state="failed"] { font-size: 12.5px; font-weight: 600; color: var(--ui-red-strong); }
.wf-help { cursor: help; }
.wf-discard { position: relative; }
.wf-discard:hover { background: var(--ui-red-soft); color: var(--ui-red-strong); }
.wf-count { position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border: 2px solid var(--ui-surface); border-radius: 999px; background: var(--ui-blue-strong);
  color: var(--ui-surface); font-size: 9.5px; font-weight: 800; line-height: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.wf-count[data-change-count="0"] { display: none; }
.wf-tools { justify-self: center; }
.wf-tools .wf-add-step { margin-right: 2px; }

/* WKF-11 · the budget is per turn, so the meter reads the busiest one. */
.wf-meter { justify-self: start; gap: 8px; height: 44px; padding: 0 14px; font-size: 12.5px; color: var(--ui-soft); }
.wf-meter i { font-size: 14px; }
.wf-meter-text { font-weight: 700; color: var(--ui-text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wf-meter-track { display: block; width: 88px; height: 4px; overflow: hidden; border-radius: 999px; background: var(--ui-border-soft); }
.wf-meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--ui-blue-strong); }
.wf-meter[data-over="true"] { color: var(--ui-red-strong); }
.wf-meter[data-over="true"] .wf-meter-text { color: var(--ui-red-strong); }
.wf-meter[data-over="true"] .wf-meter-fill { background: var(--ui-red-strong); }

/* WKF-10 · problems, listed errors first, each one a way back to the step. */
.wf-problem-list { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
.wf-problem-button { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; background: none; border: 0; border-radius: var(--ui-radius-xs);
  text-align: left; font-size: 13.5px; line-height: 1.45; color: var(--ui-text); cursor: pointer; }
.wf-problem-button:hover { background: var(--ui-fill-soft); }
.wf-problem-button i { margin-top: 2px; color: var(--ui-red-strong); }
.wf-problem[data-severity="warning"] .wf-problem-button i { color: var(--ui-orange-strong); }

.wf-history-list { display: grid; gap: 2px; list-style: none; margin: 6px 0 0; padding: 0; }
.wf-history-entry { display: flex; align-items: center; gap: 6px; border-radius: var(--ui-radius-xs); }
.wf-history-entry.is-current { background: var(--ui-fill-soft); }
.wf-history-link { flex: 1; min-width: 0; display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 8px; padding: 8px 10px; border-radius: var(--ui-radius-xs); color: var(--ui-text); }
.wf-history-link:hover { background: var(--ui-fill-soft); color: var(--ui-text); text-decoration: none; }
.wf-history-version { grid-row: span 2; align-self: center; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wf-history-status { font-size: 12.5px; font-weight: 700; color: var(--ui-soft); }
.wf-history-status[data-status="published"] { color: var(--ui-green-strong); }
.wf-history-status[data-status="draft"] { color: var(--ui-blue-strong); }
.wf-history-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ui-soft); }

/* WKF-03 · inspector controls, generated from the step registry. A column beside the canvas, never over it. */
.wf-inspector { width: 340px; min-height: 0; background: var(--ui-surface); border-left: 1px solid var(--ui-border-soft); overflow-y: auto; }
.wf-inspector-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 16px 14px 14px 18px;
  background: var(--ui-surface); border-bottom: 1px solid var(--ui-border-soft); }
.wf-inspector-icon { width: 36px; height: 36px; border-radius: 10px; font-size: 17px; }
.wf-inspector-heading { flex: 1; min-width: 0; display: grid; gap: 1px; }
.wf-inspector-heading .field-key { font-size: 12px; color: var(--ui-soft); }
.wf-inspector-body { padding: 16px 18px 22px; }
.wf-inspector-description { margin: 0 0 18px; font-size: 13.5px; line-height: 1.55; color: var(--ui-soft); }
.wf-setting { margin-bottom: 16px; }
.wf-inspector .ui-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12.5px; font-weight: 700; color: var(--ui-text); }
.wf-setting-optional { font-size: 12px; font-weight: 500; color: var(--ui-soft); }
.wf-inspector .ui-help { margin: 5px 0 0; font-size: 12px; color: var(--ui-soft); }
.wf-inspector .ui-input, .wf-inspector .ui-select, .wf-inspector .ui-textarea { min-height: 38px; padding: 7px 11px; border-color: var(--ui-track); border-radius: var(--ui-radius-xs); font-size: 13.5px; }
.wf-inspector .ui-select { padding-right: 34px; background-position: right 10px center; }
.wf-inspector .ui-textarea { min-height: 84px; }
.wf-inspector .ui-input:disabled, .wf-inspector .ui-select:disabled, .wf-inspector .ui-textarea:disabled { background-color: var(--ui-fill-soft); color: var(--ui-soft); cursor: not-allowed; }
.wf-behaviour { display: flex; align-items: flex-start; gap: 8px; margin: 20px 0 0; padding: 10px 12px; background: var(--ui-fill-soft);
  border-radius: var(--ui-radius-xs); font-size: 12.5px; line-height: 1.5; color: var(--ui-soft); }
.wf-behaviour i, .wf-inspector-problem i, .wf-broken-note i { margin-top: 2px; }
.wf-inspector-problem { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0; padding: 10px 12px; background: var(--ui-red-soft);
  border-radius: var(--ui-radius-xs); font-size: 12.5px; line-height: 1.5; color: var(--ui-red-strong); }
.wf-inspector-problem[data-severity="warning"] { background: var(--ui-orange-soft); color: var(--ui-orange-strong); }
.wf-remove-step { width: 100%; min-height: 36px; margin-top: 22px; border: 0; background: none; color: var(--ui-red-strong); }
.wf-remove-step:hover { background: var(--ui-red-soft); color: var(--ui-red-strong); }
.wf-broken { border-color: var(--ui-red-strong); color: var(--ui-red-strong); }
.wf-broken-note { display: flex; align-items: flex-start; gap: 6px; margin: 5px 0 0; font-size: 12px; color: var(--ui-red-strong); }

/* WKF-12 · the test call, and the steps it walked outlined in place on the canvas. */
.wf-testcall { width: 400px; }
.wf-testcall .ui-textarea { min-height: 84px; padding: 9px 12px; border-color: var(--ui-track); border-radius: var(--ui-radius-xs); font-size: 13.5px; line-height: 1.55; }
.wf-test-options { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 12px; }
.wf-test-options .ui-check { align-items: center; gap: 8px; font-size: 13.5px; }
.wf-test-options .ui-check input { width: 16px; height: 16px; margin: 0; }
.wf-run { width: 100%; min-height: 38px; }
.wf-test-ending { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; padding: 10px 12px; background: var(--ui-fill-soft); border-radius: var(--ui-radius-xs);
  font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.wf-test-ending[hidden] { display: none; }
.wf-test-ending[data-tone="error"] { background: var(--ui-red-soft); color: var(--ui-red-strong); }
.wf-test-ending i { margin-top: 2px; color: var(--ui-blue-strong); }
.wf-test-ending[data-tone="error"] i { color: var(--ui-red-strong); }
.wf-run-trace { display: grid; list-style: none; margin: 10px 0 0 6px; padding: 0 0 0 10px; border-left: 1px solid var(--ui-border-soft); }
.wf-run-step-button { display: grid; gap: 2px; width: 100%; padding: 7px 8px; background: none; border: 0; border-radius: var(--ui-radius-xs); text-align: left; color: var(--ui-text); cursor: pointer; }
.wf-run-step-button:hover { background: var(--ui-fill-soft); }
.wf-run-step-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; }
.wf-run-step-head i { font-size: 13px; color: var(--wf-cat); }
.wf-run-step-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-run-step-outcome { flex-shrink: 0; min-height: 0; padding: 1px 7px; font-size: 10.5px; line-height: 14px; }
.wf-run-step-detail { font-size: 12.5px; line-height: 1.45; color: var(--ui-soft); }
.wf-run-step[data-outcome="failed"] .wf-run-step-detail { color: var(--ui-red-strong); }

@keyframes wf-spin { to { transform: rotate(360deg); } }
.wf-spin, .wf-save-state[data-state="saving"] i { display: inline-block; animation: wf-spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .wf-spin, .wf-save-state[data-state="saving"] i { animation: none; } .wf-node { transition: none; } }
@media (max-width: 1280px) { .wf-inspector { width: 300px; } }
@media (max-width: 900px) {
  .wf-builder { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; min-height: 0; }
  .wf-stage { flex: none; height: 72vh; min-height: 460px; }
  .wf-inspector { width: auto; border-left: 0; border-top: 1px solid var(--ui-border-soft); }
}
@container wf-stage (max-width: 760px) {
  .wf-overlay-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .wf-identity { max-width: 100%; }
  .wf-stage .ui-popover-end { right: auto; left: -1px; }
  .wf-overlay-bottom { grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 8px; }
  .wf-tools { justify-self: start; flex-wrap: wrap; }
  .wf-canvas-hint { bottom: 128px; max-width: calc(100% - 24px); white-space: normal; }
}
@container wf-stage (max-width: 480px) { .wf-meter-track { display: none; } }

/* SAF-05 · the run trace, read the same way in the builder and in history. */
.wf-outcome { padding: 1px 8px; border: 1px solid var(--ui-border-strong); border-radius: 2px; font-size: 12px; }
.wf-outcome[data-outcome="failed"] { border-color: var(--ui-danger, #b3261e); color: var(--ui-danger, #b3261e); }
.wf-outcome[data-outcome="partial"] { border-color: #b26a00; color: #b26a00; }
.wf-outcome[data-outcome="waiting"] { border-color: #7a5cff; color: #7a5cff; }
.wf-trace { list-style: none; margin: 0; padding: 0; }
.wf-trace-step { border-left: 2px solid var(--ui-border-strong); padding: 8px 12px; margin-bottom: 4px; }
.wf-trace-step[data-outcome="failed"] { border-left-color: var(--ui-danger, #b3261e); }
.wf-trace-step[data-outcome="skipped"] { border-left-color: var(--ui-muted); }
.wf-trace-head { display: flex; gap: 12px; align-items: baseline; }
.wf-trace-error { color: var(--ui-danger, #b3261e); }
.wf-diff-steps { list-style: none; margin: 0; padding: 0; }
.wf-diff-steps li { border-left: 3px solid transparent; padding: 4px 10px; }
.wf-diff-steps li[data-diff="added"] { border-left-color: #1a7f37; }
.wf-diff-steps li[data-diff="removed"] { border-left-color: var(--ui-danger, #b3261e); text-decoration: line-through; }
.wf-diff-steps li[data-diff="changed"] { border-left-color: #b26a00; }
/* NAV-03 · one centred block of plain text and a single action. No illustrations. */
.ui-empty { max-width: 520px; margin: 48px auto; text-align: center; }
.ui-empty h2 { font-size: 18px; margin-bottom: 8px; }
.ui-empty p { color: var(--ui-muted); margin-bottom: 16px; }
.ui-empty form { display: inline-block; }
/* NAV-04 · anchors rather than tabs, so the browser's own find works across the page. */
.settings-rail { position: sticky; top: 0; background: var(--ui-surface); border-bottom: 1px solid var(--ui-border); padding: 6px 0; margin-bottom: 12px; z-index: 2; }
.settings-rail ol { display: flex; flex-wrap: wrap; gap: 12px; list-style: none; margin: 0; padding: 0; font-size: 13px; }
.settings-section-blurb { margin: 0 0 8px; color: var(--ui-muted); font-size: 13px; }
.settings-depends { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 8px; font-size: 12px; }
.settings-depends dt { color: var(--ui-text); }
.settings-depends dd { margin: 0; color: var(--ui-muted); }
