/* Import Inter font */
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
    
    /* Global Styles & Reset */
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }
    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      background-color: #fafbfc;
      color: #1f2937;
      height: 100vh;
      overflow: hidden;
      line-height: 1.6;
      font-size: 14px;
    }

    #loginScreen {
      height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 55%, #f1f5f9 100%);
      padding: 1rem;
    }

    .login-shell {
      width: 100%;
      max-width: 980px;
      min-height: 560px;
      border-radius: 16px;
      overflow: hidden;
      border: 1px solid #dbeafe;
      box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
      background: #ffffff;
      display: grid;
      grid-template-columns: 1.05fr 0.95fr;
    }

    .login-left-panel {
      background: linear-gradient(160deg, #1e3a8a 0%, #1d4ed8 58%, #2563eb 100%);
      color: #ffffff;
      padding: 2.25rem 2rem;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .login-left-content {
      width: 100%;
      max-width: 500px;
    }

    .login-card {
      width: 100%;
      max-width: none;
      background: #ffffff;
      padding: 2.25rem 2rem;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .login-brand {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 1.25rem;
    }

    .login-brand-icon {
      width: 42px;
      height: 42px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #2563eb, #1d4ed8);
      color: #fff;
      box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
      font-size: 1.05rem;
    }

    .login-brand h1 {
      font-size: 1.62rem;
      font-weight: 700;
      color: #ffffff;
      line-height: 1.2;
    }

    .login-brand p {
      font-size: 1rem;
      color: rgba(255, 255, 255, 0.8);
      margin-top: 0.1rem;
    }

    .login-left-copy {
      font-size: 1.14rem;
      line-height: 1.55;
      color: rgba(255, 255, 255, 0.88);
      margin-top: 0.8rem;
      margin-bottom: 0;
      max-width: 460px;
      font-style: italic;
    }

    .login-subtitle {
      color: #334155;
      margin-bottom: 1.15rem;
      font-size: 1.02rem;
      font-weight: 600;
    }

    .login-card .form-row {
      display: block;
      margin-bottom: 0.95rem;
    }

    .login-card .form-row label {
      display: block;
      margin-bottom: 0.3rem;
      font-size: 0.82rem;
      font-weight: 600;
      color: #334155;
    }

    .login-card .text-input {
      width: 100%;
      border: 1px solid #cbd5e1;
      border-radius: 9px;
      padding: 0.7rem 0.8rem;
      background: #fff;
      color: #0f172a;
    }

    .login-submit-btn {
      width: 100%;
      justify-content: center;
      margin-top: 0.35rem;
      background: linear-gradient(135deg, #2563eb, #1d4ed8);
      border-color: #1d4ed8;
      color: #fff;
    }

    .login-submit-btn:hover {
      background: linear-gradient(135deg, #1d4ed8, #1e40af);
      border-color: #1e40af;
    }

    .login-error {
      color: #dc2626;
      margin: 0.55rem 0;
      font-size: 0.87rem;
    }

    .login-footer-note {
      margin-top: 0.85rem;
      font-size: 0.8rem;
      color: #64748b;
      text-align: center;
    }

    @media (max-width: 900px) {
      .login-shell {
        max-width: 560px;
        min-height: auto;
        grid-template-columns: 1fr;
      }

      .login-left-panel {
        padding: 1.5rem 1.4rem;
      }

      .login-left-copy {
        margin-bottom: 0.85rem;
      }

      .login-card {
        padding: 1.5rem 1.4rem;
      }
    }
    
    .app-layout {
      display: flex;
      height: 100vh;
    }
    
    /* Sidebar */
    #sidebar {
      width: 220px;
      background: #1e3a8a;
      border-right: 1px solid #1e40af;
      display: flex;
      flex-direction: column;
      transition: width 0.25s ease;
      flex-shrink: 0;
      position: relative;
    }

    #sidebar.collapsed {
      width: 56px;
      overflow: hidden;
    }

    .sidebar-header {
      background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
      padding: 1.25rem 1rem;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 72px;
      flex-shrink: 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .header-left {
      display: flex;
      align-items: center;
      gap: 1rem;
    }
    
    #sidebarToggle {
      background: none;
      border: none;
      color: #6b7280;
      cursor: pointer;
      padding: 0.5rem;
      border-radius: 6px;
      transition: all 0.15s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1rem;
    }
    
    #sidebarToggle:hover {
      background: #f3f4f6;
      color: #374151;
    }
    
    .sidebar-logo {
      display: flex;
      align-items: center;
      gap: 0.6rem;
      color: #f8fafc;
      font-size: 0.95rem;
      font-weight: 600;
      letter-spacing: 0.06em;
    }
    .sidebar-logo i { font-size: 1.05rem; opacity: 0.85; }
    #sidebar.collapsed .sidebar-logo span { display: none; }
    #sidebar.collapsed .sidebar-header { padding: 1rem 0; justify-content: center; }

    /* App nav */
    .sidebar-nav {
      padding: 0.75rem 0;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .nav-item {
      display: flex;
      align-items: center;
      gap: 0.7rem;
      padding: 0.65rem 1.15rem;
      color: #94a3b8;
      cursor: pointer;
      font-size: 0.85rem;
      font-weight: 500;
      border-left: 3px solid transparent;
      transition: all 0.12s;
      text-decoration: none;
    }
    .nav-item:hover { color: #e2e8f0; background: rgba(255,255,255,0.06); }
    .nav-item.active {
      color: #ffffff;
      background: rgba(255,255,255,0.1);
      border-left-color: #fbbf24;
      font-weight: 600;
    }
    .nav-item i { width: 1.1rem; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
    #sidebar.collapsed .nav-item { justify-content: center; padding: 0.65rem 0; }
    #sidebar.collapsed .nav-item span { display: none; }

    .sidebar-spacer { flex: 1; }

    /* User card */
    .sidebar-user-card {
      display: flex;
      align-items: center;
      gap: 0.6rem;
      padding: 0.75rem 0.85rem;
      margin: 0 0.5rem 0.5rem;
      border-radius: 10px;
      background: rgba(255,255,255,0.07);
      border: 1px solid rgba(255,255,255,0.08);
    }
    .user-card-avatar {
      width: 32px;
      height: 32px;
      border-radius: 8px;
      background: linear-gradient(135deg, #3b82f6, #6366f1);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.8rem;
      font-weight: 700;
      flex-shrink: 0;
      text-transform: uppercase;
    }
    .user-card-details { flex: 1; min-width: 0; overflow: hidden; }
    .user-card-name {
      color: #e2e8f0;
      font-size: 0.8rem;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .user-card-role {
      color: #64748b;
      font-size: 0.68rem;
      text-transform: capitalize;
    }
    .user-card-logout {
      background: none;
      border: none;
      color: #64748b;
      cursor: pointer;
      padding: 0.3rem;
      border-radius: 6px;
      font-size: 0.78rem;
      transition: all 0.15s;
      flex-shrink: 0;
    }
    .user-card-logout:hover { color: #fca5a5; background: rgba(255,255,255,0.08); }

    #sidebar.collapsed .user-card-details { display: none; }
    #sidebar.collapsed .user-card-logout { display: none; }
    #sidebar.collapsed .sidebar-user-card {
      justify-content: center;
      margin: 0 0.25rem 0.4rem;
      padding: 0.5rem;
    }
    
    /* Main Content Area */
    .main-layout {
      display: flex;
      flex-direction: column;
      flex-grow: 1;
      height: 100vh;
    }
    
    header {
      background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
      color: #1f2937;
      padding: 0 2rem;
      border-bottom: 1px solid #dbe3ee;
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 72px;
      flex-shrink: 0;
    }
    
    h1 {
      font-size: 1.5rem;
      font-weight: 600;
      color: #1f2937;
      letter-spacing: -0.02em;
    }
    
    .header-actions {
      display: flex;
      gap: 0.75rem;
      align-items: center;
    }

    .header-left h1 {
      font-size: 1.18rem;
      font-weight: 700;
      color: #0f172a;
      letter-spacing: -0.015em;
    }
    
    /* Primary action - Create Measure */
    #newMeasureBtn {
      background: #1E40AF !important;
      font-weight: 600;
      box-shadow: 0 2px 4px rgba(30, 64, 175, 0.2);
    }
    #newMeasureBtn:hover {
      background: #1e3a8a !important;
      box-shadow: 0 4px 8px rgba(30, 64, 175, 0.3);
      transform: translateY(-1px);
    }
    
    /* Secondary action - Export Measures */
    #exportMeasuresBtn {
      background: #ffffff !important;
      color: #6b7280 !important;
      border: 1px solid #d1d5db !important;
      font-weight: 500;
    }
    #exportMeasuresBtn:hover {
      background: #f9fafb !important;
      border-color: #9ca3af !important;
      color: #374151 !important;
    }
    
    #main-content {
      flex-grow: 1;
      padding: 2rem;
      padding-bottom: 4rem;
      overflow-y: auto;
      background-color: #fafbfc;
      height: calc(100vh - 72px);
    }

    /* Dashboard page */
    .db-page { padding: 0; max-width: 1180px; }

    /* Dashboard redesign (scoped reporting year — mockup-aligned) */
    .db-dash-header {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 1rem;
      margin-bottom: 1.25rem;
      flex-wrap: wrap;
    }
    .db-dash-title { margin: 0; font-size: 1.2rem; font-weight: 700; color: #0f172a; letter-spacing: -0.02em; }
    .db-dash-welcome { margin: 0.35rem 0 0; font-size: 0.85rem; color: #64748b; }
    .db-dash-scope {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 0.25rem;
      font-size: 0.8rem;
      color: #64748b;
    }
    .db-dash-scope label { font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.68rem; }
    .db-year-scope-select { min-width: 110px; font-weight: 600; padding: 0.35rem 0.65rem; }

    .db-stat-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 0.75rem;
      margin-bottom: 1rem;
    }
    @media (max-width: 900px) {
      .db-stat-grid { grid-template-columns: repeat(2, 1fr); }
    }
    @media (max-width: 520px) {
      .db-stat-grid { grid-template-columns: 1fr; }
    }
    .db-stat-card {
      background: #fff;
      border: 1px solid #e2e8f0;
      border-top: 3px solid #cbd5e1;
      border-radius: 10px;
      padding: 0.95rem 1rem;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }
    .db-stat-card.is-total    { border-top-color: #1e40af; }
    .db-stat-card.is-approved { border-top-color: #3b6d11; }
    .db-stat-card.is-review   { border-top-color: #ba7517; }
    .db-stat-card.is-draft    { border-top-color: #94a3b8; }
    .db-stat-label { font-size: 0.78rem; color: #64748b; font-weight: 600; margin-bottom: 0.35rem; }
    .db-stat-value { font-size: 1.55rem; font-weight: 700; color: #0f172a; line-height: 1.1; }
    .db-stat-muted { margin-top: 0.35rem; font-size: 0.72rem; color: #94a3b8; }
    .db-stat-card .db-stat-value.db-stat-approved { color: #3b6d11; }
    .db-stat-card .db-stat-value.db-stat-review   { color: #ba7517; }
    .db-stat-card .db-stat-value.db-stat-draft    { color: #57534e; }

    .db-panel {
      background: #fff;
      border: 1px solid #e2e8f0;
      border-radius: 12px;
      padding: 1rem 1.15rem;
      box-shadow: 0 1px 3px rgba(15,23,42,0.06);
    }
    .db-panel-title { margin: 0 0 0.85rem; font-size: 0.98rem; font-weight: 700; color: #1e293b; }
    .db-panel-heading-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 0.75rem;
    }
    .db-panel-heading-row .db-panel-title { margin-bottom: 0; }

    .db-build-progress-panel { margin-bottom: 1rem; }
    .db-build-progress-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0.65rem;
      gap: 0.5rem;
      flex-wrap: wrap;
    }
    .db-build-progress-caption { font-size: 0.78rem; color: #64748b; }
    .db-progress-track {
      display: flex;
      height: 8px;
      border-radius: 4px;
      overflow: hidden;
      background: #f1f5f9;
    }
    .db-progress-seg { height: 100%; transition: width 0.25s ease; }
    .db-progress-approved { background: #639922; min-width: 0; }
    .db-progress-review { background: #ef9f27; min-width: 0; }
    .db-progress-draft { background: #888780; min-width: 0; }
    .db-progress-archived { background: #cbd5e1; min-width: 0; }
    .db-progress-legend {
      display: flex;
      gap: 1rem;
      margin-top: 0.65rem;
      flex-wrap: wrap;
      font-size: 0.72rem;
      color: #64748b;
    }
    .db-leg-item { display: inline-flex; align-items: center; gap: 0.35rem; }
    .db-leg-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
    .db-swatch-approved { background: #639922; }
    .db-swatch-review { background: #ef9f27; }
    .db-swatch-draft { background: #888780; }
    .db-swatch-archived { background: #cbd5e1; }

    .db-mid-grid {
      display: grid;
      grid-template-columns: 1.35fr minmax(0, 1fr);
      gap: 0.75rem;
      margin-bottom: 0.75rem;
      align-items: stretch;
    }
    @media (max-width: 900px) {
      .db-mid-grid { grid-template-columns: 1fr; }
    }

    .db-attention-stack { display: flex; flex-direction: column; gap: 0.5rem; }
    .db-attention-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
      width: 100%;
      text-align: left;
      border: none;
      border-radius: 8px;
      padding: 0.4rem 0.55rem 0.4rem 0.72rem;
      font-size: 0.82rem;
      transition: background 0.12s ease;
      font-family: inherit;
    }
    .db-attention-red { background: #fcebeb; color: #501313; }
    .db-attention-amber { background: #faeeda; color: #412402; }
    .db-attention-main {
      flex: 1;
      min-width: 0;
      background: transparent;
      border: none;
      color: inherit;
      font: inherit;
      text-align: left;
      padding: 0;
      cursor: pointer;
    }
    .db-attention-main:hover { text-decoration: underline; text-underline-offset: 2px; }
    .db-attention-tools {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      flex-shrink: 0;
    }
    .db-attention-info,
    .db-attention-cta {
      background: transparent;
      border: none;
      color: inherit;
      cursor: pointer;
      font: inherit;
      padding: 0.2rem 0.4rem;
      border-radius: 4px;
    }
    .db-attention-info { opacity: 0.6; }
    .db-attention-info:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
    .db-attention-cta { font-size: 0.72rem; opacity: 0.85; white-space: nowrap; font-weight: 600; }
    .db-attention-cta:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
    .db-attention-error {
      font-size: 0.75rem;
      color: #b45309;
      padding: 0.35rem 0.45rem;
      border-radius: 6px;
      background: #fffbeb;
    }

    .db-health-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.55rem;
      font-size: 0.83rem;
    }
    .db-health-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
      color: #475569;
    }
    .db-health-ok { color: #3b6d11; font-weight: 600; white-space: nowrap; }
    .db-health-warn { color: #92400e; font-weight: 600; white-space: nowrap; }
    .db-health-bad { color: #b91c1c; font-weight: 600; white-space: nowrap; }

    .db-bottom-split {
      display: grid;
      grid-template-columns: 1.35fr minmax(0, 1fr);
      gap: 0.75rem;
      align-items: stretch;
    }
    @media (max-width: 960px) {
      .db-bottom-split { grid-template-columns: 1fr; }
    }
    .db-activity-rich-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.65rem;
      max-height: 320px;
      overflow-y: auto;
    }
    .db-activity-row {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 0.85rem;
      padding-bottom: 0.65rem;
      border-bottom: 1px solid #f1f5f9;
    }
    .db-activity-row:last-child { border-bottom: none; padding-bottom: 0; }
    .db-activity-title { font-size: 0.84rem; font-weight: 600; color: #0f172a; }
    .db-activity-sub { font-size: 0.74rem; color: #64748b; margin-top: 0.2rem; line-height: 1.35; }
    .db-activity-time { font-size: 0.73rem; color: #94a3b8; white-space: nowrap; }
    .db-activity-rich-list .db-activity-empty { color: #94a3b8; font-style: italic; font-size: 0.84rem; padding: 0.25rem 0; }

    .db-actions-grid-compact .db-action-btn {
      flex-direction: row;
      justify-content: flex-start;
      text-align: left;
      padding: 0.72rem 0.85rem;
      gap: 0.55rem;
      font-weight: 600;
      font-size: 0.8rem;
    }
    .db-actions-grid-compact .db-action-btn i {
      font-size: 1rem;
      color: #64748b;
    }

    .db-section-title {
      font-size: 0.82rem;
      font-weight: 600;
      color: #374151;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 0.6rem;
    }

    .db-year-cards-top {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 0.85rem;
      margin-bottom: 1.5rem;
    }
    .db-year-card {
      background: #fff;
      border: 1px solid #e2e8f0;
      border-radius: 12px;
      padding: 1.25rem 1.3rem;
      cursor: pointer;
      transition: all 0.15s;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    .db-year-card:hover {
      border-color: #93c5fd;
      box-shadow: 0 4px 12px rgba(59,130,246,0.14);
      transform: translateY(-2px);
    }
    .db-year-card-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0.65rem;
    }
    .db-year-card-head span {
      font-size: 1.25rem;
      font-weight: 700;
      color: #1e293b;
    }
    .db-year-card-head i {
      color: #94a3b8;
      font-size: 0.85rem;
      transition: transform 0.15s;
    }
    .db-year-card:hover .db-year-card-head i { transform: translateX(3px); color: #3b82f6; }
    .db-year-bar {
      height: 6px;
      border-radius: 3px;
      background: #e2e8f0;
      overflow: hidden;
      display: flex;
      margin-bottom: 0.7rem;
    }
    .db-year-bar .seg-approved { background: #22c55e; }
    .db-year-bar .seg-review   { background: #f59e0b; }
    .db-year-bar .seg-draft    { background: #94a3b8; }
    .db-year-stats {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 0.25rem;
      text-align: center;
    }
    .db-year-stat-item {
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
    }
    .db-year-stat-val { font-size: 1.1rem; font-weight: 700; color: #1e293b; }
    .db-year-stat-lbl { font-size: 0.68rem; color: #64748b; }

    .db-bottom-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.75rem;
    }
    .db-activity-panel, .db-actions-panel {
      background: #fff;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      padding: 1rem 1.15rem;
      box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    .db-activity-list {
      list-style: none;
      padding: 0;
      margin: 0;
      font-size: 0.8rem;
      color: #475569;
      max-height: 220px;
      overflow-y: auto;
    }
    .db-activity-list li { padding: 0.35rem 0; border-bottom: 1px solid #f1f5f9; }
    .db-activity-list li:last-child { border-bottom: none; }
    .db-activity-empty { color: #94a3b8; font-style: italic; }
    .db-actions-panel {
      display: flex;
      flex-direction: column;
    }
    .db-actions-panel .db-section-title { margin-bottom: 0.75rem; }
    .db-actions-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.5rem;
      flex: 1;
    }
    .db-action-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      padding: 1rem 0.75rem;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      background: #f8fafc;
      color: #334155;
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s;
      flex-direction: column;
      text-align: center;
    }
    .db-action-btn:hover {
      background: #eff6ff;
      border-color: #93c5fd;
      color: #1e40af;
      box-shadow: 0 2px 6px rgba(59,130,246,0.1);
      transform: translateY(-1px);
    }
    .db-action-btn i { font-size: 1.1rem; }

    /* ── Measure Library Page ── */
    .ml-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0.75rem;
      flex-wrap: wrap;
      gap: 0.5rem;
    }
    .ml-header-left { display: flex; align-items: center; gap: 0.75rem; }
    .ml-year-select {
      font-size: 1.05rem;
      font-weight: 700;
      color: #1e293b;
      padding: 0.4rem 0.6rem;
      border-radius: 8px;
      min-width: 120px;
    }
    .ml-summary { font-size: 0.82rem; color: #64748b; }
    .ml-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

    .ml-progress-bar {
      height: 6px;
      border-radius: 3px;
      background: #e2e8f0;
      overflow: hidden;
      margin-bottom: 0.85rem;
      display: flex;
    }
    .ml-progress-bar .seg-approved { background: #22c55e; }
    .ml-progress-bar .seg-review   { background: #f59e0b; }
    .ml-progress-bar .seg-draft    { background: #94a3b8; }
    .ml-progress-bar .seg-archived { background: #cbd5e1; }

    .ml-toolbar {
      display: flex;
      gap: 0.5rem;
      margin-bottom: 0.65rem;
      flex-wrap: wrap;
    }
    .ml-search { flex: 1; min-width: 180px; }
    .ml-filter { width: 150px; flex: none; }

    .ml-bulk-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: 8px;
      padding: 0.5rem 0.75rem;
      margin-bottom: 0.65rem;
      font-size: 0.82rem;
      color: #1e40af;
      font-weight: 500;
    }
    .ml-bulk-actions { display: flex; gap: 0.4rem; align-items: center; }
    .ml-bulk-actions .dropdown { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
    .ml-bulk-actions .popout-btn { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

    .ml-table-wrap {
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      overflow: auto;
      max-height: calc(100vh - 330px);
    }
    .ml-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.85rem;
    }
    .ml-table th, .ml-table td {
      padding: 0.6rem 0.75rem;
      text-align: left;
      border-bottom: 1px solid #f1f5f9;
    }
    .ml-table th {
      background: #f8fafc;
      color: #374151;
      font-weight: 600;
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      position: sticky;
      top: 0;
      z-index: 1;
    }
    .ml-th-check { width: 36px; }
    .ml-table tbody tr { cursor: pointer; transition: background 0.1s; }
    .ml-table tbody tr:hover { background: #f8fafc; }
    .ml-table tbody tr.ml-selected { background: #eff6ff; }
    .ml-table input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }

    .ml-status-badge {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      padding: 0.15rem 0.55rem;
      border-radius: 10px;
      font-size: 0.72rem;
      font-weight: 600;
      letter-spacing: 0.01em;
      text-transform: none;
      border: 1px solid transparent;
    }
    .ml-status-badge.approved  { background: #eaf3de; color: #173404; border-color: #cce6a4; }
    .ml-status-badge.in_review { background: #faeeda; color: #854f0b; border-color: #f3d8a4; }
    .ml-status-badge.draft     { background: #f1efe8; color: #444441; border-color: #e2dfd2; }
    .ml-status-badge.archived  { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; }
    .ml-status-mixed-count {
      font-size: 0.65rem;
      font-weight: 700;
      padding: 0 0.3rem;
      border-radius: 6px;
      background: rgba(0, 0, 0, 0.08);
    }

    /* ── Title truncation: keep rows uniform height; full title in tooltip ── */
    .ml-cell-title-col {
      max-width: 0;
    }
    .ml-cell-title {
      display: block;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .ml-cell-id { white-space: nowrap; }
    .ml-cell-stratum { white-space: nowrap; color: #64748b; font-size: 0.78rem; }
    .ml-cell-updated { white-space: nowrap; color: #475569; font-size: 0.78rem; }
    .ml-cell-status  { white-space: nowrap; }

    /* ── Strata grouping: parent row + child indentation ── */
    .ml-row-parent { background: #f8fafc; }
    .ml-row-parent:hover { background: #eef2f7; }
    .ml-row-parent td { font-weight: 500; }
    .ml-group-toggle {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      background: transparent;
      border: none;
      padding: 0.1rem 0.2rem;
      margin: 0;
      cursor: pointer;
      color: inherit;
      font: inherit;
    }
    .ml-group-toggle:hover { color: #1d4ed8; }
    .ml-group-toggle i { font-size: 0.72rem; color: #64748b; transition: transform 0.12s ease; }
    .ml-row-parent.is-open .ml-group-toggle i { color: #1e293b; }
    .ml-group-count {
      display: inline-block;
      background: #e2e8f0;
      color: #334155;
      font-size: 0.7rem;
      font-weight: 600;
      padding: 0.1rem 0.5rem;
      border-radius: 999px;
    }
    .ml-row-child td { background: #fff; }
    .ml-row-child:hover td { background: #f8fafc; }
    .ml-child-id {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      color: #64748b;
      font-size: 0.78rem;
      padding-left: 1.1rem;
    }
    .ml-child-bar {
      width: 8px;
      height: 1px;
      background: #cbd5e1;
      display: inline-block;
    }
    .ml-child-title {
      color: #64748b;
      font-style: italic;
      font-size: 0.82rem;
    }

    .ml-empty {
      text-align: center;
      padding: 3rem 1rem;
      color: #94a3b8;
    }
    .ml-empty i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
    .ml-empty p { font-size: 0.9rem; }

    /* Notes */
    .notes-add { margin-bottom: 1rem; }
    .notes-list { max-height: 350px; overflow-y: auto; }
    .notes-empty { color: #94a3b8; font-style: italic; font-size: 0.85rem; }
    .note-item {
      padding: 0.65rem 0.75rem;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      margin-bottom: 0.5rem;
      background: #f8fafc;
    }
    .note-meta {
      display: flex;
      justify-content: space-between;
      font-size: 0.72rem;
      color: #64748b;
      margin-bottom: 0.3rem;
    }
    .note-meta .note-author { font-weight: 600; color: #334155; }
    .note-text { font-size: 0.85rem; color: #1e293b; line-height: 1.5; white-space: pre-wrap; }
    .note-delete-btn {
      background: none;
      border: none;
      color: #cbd5e1;
      cursor: pointer;
      padding: 0.15rem 0.3rem;
      border-radius: 4px;
      font-size: 0.7rem;
      transition: all 0.12s;
    }
    .note-delete-btn:hover { color: #dc2626; background: #fef2f2; }

    .admin-page-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 1.25rem;
      padding: 1.25rem 1.4rem;
      background: #ffffff;
      border: 1px solid #e5e7eb;
      border-radius: 12px;
    }

    .admin-page-header h2 {
      font-size: 1.25rem;
      color: #1f2937;
      margin-bottom: 0.2rem;
    }

    .admin-page-header p {
      color: #6b7280;
      font-size: 0.9rem;
    }

    .admin-grid {
      display: grid;
      grid-template-columns: 1.2fr 1fr;
      gap: 1rem;
    }

    .admin-card {
      background: #ffffff;
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      padding: 1.15rem;
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    }

    .admin-card h3 {
      font-size: 1rem;
      color: #1f2937;
      margin-bottom: 0.9rem;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    .admin-form-row {
      margin-bottom: 0.75rem;
    }

    .admin-form-row label {
      display: block;
      font-size: 0.82rem;
      font-weight: 600;
      color: #374151;
      margin-bottom: 0.3rem;
    }

    .admin-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 0.55rem;
      margin-bottom: 0.65rem;
    }

    .admin-table-wrap {
      margin-top: 0.7rem;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      overflow: auto;
      max-height: 320px;
    }

    .admin-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.86rem;
    }

    .admin-table th,
    .admin-table td {
      padding: 0.6rem 0.65rem;
      border-bottom: 1px solid #f1f5f9;
      text-align: left;
      vertical-align: top;
    }

    .admin-table th {
      background: #f8fafc;
      color: #374151;
      font-weight: 600;
      position: sticky;
      top: 0;
      z-index: 1;
    }

    .ref-upload-shell {
      border: 1px solid #dbeafe;
      background: linear-gradient(180deg, #f8fbff 0%, #f8fafc 100%);
      border-radius: 12px;
      padding: 0.9rem;
      margin-bottom: 0.35rem;
      position: relative;
    }

    /* Pass S Phase 3 — CMS Single Source delta panel.
       Three-tier chip system (red/yellow/blue/advisory/clean) for
       surfacing ssMissing / ssUnexpected / groupedHints / mapping.hint
       in the diff modal post-apply state and the wizard Done step. */
    .ss-panel {
      display: flex;
      flex-direction: column;
      gap: 0.6rem;
    }
    .ss-panel-header {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.5rem;
      padding: 0.5rem 0.8rem;
      background: #f1f5f9;
      border-radius: 8px;
      border: 1px solid #e2e8f0;
      font-size: 0.85rem;
    }
    .ss-mapping-pill {
      display: inline-flex;
      align-items: center;
      padding: 0.15rem 0.55rem;
      border-radius: 999px;
      font-size: 0.72rem;
      font-weight: 600;
    }
    .ss-mapping-pill.ok {
      background: #dcfce7;
      color: #166534;
      border: 1px solid #86efac;
    }
    .ss-mapping-pill.unmapped {
      background: #fef3c7;
      color: #92400e;
      border: 1px solid #fcd34d;
    }
    .ss-mapping-source {
      color: #64748b;
      font-size: 0.75rem;
      font-style: italic;
    }
    .ss-panel-body {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      max-height: 60vh;
      overflow-y: auto;
    }
    .ss-panel-actions {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding-top: 0.5rem;
      border-top: 1px solid #e2e8f0;
    }
    .ss-tile {
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      padding: 0.7rem 0.9rem;
      background: #ffffff;
      display: flex;
      flex-direction: column;
      gap: 0.4rem;
    }
    .ss-tile-header {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 0.45rem;
      font-size: 0.85rem;
    }
    .ss-tile-icon {
      font-size: 1rem;
    }
    .ss-tile-subtitle {
      color: #64748b;
      font-size: 0.78rem;
      font-weight: normal;
    }
    .ss-tile-body {
      font-size: 0.82rem;
      color: #334155;
      line-height: 1.5;
    }
    .ss-tile-body code {
      background: #f1f5f9;
      padding: 0.1rem 0.35rem;
      border-radius: 4px;
      font-size: 0.78rem;
    }
    .ss-tile-more {
      color: #64748b;
      font-style: italic;
      font-size: 0.75rem;
    }
    .ss-tile-hint {
      color: #475569;
      font-size: 0.78rem;
      font-style: italic;
    }
    .ss-tile-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 0.35rem;
      padding-top: 0.25rem;
    }
    .ss-tile-actions .popout-btn {
      padding: 0.3rem 0.65rem;
      font-size: 0.78rem;
    }
    .ss-tile-red {
      border-color: #fecaca;
      background: #fef2f2;
    }
    .ss-tile-yellow {
      border-color: #fcd34d;
      background: #fffbeb;
    }
    .ss-tile-advisory {
      border-color: #bfdbfe;
      background: #eff6ff;
    }
    .ss-tile-passive {
      border-color: #cbd5e1;
      background: #f8fafc;
    }
    .ss-tile-clean {
      border-color: #86efac;
      background: #f0fdf4;
    }
    .ss-pf-row {
      display: flex;
      align-items: center;
      gap: 0.45rem;
      padding: 0.35rem 0.5rem;
      border-radius: 6px;
      margin: 0.2rem 0;
      font-size: 0.8rem;
    }
    .ss-pf-row.ss-pf-red {
      background: #fef2f2;
      border-left: 3px solid #f87171;
    }
    .ss-pf-row.ss-pf-yellow {
      background: #fffbeb;
      border-left: 3px solid #fcd34d;
    }
    .ss-pf-icon {
      flex: 0 0 auto;
    }
    .ss-pf-system {
      color: #64748b;
      font-size: 0.72rem;
      font-style: italic;
    }
    .ss-pf-hint {
      flex: 1 1 auto;
      color: #475569;
      font-size: 0.75rem;
    }
    .ss-pf-hint.ss-pf-warn {
      color: #b45309;
      font-weight: 500;
    }
    .ss-pf-dismiss {
      padding: 0.2rem 0.5rem;
      font-size: 0.72rem;
    }
    .ss-pf-section {
      list-style: none;
      padding: 0.4rem 0;
    }
    .ss-pf-list {
      list-style: none;
      padding: 0;
      margin: 0.2rem 0 0 0;
    }
    .ss-pf-more {
      color: #94a3b8;
      font-style: italic;
      padding: 0.2rem 0.5rem;
    }

    /* Terminology health banner (Pass T). Three states — loading (grey),
       ok (green), missing (red). Width and spacing match the upload card
       so the banner reads as part of the same section. */
    .ref-health-banner {
      display: flex;
      align-items: center;
      gap: 0.55rem;
      padding: 0.55rem 0.8rem;
      border-radius: 10px;
      border: 1px solid transparent;
      font-size: 0.82rem;
      margin-bottom: 0.55rem;
    }
    .ref-health-banner .ref-health-banner-text {
      flex: 1 1 auto;
      min-width: 0;
    }
    .ref-health-banner-refresh {
      padding: 0.2rem 0.45rem;
      font-size: 0.72rem;
    }
    .ref-health-banner-loading {
      color: #475569;
      background: #f1f5f9;
      border-color: #e2e8f0;
    }
    .ref-health-banner-ok {
      color: #15803d;
      background: #f0fdf4;
      border-color: #bbf7d0;
    }
    .ref-health-banner-missing {
      color: #b91c1c;
      background: #fef2f2;
      border-color: #fecaca;
    }
    .ref-health-banner-missing .ref-health-banner-list {
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.74rem;
      color: #7f1d1d;
    }

    .ref-drop-overlay {
      position: absolute;
      inset: 0;
      background: rgba(219, 234, 254, 0.92);
      border: 2px dashed #3b82f6;
      border-radius: 12px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      z-index: 10;
      font-size: 1rem;
      font-weight: 600;
      color: #1e40af;
      pointer-events: none;
    }

    .ref-drop-overlay i {
      font-size: 2rem;
    }

    .ref-auto-hint {
      display: inline-block;
      margin-top: 0.3rem;
      font-size: 0.75rem;
      color: #16a34a;
      font-weight: 500;
    }

    .ref-upload-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.75rem;
      align-items: end;
    }

    .ref-file-picker-row {
      display: flex;
      align-items: center;
      gap: 0.65rem;
      margin-top: 0.25rem;
      flex-wrap: wrap;
    }

    .ref-selected-file {
      flex: 1;
      min-width: 240px;
      border: 1px solid #dbe4f0;
      background: #ffffff;
      color: #475569;
      border-radius: 8px;
      padding: 0.62rem 0.75rem;
      font-size: 0.82rem;
      line-height: 1.25;
    }

    .ref-selected-file.pending {
      border-color: #93c5fd;
      color: #1e3a8a;
      background: #eff6ff;
    }

    .ref-upload-hint {
      margin: 0.55rem 0 0;
      font-size: 0.77rem;
      color: #64748b;
    }

    .ref-upload-status-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0.4rem;
    }

    .ref-upload-status-header strong {
      font-size: 0.85rem;
      color: #334155;
    }

    .ref-upload-status-header .popout-btn {
      padding: 0.35rem 0.55rem;
      font-size: 0.74rem;
    }

    .ref-upload-results {
      max-height: 220px;
      overflow-y: auto;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      font-size: 0.8rem;
      background: #ffffff;
    }

    .ref-upload-row {
      padding: 0.44rem 0.64rem;
      border-bottom: 1px solid #f1f5f9;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    .ref-upload-row:last-child {
      border-bottom: none;
    }

    @media (max-width: 1024px) {
      .ref-upload-grid {
        grid-template-columns: 1fr;
      }
    }

    .admin-csv-input {
      min-height: 200px;
      font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
      font-size: 0.82rem;
    }
    
    /* Measure Context Bar */
    .measure-context-bar {
      background: #ffffff;
      padding: 1.25rem 1.5rem;
      margin-bottom: 1.5rem;
      border-radius: 12px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
      border: 1px solid #e5e7eb;
      display: flex;
      align-items: center;
      gap: 1.5rem;
    }

    @media (max-width: 1024px) {
      .admin-grid {
        grid-template-columns: 1fr;
      }
    }
    
    #currentMeasureTitle {
      font-size: 1.125rem;
      font-weight: 600;
      flex-grow: 1;
      color: #1f2937;
      letter-spacing: -0.01em;
    }

    /* Buttons */
    .popout-btn {
      background: #1E40AF;
      color: #ffffff;
      border: none;
      padding: 0.625rem 1rem;
      border-radius: 8px;
      cursor: pointer;
      font-size: 0.875rem;
      font-weight: 500;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      transition: all 0.15s ease;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
      letter-spacing: -0.01em;
    }
    .popout-btn:hover {
      background: #1e3a8a;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .popout-btn.secondary {
      background: #ffffff;
      color: #6b7280;
      border: 1px solid #d1d5db;
    }
    .popout-btn.secondary:hover {
      background: #f9fafb;
      border-color: #9ca3af;
      color: #374151;
    }
    
    .popout-btn.tertiary {
      background: transparent;
      color: #6b7280;
      border: none;
      box-shadow: none;
    }
    .popout-btn.tertiary:hover {
      background: #f3f4f6;
      color: #374151;
    }

    /* Destructive actions */
    #deleteMeasureBtn {
      background: #ef4444;
      color: #ffffff;
    }
    #deleteMeasureBtn:hover {
      background: #dc2626;
    }

    .popout-btn.destructive {
      background: #ef4444;
      color: #ffffff;
    }
    .popout-btn.destructive:hover {
      background: #dc2626;
    }

    /* Hidden class */
    .hidden {
      display: none !important;
    }

    /* Accordion Styles */
    .accordion-item {
      background: #ffffff;
      border-radius: 12px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
      border: 1px solid #e5e7eb;
      margin-bottom: 1.5rem;
      overflow: visible; /* allow dropdowns to extend beyond card */
      transition: box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      will-change: box-shadow;
    }
    .accordion-item:hover {
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    }
    
    .accordion-button {
      background: #ffffff;
      color: #374151;
      cursor: pointer;
      padding: 1.25rem 1.5rem;
      width: 100%;
      text-align: left;
      border: none;
      border-bottom: 1px solid #e5e7eb;
      outline: none;
      font-size: 1rem;
      font-weight: 500;
      transition: background-color 0.1s ease, color 0.1s ease, border-bottom-color 0.1s ease;
      display: flex;
      justify-content: space-between;
      align-items: center;
      letter-spacing: -0.01em;
      will-change: background-color, color;
    }
    .accordion-button:hover {
      background: #f9fafb;
      color: #1E40AF;
    }
    .accordion-button.active {
      background: #f9fafb;
      color: #1E40AF;
      border-bottom-color: #1E40AF;
    }
    
    .accordion-content {
       padding: 0 1.5rem;
       background-color: #ffffff;
       max-height: 0;
       overflow: hidden; /* keep collapsed state */
     }
     .accordion-content.show {
       padding: 1.5rem;
       max-height: 1500px;
       overflow: visible; /* when expanded, allow dropdowns to extend */
       transition: max-height 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
     }

    /* Forms */
    .form-row {
      margin-bottom: 0.75rem;
      display: flex;
      gap: 0.5rem;
      align-items: center;
    }
    .form-row label {
      flex: 0 0 120px;
      font-weight: bold;
      font-size: 0.9rem;
    }
    .dropdown, .text-input {
      flex: 1;
      padding: 0.625rem 0.75rem;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      font-size: 0.875rem;
      background: #ffffff;
      color: #374151;
      transition: all 0.15s ease;
    }
    .dropdown:focus, .text-input:focus {
      outline: none;
      border-color: #1E40AF;
      box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
    }
    
    /* Smart year input specific styling */
    #measureYear {
      position: relative;
    }
    
    #measureYear::-webkit-calendar-picker-indicator {
      background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%236b7280' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat center;
      background-size: 16px;
      cursor: pointer;
      opacity: 0.7;
      transition: opacity 0.15s ease;
    }
    
    #measureYear::-webkit-calendar-picker-indicator:hover {
      opacity: 1;
    }

    /* Stratum description styling */
    .stratum-description {
      padding: 0.75rem;
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      font-size: 0.875rem;
      color: #475569;
      line-height: 1.5;
      font-style: italic;
      min-height: 2.5rem;
      transition: all 0.2s ease;
    }
    
    .stratum-description.empty {
      background: #f3f4f6;
      color: #9ca3af;
      border-color: #d1d5db;
    }
    
    /* Smart combo box styling */
    .smart-combo-container {
      position: relative;
      width: 100%;
    }
    
    .smart-combo-input {
      width: 100%;
      padding: 0.625rem 2.5rem 0.625rem 0.75rem;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      font-size: 0.875rem;
      background: #ffffff;
      color: #374151;
      cursor: pointer;
      transition: all 0.15s ease;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%236b7280' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 0.75rem center;
      background-size: 16px;
    }
    
    .smart-combo-input:focus {
      outline: none;
      border-color: #1E40AF;
      box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
      cursor: text;
    }
    
    .smart-combo-input.editable {
      cursor: text;
      background-color: #eff6ff;
      border-color: #3b82f6;
    }
    
    .smart-combo-dropdown {
       position: absolute;
       top: 100%;
       left: 0;
       right: 0;
       background: #ffffff;
       border: 1px solid #d1d5db;
       border-top: none;
       border-radius: 0 0 6px 6px;
       box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
       max-height: 320px; /* allow more options before scrolling */
       overflow-y: auto;
       z-index: 1000;
       display: none;
     }
    
    .smart-combo-dropdown.show {
      display: block;
    }
    
    .dropdown-option {
      padding: 0.75rem;
      cursor: pointer;
      transition: background-color 0.15s ease;
      font-size: 0.875rem;
      border-bottom: 1px solid #f3f4f6;
    }
    
    .dropdown-option:hover {
      background-color: #f9fafb;
    }
    
    .dropdown-option.highlighted {
      background-color: #eff6ff;
      color: #1e40af;
    }
    
    .dropdown-option.custom-option {
      color: #3b82f6;
      font-style: italic;
      border-top: 1px solid #e5e7eb;
    }
    
    .dropdown-option:last-child {
      border-bottom: none;
    }

    /* Multi-field form row styles */
    .form-row-multi {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 1.5rem;
      margin-bottom: 0.75rem;
      align-items: end;
    }
    .form-field-group {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }
    .form-field-group label {
      font-weight: bold;
      font-size: 0.9rem;
      color: #374151;
      margin: 0;
    }
    .form-field-group .dropdown,
    .form-field-group .text-input {
      flex: none;
      width: 100%;
      min-height: 42px;
    }
    
    /* Responsive behavior for smaller screens */
    @media (max-width: 1200px) {
      .form-row-multi {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
      }
    }
    
    @media (max-width: 768px) {
      .form-row-multi {
        grid-template-columns: 1fr;
        gap: 0.75rem;
      }
    }

    /* Value Set Table */
    #valueSetTable {
      width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      border: 1px solid #e2e8f0;
    }
    #valueSetTable th, #valueSetTable td {
      border: none;
      border-bottom: 1px solid #e2e8f0;
      padding: 0.75rem 1rem;
      vertical-align: middle;
      text-align: left;
      font-size: 0.9rem;
    }
    #valueSetTable th:first-child {
      border-top-left-radius: 8px;
    }
    #valueSetTable th:last-child {
      border-top-right-radius: 8px;
    }
    #valueSetTable th {
      background: #f8fafc;
      color: #374151;
      font-weight: 600;
      font-size: 0.85rem;
      letter-spacing: 0.02em;
      padding: 0.75rem 1rem;
      text-align: left;
      border-bottom: 2px solid #e2e8f0;
    }
    #valueSetTable tbody tr {
      background: #ffffff;
      transition: all 0.2s ease;
      border-bottom: 1px solid #e2e8f0;
    }
    #valueSetTable tbody tr:nth-child(even) {
      background: #f8fafc;
    }
    #valueSetTable tbody tr:hover {
      background: #f8fafc;
    }
    #valueSetTable tbody tr:last-child td:first-child {
      border-bottom-left-radius: 8px;
    }
    #valueSetTable tbody tr:last-child td:last-child {
      border-bottom-right-radius: 8px;
    }
    #valueSetTable tbody tr:last-child td {
      border-bottom: none;
    }

    /* Logic Builder - Horizontal Tabs */
    .logic-tabs {
      display: flex;
      background: #f9fafb;
      border-radius: 8px;
      overflow: hidden;
      margin-bottom: 1.5rem;
      border: 1px solid #e5e7eb;
    }
    .logic-tab {
      flex: 1;
      padding: 0.75rem 0.5rem;
      text-align: center;
      cursor: pointer;
      font-weight: 400;
      color: #6b7280;
      border-right: 1px solid #e5e7eb;
      transition: all 0.15s ease;
      font-size: 0.8rem;
    }
    .logic-tab:last-child { border-right: none; }
    .logic-tab:hover {
      background: #f3f4f6;
      color: #374151;
    }
    .logic-tab.active {
      background: #1E40AF;
      color: #ffffff;
      font-weight: 500;
    }

    /* Expression Fields */
    .logic-expression {
      width: 100%;
      min-height: 100px;
      padding: 1rem;
      font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      background: #ffffff;
      margin-bottom: 1rem;
      white-space: pre-wrap;
      transition: all 0.15s ease;
      font-size: 0.875rem;
      line-height: 1.6;
    }
    .logic-expression:focus {
      border-color: #1E40AF;
      box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
    }

    /* Logic Builder Controls */
    #logicBuilder {
      border: 1px solid #e5e7eb;
      padding: 2rem;
      border-radius: 8px;
      background: #f9fafb;
      margin-top: 1rem;
    }
    .logic-row {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 1rem;
    }
    .logic-row-label {
      font-weight: bold;
      color: #555;
      width: 150px;
      font-size: 0.875rem;
    }
    .logic-row .dropdown {
      flex: 1;
      min-width: 150px;
    }
    .logic-row .dropdown.compact {
      flex: 1;
      min-width: 150px;
    }
    .logic-actions {
      display: flex;
      gap: 0.75rem;
      justify-content: center;
      margin-top: 1rem;
      padding-top: 1rem;
      border-top: 1px solid #e5e7eb;
    }

    /* Temporal Builder UI */
    #temporalBuilder {
      border: 1px solid #e5e7eb;
      padding: 1.5rem;
      border-radius: 8px;
      background: #f9fafb;
    }
    .temporal-row {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 1rem;
    }
    .temporal-row-label {
      font-weight: bold;
      color: #555;
      width: 150px;
    }
    .temporal-row-label.inline {
      width: auto;
      margin: 0 0.5rem;
    }
    .temporal-row .dropdown, .temporal-row .text-input {
      flex: 1;
      min-width: 150px;
    }
    .temporal-row .dropdown.boundary {
      flex: 0 0 120px;
    }
    .temporal-row .text-input.numeric {
      flex: 0 0 100px;
    }
    #temporalBetweenAndLabel {
      display: none;
    }

    /* New Constraint Type Selector */
    .constraint-type-selector {
      margin-bottom: 1.5rem;
    }
    .constraint-type-tabs {
      display: flex;
      background: #f1f5f9;
      border-radius: 8px;
      padding: 4px;
      gap: 4px;
    }
    .constraint-type-tab {
      flex: 1;
      padding: 12px 16px;
      border: none;
      background: transparent;
      border-radius: 6px;
      cursor: pointer;
      font-weight: 500;
      color: #64748b;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
    }
    .constraint-type-tab:hover {
      background: #e2e8f0;
      color: #475569;
    }
    .constraint-type-tab.active {
      background: #ffffff;
      color: #1e293b;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    /* Constraint Builders */
    .constraint-builder {
      display: none;
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      padding: 1.5rem;
    }
    .constraint-builder.active {
      display: block;
    }

    /* Constraint Preview */
    .constraint-preview {
      background: #f8fafc;
      border: 1px dashed #cbd5e1;
      border-radius: 6px;
      padding: 12px 16px;
      margin-bottom: 1.5rem;
      text-align: center;
    }
    .constraint-preview-text {
      color: #64748b;
      font-style: italic;
    }
    .constraint-preview.populated {
      background: #ecfdf5;
      border-color: #10b981;
      border-style: solid;
    }
    .constraint-preview.populated .constraint-preview-text {
      color: #059669;
      font-style: normal;
      font-weight: 500;
    }

    /* Logic Expression Container - Modern SaaS Style */
    .logic-expression {
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      padding: 0;
      min-height: 120px;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      font-size: 0.875rem;
      line-height: 1.5;
      overflow-y: auto;
      max-height: 400px;
      position: relative;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    /* Logic Lines - Clean, Modern Style */
    .logic-line {
      display: flex;
      align-items: center;
      padding: 0.375rem 0.75rem;
      min-height: 2rem;
      position: relative;
      transition: background-color 0.15s ease;
      border-left: 2px solid transparent;
    }
    
    .logic-line:hover {
      background: #f8fafc;
      border-left-color: #e2e8f0;
    }

    /* Visual grouping for nested logic */
    .logic-line.nested-group {
      background: #f8fafc;
      border-left-color: #cbd5e1;
    }

    .logic-line.nested-group:hover {
      background: #f1f5f9;
      border-left-color: #94a3b8;
    }

    /* Line Numbers - Elegant and Subtle */
    .logic-line-number {
      flex-shrink: 0;
      width: 1.75rem;
      color: #94a3b8;
      font-size: 0.75rem;
      font-weight: 500;
      text-align: right;
      margin-right: 1rem;
      user-select: none;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    }

    /* Logic Content Container with Visual Hierarchy */
    .logic-line-content {
      flex-grow: 1;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 0.375rem;
      padding-left: var(--indent-level, 0);
      position: relative;
    }

    /* Indentation Guide Lines */
    .logic-line-content::before {
      content: '';
      position: absolute;
      left: calc(var(--indent-level, 0) - 0.5rem);
      top: 0;
      bottom: 0;
      width: 1px;
      background: #e2e8f0;
      opacity: 0;
      transition: opacity 0.15s ease;
    }

    .logic-line:hover .logic-line-content::before {
      opacity: 1;
    }

    /* Modern, Refined Tokens */
    .logic-chip {
      display: inline-flex;
      align-items: center;
      padding: 0.25rem 0.5rem;
      border-radius: 6px;
      font-size: 0.75rem;
      font-weight: 500;
      border: 1px solid;
      transition: all 0.15s ease;
      cursor: pointer;
      position: relative;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }
    
    /* Muted, Professional Token Colors - Modern SaaS Palette */
    .logic-chip.step {
      background: #dbeafe;
      color: #1e40af;
      border-color: #bfdbfe;
      font-weight: 500;
    }
    .logic-chip.step:hover {
      background: #bfdbfe;
      border-color: #93c5fd;
      box-shadow: 0 2px 4px rgba(30, 64, 175, 0.1);
    }
    
    .logic-chip.and {
      background: #dcfce7;
      color: #166534;
      border-color: #bbf7d0;
      font-weight: 500;
    }
    .logic-chip.and:hover {
      background: #bbf7d0;
      border-color: #86efac;
      box-shadow: 0 2px 4px rgba(22, 101, 52, 0.1);
    }
    
    .logic-chip.or {
      background: #fed7aa;
      color: #c2410c;
      border-color: #fdba74;
      font-weight: 500;
    }
    .logic-chip.or:hover {
      background: #fdba74;
      border-color: #fb923c;
      box-shadow: 0 2px 4px rgba(194, 65, 12, 0.1);
    }
    
    .logic-chip.paren {
      background: #f1f5f9;
      color: #64748b;
      border-color: #e2e8f0;
      font-weight: 400;
    }
    .logic-chip.paren:hover {
      background: #e2e8f0;
      border-color: #cbd5e1;
      box-shadow: 0 1px 2px rgba(100, 116, 139, 0.1);
    }
    
    .logic-chip.logic-ref {
      background: #e9d5ff;
      color: #7c2d92;
      border-color: #d8b4fe;
      font-weight: 500;
    }
    .logic-chip.logic-ref:hover {
      background: #d8b4fe;
      border-color: #c084fc;
      box-shadow: 0 2px 4px rgba(124, 45, 146, 0.1);
    }
    
    /* Remove Token Button - Subtle and Professional */
    .logic-chip .remove-token {
      margin-left: 0.375rem;
      color: #9ca3af;
      font-weight: 500;
      font-size: 0.6875rem;
      cursor: pointer;
      transition: all 0.15s ease;
      opacity: 0;
      border-radius: 3px;
      padding: 1px 3px;
    }
    
    .logic-chip:hover .remove-token {
      opacity: 1;
    }
    
    .logic-chip .remove-token:hover {
      color: #dc2626;
      background: rgba(220, 38, 38, 0.1);
    }

    /* Logic Section Header */
    .logic-section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0.75rem;
    }

    .logic-section-label {
      font-weight: 600;
      color: #374151;
    }

    /* Improved Indentation for Better Visual Hierarchy */
    .logic-indent-1 { --indent-level: 1.5rem; }
    .logic-indent-2 { --indent-level: 3rem; }
    .logic-indent-3 { --indent-level: 4.5rem; }
    .logic-indent-4 { --indent-level: 6rem; }

    /* Code Editor Mode - Performance Optimized */
    .logic-code-editor {
      width: 100%;
      min-height: 120px;
      max-height: 400px;
      padding: 1rem;
      font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
      font-size: 0.875rem;
      line-height: 1.6;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      background: #ffffff;
      color: #1f2937;
      resize: vertical;
      transition: border-color 0.1s ease, box-shadow 0.1s ease;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
      position: relative;
      will-change: border-color, box-shadow;
    }

    /* Autocomplete Preview - Performance Optimized */
    .autocomplete-preview {
      position: absolute;
      pointer-events: none;
      color: #9ca3af;
      font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
      font-size: 0.875rem;
      line-height: 1.6;
      padding: 1rem;
      white-space: pre-wrap;
      z-index: 1;
      will-change: contents;
      contain: layout;
    }

    .logic-code-editor:focus {
      outline: none;
      border-color: #1E40AF;
      box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .logic-code-editor.error {
      border-color: #ef4444;
      box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
    }

    /* Editor Toggle Button */
    #toggleEditorMode {
      font-size: 0.8125rem;
      padding: 0.375rem 0.75rem;
    }

    #toggleEditorMode.active {
      background: #1E40AF;
      color: #ffffff;
    }

    /* Boundary Controls */
    .boundary-controls {
      display: flex;
      gap: 1.5rem;
      align-items: center;
    }

    .boundary-checkbox {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      cursor: pointer;
      font-size: 0.875rem;
      color: #374151;
      position: relative;
    }

    .boundary-checkbox input[type="checkbox"] {
      width: 16px;
      height: 16px;
      cursor: pointer;
    }

    .boundary-info {
      color: #6b7280;
      font-size: 0.75rem;
      cursor: help;
      margin-left: 0.25rem;
    }

    .boundary-info:hover {
      color: #1E40AF;
    }

    /* Mode-specific visibility */
    .logic-inputs.editor-mode .logic-expression { display: none !important; }
    .logic-inputs.editor-mode .logic-code-editor { display: block !important; }
    .logic-inputs.editor-mode ~ #logicTokenControls { opacity: 0.5; pointer-events: none; }
    .logic-inputs.editor-mode ~ #temporalTokenControls { opacity: 0.5; pointer-events: none; }
    
    .logic-code-editor.hidden { display: none !important; }

    /* Empty State */
    .logic-expression-empty {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 2rem;
      color: #6e7781;
      font-style: italic;
      min-height: 120px;
    }

    /* Code Editor Validation Messages */
    .editor-validation-message {
      margin-top: 0.5rem;
      padding: 0.5rem 0.75rem;
      border-radius: 6px;
      font-size: 0.8125rem;
      display: none;
    }

    .editor-validation-message.error {
      background: #fef2f2;
      color: #dc2626;
      border: 1px solid #fecaca;
      display: block;
    }

    .editor-validation-message.success {
      background: #f0fdf4;
      color: #166534;
      border: 1px solid #bbf7d0;
      display: block;
    }

    /* Logic Expression Placeholder */
    .logic-expression[data-placeholder]:empty::before {
      content: attr(data-placeholder);
      color: #6e7781;
      font-style: italic;
      padding: 1rem;
      display: block;
    }

    /* Modal Styles */
    .modal {
      display: none;
      position: fixed;
      z-index: 1000;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      overflow: auto;
      background-color: rgba(0,0,0,0.5);
    }
    .modal-content {
      background: #ffffff;
      margin: 5% auto;
      padding: 1.5rem;
      border-radius: 12px;
      width: 90%;
      max-width: 600px;
      position: relative;
      border: 1px solid #e5e7eb;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
      animation: modalSlideIn 0.2s ease-out;
    }
    @keyframes modalSlideIn {
      from {
        opacity: 0;
        transform: translateY(-10px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }
    .close-modal {
      color: #777;
      position: absolute;
      top: 1rem;
      right: 1rem;
      font-size: 1.5rem;
      font-weight: bold;
      cursor: pointer;
    }
    .modal-content h3 {
      margin-bottom: 1.5rem;
      color: #1f2937;
      text-align: center;
      font-size: 1.25rem;
      font-weight: 600;
      letter-spacing: -0.01em;
    }

    hr {
      border: 0;
      border-top: 1px solid #dee2e6;
      margin: 1rem 0;
    }
    .action-buttons {
      display: flex;
      justify-content: center;
      gap: 1rem;
      margin-top: 1rem;
    }

    /* Code Value ellipsis */
    .ellipsis {
      cursor: pointer;
      color: #1E40AF;
    }
    
    /* Category and status chips */
    .chip {
      display: inline-block;
      padding: 0.25rem 0.625rem;
      border-radius: 6px;
      font-size: 0.75rem;
      font-weight: 500;
    }
    .chip.category { background: #dbeafe; color: #1E40AF; }
    .chip.source { background: #f0fdf4; color: #166534; }
    .chip.section { background: #fef3c7; color: #92400e; }

    /* Export Modal styles */
    #exportModal .modal-content {
      max-width: 700px;
    }
    .export-filters {
      display: grid;
      grid-template-columns: 1.5fr 0.8fr 0.9fr;
      gap: 0.6rem;
      margin-bottom: 0.8rem;
    }
    #exportMeasuresList {
      list-style-type: none;
      padding: 0;
      margin-bottom: 1rem;
      max-height: 300px;
      overflow-y: auto;
      border: 1px solid #dee2e6;
      border-radius: 4px;
    }
    #exportMeasuresList li {
      padding: 0.75rem;
      border-bottom: 1px solid #dee2e6;
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }
    #exportMeasuresList li:last-child {
      border-bottom: none;
    }
    #exportMeasuresList input[type="checkbox"] {
      width: 18px;
      height: 18px;
    }
    .export-actions {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 1rem;
    }

    @media (max-width: 900px) {
      .export-filters {
        grid-template-columns: 1fr;
      }
    }

    /* Toast Notification Styles */
    #toastContainer {
      position: fixed;
      bottom: 20px;
      left: 20px;
      z-index: 2000;
      display: flex;
      flex-direction: column;
      gap: 12px;
      max-width: 400px;
    }
    .toast {
      padding: 1rem 1.25rem;
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      opacity: 0;
      transform: translateX(-100%);
      animation: slideInLeft 0.3s ease-out forwards;
      position: relative;
    }
    .toast.success { background-color: #10b981; }
    .toast.info { background-color: #3b82f6; }
    .toast.error { background-color: #ef4444; }
    
    .toast-content {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-grow: 1;
    }
    
    .toast-close {
      background: none;
      border: none;
      color: rgba(255, 255, 255, 0.8);
      cursor: pointer;
      padding: 0;
      font-size: 1.2rem;
      line-height: 1;
      transition: color 0.15s ease;
      flex-shrink: 0;
    }
    .toast-close:hover {
      color: #ffffff;
    }

    @keyframes slideInLeft {
      to {
        opacity: 1;
        transform: translateX(0);
      }
    }
    
    .toast.fadeOut {
      animation: fadeOutLeft 0.3s ease-in forwards;
    }
    
    @keyframes fadeOutLeft {
      to {
        opacity: 0;
        transform: translateX(-100%);
      }
    }

/* ============================================================ */
/*  AI Measure Builder (Phase 1+) UI                            */
/* ============================================================ */

.ai-status-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin: 0.5rem 0 1rem;
  font-size: 0.85rem;
}

/* ───────────────────────────── Editor sections ───────────────────────────── */

/* Header bar — measure title + Save / Delete / Close. The shared
   surface rule above (.measure-context-bar-header alongside notes
   and AI panel) provides the white card + 2px navy accent. This
   block tunes the layout: title left, actions right, restrained
   typographic weight. */
.measure-context-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  margin: 0.5rem 0 0.75rem;
}
/* The previous .measure-context-bar rule above (line ~1156) used
   heavy padding and a stronger shadow that would override the shared
   restrained look. Reset those for the header variant. */
.measure-context-bar.measure-context-bar-header {
  padding: 0.85rem 1.25rem;
  margin: 0.5rem 0 0.75rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.measure-header-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
/* Header actions are housekeeping (Save / Delete / Close), not the
   star of the page — render them at a more restrained size so they
   don't compete with the measure title or the AI cards below. */
.measure-header-actions .popout-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 6px;
  box-shadow: none;
}
.measure-header-actions .popout-btn:hover {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
.measure-header-actions .popout-btn.tertiary {
  background: transparent;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.measure-header-actions .popout-btn.tertiary:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}
.measure-header-actions .popout-btn.secondary {
  background: #ffffff;
  color: #1e3a5f;
  border: 1px solid #cbd5e1;
}
.measure-header-actions .popout-btn.secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}
#currentMeasureTitle {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.01em;
}

/* ─── Notes & Status — top-of-editor section ─── */
.measure-status-notes {
  padding: 0.95rem 1.25rem;
  margin: 0 0 0.75rem;
}
.status-notes-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding-bottom: 0.65rem;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid #f1f5f9;
}
.status-notes-head h3 {
  margin: 0;
  font-size: 0.96rem;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.status-notes-head h3 i { color: #1e3a5f; font-size: 0.9rem; }

.status-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.status-row-label {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.status-row-select {
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  min-width: 130px;
}

/* Status badge — color-coded so the lifecycle state is visible
   at-a-glance even before reading the dropdown value. */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}
.status-badge::before {
  content: "●";
  font-size: 0.6rem;
  line-height: 1;
}
.status-badge-draft     { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.status-badge-in_review { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.status-badge-approved  { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-badge-archived  { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }

.measure-status-notes .notes-add { margin-bottom: 0.55rem; }
.measure-status-notes .notes-list { margin-top: 0.4rem; }
.measure-status-notes .notes-empty {
  margin: 0;
  padding: 0.4rem 0.55rem;
  color: #94a3b8;
  font-size: 0.82rem;
  font-style: italic;
}

/* ─── Unified editor sections — header bar, Notes & Status, AI panel ──
 *
 * All three sections that sit at the top of the measure editor share
 * one design language: pure white surface, hairline slate border, a
 * single 2px deep-navy accent at the top-left as the unifying mark.
 * Restrained. Editorial. The cards inside the AI panel are where the
 * visual interest lives; the panel chrome itself stays out of the way.
 *
 * Override order: the shared rule sets shape; per-section rules below
 * tune padding/spacing without re-declaring the surface.
 */
.measure-context-bar-header,
.measure-status-notes,
.ai-workflow-panel {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}
.measure-context-bar-header::before,
.measure-status-notes::before,
.ai-workflow-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4rem;
  height: 2px;
  background: #1e3a5f;
  pointer-events: none;
}

.ai-workflow-panel {
  padding: 1.15rem 1.35rem 1.25rem;
  margin: 0.5rem 0 1rem;
}

.ai-workflow-panel-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.95rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid #f1f5f9;
}
.ai-workflow-panel-header h3 {
  margin: 0;
  font-size: 0.96rem;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.ai-workflow-panel-header h3 i {
  color: #1e3a5f;
  font-size: 0.9rem;
}
.ai-workflow-subtitle {
  font-size: 0.82rem;
  color: #64748b;
  font-style: italic;
}

.ai-workflow-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}
@media (max-width: 1100px) { .ai-workflow-cards { grid-template-columns: 1fr; } }

.ai-workflow-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.05rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.ai-workflow-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
}
.ai-workflow-card[data-active="true"] {
  border-color: #1e3a5f;
}
/* Disabled cards: lift opacity slightly and remove shadow so they
   visually recede without losing legibility. */
.ai-workflow-card[data-disabled="true"] {
  opacity: 0.55;
  background: #fafbfc;
  box-shadow: none;
}
.ai-workflow-card[data-disabled="true"] button { pointer-events: none; }

/* Intent: "recommended" — primary path. The mark is a 3px deep-navy
   left border (FT/Bloomberg editorial style). No color flooding, no
   glow — just a single deliberate accent that says "do this one." */
.ai-workflow-card[data-recommended="true"] {
  border-color: #cbd5e1;
  border-left: 3px solid #1e3a5f;
  padding-left: calc(1.1rem - 2px);
  box-shadow: 0 2px 6px -2px rgba(15, 23, 42, 0.1);
}
.ai-workflow-card-badge {
  display: none;
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  color: #1e3a5f;
  background: transparent;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0;
}
.ai-workflow-card[data-recommended="true"] .ai-workflow-card-badge {
  display: inline-block;
}

/* Intent: "muted" — secondary path; valid but not the recommendation. */
.ai-workflow-card[data-muted="true"] {
  opacity: 0.78;
  background: #fafbfc;
}
.ai-workflow-card[data-muted="true"]:hover { opacity: 0.92; }
.ai-workflow-card-reason {
  margin: 0;
  font-size: 0.76rem;
  color: #64748b;
  background: transparent;
  border-left: 2px solid #cbd5e1;
  padding: 0.1rem 0 0.1rem 0.55rem;
  line-height: 1.4;
  font-style: italic;
}

.ai-workflow-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #1e3a5f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.ai-workflow-card[data-workflow="build"]   .ai-workflow-card-icon { background: #f1f5f9; color: #1e3a5f; }
.ai-workflow-card[data-workflow="enhance"] .ai-workflow-card-icon { background: #f1f5f9; color: #1e3a5f; }

.ai-workflow-card h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #0f172a;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.ai-workflow-card-body {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #475569;
}
.ai-workflow-card-checks {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.ai-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #475569;
}
.ai-check.ok    { color: #16a34a; }
.ai-check.warn  { color: #b45309; }
.ai-check.error { color: #b91c1c; }
.ai-check i { width: 0.95rem; text-align: center; }

.ai-workflow-card-actions {
  margin-top: auto;
  padding-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.ai-card-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: #475569;
  cursor: pointer;
}
.ai-card-primary { font-weight: 600; }
.ai-card-secondary { font-size: 0.82rem; }

.ai-workflow-utility {
  margin: 0.95rem 0 0;
  font-size: 0.8rem;
  color: #64748b;
}
.ai-link-btn {
  background: none;
  border: none;
  color: #1e3a5f;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.ai-link-btn:hover { color: #0f172a; }
.ai-link-btn i { margin-right: 0.25rem; }

/* ─── Build-from-Scratch modal ─── */
.modal-helper {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
  color: #475569;
  line-height: 1.45;
}
.ai-bfs-drop {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: #f8fafc;
}
.ai-bfs-drop:hover { border-color: #6366f1; background: #eef2ff; }
.ai-bfs-drop.drag-active { border-color: #6366f1; background: #e0e7ff; }
.ai-bfs-drop i {
  font-size: 1.5rem;
  color: #6366f1;
}
.ai-bfs-drop strong { color: #0f172a; }

/* Pulsing highlight for the Save button after AI populates fields */
@keyframes saveButtonPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.0); }
  50%      { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.35); }
}
.popout-btn.highlight-pulse {
  animation: saveButtonPulse 1.4s ease-in-out 0s 3;
}

/* ─── Card progress panel (Run Update / Run Enrichment in flight) ─── */
.ai-card-progress {
  margin-top: 0.55rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: linear-gradient(180deg, #eef2ff 0%, #f5f7ff 100%);
  font-size: 0.8rem;
  color: #1e293b;
}
.ai-card-progress-stage {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
}
.ai-card-progress-stage i { color: #4f46e5; }
.ai-card-progress-detail {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.4;
}
.ai-card-progress-list {
  margin: 0.55rem 0 0;
  padding-left: 0;
  list-style: none;
}
.ai-card-progress-list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.18rem 0;
  font-size: 0.74rem;
  color: #94a3b8;
}
.ai-card-progress-list li i { width: 0.95rem; text-align: center; }
.ai-card-progress-list li.done   { color: #16a34a; }
.ai-card-progress-list li.done i { color: #16a34a; }
.ai-card-progress-list li.active { color: #1e293b; font-weight: 600; }
.ai-card-progress-list li.active i { color: #4f46e5; }
.ai-workflow-card.ai-card-busy { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
.ai-workflow-card.ai-card-busy .ai-card-dropzone { opacity: 0.4; pointer-events: none; }

/* ─── AI Diff Review modal (Option B redesign) ─── */
.diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.4rem 0;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid #e2e8f0;
}
.diff-header-title { display: flex; align-items: baseline; gap: 0.5rem; }
.diff-header-title strong { font-size: 1rem; color: #0f172a; }
.diff-header-name { color: #64748b; font-size: 0.85rem; }
.diff-header-years { font-size: 0.82rem; color: #475569; }
.diff-header-years strong { color: #0f172a; }

.diff-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}
@media (max-width: 900px) { .diff-stats { grid-template-columns: repeat(3, 1fr); } }
.diff-stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem 0.4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.diff-stat-num { font-size: 1.05rem; font-weight: 700; color: #475569; }
.diff-stat-label { font-size: 0.7rem; color: #64748b; }
.diff-stat.stat-add    { background: #f0fdf4; border-color: #bbf7d0; }
.diff-stat.stat-add    .diff-stat-num { color: #15803d; }
.diff-stat.stat-remove { background: #fef2f2; border-color: #fecaca; }
.diff-stat.stat-remove .diff-stat-num { color: #b91c1c; }
.diff-stat.stat-warn   { background: #fef3c7; border-color: #fde68a; }
.diff-stat.stat-warn   .diff-stat-num { color: #b45309; }
.diff-stat.stat-ok     { background: #eef2ff; border-color: #c7d2fe; }
.diff-stat.stat-ok     .diff-stat-num { color: #4338ca; }

.diff-no-changes {
  text-align: center;
  padding: 1.2rem 0.5rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  margin-bottom: 0.85rem;
}
.diff-no-changes i { font-size: 2rem; color: #16a34a; margin-bottom: 0.4rem; }
.diff-no-changes h3 { margin: 0.3rem 0 0.25rem; color: #15803d; font-size: 1rem; }
.diff-no-changes p  { margin: 0; color: #166534; font-size: 0.85rem; }

.diff-section {
  margin-bottom: 0.65rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}
.diff-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.diff-section > summary::-webkit-details-marker { display: none; }
.diff-section > summary::before {
  content: "▸";
  color: #94a3b8;
  font-size: 0.7rem;
  margin-right: 0.2rem;
  transition: transform 0.15s ease;
  display: inline-block;
}
.diff-section[open] > summary::before { transform: rotate(90deg); }
.diff-section > summary i { color: #6366f1; }

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  border-top: 1px solid #e2e8f0;
}
.diff-table thead th {
  background: #f8fafc;
  text-align: left;
  font-weight: 600;
  color: #475569;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #e2e8f0;
}
.diff-table tbody td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
.diff-table tbody tr:last-child td { border-bottom: none; }
.diff-table code {
  background: #f1f5f9;
  padding: 0.05rem 0.32rem;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #0f172a;
}
.diff-cell-add code    { background: #dcfce7; color: #15803d; }
.diff-cell-remove code { background: #fecaca; color: #b91c1c; text-decoration: line-through; text-decoration-thickness: 1px; }
.diff-confidence {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.diff-confidence.high   { background: #dcfce7; color: #15803d; }
.diff-confidence.medium { background: #fef3c7; color: #92400e; }
.diff-confidence.low    { background: #fecaca; color: #b91c1c; }
.diff-accept-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.diff-note {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 0.25rem;
  font-style: italic;
}

.diff-checked-list,
.diff-prefetch-list {
  margin: 0;
  padding: 0.4rem 1.1rem 0.65rem;
  font-size: 0.78rem;
  color: #475569;
  line-height: 1.5;
}
.diff-checked-list li { padding: 0.15rem 0; }
.diff-prefetch-list li {
  padding: 0.35rem 0.55rem;
  margin: 0.2rem 0;
  border-radius: 6px;
  list-style: none;
}
.diff-prefetch-list li.retired      { background: #fef2f2; }
.diff-prefetch-list li.unrecognized { background: #fef9c3; }
.diff-prefetch-list li.posthoc      { background: #eef2ff; }
.diff-prefetch-hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: #64748b;
}
.diff-reasoning > p,
.diff-reasoning .diff-reasoning-prose {
  padding: 0 0.85rem 0.7rem;
  margin: 0;
  color: #334155;
  font-size: 0.82rem;
  line-height: 1.5;
}
.diff-reasoning .diff-reasoning-bullets {
  margin: 0;
  padding: 0.4rem 0.85rem 0.75rem 1.85rem;
  list-style: disc;
  color: #334155;
}
.diff-reasoning .diff-reasoning-bullets li {
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0.18rem 0;
}
.diff-reasoning .diff-reasoning-bullets li::marker {
  color: #6366f1;
}

/* ─── Greenfield Wizard — top stepper, structure card, file selector ─── */

.gf-wizard-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 0 0.95rem;
  padding: 0.45rem 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.gf-wizard-step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  flex: 1;
  border-radius: 6px;
  position: relative;
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 600;
}
.gf-wizard-step:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  width: 14px;
  height: 2px;
  background: #cbd5e1;
  transform: translateY(-50%);
}
.gf-wizard-step-num {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.gf-wizard-step-active .gf-wizard-step-num {
  background: #6366f1;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.gf-wizard-step-active { color: #1e293b; background: #eef2ff; }
.gf-wizard-step-done .gf-wizard-step-num { background: #16a34a; color: #ffffff; }
.gf-wizard-step-done { color: #166534; }
.gf-wizard-step-done:not(:last-child)::after { background: #86efac; }

/* Structure step card */
.gf-card-section {
  background: #ffffff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 0.95rem 1.05rem;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.06);
}
.gf-card-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.gf-card-section-head h4 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}
.gf-status-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.gf-status-badge.ok   { background: #dcfce7; color: #15803d; border-color: #86efac; }
.gf-status-badge.warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }

.gf-extras {
  margin: 0.5rem 0 0.85rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}
.gf-extras > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}
.gf-extras > summary::-webkit-details-marker { display: none; }
.gf-extras > summary::before {
  content: "▸";
  color: #94a3b8;
  font-size: 0.7rem;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
  display: inline-block;
}
.gf-extras[open] > summary::before { transform: rotate(90deg); }
.gf-extras > summary i { color: #6366f1; margin-right: 0.25rem; }
.gf-extras .diff-reasoning-bullets {
  margin: 0;
  padding: 0.3rem 0.85rem 0.6rem 1.85rem;
  list-style: disc;
  color: #334155;
}
.gf-extras .diff-reasoning-bullets li { font-size: 0.8rem; line-height: 1.45; padding: 0.15rem 0; }
.gf-extras .diff-reasoning-bullets li::marker { color: #6366f1; }

.gf-files-head {
  margin: 0.65rem 0 0.45rem;
  font-size: 0.85rem;
  color: #475569;
  font-weight: 600;
}
.gf-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.gf-file-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.gf-file-row:hover { border-color: #c7d2fe; background: #fafaff; }
.gf-file-row.active { border-color: #6366f1; background: #eef2ff; box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12); }
.gf-file-row.done { background: #f0fdf4; border-color: #86efac; }
.gf-file-row input[type="radio"] { margin-top: 0.2rem; flex-shrink: 0; cursor: pointer; }
.gf-file-meta { flex: 1; min-width: 0; }
.gf-file-row-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.gf-file-row-head code {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: #0f172a;
  font-weight: 700;
}
.gf-file-row-head strong {
  color: #0f172a;
  font-size: 0.85rem;
}
.gf-file-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}
.gf-file-status.done    { background: #dcfce7; color: #15803d; }
.gf-file-status.active  { background: #eef2ff; color: #4338ca; }
.gf-file-status.pending { background: #f1f5f9; color: #64748b; }
.gf-file-desc {
  font-size: 0.78rem;
  color: #475569;
  margin-top: 0.2rem;
  line-height: 1.45;
}
.gf-file-diff {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 0.15rem;
}
.gf-file-diff em { font-style: italic; color: #94a3b8; }

.gf-feedback-block {
  margin-top: 0.65rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fffbeb;
}
.gf-feedback-block > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: #78350f;
  font-weight: 600;
}
.gf-feedback-block > summary::-webkit-details-marker { display: none; }
.gf-feedback-block > summary::before {
  content: "▸";
  color: #b45309;
  font-size: 0.7rem;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
  display: inline-block;
}
.gf-feedback-block[open] > summary::before { transform: rotate(90deg); }
.gf-feedback-block > summary i { margin-right: 0.25rem; color: #b45309; }
.gf-feedback-block textarea {
  margin: 0 0.75rem;
  width: calc(100% - 1.5rem);
  font-size: 0.82rem;
  font-family: inherit;
}
.gf-feedback-hint {
  margin: 0 0.75rem 0.4rem;
  font-size: 0.74rem;
  color: #78350f;
  line-height: 1.45;
}
.gf-feedback-block .diff-actions {
  margin: 0.4rem 0.75rem 0.6rem;
  padding-top: 0;
  border-top: none;
}

/* Done step */
.gf-done-hero {
  text-align: center;
  padding: 1.2rem 0.5rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  margin-bottom: 0.65rem;
}
.gf-done-hero i { font-size: 2.2rem; color: #16a34a; }
.gf-done-hero h3 { margin: 0.4rem 0 0.25rem; color: #15803d; font-size: 1.1rem; }
.gf-done-hero p  { margin: 0; color: #166534; font-size: 0.85rem; line-height: 1.5; }
.gf-done-summary {
  margin: 0;
  padding: 0.4rem 0;
  list-style: none;
}
.gf-done-summary li {
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.gf-done-summary li i { color: #16a34a; }
.gf-done-summary code {
  background: #f1f5f9;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: #0f172a;
  font-weight: 700;
}

/* ─── Manual-review "Convert to row" inline form ─── */
.diff-item.manual-review-item {
  border-left: 3px solid #f59e0b;
}
.diff-item.from-review {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
}
.mr-converter-box {
  margin-top: 0.55rem;
  padding: 0.7rem 0.85rem;
  background: #ffffff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.06);
}
.mr-converter-hint {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  color: #475569;
  line-height: 1.45;
}
.mr-converter-hint i { color: #6366f1; margin-right: 0.25rem; }
.mr-converter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.55rem;
}
@media (max-width: 720px) { .mr-converter-grid { grid-template-columns: 1fr; } }
.mr-converter-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.mr-converter-field > span {
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mr-converter-field input.text-input {
  font-size: 0.82rem;
  padding: 0.35rem 0.55rem;
}

/* ─── Code-Set Library — AI search progress strip ─── */
.cs-ai-progress {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.85rem;
  background: linear-gradient(180deg, #eef2ff 0%, #f5f7ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 8px;
}
.cs-ai-progress-stage {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: #1e293b;
}
.cs-ai-progress-stage i { color: #4f46e5; }
.cs-ai-progress-detail {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: #64748b;
}

.diff-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 1px solid #e2e8f0;
}

/* ─── Greenfield wizard: Step 2 (Logic) auto-propose + feedback loop ─── */
.gf-logic-summary {
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.82rem;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.gf-logic-summary.ok    { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.gf-logic-summary.warn  { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.gf-logic-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
@media (max-width: 800px) { .gf-logic-fields { grid-template-columns: 1fr; } }
.gf-logic-field { display: flex; flex-direction: column; gap: 0.2rem; }
.gf-logic-field-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gf-logic-textarea {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important;
  font-size: 0.82rem;
  padding: 0.4rem 0.55rem;
  resize: vertical;
  min-height: 2.2rem;
  line-height: 1.4;
}

.gf-logic-review {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #78350f;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  margin: 0.6rem 0;
}
.gf-logic-review ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.gf-logic-review li { padding: 0.15rem 0; }

.gf-logic-extras {
  margin: 0.65rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}
.gf-logic-extras > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}
.gf-logic-extras > summary::-webkit-details-marker { display: none; }
.gf-logic-extras > summary::before {
  content: "▸";
  color: #94a3b8;
  font-size: 0.7rem;
  margin-right: 0.4rem;
  display: inline-block;
  transition: transform 0.15s ease;
}
.gf-logic-extras[open] > summary::before { transform: rotate(90deg); }
.gf-logic-reasoning,
.gf-logic-narrative {
  margin: 0;
  padding: 0.4rem 0.85rem 0.7rem;
  font-size: 0.78rem;
  color: #334155;
  line-height: 1.5;
}
.gf-logic-narrative {
  background: #ffffff;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.74rem;
  white-space: pre-wrap;
  border-top: 1px solid #e2e8f0;
}

.gf-logic-feedback {
  margin: 0.65rem 0;
  padding: 0.6rem 0.75rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
}
.gf-logic-feedback strong { font-size: 0.85rem; color: #1e293b; }
.gf-logic-feedback textarea { font-size: 0.82rem; }

/* ─── Sub-stepper for Step 2 (one section at a time) ─── */
.gf-substepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0.6rem 0 0.85rem;
  padding: 0.5rem 0.4rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow-x: auto;
}
.gf-substepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  flex: 1;
  min-width: 80px;
  position: relative;
  transition: background 0.15s ease;
}
.gf-substepper-step:hover { background: #eef2ff; }
.gf-substepper-step .gf-substepper-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #e2e8f0;
  border: 2px solid #cbd5e1;
}
.gf-substepper-step .gf-substepper-label {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
}
.gf-substepper-step.active { background: #eef2ff; }
.gf-substepper-step.active .gf-substepper-dot { background: #6366f1; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18); }
.gf-substepper-step.active .gf-substepper-label { color: #1e293b; }
.gf-substepper-step.done .gf-substepper-dot { background: #16a34a; border-color: #15803d; }
.gf-substepper-step.done .gf-substepper-label { color: #166534; }
.gf-substepper-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  right: -2px;
  width: calc(100% - 24px);
  height: 2px;
  background: #cbd5e1;
  z-index: -1;
}
.gf-substepper-step.done:not(:last-child)::after { background: #86efac; }

/* ─── Upstream context (collapsed reference) ─── */
.gf-upstream {
  margin: 0.4rem 0 0.65rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}
.gf-upstream > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
}
.gf-upstream > summary::-webkit-details-marker { display: none; }
.gf-upstream > summary::before {
  content: "▸";
  color: #94a3b8;
  font-size: 0.7rem;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
  display: inline-block;
}
.gf-upstream[open] > summary::before { transform: rotate(90deg); }
.gf-upstream-row {
  padding: 0.35rem 0.85rem 0.5rem;
  font-size: 0.78rem;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.4rem 0.85rem;
  align-items: baseline;
  border-top: 1px dashed #e2e8f0;
}
.gf-upstream-row strong { color: #475569; font-weight: 600; }
.gf-upstream-row code {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: #0f172a;
  word-break: break-word;
}
.gf-upstream-row em {
  grid-column: 2;
  font-style: normal;
  color: #64748b;
  font-size: 0.74rem;
  line-height: 1.45;
}

/* ─── Active section card ─── */
.gf-logic-section {
  background: #ffffff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 0.85rem 1rem 0.75rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}
.gf-logic-section-head { margin-bottom: 0.5rem; }
.gf-logic-section-head h5 {
  margin: 0;
  font-size: 0.95rem;
  color: #0f172a;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.gf-logic-section-num {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}
.gf-logic-section-hint {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: #64748b;
}
.gf-logic-section-hint i { color: #6366f1; margin-right: 0.3rem; }

.gf-logic-section-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.4rem;
}
.gf-logic-textarea-wide {
  width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important;
  font-size: 0.92rem;
  padding: 0.55rem 0.7rem;
  resize: vertical;
  min-height: 2.4rem;
  line-height: 1.45;
}

.gf-logic-translation {
  margin: 0.45rem 0 0.65rem;
  padding: 0.5rem 0.65rem;
  background: #f0fdf4;
  border-left: 3px solid #16a34a;
  border-radius: 4px;
}
.gf-logic-translation-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #166534;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}
.gf-logic-translation-text {
  font-size: 0.85rem;
  color: #14532d;
  line-height: 1.45;
  word-break: break-word;
}

/* ─── Step legend chips ─── */
.gf-step-legend {
  margin: 0.55rem 0 0.65rem;
  padding: 0.5rem 0.6rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.gf-step-legend-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.4rem;
}
.gf-step-legend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.gf-step-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  cursor: pointer;
  font-size: 0.74rem;
  color: #334155;
  transition: border-color 0.12s ease, background 0.12s ease;
  max-width: 280px;
}
.gf-step-chip:hover { border-color: #6366f1; background: #eef2ff; color: #1e293b; }
.gf-step-chip-letter {
  display: inline-flex;
  width: 18px; height: 18px;
  align-items: center;
  justify-content: center;
  background: #4f46e5;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.7rem;
  border-radius: 50%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  flex-shrink: 0;
}
.gf-step-chip-desc {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

/* ─── Inline per-card drop zones (Option B) ─── */
.ai-card-dropzone {
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  background: #f8fafc;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-size: 0.78rem;
}
.ai-card-dropzone:hover { border-color: #6366f1; background: #eef2ff; }
.ai-card-dropzone.drag-active { border-color: #6366f1; background: #e0e7ff; }
.ai-card-dropzone i {
  font-size: 1.1rem;
  color: #6366f1;
  flex-shrink: 0;
}
.ai-card-dropzone span {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  line-height: 1.25;
  min-width: 0;
}
.ai-card-dropzone strong {
  color: #0f172a;
  font-weight: 600;
  font-size: 0.8rem;
}
.ai-card-dropzone em {
  font-style: normal;
  color: #64748b;
  font-size: 0.72rem;
}
.ai-card-dropzone.busy { opacity: 0.6; pointer-events: none; }
.ai-card-dropzone.has-file {
  border-style: solid;
  border-color: #16a34a;
  background: #f0fdf4;
}
.ai-card-dropzone.has-file i { color: #16a34a; }
.ai-card-dropzone.has-error {
  border-color: #dc2626;
  background: #fef2f2;
}
.ai-card-dropzone.has-error i { color: #dc2626; }

/* Inline result panel inside Build card (replaces the modal) */
.ai-card-result {
  display: none;
}
.ai-card-result.visible {
  display: block;
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.8rem;
}
.ai-card-result h5 {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: #0f172a;
}
.ai-card-result .ai-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}
.ai-card-result label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.74rem;
}
.ai-card-result label > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #475569;
  font-weight: 600;
}
.ai-card-result input.text-input {
  font-size: 0.78rem;
  padding: 0.32rem 0.5rem;
}
.ai-card-result .ai-result-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* ─── Compact "All attached files" footer ─── */
.ai-files-summary {
  margin-top: 0.95rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafbfc;
}
.ai-files-summary > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  color: #0f172a;
  font-weight: 600;
  user-select: none;
}
.ai-files-summary > summary::-webkit-details-marker { display: none; }
.ai-files-summary > summary::before {
  content: "▸";
  margin-right: 0.4rem;
  color: #94a3b8;
  font-size: 0.7rem;
  transition: transform 0.15s ease;
  display: inline-block;
}
.ai-files-summary[open] > summary::before { transform: rotate(90deg); }
.ai-files-summary-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 400;
}
.ai-files-summary-actions {
  padding: 0.4rem 0.85rem;
  border-top: 1px dashed #e2e8f0;
}
.ai-files-summary-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 0.5rem;
}
.ai-files-summary-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  font-size: 0.78rem;
}
.ai-files-summary-list li:hover { background: #f8fafc; }
.ai-files-summary-list li .file-icon { color: #94a3b8; }
.ai-files-summary-list li .file-name { font-weight: 500; color: #0f172a; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-files-summary-list li .file-meta { color: #64748b; font-size: 0.72rem; white-space: nowrap; }
.ai-files-summary-list li .file-cat {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}
.ai-files-summary-list li .file-cat.source { background: #dbeafe; color: #1e40af; }
.ai-files-summary-list li .file-cat.working_enrichment { background: #dcfce7; color: #166534; }
.ai-files-summary-list li .file-cat.working_reference { background: #fef3c7; color: #92400e; }
.ai-files-summary-list li button {
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}
.ai-files-summary-list li button:hover { color: #0f172a; background: #e2e8f0; }
.ai-files-summary-list li button.delete:hover { color: #dc2626; }
.ai-files-summary-list .ai-file-empty {
  color: #94a3b8;
  font-style: italic;
  font-size: 0.78rem;
  padding: 0.4rem 0.55rem;
  justify-content: flex-start;
}

.ai-resume-banner {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ai-resume-banner .ai-resume-actions {
  display: flex;
  gap: 0.4rem;
}

.ai-stale-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.08rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  vertical-align: middle;
}

.ai-files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.ai-files-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: #fafafa;
}
.ai-files-card h4 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ai-files-card .ai-files-pill {
  background: #e0f2fe;
  color: #075985;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.ai-files-card .ai-files-pill.warn { background: #fef3c7; color: #92400e; }
.ai-files-card .ai-files-pill.ok { background: #dcfce7; color: #166534; }
.ai-files-hint { color: #64748b; font-size: 0.78rem; margin: 0 0 0.5rem; }

.ai-upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-upload-zone.drag-active { border-color: #3b82f6; background: #eff6ff; }

.ai-file-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.ai-file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.85rem;
}
.ai-file-row .ai-file-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-file-row .ai-file-size { color: #64748b; font-size: 0.75rem; }
.ai-file-row .ai-file-pill { font-size: 0.65rem; padding: 1px 6px; border-radius: 4px; font-weight: 500; }
.ai-file-row .ai-file-pill.ok { background: #dcfce7; color: #166534; }
.ai-file-row .ai-file-pill.warn { background: #fef3c7; color: #92400e; }
.ai-file-empty { color: #94a3b8; font-style: italic; padding: 0.4rem 0.5rem; font-size: 0.8rem; }
.ai-file-download-btn,
.ai-file-delete-btn {
  background: transparent;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
  color: #475569;
}
.ai-file-delete-btn:hover { color: #dc2626; border-color: #fca5a5; }

/* AI workflow modals (diff review, enrichment review, greenfield wizard,
   multi-strata) take 85% of the viewport per Marvin's UI feedback —
   gives reasoning lists, diff tables, and tool-call audits real estate
   to breathe. The default narrow modal stays 600px capped for things
   like Login / Confirm. */
.modal-content.wide {
  max-width: 85vw;
  width: 85vw;
  max-height: 85vh;
  margin: 7.5vh auto;
  padding: 1.4rem 1.6rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-content.wide > h3 {
  text-align: left;
  margin: 0 0 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 1.1rem;
}
.modal-content.wide .modal-content-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.diff-summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.95rem;
  font-size: 0.82rem;
}
.diff-summary-bar > span {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: center;
  text-align: center;
  color: #64748b;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.diff-summary-bar > span > strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  text-transform: none;
  letter-spacing: 0;
}
.diff-prefetch-box {
  background: #f0f9ff; border-left: 4px solid #0ea5e9;
  padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; border-radius: 4px; font-size: 0.85rem;
}
.diff-prefetch-box.warn { background: #fef3c7; border-left-color: #f59e0b; }
.diff-flag-item { margin-top: 0.25rem; font-size: 0.8rem; font-family: monospace; }
.diff-flag-item.retired { color: #b45309; }
.diff-flag-item.unrecognized { color: #b91c1c; }

.diff-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.55rem;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.diff-item:hover { border-color: #cbd5e1; }
.diff-item.warn  { background: #fffbeb; border-color: #fbbf24; }
.diff-accept {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.86rem;
  color: #0f172a;
  font-weight: 500;
}
.diff-accept input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}
.diff-accept > strong { font-weight: 600; }
.diff-confidence {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.diff-confidence.high   { background: #dcfce7; color: #166534; }
.diff-confidence.medium { background: #fef3c7; color: #92400e; }
.diff-confidence.low    { background: #fee2e2; color: #b91c1c; }

.diff-codes {
  margin: 0.5rem 0 0.25rem;
  padding: 0.4rem 0.55rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: #475569;
  word-break: break-all;
  line-height: 1.55;
}
.diff-code-add    { background: #dcfce7; color: #166534; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.78rem; }
.diff-code-remove { background: #fee2e2; color: #b91c1c; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.78rem; }

.diff-note { color: #64748b; font-size: 0.78rem; margin-top: 0.25rem; }

.diff-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  margin-top: 1rem; padding-top: 0.5rem; border-top: 1px solid #e5e7eb;
}

.enrichment-reasoning {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  margin-bottom: 0.95rem;
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.5;
}
.enrichment-reasoning > strong {
  display: block;
  font-size: 0.78rem;
  color: #4338ca;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
}
.enrichment-reasoning .diff-reasoning-bullets {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}
.enrichment-reasoning .diff-reasoning-bullets li {
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0.18rem 0;
}
.enrichment-reasoning .diff-reasoning-bullets li::marker { color: #6366f1; }
.enrichment-reasoning .diff-reasoning-prose { margin: 0; }

/* Section headers in the enrichment modal — keeps them visually distinct
   from the rest of the modal and aligned with the diff modal's section
   header styling. */
.modal-content.wide .modal-content-body > h4 {
  margin: 1.2rem 0 0.55rem;
  padding-bottom: 0.4rem;
  font-size: 0.92rem;
  color: #0f172a;
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.enrichment-tool-call {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f8fafc;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.enrichment-tool-call > code {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  flex: 1 1 auto;
  word-break: break-all;
}
.enrichment-tool-call .tc-duration {
  color: #64748b;
  font-size: 0.72rem;
  font-family: inherit;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
}
.enrichment-tool-call .tc-error {
  color: #b91c1c;
  font-weight: 700;
  font-size: 0.72rem;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
}
.enrichment-tool-call > details {
  flex: 1 0 100%;
  margin-top: 0.35rem;
}
.enrichment-tool-call > details > summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: #4f46e5;
  padding: 0.2rem 0;
}
.enrichment-tool-call pre {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 0.55rem;
  margin: 0.4rem 0 0;
  border-radius: 6px;
  max-height: 260px;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.45;
}

/* Launch modals — small, focused, used by Update + Enhance card buttons.
   Drop zone styling reused from .ai-card-dropzone (defined far below);
   the .ai-launch-* classes here are only for the surrounding chrome. */
.ai-launch-intro {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.5;
}
.ai-modal-dropzone {
  margin-bottom: 0.95rem;
}
.ai-launch-existing {
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.ai-launch-existing > h5 {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.ai-launch-files-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.ai-launch-files-list li {
  font-size: 0.82rem;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ai-launch-files-list li i { color: #94a3b8; width: 0.85rem; text-align: center; }
.ai-launch-files-warn { color: #b45309; }
.ai-launch-empty {
  margin: 0;
  font-size: 0.82rem;
  color: #94a3b8;
  font-style: italic;
}
.ai-launch-multi {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  color: #334155;
}
.ai-launch-actions {
  justify-content: flex-end;
  margin-top: 0.4rem;
}

#aiEnhanceBtn.active { background: #7c3aed; color: #fff; border-color: #6d28d9; }

/* Carry-forward modal (PR 2 — skip-by-default + replace opt-in) */
.carry-forward-preview {
  font-size: 0.88rem;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.85rem;
}
.carry-forward-replace-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.82rem;
  line-height: 1.35;
  cursor: pointer;
}
.carry-forward-replace-row input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}
.carry-forward-second-warn {
  font-size: 0.82rem;
  color: #92400e;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.65rem;
}
#carryForwardConfirmBtn.carry-forward-replace-phase {
  border-color: #d97706;
  color: #9a3412;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}
#carryForwardConfirmBtn.carry-forward-replace-phase:hover {
  border-color: #b45309;
  color: #7c2d12;
}
#carryForwardConfirmBtn.carry-forward-confirm-phase2 {
  border-color: #dc2626;
  color: #991b1b;
  background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%);
}
#carryForwardConfirmBtn.carry-forward-confirm-phase2:hover {
  border-color: #b91c1c;
  color: #7f1d1d;
}
