    :root {
      --bg: #f5f7fb;
      --bg-grad-a: #eef3fb;
      --bg-grad-b: #f8fbff;
      --surface: #ffffff;
      --surface-soft: #f8fafc;
      --surface-strong: #f1f5f9;
      --text: #0f172a;
      --text-soft: #475569;
      --line: #dbe4ee;
      --line-strong: #c8d5e3;
      --primary: #2563eb;
      --primary-strong: #1d4ed8;
      --danger: #dc2626;
      --radius: 14px;
      --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
      --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    }
    * { box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    body {
      font-family: Manrope, "Avenir Next", "Segoe UI Variable", "Segoe UI", sans-serif;
      margin: 0;
      color: var(--text);
      background: #f3f4f6;
      min-height: 100vh;
    }
    body.has-overlay-open { overflow: hidden; }
    .skip-link {
      position: fixed;
      left: 12px;
      top: 12px;
      z-index: 2000;
      padding: 10px 12px;
      border-radius: 10px;
      background: #0f172a;
      color: #fff;
      transform: translateY(-160%);
      transition: transform 120ms ease;
    }
    .skip-link:focus { transform: translateY(0); }
    a { color: var(--primary); text-decoration: none; }
    a:hover { text-decoration: underline; }
    a:focus-visible,
    button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible,
    summary:focus-visible {
      outline: 3px solid rgba(37, 99, 235, 0.22);
      outline-offset: 2px;
    }
    header {
      position: sticky;
      top: 0;
      z-index: 20;
      background: #ffffff;
      color: #111827;
      border-bottom: 1px solid #e5e7eb;
      padding: 12px 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 14px;
    }
    .header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
    .header-right {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .header-links {
      display: flex;
      align-items: center;
      gap: 0;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .menu-toggle {
      display: none;
      border: 1px solid #d1d5db;
      background: #fff;
      color: #111827;
      border-radius: 10px;
      padding: 8px 10px;
      line-height: 1;
      font-size: 20px;
      min-width: 42px;
    }
    .menu-toggle:hover { background: #f9fafb; }
    .menu-drawer {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 1400;
      background: rgba(15, 23, 42, 0.42);
    }
    .menu-drawer-panel {
      width: min(86vw, 320px);
      height: 100%;
      background: #fff;
      border-left: 1px solid #e5e7eb;
      box-shadow: 0 20px 60px rgba(2, 6, 23, 0.25);
      padding: 14px;
      display: grid;
      gap: 8px;
      align-content: start;
      margin-left: auto;
    }
    .menu-drawer-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 6px;
    }
    .menu-drawer-title {
      font-size: 12px;
      color: #6b7280;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      font-weight: 700;
    }
    .menu-drawer .menu-link {
      display: block;
      padding: 10px 12px;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      color: #111827;
      font-weight: 600;
      background: #fff;
      text-decoration: none;
    }
    .menu-drawer .menu-link:hover {
      background: #f8fafc;
      text-decoration: none;
    }
    .menu-drawer .menu-link.is-active {
      background: #eef2ff;
      border-color: #c7d2fe;
      color: #3730a3;
    }
    .app-brand-logo {
      display: block;
      width: auto;
      height: 46px;
      object-fit: contain;
    }
    header a {
      color: #4b5563;
      margin-left: 8px;
      padding: 6px 10px;
      border-radius: 999px;
      transition: background 120ms ease;
    }
    header a:hover { background: #f3f4f6; text-decoration: none; }
    .header-links .main-nav-link.is-active {
      background: #eef2ff;
      color: #3730a3;
      font-weight: 700;
    }
    main {
      width: 100%;
      max-width: none;
      margin: 0;
      padding: clamp(10px, 2.2vw, 22px);
    }
    #app-content {
      min-height: calc(100vh - 96px);
    }
    .app-main-content {
      display: grid;
      align-content: start;
      gap: 12px;
    }
    .app-main-content > *:first-child {
      margin-top: 0 !important;
    }
    .app-main-content > .page-shell > :first-child,
    .app-main-content > .cases-page > :first-child,
    .app-main-content > .admin-shell > .admin-main > :first-child,
    .app-main-content > .kb-shell > :first-child {
      margin-top: 0 !important;
    }
    .app-loading {
      position: fixed;
      top: 0;
      left: 0;
      height: 3px;
      width: 0;
      background: linear-gradient(90deg, #2563eb, #22c55e);
      z-index: 1600;
      opacity: 0;
      transition: width 160ms ease, opacity 160ms ease;
    }
    .app-loading.active {
      width: 48%;
      opacity: 1;
    }
    .app-loading.done {
      width: 100%;
      opacity: 0;
    }
    .card {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 18px;
      margin: 10px 0;
      box-shadow: none;
    }
    .board-card {
      border: 1px solid var(--line);
      border-radius: 12px;
      box-shadow: var(--shadow-sm);
      transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
    }
    .board-card:hover {
      transform: translateY(-1px);
      box-shadow: var(--shadow-md);
      border-color: var(--line-strong);
    }
    .board {
      width: 100%;
      min-width: 980px;
      min-height: 100%;
      height: 100%;
      border-collapse: separate;
      border-spacing: 0;
      table-layout: fixed;
      background: #fff;
      border: 1px solid #e5e7eb;
      border-radius: 0 0 12px 12px;
      overflow: hidden;
    }
    .board th {
      text-align: left;
      background: #f9fafb;
      color: #111827;
      padding: 14px 12px;
      font-size: 13px;
      font-weight: 700;
      border-bottom: 1px solid #e5e7eb;
    }
    .board td { vertical-align: top; min-width: 240px; border-right: 1px solid #e5e7eb; }
    .board tr td:last-child, .board tr th:last-child { border-right: 0; }
    .board tr + tr th, .board tr + tr td { border-top: 1px solid #f1f5f9; }
    .board tr > th:first-child {
      width: 120px;
      min-width: 120px;
      max-width: 120px;
      background: #eef2ff;
      color: #334155;
      border-right: 1px solid #dbeafe;
    }
    .lane {
      background: #f8fafc;
      padding: 10px;
      min-height: 170px;
      max-height: none;
      overflow-y: visible;
      overscroll-behavior: contain;
      transition: border-color 120ms ease, background-color 120ms ease;
      height: 100%;
    }
    .board-role-row > th,
    .board-role-row > td {
      height: 100%;
    }
    .lane.drag-over { background: #eef5ff; }
    .lane .board-card {
      position: sticky;
      top: calc(var(--stack-order, 0) * 8px);
      z-index: calc(200 - var(--stack-order, 0));
      margin: 0;
    }
    .lane .board-card + .board-card {
      margin-top: -16px;
    }
    .lane .board-card:hover {
      z-index: 260;
    }
    .mobile-board { display: none; padding: 10px; background: #fff; }
    .mobile-role {
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      background: #f8fafc;
      padding: 12px;
      margin-bottom: 12px;
    }
    .mobile-role h3 {
      margin: 0 0 10px 0;
      font-size: 15px;
      color: #111827;
    }
    .mobile-status-group + .mobile-status-group { margin-top: 10px; }
    .mobile-status-group h4 {
      margin: 0 0 6px 0;
      color: #475569;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 0.03em;
    }
    .board-card-mobile {
      position: static;
      margin: 0 0 8px 0 !important;
      box-shadow: var(--shadow-sm);
    }
    .mobile-empty {
      padding: 8px 10px;
      border: 1px dashed #d1d5db;
      border-radius: 10px;
      background: #fff;
    }
    .kb-shell {
      min-height: calc(100dvh - 118px);
      height: calc(100dvh - 118px);
      display: grid;
      grid-template-columns: 1fr;
    }
    .kb-main {
      display: flex;
      flex-direction: column;
      min-height: 0;
      height: 100%;
    }
    .toprow { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
    .board-wrap {
      padding: 0;
      overflow: auto;
      min-height: 0;
      flex: 1 1 auto;
      border-radius: 0 0 12px 12px;
      border: 1px solid #e5e7eb;
      border-top: 0;
      background: #fff;
    }
    .kb-filterrow {
      padding: 12px 14px;
      margin: 0;
      border: 1px solid #e5e7eb;
      border-bottom: 0;
      background: #fff;
      border-radius: 12px 12px 0 0;
      padding-bottom: 18px;
    }
    .filter-bar {
      margin: 0;
      display: flex;
      gap: 10px;
      align-items: center;
      flex-wrap: wrap;
      padding: 10px 12px;
      border-radius: 10px;
    }
    .card.filter-bar { margin: 0; }
    .quick-link { margin: 0; padding: 10px 14px; }
    button.quick-link {
      background: #ffffff;
      color: #111827;
      border: 1px solid #d1d5db;
      box-shadow: none;
    }
    button.quick-link:hover {
      background: #f9fafb;
      color: #111827;
    }
    .btn-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 8px 12px;
      border: 1px solid #1f57d1;
      border-radius: 10px;
      background: linear-gradient(180deg, #2f6eeb, var(--primary));
      color: #fff;
      font-weight: 600;
      text-decoration: none;
    }
    .btn-link:hover {
      background: linear-gradient(180deg, #2d64d5, var(--primary-strong));
      text-decoration: none;
      color: #fff;
    }
    .back-link {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 7px 10px;
      border: 1px solid #dbe4ee;
      border-radius: 10px;
      background: #f8fafc;
      color: #334155;
      font-weight: 600;
      text-decoration: none;
    }
    .back-link:hover {
      background: #eef2f7;
      color: #0f172a;
      text-decoration: none;
    }
    .form-stack {
      display: grid;
      gap: 18px;
    }
    .form-grid-2 {
      display: grid;
      gap: 16px;
      grid-template-columns: 1fr 1fr;
    }
    .field {
      display: grid;
      gap: 8px;
    }
    .field label {
      font-size: 13px;
      color: #374151;
      font-weight: 600;
      line-height: 1.35;
    }
    .field-help {
      color: #6b7280;
      font-size: 12px;
      line-height: 1.5;
    }
    .check-list {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
      gap: 8px;
      padding: 10px;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      background: #f9fafb;
    }
    .check-item {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      color: #374151;
    }
    .form-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      align-items: center;
    }
    .auth-shell {
      min-height: calc(100dvh - 120px);
      display: grid;
      place-items: center;
      padding: 24px 12px;
    }
    .auth-panel {
      width: min(100%, 520px);
      background: #fff;
      border: 1px solid #e5e7eb;
      border-radius: 16px;
      padding: 22px;
      box-shadow: var(--shadow-md);
    }
    .auth-head h1 {
      margin: 0 0 6px 0;
      font-size: 28px;
      line-height: 1.15;
      color: #0f172a;
    }
    .auth-head p {
      margin: 0 0 14px 0;
      color: #475569;
      font-size: 14px;
    }
    .auth-alert {
      margin-bottom: 12px;
      padding: 10px 12px;
      border: 1px solid #fecaca;
      background: #fef2f2;
      color: #991b1b;
      border-radius: 10px;
      font-size: 13px;
    }
    .output-list {
      display: grid;
      gap: 10px;
    }
    .output-item {
      padding: 12px 14px;
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      background: #fbfcfe;
    }
    .output-item label {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 14px;
      color: #374151;
      font-weight: 600;
    }
    .output-item .output-required {
      color: #b91c1c;
    }
    .io-save-status {
      margin-top: 8px;
      margin-bottom: 0;
      min-height: 1.25em;
    }
    .io-form {
      margin-bottom: 0;
    }
    .io-form-actions {
      margin-top: 10px;
      margin-bottom: 0;
    }
    .item-builder-panel,
    .output-builder {
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      background: #fff;
      padding: 10px;
      display: grid;
      gap: 10px;
    }
    .item-builder-head,
    .output-builder-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }
    .item-row-list,
    .output-row-list {
      display: grid;
      gap: 8px;
    }
    .item-row,
    .output-row {
      display: grid;
      grid-template-columns: 150px 1fr 130px auto;
      gap: 8px;
      align-items: center;
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      padding: 8px;
    }
    .item-row .danger,
    .output-row .danger {
      padding-left: 10px;
      padding-right: 10px;
    }
    .item-add-btn,
    .output-add-btn {
      padding: 6px 10px;
    }
    .wip-workspace {
      padding: 0;
      background: transparent;
    }
    .case-head-card .wip-workspace {
      border: 0;
      box-shadow: none;
      border-radius: 0;
    }
    .wip-grid {
      display: grid;
      grid-template-columns: 1.1fr 1fr;
      gap: 12px;
      margin-bottom: 12px;
      align-items: start;
    }
    .wip-grid .wip-block {
      background: #fff;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      padding: 12px;
    }
    .wip-block h3 {
      margin: 0 0 8px 0;
      font-size: 15px;
    }
    .wip-grid .instructions-scroll,
    .wip-grid .sop-scroll {
      display: block;
      min-height: 320px;
      height: 320px;
      max-height: 320px;
      overflow: auto;
      padding-right: 4px;
      font-size: 14px;
      line-height: 1.45;
    }
    .comment-stream {
      display: grid;
      gap: 10px;
      max-height: 220px;
      overflow: auto;
      padding-right: 4px;
    }
    .comment-item {
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      background: #fbfcfe;
      padding: 12px 14px;
    }
    .comment-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 8px;
      line-height: 1.2;
    }
    .comment-meta strong {
      font-size: 13px;
      color: #1f2937;
      font-weight: 700;
    }
    .comment-body {
      font-size: 15px;
      color: #334155;
      line-height: 1.6;
    }
    .comment-body p {
      margin: 4px 0;
    }
    .comment-body ul,
    .comment-body ol {
      margin: 4px 0 4px 18px;
      padding: 0;
    }
    .comment-body pre {
      margin: 6px 0;
      padding: 6px 8px;
      border-radius: 6px;
      background: #f8fafc;
      border: 1px solid #e5e7eb;
      font-size: 12px;
      overflow: auto;
    }
    .comment-input {
      box-shadow: none;
    }
    .comment-input:focus {
      box-shadow: none;
      border-color: #93c5fd;
    }
    .chat-shell {
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      overflow: hidden;
      background: #fff;
    }
    .chat-head {
      padding: 12px 14px;
      border-bottom: 1px solid #e5e7eb;
      background: #f8fafc;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
    }
    .conn-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 5px 10px;
      border-radius: 999px;
      border: 1px solid #dbe4ee;
      font-size: 12px;
      font-weight: 600;
      background: #f8fafc;
      color: #334155;
    }
    .conn-dot {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      display: inline-block;
      background: #94a3b8;
    }
    .conn-pill.connected {
      border-color: #bbf7d0;
      color: #166534;
      background: #f0fdf4;
    }
    .conn-pill.connected .conn-dot {
      background: #22c55e;
      box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
    }
    .conn-pill.disconnected {
      border-color: #fecaca;
      color: #991b1b;
      background: #fef2f2;
    }
    .conn-pill.disconnected .conn-dot {
      background: #ef4444;
      box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
    }
    .chat-window {
      height: 56vh;
      min-height: 320px;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 14px;
      background: #fff;
      display: block;
    }
    .chat-msg {
      display: block;
      width: auto;
      max-width: min(820px, 100%);
      max-height: none;
      padding: 10px 12px;
      margin: 0 0 10px 0;
      border-radius: 10px;
      border: 1px solid #e5e7eb;
      background: #f8fafc;
      white-space: normal;
      line-height: 1.4;
      font-size: 14px;
      overflow: visible;
    }
    .chat-msg.user {
      margin-left: auto;
      background: #e9f0ff;
      border-color: #c7d7ff;
      white-space: pre-wrap;
    }
    .chat-msg.agent {
      margin-right: auto;
      background: #fff;
      overflow: visible;
      white-space: normal;
    }
    .chat-msg.agent code {
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      font-size: 12px;
      background: #f1f5f9;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      padding: 1px 6px;
    }
    .chat-msg.agent pre {
      margin: 8px 0;
      padding: 10px;
      max-height: none;
      overflow-x: auto;
      overflow-y: visible;
      white-space: pre-wrap;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      background: #f8fafc;
    }
    .chat-msg.agent pre code {
      border: 0;
      background: transparent;
      padding: 0;
      font-size: 12px;
    }
    .md-content table {
      width: fit-content;
      max-width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      margin: 8px 0;
      font-size: 13px;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      table-layout: auto;
      display: table;
      overflow: hidden;
      background: #fff;
    }
    .md-content thead {
      background: #f8fafc;
    }
    .md-content th,
    .md-content td {
      border-bottom: 1px solid #e2e8f0;
      border-right: 1px solid #e2e8f0;
      padding: 7px 8px;
      text-align: left;
      vertical-align: top;
      white-space: normal;
    }
    .md-content tr > *:last-child {
      border-right: 0;
    }
    .md-content tr:last-child td {
      border-bottom: 0;
    }
    .md-content {
      line-height: 1.5;
      color: #0f172a;
    }
    .md-content > :first-child { margin-top: 0; }
    .md-content > :last-child { margin-bottom: 0; }
    .md-content p {
      margin: 0 0 6px 0;
    }
    .md-content h1,
    .md-content h2,
    .md-content h3,
    .md-content h4 {
      margin: 10px 0 6px 0;
      line-height: 1.25;
      color: #0b1324;
    }
    .md-content ul,
    .md-content ol {
      margin: 4px 0 8px 0;
      padding-left: 20px;
    }
    .md-content ul ul,
    .md-content ul ol,
    .md-content ol ul,
    .md-content ol ol {
      margin-top: 3px;
      margin-bottom: 3px;
      padding-left: 18px;
    }
    .md-content li {
      margin: 2px 0;
      line-height: 1.45;
    }
    .md-content li > p {
      margin: 2px 0;
    }
    .md-content ol ol { list-style-type: lower-alpha; }
    .md-content ol ol ol { list-style-type: lower-roman; }
    .md-content ul ul { list-style-type: circle; }
    .md-content ul ul ul { list-style-type: square; }
    .md-content hr {
      border: 0;
      border-top: 1px solid #e2e8f0;
      margin: 10px 0;
    }
    .md-content blockquote {
      margin: 8px 0;
      padding: 4px 10px;
      border-left: 3px solid #cbd5e1;
      color: #475569;
      background: #f8fafc;
      border-radius: 6px;
    }
    .md-content a {
      color: #1d4ed8;
      text-decoration: underline;
      text-underline-offset: 2px;
    }
    .md-content a:hover {
      color: #1e40af;
    }
    .md-content code {
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
      font-size: 0.92em;
      background: #f1f5f9;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      padding: 0.1em 0.35em;
    }
    .md-content pre {
      margin: 8px 0;
      padding: 10px 12px;
      background: #0f172a;
      color: #e2e8f0;
      border-radius: 10px;
      border: 1px solid #1e293b;
      overflow: auto;
    }
    .md-content pre code {
      background: transparent;
      border: 0;
      border-radius: 0;
      padding: 0;
      color: inherit;
      font-size: 0.9em;
      line-height: 1.5;
    }
    .md-content .md-field-control {
      display: grid;
      grid-template-columns: 1fr;
      gap: 6px;
      align-items: start;
      margin: 8px 0;
      padding: 10px 12px;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      background: #f8fafc;
    }
    .md-content .md-field-label {
      margin: 0;
      font-size: 13px;
      color: #334155;
      font-weight: 700;
      line-height: 1.25;
    }
    .md-content .md-field-control.is-required .md-field-label::after {
      content: " *";
      color: #b91c1c;
    }
    .md-content .md-field-input-wrap {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      width: 100%;
    }
    .md-content .md-field-input {
      width: min(100%, 460px);
      border-radius: 9px;
      border-color: #c9d6e3;
      background: #ffffff;
    }
    .md-content .md-field-number {
      max-width: 180px;
    }
    .md-content .md-field-textarea {
      min-height: 92px;
      max-width: 560px;
    }
    .md-content .md-field-select {
      max-width: 360px;
    }
    .md-content img {
      max-width: 100%;
      height: auto;
      border-radius: 8px;
    }
    .chat-form {
      border-top: 1px solid #e5e7eb;
      padding: 12px;
      display: grid;
      gap: 8px;
      background: #fff;
    }
    .user-row {
      display: grid;
      gap: 10px;
      margin-bottom: 10px;
      padding-bottom: 10px;
      border-bottom: 1px solid #eef2f7;
    }
    .user-row:last-child {
      margin-bottom: 0;
      padding-bottom: 0;
      border-bottom: 0;
    }
    .muted { color: var(--text-soft); font-size: 12px; }
    form.inline { display: inline; }
    input, select, textarea, button {
      padding: 8px 10px;
      border: 1px solid var(--line-strong);
      border-radius: 10px;
      font: inherit;
      background: #fff;
      color: var(--text);
    }
    .role-select {
      display: block;
      width: 100%;
    }
    textarea { resize: vertical; }
    input:focus, select:focus, textarea:focus {
      outline: none;
      border-color: #93c5fd;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
    }
    button {
      background: linear-gradient(180deg, #2f6eeb, var(--primary));
      color: #fff;
      cursor: pointer;
      border-color: #1f57d1;
      font-weight: 600;
    }
    button:hover { background: linear-gradient(180deg, #2d64d5, var(--primary-strong)); }
    .danger { background: linear-gradient(180deg, #ef4444, var(--danger)); border-color: #b91c1c; }
    .grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
    #card-modal-root {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.46);
      z-index: 1000;
      overflow: auto;
      backdrop-filter: blur(3px);
      animation: fadeIn 140ms ease-out;
    }
    #card-modal-content {
      max-width: 920px;
      width: min(920px, calc(100vw - 24px));
      margin: 32px auto;
      background: var(--surface);
      border-radius: 16px;
      border: 1px solid var(--line);
      box-shadow: 0 30px 90px rgba(2, 6, 23, 0.25);
      padding: 18px;
      overflow-x: hidden;
      animation: slideUp 150ms ease-out;
    }
    #card-modal-content .card {
      overflow-x: auto;
      max-width: 100%;
    }
    #card-modal-content .md-content,
    #card-modal-content .comment-body,
    #card-modal-content .muted {
      overflow-wrap: anywhere;
      word-break: break-word;
    }
    #card-modal-content input,
    #card-modal-content select,
    #card-modal-content textarea {
      max-width: 100%;
    }
    details > summary { cursor: pointer; color: #1e293b; }
    details > summary:hover { color: var(--primary); }
    .board-card-link {
      display: grid;
      gap: 4px;
      color: #0f172a;
      text-decoration: none;
    }
    .board-card-link:hover {
      color: #0f172a;
      text-decoration: none;
    }
    .admin-shell {
      display: grid;
      grid-template-columns: 240px minmax(0, 1fr);
      gap: 14px;
      align-items: start;
    }
    .admin-sidebar {
      background: #ffffff;
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      padding: 10px;
      position: sticky;
      top: 76px;
    }
    .admin-sidebar h3 {
      margin: 6px 8px 10px 8px;
      font-size: 13px;
      color: #6b7280;
      letter-spacing: 0.02em;
      text-transform: uppercase;
    }
    .admin-nav-disclosure {
      display: block;
    }
    .admin-nav-summary {
      display: none;
      list-style: none;
    }
    .admin-nav-summary::-webkit-details-marker {
      display: none;
    }
    .admin-menu {
      --admin-menu-gap: 6px;
      list-style: none;
      margin: 0;
      padding: 0;
      display: grid;
      gap: var(--admin-menu-gap);
    }
    .admin-menu li {
      margin: 0;
      padding: 0;
    }
    .admin-menu a {
      display: flex;
      align-items: center;
      min-height: 36px;
      padding: 9px 10px;
      border-radius: 10px;
      color: #111827;
      font-weight: 600;
      border: 1px solid transparent;
      white-space: nowrap;
      line-height: 1.2;
    }
    .admin-menu a:hover {
      background: #f8fafc;
      border-color: #e5e7eb;
      text-decoration: none;
    }
    .admin-menu a.is-active {
      background: #eef2ff;
      border-color: #c7d2fe;
      color: #3730a3;
    }
    .button-link {
      appearance: none;
      border: 0;
      padding: 0;
      margin: 0;
      background: none;
      color: var(--primary);
      font: inherit;
      font-weight: 600;
      text-align: left;
      cursor: pointer;
      box-shadow: none;
    }
    .button-link:hover {
      background: none;
      color: var(--primary-strong);
      text-decoration: underline;
    }
    .button-link:active {
      background: none;
    }
    .admin-main {
      display: grid;
      gap: 16px;
      background: #ffffff;
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      padding: 20px;
    }
    .admin-main > .admin-head,
    .admin-main > .card,
    .admin-main > .admin-board,
    .admin-main > .grid2,
    .admin-main > section {
      margin: 0;
    }
    .admin-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 14px;
      margin-bottom: 0;
    }
    .admin-head h2 {
      margin: 0;
    }
    .admin-table {
      width: 100%;
      min-width: 640px;
      border-collapse: collapse;
    }
    .admin-table th, .admin-table td {
      text-align: left;
      padding: 10px;
      border-bottom: 1px solid #eef2f7;
      vertical-align: top;
      font-size: 14px;
      word-break: break-word;
    }
    .admin-table tbody tr:hover { background: #f8fafc; }
    .admin-table td a { font-weight: 600; }
    .admin-table th {
      color: #6b7280;
      font-weight: 700;
      font-size: 12px;
      letter-spacing: 0.02em;
      text-transform: uppercase;
      background: #f8fafc;
    }
    .step-library-table {
      table-layout: auto;
      min-width: 0;
    }
    .step-library-table th:nth-child(1),
    .step-library-table td:nth-child(1) {
      width: 1%;
      white-space: nowrap;
    }
    .step-library-table th:nth-child(2),
    .step-library-table td:nth-child(2) {
      width: 1%;
      white-space: nowrap;
    }
    .step-library-table td:nth-child(3) {
      white-space: normal;
      overflow-wrap: anywhere;
    }
    .table-tools {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      align-items: end;
      margin-bottom: 12px;
    }
    .table-tools .field input,
    .table-tools .field select {
      height: 40px;
      padding-top: 8px;
      padding-bottom: 8px;
    }
    .pager {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 10px;
    }
    .cases-page {
      display: grid;
      gap: 12px;
    }
    .page-shell {
      display: grid;
      gap: 12px;
    }
    .page-main-card {
      display: grid;
      gap: 8px;
    }
    .page-main-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      flex-wrap: wrap;
      margin-bottom: 10px;
    }
    .cases-head-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      flex-wrap: wrap;
      margin-bottom: 10px;
    }
    .cases-head-row h2 {
      margin: 0;
    }
    .cases-head-actions {
      display: inline-flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
    }
    .cases-list-card {
      display: grid;
      gap: 8px;
    }
    .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;
    }
    .case-calendar-card {
      display: grid;
      gap: 0;
      overflow: hidden;
      padding: 0;
    }
    .case-calendar-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px;
      border-bottom: 1px solid #e5e7eb;
      background: #fbfcfe;
    }
    .case-calendar-head h2 {
      margin: 0;
      font-size: 16px;
    }
    .case-calendar-controls {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .case-calendar-view-switch {
      display: inline-flex;
      align-items: center;
      border: 1px solid #d1d5db;
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }
    .case-calendar-view-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 36px;
      padding: 0 12px;
      text-decoration: none;
      color: #334155;
      font-weight: 600;
      border-right: 1px solid #e5e7eb;
      background: #fff;
    }
    .case-calendar-view-switch a:last-child {
      border-right: 0;
    }
    .case-calendar-view-btn:hover {
      background: #f8fafc;
      color: #111827;
    }
    .case-calendar-view-btn.is-active {
      background: #eef2ff;
      color: #3730a3;
    }
    .case-calendar-nav {
      display: inline-flex;
      align-items: center;
      border: 1px solid #d1d5db;
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }
    .case-calendar-nav-btn,
    .case-calendar-today-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 36px;
      padding: 0 12px;
      text-decoration: none;
      color: #334155;
      font-weight: 600;
      border-right: 1px solid #e5e7eb;
      background: #fff;
    }
    .case-calendar-nav a:last-child {
      border-right: 0;
    }
    .case-calendar-nav-btn {
      width: 36px;
      font-size: 20px;
      line-height: 1;
      padding: 0;
    }
    .case-calendar-nav-btn:hover,
    .case-calendar-today-btn:hover {
      background: #f8fafc;
      color: #111827;
    }
    .case-calendar-shell {
      border-top: 0;
      border: 1px solid #e5e7eb;
      border-left: 0;
      border-right: 0;
      background: #dde6ef;
    }
    .case-calendar-weekdays {
      display: grid;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      gap: 1px;
      border-bottom: 1px solid #cfd8e3;
      background: #d2dbe5;
    }
    .case-calendar-weekdays > div {
      padding: 8px 10px;
      background: #f8fafc;
      font-size: 12px;
      font-weight: 700;
      color: #475569;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      text-align: center;
    }
    .case-calendar-grid {
      display: grid;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      grid-auto-rows: minmax(120px, 1fr);
      gap: 1px;
      background: #d2dbe5;
    }
    .case-calendar-day {
      position: relative;
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 10px;
      background: #fff;
      color: #0f172a;
      text-decoration: none;
      min-height: 120px;
    }
    .case-calendar-day:hover {
      background: #f8fafc;
    }
    .case-calendar-day-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: fit-content;
      color: inherit;
      text-decoration: none;
      border-radius: 999px;
    }
    .case-calendar-day-link:hover {
      text-decoration: none;
    }
    .case-calendar-day.is-outside {
      background: #f5f7fa;
      color: #64748b;
    }
    .case-calendar-day.is-today .case-calendar-date {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 28px;
      height: 28px;
      border-radius: 999px;
      background: #4f46e5;
      color: #fff;
      font-weight: 700;
    }
    .case-calendar-day.is-selected {
      box-shadow: inset 0 0 0 2px #4f46e5;
      z-index: 1;
    }
    .case-calendar-date {
      font-size: 13px;
      font-weight: 600;
    }
    .case-calendar-items {
      list-style: none;
      margin: 0;
      padding: 0;
      display: grid;
      gap: 4px;
      min-height: 0;
    }
    .case-calendar-items li {
      min-width: 0;
      font-size: 12px;
      color: #334155;
    }
    .case-calendar-item-link {
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
      padding: 6px 8px;
      border: 1px solid #dbe4ee;
      border-radius: 999px;
      background: linear-gradient(180deg, #f8fbff 0%, #eff6ff 100%);
      color: #1e3a8a;
      text-decoration: none;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
      transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
    }
    .case-calendar-item-link:hover {
      text-decoration: none;
      border-color: #93c5fd;
      background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
      transform: translateY(-1px);
    }
    .case-calendar-item-link.is-archived {
      border-color: #cbd5e1;
      background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
      color: #475569;
    }
    .case-calendar-dot {
      flex: 0 0 6px;
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: #2563eb;
    }
    .case-calendar-item-link.is-archived .case-calendar-dot {
      background: #94a3b8;
    }
    .case-calendar-item-title {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
    }
    .case-calendar-more {
      color: #64748b;
      font-weight: 600;
      padding-left: 4px;
    }
    .case-calendar-more a {
      color: #475569;
      text-decoration: none;
    }
    .case-calendar-more a:hover {
      color: #1d4ed8;
      text-decoration: underline;
    }
    .case-calendar-agenda h3 {
      margin: 0 0 8px 0;
    }
    .case-calendar-agenda ol {
      list-style: none;
      margin: 0;
      padding: 0;
      display: grid;
      gap: 8px;
    }
    .case-calendar-agenda li {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
      padding: 10px;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      background: #fff;
    }
    .case-calendar-agenda li a {
      color: #0f172a;
      text-decoration: none;
    }
    .case-calendar-agenda li a:hover {
      text-decoration: underline;
      color: #4338ca;
    }
    .case-calendar-agenda-title {
      margin: 0;
      font-weight: 700;
    }
    .case-week-shell {
      border-top: 0;
      border: 1px solid #e5e7eb;
      border-left: 0;
      border-right: 0;
      background: #fff;
    }
    .case-week-scroll {
      overflow: auto;
    }
    .case-week-mobile {
      display: none;
    }
    .case-week-head-row {
      position: sticky;
      top: 0;
      z-index: 5;
      display: grid;
      grid-template-columns: 76px repeat(7, minmax(140px, 1fr));
      border-bottom: 1px solid #dbe4ee;
      background: #f8fafc;
      min-width: 980px;
    }
    .case-week-hour-head {
      border-right: 1px solid #e5e7eb;
      background: #f8fafc;
    }
    .case-week-day-head {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 50px;
      text-decoration: none;
      color: #475569;
      border-right: 1px solid #e5e7eb;
      font-size: 13px;
      font-weight: 600;
    }
    .case-week-day-head time {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 28px;
      height: 28px;
      border-radius: 999px;
      color: #0f172a;
      font-weight: 700;
    }
    .case-week-day-head.is-today time {
      background: #4f46e5;
      color: #fff;
    }
    .case-week-day-head.is-selected {
      box-shadow: inset 0 -2px 0 #4f46e5;
      background: #eef2ff;
    }
    .case-week-body {
      min-width: 980px;
      background: #fff;
    }
    .case-week-row {
      display: grid;
      grid-template-columns: 76px 1fr;
      border-bottom: 1px solid #eef2f7;
      min-height: 56px;
    }
    .case-week-row:first-child,
    .case-week-row:last-child {
      min-height: 48px;
      background: #fbfcfe;
    }
    .case-week-hour {
      padding: 6px 8px;
      border-right: 1px solid #e5e7eb;
      color: #64748b;
      font-size: 12px;
      font-weight: 600;
      text-align: right;
      background: #fafcff;
    }
    .case-week-cells {
      display: grid;
      grid-template-columns: repeat(7, minmax(140px, 1fr));
    }
    .case-week-cell {
      border-right: 1px solid #eef2f7;
      padding: 4px;
      display: grid;
      gap: 4px;
      align-content: start;
      min-height: 56px;
    }
    .case-week-row:first-child .case-week-cell,
    .case-week-row:last-child .case-week-cell {
      min-height: 48px;
      background: #fbfcfe;
    }
    .case-week-event {
      display: grid;
      gap: 2px;
      padding: 5px 6px;
      border-radius: 8px;
      text-decoration: none;
      border: 1px solid #bfdbfe;
      background: #eff6ff;
      color: #1d4ed8;
      min-width: 0;
    }
    .case-week-event:hover {
      background: #dbeafe;
      border-color: #93c5fd;
    }
    .case-week-event.is-archived {
      border-color: #cbd5e1;
      background: #f8fafc;
      color: #475569;
    }
    .case-week-event.is-archived:hover {
      border-color: #94a3b8;
      background: #f1f5f9;
    }
    .case-week-event-title {
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .case-week-event-time {
      font-size: 11px;
      color: #1e40af;
    }
    .cases-table-wrap {
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      overflow: hidden;
      background: #fff;
    }
    .cases-table {
      width: 100%;
      border-collapse: collapse;
      min-width: 900px;
    }
    .case-status-pill {
      display: inline-flex;
      align-items: center;
      min-height: 26px;
      padding: 0 10px;
      border-radius: 999px;
      border: 1px solid #bfdbfe;
      background: #eff6ff;
      color: #1d4ed8;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.01em;
    }
    .case-status-pill.is-archived {
      border-color: #cbd5e1;
      background: #f1f5f9;
      color: #475569;
    }
    .cases-table th,
    .cases-table td {
      text-align: left;
      padding: 10px;
      border-bottom: 1px solid #eef2f7;
      vertical-align: middle;
      font-size: 14px;
    }
    .cases-table thead th {
      color: #6b7280;
      font-weight: 700;
      font-size: 12px;
      letter-spacing: 0.02em;
      text-transform: uppercase;
      background: #f8fafc;
    }
    .cases-table tbody tr:hover {
      background: #f8fafc;
    }
    .cases-table tbody tr:last-child td {
      border-bottom: 0;
    }
    .case-list-item {
      display: block;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      padding: 10px 12px;
      background: #f8fafc;
    }
    .case-list-item:hover {
      border-color: #c5d1dc;
      background: #f1f5f9;
    }
    .case-list-title {
      color: #0f172a;
      font-weight: 700;
    }
    .case-list-link {
      color: inherit;
      text-decoration: none;
      font-weight: 700;
    }
    .case-list-link:hover {
      text-decoration: underline;
    }
    .case-list-meta {
      margin-top: 4px;
      color: #64748b;
      font-size: 13px;
    }
    .case-step-strip {
      margin: 0;
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
    }
    .case-step-chip {
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      max-width: 100%;
      padding: 5px 10px;
      border-radius: 999px;
      border: 1px solid #dbe4ee;
      background: #f8fafc;
      color: #475569;
      font-size: 12px;
      font-weight: 600;
      line-height: 1.1;
      min-height: 24px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .case-step-chip.future {
      border-color: #dbe4ee;
      background: #f1f5f9;
      color: #475569;
    }
    .case-step-chip.completed {
      border-color: #2f8a57;
      background: #ddf6e7;
      color: #14532d;
    }
    .case-step-chip.current {
      border-color: #c08a07;
      background: #fff7d6;
      color: #7a5500;
    }
    .case-detail-shell {
      display: grid;
      gap: 14px;
    }
    .case-action-bar {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      align-items: center;
    }
    .case-head-card {
      padding: 18px;
    }
    .case-head-card .case-detail-subcard {
      margin: 14px 0 0 0;
    }
    .case-head-row {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 16px;
      flex-wrap: nowrap;
    }
    .case-head-copy {
      min-width: 0;
      display: grid;
      gap: 10px;
    }
    .case-head-row h2,
    .case-head-row h1 {
      margin: 0;
    }
    .case-title {
      font-size: clamp(26px, 4vw, 34px);
      line-height: 1.05;
      letter-spacing: -0.035em;
      font-weight: 800;
      color: #0f172a;
    }
    .case-summary {
      font-size: 15px;
      line-height: 1.65;
      color: #334155;
      max-width: 72ch;
    }
    .case-meta-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .case-meta-chip {
      display: inline-flex;
      align-items: center;
      min-height: 28px;
      padding: 0 10px;
      border-radius: 999px;
      border: 1px solid #dbe4ee;
      background: #f8fafc;
      color: #475569;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.01em;
    }
    .case-meta-chip-status {
      background: #eef2ff;
      border-color: #c7d2fe;
      color: #3730a3;
    }
    .case-meta-chip-status.is-archived {
      background: #f1f5f9;
      border-color: #cbd5e1;
      color: #475569;
    }
    .case-close-link {
      text-decoration: none;
      margin-left: auto;
      flex: 0 0 auto;
    }
    .case-step-title {
      margin: 4px 0 0 0;
      font-size: clamp(18px, 2.2vw, 22px);
      font-weight: 700;
      letter-spacing: -0.02em;
      color: #0f172a;
    }
    .case-current-action-card {
      background: linear-gradient(180deg, #fbfdff 0%, #f8fbff 100%);
      border-color: #d7e6f4;
    }
    .case-section-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 14px;
      margin-bottom: 14px;
      flex-wrap: wrap;
    }
    .case-section-head h3 {
      margin: 4px 0 0 0;
      font-size: 17px;
      line-height: 1.2;
      color: #0f172a;
    }
    .case-section-label {
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: #64748b;
    }
    .case-detail-section {
      padding: 16px 18px;
    }
    .list-filters {
      padding: 14px;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      background: #f8fafc;
      margin-bottom: 12px;
    }
    .admin-board {
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      background: #fff;
      overflow-x: auto;
      overflow-y: hidden;
    }
    .admin-board-head {
      padding: 14px 16px;
      border-bottom: 1px solid #e5e7eb;
      background: #fff;
    }
    .admin-board-head .list-filters {
      margin: 0;
      padding: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
    }
    .admin-board .admin-table th {
      background: #f9fafb;
    }
    .admin-board .pager {
      margin-top: 0;
      padding: 10px 12px;
      border-top: 1px solid #eef2f7;
      background: #fff;
    }
    .admin-edit-block {
      background: #f8fafc;
    }
    .workflow-step-form .field label {
      margin-bottom: 8px;
      font-size: 13px;
      letter-spacing: 0.01em;
    }
    .workflow-step-form .admin-edit-block {
      display: grid;
      gap: 14px;
      background: #fff;
    }
    .workflow-step-form .item-builder-panel,
    .workflow-step-form .output-builder {
      border: 0;
      background: transparent;
      padding: 0;
    }
    .workflow-step-form .item-builder-head,
    .workflow-step-form .output-builder-head {
      padding-bottom: 4px;
      justify-content: flex-start;
      gap: 8px;
    }
    .workflow-step-form .item-builder-head strong,
    .workflow-step-form .output-builder-head strong {
      font-size: 14px;
      color: #1f2937;
    }
    .workflow-step-form .item-row,
    .workflow-step-form .output-row {
      background: #f9fafb;
      border-color: #e5e7eb;
      padding: 10px;
    }
    .workflow-step-form .field textarea,
    .workflow-step-form .field input,
    .workflow-step-form .field select {
      margin-top: 2px;
    }
    .workflow-step-actions {
      margin-top: 16px;
      padding-top: 4px;
      justify-content: flex-end;
    }
    .readonly-block {
      padding: 10px;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      background: #fff;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      font-size: 12px;
      white-space: pre-wrap;
      word-break: break-word;
    }
    .-item {
      padding: 10px;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      background: #fff;
      margin-bottom: 10px;
    }
    .-item:last-child { margin-bottom: 0; }
    .dnd-dropzone {
      min-height: 180px;
      border: 2px dashed #c5d1dc;
      border-radius: 8px;
      padding: 8px;
      margin-top: 10px;
      background: #f8fbfd;
    }
    .workflow-step-list,
    .workflow-step-source-list {
      list-style: none;
      padding: 0;
      margin: 0;
      display: grid;
      gap: 8px;
    }
    .workflow-step-item,
    .workflow-step-source-item {
      cursor: move;
      background: #fff;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      padding: 10px;
    }
    .workflow-step-source-item { cursor: grab; }
    .item-head {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 10px;
    }
    .item-copy {
      min-width: 0;
      display: grid;
      gap: 4px;
    }
    .item-title {
      line-height: 1.35;
    }
    .item-meta {
      font-size: 13px;
      color: #64748b;
      line-height: 1.3;
    }
    .pill {
      display: inline-flex;
      align-items: center;
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 12px;
      color: #334155;
      background: #e2e8f0;
      margin: 2px 6px 2px 0;
    }
    .simple-modal {
      display: none;
      position: fixed;
      inset: 0;
      background:
        radial-gradient(circle at top, rgba(59, 130, 246, 0.16), transparent 36%),
        rgba(15, 23, 42, 0.52);
      z-index: 1200;
      overflow: auto;
      backdrop-filter: blur(10px);
      padding: 32px 12px;
      animation: fadeIn 140ms ease-out;
    }
    .simple-modal-surface {
      position: relative;
      max-width: 760px;
      width: min(760px, calc(100vw - 24px));
      margin: 0 auto;
      background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(255, 255, 255, 0.98) 18%, #ffffff 100%);
      border: 1px solid rgba(203, 213, 225, 0.9);
      border-radius: 22px;
      box-shadow:
        0 28px 90px rgba(2, 6, 23, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.7) inset;
      padding: 24px;
      outline: none;
      overflow: hidden;
      animation: slideUp 150ms ease-out;
    }
    .simple-modal-surface::before {
      content: "";
      position: absolute;
      inset: 0 0 auto 0;
      height: 5px;
      background: linear-gradient(90deg, #2563eb 0%, #0ea5e9 52%, #22c55e 100%);
    }
    .simple-modal-surface .admin-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;
      padding-bottom: 16px;
      margin-bottom: 20px;
      border-bottom: 1px solid #e2e8f0;
    }
    .simple-modal-surface .admin-head h3 {
      margin: 0;
      font-size: 22px;
      line-height: 1.15;
      letter-spacing: -0.02em;
      color: #0f172a;
    }
    .simple-modal-surface form {
      display: grid;
      gap: 16px;
    }
    .simple-modal-surface .grid2 {
      gap: 16px;
    }
    .simple-modal-surface .form-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      justify-content: flex-end;
      margin-top: 4px;
      padding-top: 16px;
      border-top: 1px solid #e2e8f0;
    }
    .simple-modal-surface .field {
      display: grid;
      gap: 6px;
    }
    .simple-modal-surface label {
      font-size: 13px;
      font-weight: 700;
      color: #334155;
    }
    .modal-eyebrow {
      display: inline-flex;
      align-items: center;
      min-height: 26px;
      padding: 0 10px;
      margin-bottom: 14px;
      border-radius: 999px;
      background: #e0f2fe;
      color: #075985;
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }
    .modal-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;
      margin-bottom: 20px;
    }
    .modal-title {
      margin: 0;
      font-size: 24px;
      line-height: 1.1;
      letter-spacing: -0.03em;
      color: #0f172a;
    }
    .modal-copy {
      margin: 8px 0 0 0;
      color: #475569;
      line-height: 1.5;
    }
    .modal-close,
    .modal-secondary {
      background: #f8fafc;
      color: #334155;
      border-color: #cbd5e1;
    }
    .modal-close:hover,
    .modal-secondary:hover {
      background: #eef2f7;
    }
    .modal-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding-top: 18px;
      margin-top: 18px;
      border-top: 1px solid #e2e8f0;
    }
    .confirm-modal-surface {
      max-width: 560px;
      margin-top: min(12vh, 96px);
    }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    @keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
    @media (max-width: 1200px) {
      .board td { min-width: 210px; }
      .lane .board-card + .board-card { margin-top: -12px; }
    }
    @media (max-width: 980px) {
      .grid2 { grid-template-columns: 1fr; }
      .kb-shell {
        min-height: auto;
        height: auto;
      }
      .kb-main {
        height: auto;
      }
      .board { display: none; }
      .mobile-board { display: block; }
      #card-modal-content {
        width: calc(100vw - 24px);
        margin: 12px;
      }
      .simple-modal {
        padding: 16px 10px;
      }
      .simple-modal-surface {
        width: min(100%, calc(100vw - 20px));
        padding: 20px 16px;
        border-radius: 18px;
      }
      .modal-header,
      .simple-modal-surface .admin-head {
        flex-direction: column;
        align-items: stretch;
      }
      .modal-actions,
      .simple-modal-surface .form-actions {
        justify-content: stretch;
      }
      .modal-actions > *,
      .simple-modal-surface .form-actions > * {
        width: 100%;
      }
      main { padding: 12px; }
      header { padding: 10px 12px; }
      .kb-shell { grid-template-columns: 1fr; }
      .kb-sidebar { display: none; }
      .header-right { display: flex; }
      .header-links { display: none; }
      .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
      .admin-shell { grid-template-columns: 1fr; }
      .admin-sidebar {
        position: static;
        padding: 6px 8px;
        border-radius: 10px;
        margin-bottom: 8px;
        min-width: 0;
      }
      .admin-sidebar h3 {
        display: none;
      }
      .admin-nav-summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 42px;
        padding: 10px 12px;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        background: #fff;
        color: #111827;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
      }
      .admin-nav-summary-icon {
        color: #64748b;
        transition: transform 120ms ease;
      }
      .admin-nav-disclosure[open] .admin-nav-summary {
        margin-bottom: 8px;
      }
      .admin-nav-disclosure[open] .admin-nav-summary-icon {
        transform: rotate(180deg);
      }
      .admin-menu {
        --admin-menu-gap: 6px;
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--admin-menu-gap);
        width: 100%;
        min-width: 0;
      }
      .admin-menu a {
        min-height: 38px;
        padding: 8px 10px;
        font-size: 13px;
        border: 1px solid #e5e7eb;
        background: #fff;
        white-space: normal;
        overflow-wrap: break-word;
      }
      .admin-board {
        overflow: hidden;
      }
      .admin-table {
        min-width: 0;
        width: 100%;
        table-layout: fixed;
      }
      .admin-table thead {
        display: none;
      }
      .admin-table,
      .admin-table tbody,
      .admin-table tr,
      .admin-table td {
        display: block;
        width: 100%;
      }
      .admin-table tbody {
        border: 0;
        border-radius: 0;
        overflow: visible;
        background: transparent;
      }
      .admin-table tbody tr {
        margin-bottom: 0;
        padding: 10px 12px;
        border: 0;
        border-bottom: 1px solid #e5e7eb;
        background: #fff;
        border-radius: 0;
      }
      .admin-table tbody tr:last-child {
        border-bottom: 0;
      }
      .admin-table td {
        padding: 8px 2px;
        border: 0;
        border-bottom: 1px solid #eef2f7;
        border-radius: 0;
      }
      .admin-table td:last-child {
        border-bottom: 0;
      }
      .admin-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        color: #6b7280;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
      }
      .admin-table tr.empty-row {
        padding: 0;
        margin: 0;
        border: 0;
        background: transparent;
      }
      .admin-table tr.empty-row td {
        border: 0;
        border-radius: 0;
        padding: 10px;
        background: transparent;
      }
      .admin-table tr.empty-row td::before {
        display: none;
      }
      .admin-board.admin-board-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }
      .compact-mobile-table {
        min-width: 100%;
        width: auto;
        table-layout: auto;
        border-collapse: collapse;
      }
      .compact-mobile-table thead {
        display: table-header-group;
      }
      .compact-mobile-table tbody {
        display: table-row-group;
      }
      .compact-mobile-table tr {
        display: table-row;
      }
      .compact-mobile-table td,
      .compact-mobile-table th {
        display: table-cell;
        white-space: nowrap;
      }
      .compact-mobile-table td::before {
        display: none;
        content: none;
      }
      .compact-mobile-table tbody tr {
        margin-bottom: 0;
        padding: 0;
        border: 0;
        border-bottom: 1px solid #eef2f7;
        background: transparent;
      }
      .compact-mobile-table tbody tr:last-child {
        border-bottom: 1px solid #eef2f7;
      }
      .compact-mobile-table td {
        padding: 10px;
        border: 0;
        border-bottom: 1px solid #eef2f7;
      }
      .compact-mobile-table tr.empty-row td {
        border-bottom: 0;
      }
      .cases-table {
        min-width: 0;
        width: 100%;
        table-layout: fixed;
      }
      .cases-table thead {
        display: none;
      }
      .cases-table,
      .cases-table tbody,
      .cases-table tr,
      .cases-table td {
        display: block;
        width: 100%;
      }
      .cases-table tbody {
        border: 0;
        border-radius: 0;
        overflow: visible;
        background: transparent;
      }
      .cases-table tbody tr {
        margin-bottom: 0;
        padding: 10px 12px;
        border: 0;
        border-bottom: 1px solid #e5e7eb;
        background: #fff;
        border-radius: 0;
      }
      .cases-table tbody tr:last-child {
        border-bottom: 0;
      }
      .cases-table td {
        padding: 8px 2px;
        border: 0;
        border-bottom: 1px solid #eef2f7;
        border-radius: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      .cases-table td:last-child {
        border-bottom: 0;
      }
      .cases-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        color: #6b7280;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
      }
      .cases-table tr.empty-row {
        padding: 0;
        margin: 0;
        border: 0;
        background: transparent;
      }
      .cases-table tr.empty-row td {
        border: 1px dashed #d1d5db;
        border-radius: 10px;
        padding: 10px;
      }
      .cases-table tr.empty-row td::before {
        display: none;
      }
      .case-calendar-head {
        padding: 12px;
        flex-wrap: wrap;
      }
      .case-calendar-controls {
        width: 100%;
        justify-content: flex-start;
      }
      .case-calendar-view-switch,
      .case-calendar-nav {
        width: 100%;
      }
      .case-calendar-view-btn,
      .case-calendar-today-btn,
      .case-calendar-nav-btn {
        flex: 1;
      }
      .case-calendar-grid {
        grid-auto-rows: minmax(100px, 1fr);
      }
      .case-calendar-day {
        min-height: 100px;
        padding: 8px;
      }
      .case-calendar-items li {
        font-size: 11px;
      }
      .case-week-desktop {
        display: none;
      }
      .case-week-mobile {
        display: grid;
        gap: 10px;
        padding: 10px;
      }
      .case-week-mobile-days {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 6px;
      }
      .case-week-mobile-day {
        display: grid;
        justify-items: center;
        gap: 4px;
        padding: 8px 4px;
        text-decoration: none;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        color: #475569;
        background: #fff;
        font-size: 12px;
        font-weight: 600;
      }
      .case-week-mobile-day time {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 26px;
        height: 26px;
        border-radius: 999px;
        color: #0f172a;
        font-weight: 700;
      }
      .case-week-mobile-day.is-today time {
        background: #4f46e5;
        color: #fff;
      }
      .case-week-mobile-day.is-selected {
        border-color: #818cf8;
        background: #eef2ff;
      }
      .case-week-mobile-rows {
        display: grid;
        gap: 8px;
      }
      .case-week-mobile-row {
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 8px;
        background: #fff;
      }
      .case-week-mobile-hour {
        font-size: 12px;
        font-weight: 700;
        color: #64748b;
        margin-bottom: 6px;
      }
      .case-week-mobile-events {
        display: grid;
        gap: 6px;
      }
      .form-grid-2 { grid-template-columns: 1fr; }
      .wip-grid { grid-template-columns: 1fr; }
      .md-content .md-field-input,
      .md-content .md-field-number,
      .md-content .md-field-select,
      .md-content .md-field-textarea {
        max-width: 100%;
      }
      .output-row {
        grid-template-columns: 1fr;
      }
      .workflow-step-form .item-row {
        grid-template-columns: 1fr;
      }
      .workflow-step-form .item-row .check-item,
      .workflow-step-form .output-row .check-item {
        justify-content: flex-start;
      }
      .workflow-step-form .item-row .danger,
      .workflow-step-form .output-row .danger {
        width: 100%;
      }
      .workflow-step-form .item-builder-head,
      .workflow-step-form .output-builder-head {
        flex-direction: column;
        align-items: stretch;
      }
      .workflow-step-form .item-add-btn,
      .workflow-step-form .output-add-btn {
        width: 100%;
      }
      .workflow-step-form textarea[name="instructions_md"] {
        height: 46dvh !important;
        min-height: 220px;
        max-height: 520px;
      }
      .workflow-step-form textarea[name="purpose"] {
        height: 140px !important;
      }
      .table-tools {
        flex-direction: column;
        align-items: stretch;
      }
      .table-tools .field,
      .table-tools .form-actions {
        width: 100%;
      }
      .table-tools .form-actions button {
        width: 100%;
      }
      .chat-shell {
        min-height: calc(100dvh - 98px);
        display: flex;
        flex-direction: column;
      }
      .chat-window {
        height: auto;
        min-height: 0;
        flex: 1;
      }
      .chat-form {
        margin-top: auto;
      }
    }
    @media (max-width: 760px) {
      html, body {
        min-height: 100dvh;
      }
      header {
        align-items: flex-start;
        flex-wrap: wrap;
      }
      main {
        min-height: calc(100dvh - 74px);
      }
      .header-left {
        gap: 10px;
        flex-wrap: wrap;
      }
      .app-brand-logo { height: 38px; }
      .kb-filterrow { padding: 10px; }
      .filter-bar { width: 100%; }
      .quick-link {
        width: auto;
        margin-left: auto;
        flex: 0 0 auto;
      }
      #new-card-modal-content {
        margin: 12px !important;
        padding: 14px !important;
      }
      #card-modal-content {
        width: calc(100vw - 16px);
        margin: 8px;
        padding: 12px;
      }
      .chat-msg { max-width: 100%; }
      .admin-main { padding: 12px; }
      .cases-head-actions {
        width: auto;
        margin-left: auto;
        justify-content: flex-end;
      }
      .cases-head-actions a {
        flex: 0 0 auto;
        text-align: center;
      }
      .cases-list-card {
        overflow: visible;
      }
      .admin-head {
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
      }
      .admin-head > a,
      .admin-head > button {
        width: auto;
        margin-left: auto;
      }
      .simple-modal-surface .admin-head {
        flex-direction: row;
        align-items: center;
      }
      .simple-modal-surface .admin-head > a,
      .simple-modal-surface .admin-head > button {
        width: auto;
      }
      .new-card-modal-head {
        flex-direction: row;
        align-items: center;
      }
      #card-modal-content .case-head-row {
        flex-wrap: wrap;
      }
      .form-actions {
        width: 100%;
      }
      .form-actions button {
        flex: 1;
        min-width: 120px;
      }
      .case-action-bar form,
      .case-action-bar button {
        width: 100%;
      }
    }

    /* Utility classes used by templates to avoid inline styles. */
    .w-full { width: 100%; }
    .h-50 { height: 50px; }
    .h-90 { height: 90px; }
    .h-100 { height: 100px; }
    .h-110 { height: 110px; }
    .h-120 { height: 120px; }
    .h-420 { height: 420px; }
    .m-0 { margin: 0; }
    .mt-6 { margin-top: 6px; }
    .mt-8 { margin-top: 8px; }
    .mt-10 { margin-top: 10px; }
    .mb-10 { margin-bottom: 10px; }
    .justify-end { justify-content: flex-end; }
    .justify-between { justify-content: space-between; }
    .inline-flex-gap-8 { display: flex; gap: 8px; }
    .no-pointer-events { pointer-events: none; }
    .danger-alert-card {
      border-color: #fca5a5;
      color: #991b1b;
      background: #fef2f2;
    }

    /* Shared new-case modal now used on board and cases pages. */
    .new-card-modal-root {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.46);
      z-index: 1000;
      overflow: auto;
    }
    .new-card-modal-content {
      max-width: 720px;
      margin: 32px auto;
      background: #fff;
      border-radius: 16px;
      border: 1px solid #dbe4ee;
      padding: 18px;
    }
    .new-card-modal-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
    }
    .new-card-modal-title {
      margin: 0;
    }
    .new-card-modal-form {
      margin-top: 12px;
    }
    .simple-modal-surface .admin-head {
      flex-direction: row;
      align-items: center;
    }
    .simple-modal-surface .admin-head > a,
    .simple-modal-surface .admin-head > button {
      margin-left: auto;
      width: auto;
      flex: 0 0 auto;
    }
    #card-modal-content .case-head-row {
      align-items: flex-start;
    }
    #card-modal-content .case-close-link {
      margin-left: auto;
      flex: 0 0 auto;
    }
    #card-modal-content .case-head-row h1,
    #card-modal-content .case-head-row h2,
    #card-modal-content .case-head-copy {
      min-width: 0;
    }

    /* Board move warning popup. */
    .board-warning-popup {
      display: none;
      position: fixed;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: min(520px, calc(100vw - 36px));
      background: #fff6f6;
      border: 1px solid #e7b1b1;
      border-left: 6px solid #c84646;
      border-radius: 12px;
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
      z-index: 1200;
    }
    .board-warning-body-wrap {
      padding: 12px 14px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
    }
    .board-warning-title {
      font-weight: 700;
      color: #7a1f1f;
      margin-bottom: 6px;
    }
    .board-warning-body {
      color: #5a2424;
      white-space: pre-line;
      line-height: 1.35;
    }
    .board-warning-close {
      border: 1px solid #d9a5a5;
      background: #fff;
      color: #7a1f1f;
      border-radius: 8px;
      padding: 2px 8px;
      cursor: pointer;
    }
    .board-warning-message {
      margin-bottom: 8px;
    }
    .board-warning-field-list {
      margin-bottom: 8px;
      display: grid;
      gap: 4px;
    }
    .board-warning-field-line {
      display: flex;
      gap: 8px;
      align-items: flex-start;
    }
    .board-warning-field-line.is-ok { color: #1d7f3f; }
    .board-warning-field-line.is-error { color: #b53c3c; }
    .board-warning-field-icon {
      font-weight: 700;
      min-width: 14px;
    }

    .dnd-dropzone.drag-active {
      border-color: #0f5ea8;
      background: #edf5ff;
    }
