:root {
      --primary: #2563eb;
      --primary-hover: #1d4ed8;
      --primary-light: #eff6ff;
      --danger: #ef4444;
      --success: #10b981;
      --warning: #f59e0b;
      --bg: #f8fafc;
      --card: #ffffff;
      --border: #e2e8f0;
      --border-strong: #cbd5e1;
      --text: #0f172a;
      --text-secondary: #475569;
      --text-muted: #94a3b8;
      --radius: 8px;
      --radius-lg: 12px;
      --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
      --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(0,0,0,0.06);
      --sidebar-bg: #0f172a;
      --sidebar-width: 256px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    html, body { height: 100%; }

    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background: #f1f5f9;
      color: var(--text);
      line-height: 1.5;
      display: flex;
      flex-direction: column;
      font-size: 14px;
    }
 
    /* ── Header ── */
    .site-header {
      background: #ffffff;
      position: sticky;
      top: 0;
      z-index: 200;
      flex-shrink: 0;
      border-bottom: 1px solid #e5e7eb;
      box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    /* Brand row */
    .header-brand-row {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.7rem 1.5rem;
      border-bottom: 1px solid #f3f4f6;
    }
    .site-logo {
      width: 36px; height: 36px;
      background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      color: #fff;
    }
    .header-brand-info h1 {
      font-size: 0.925rem;
      font-weight: 700;
      color: #111827;
      letter-spacing: -0.2px;
    }
    .header-brand-info .subtitle {
      font-size: 0.7rem;
      color: #9ca3af;
      margin-top: 1px;
    }

    /* Top navigation */
    .top-nav {
      display: flex;
      align-items: stretch;
      padding: 0 1.25rem;
      gap: 0;
      overflow-x: auto;
      scrollbar-width: none;
    }
    .top-nav::-webkit-scrollbar { display: none; }

    /* Tab buttons */
    .tab-btn {
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      padding: 0 0.7rem;
      height: 44px;
      background: transparent;
      border: none;
      border-bottom: 2px solid transparent;
      color: #6b7280;
      font-size: 0.815rem;
      font-weight: 500;
      cursor: pointer;
      white-space: nowrap;
      transition: color 0.15s, border-color 0.15s, background 0.15s;
      font-family: inherit;
      letter-spacing: 0.01em;
      flex-shrink: 0;
    }
    .tab-btn svg {
      flex-shrink: 0;
      opacity: 0.7;
      transition: opacity 0.15s;
    }
    .tab-btn:hover {
      color: #111827;
      background: #f9fafb;
    }
    .tab-btn:hover svg { opacity: 1; }
    .tab-btn.active {
      color: #2563eb;
      border-bottom-color: #2563eb;
      font-weight: 600;
    }
    .tab-btn.active svg { opacity: 1; color: #2563eb; }

    /* Content area */
    .content-area {
      flex: 1;
      overflow-y: auto;
      background: #f9fafb;
    }

    main { max-width: 1080px; margin: 0 auto; padding: 2rem 2rem 3rem; }

    .card {
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: var(--radius-lg);
      padding: 1.5rem;
      margin-bottom: 1.25rem;
      box-shadow: var(--shadow-sm);
      transition: box-shadow 0.2s;
    }
    .card:hover {
      box-shadow: var(--shadow-md);
    }

    .card h2 {
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 1.1rem;
      padding-bottom: 0.75rem;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    /* Drop zone */
    .drop-zone {
      border: 2px dashed #cbd5e1;
      border-radius: var(--radius-lg);
      padding: 2.5rem 2rem;
      text-align: center;
      cursor: pointer;
      transition: border-color 0.2s, background 0.2s;
      background: #fafbfc;
    }
    .drop-zone:hover, .drop-zone.dragover {
      border-color: var(--primary);
      background: var(--primary-light);
    }
    .drop-zone p { color: var(--text-muted); margin-top: 0.4rem; font-size: 0.82rem; }
    .drop-zone .icon { font-size: 2.25rem; color: #94a3b8; }

    input[type="file"] { display: none; }

    /* Merge conflict banner */
    .merge-conflict-banner {
      background: #fef2f2;
      border: 1px solid #fca5a5;
      border-radius: var(--radius);
      padding: 1rem 1.25rem;
      margin-bottom: 1rem;
      color: #991b1b;
      font-size: 0.9rem;
      line-height: 1.6;
    }
    .merge-conflict-banner .conflict-title {
      font-weight: 600;
      font-size: 0.95rem;
      margin-bottom: 0.5rem;
      display: flex;
      align-items: center;
      gap: 0.4rem;
    }
    .merge-conflict-banner .conflict-title .conflict-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: #dc2626;
      color: #fff;
      font-size: 0.75rem;
      font-weight: 700;
      flex-shrink: 0;
    }
    .merge-conflict-banner .conflict-file {
      display: flex;
      align-items: baseline;
      gap: 0.5rem;
      padding: 0.2rem 0;
    }
    .merge-conflict-banner .conflict-file-name {
      font-weight: 600;
    }
    .merge-conflict-banner .conflict-file-key {
      font-size: 0.8rem;
      color: #b91c1c;
      background: #fee2e2;
      padding: 0.1rem 0.5rem;
      border-radius: 3px;
    }
    .merge-conflict-banner .conflict-hint {
      margin-top: 0.5rem;
      padding-top: 0.5rem;
      border-top: 1px solid #fca5a5;
      font-size: 0.85rem;
      color: #b91c1c;
    }

    /* File list */
    .file-list { list-style: none; margin-top: 1rem; }

    .file-item-wrapper {
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      margin-bottom: 0.6rem;
      font-size: 0.84rem;
      overflow: hidden;
      transition: box-shadow 0.2s;
      background: #fff;
      box-shadow: var(--shadow-sm);
    }

    .file-item-wrapper.has-error {
      border-color: #fca5a5;
      box-shadow: 0 1px 6px rgba(220, 38, 38, 0.08);
    }

    .file-item-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.6rem 0.75rem;
    }

    .file-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.6rem 0.75rem;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      margin-bottom: 0.5rem;
      font-size: 0.85rem;
    }

    /* Error detail panel */
    .file-error-detail {
      background: linear-gradient(135deg, #fef2f2 0%, #fff5f5 100%);
      border-top: 1px solid #fecaca;
      padding: 0.85rem 1rem;
      font-size: 0.8rem;
      color: #451a1a;
      line-height: 1.6;
      word-break: break-word;
    }

    .file-error-detail .err-header {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.6rem;
    }

    .file-error-detail .err-icon {
      width: 20px;
      height: 20px;
      background: #dc2626;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: white;
      font-size: 0.7rem;
      font-weight: 700;
      flex-shrink: 0;
    }

    .file-error-detail .err-title {
      font-weight: 600;
      font-size: 0.82rem;
      color: #b91c1c;
    }

    .file-error-detail .err-body {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      margin-left: 1.85rem;
    }

    .file-error-detail .err-section {
      display: flex;
      align-items: flex-start;
      gap: 0.5rem;
    }

    .file-error-detail .err-label {
      font-weight: 600;
      color: #7f1d1d;
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      min-width: 60px;
      padding-top: 0.15rem;
      flex-shrink: 0;
    }

    .file-error-detail .err-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 0.35rem;
    }

    .file-error-detail .err-chip {
      background: #fee2e2;
      color: #dc2626;
      padding: 0.15rem 0.55rem;
      border-radius: 4px;
      font-weight: 600;
      font-family: "Fira Code", "Cascadia Code", monospace;
      font-size: 0.72rem;
      border: 1px solid #fecaca;
    }

    .file-error-detail .err-chip.found {
      background: #dcfce7;
      color: #166534;
      border-color: #bbf7d0;
    }

    .file-error-detail .err-cols-toggle {
      background: none;
      border: 1px solid #e5e7eb;
      color: #6b7280;
      font-size: 0.72rem;
      cursor: pointer;
      padding: 0.2rem 0.6rem;
      border-radius: 4px;
      transition: all 0.15s;
      font-family: inherit;
    }

    .file-error-detail .err-cols-toggle:hover {
      background: #f3f4f6;
      color: #374151;
    }

    .file-error-detail .err-cols-list {
      margin-top: 0.4rem;
      padding: 0.5rem 0.65rem;
      background: #fff;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      display: flex;
      flex-wrap: wrap;
      gap: 0.3rem;
    }

    .file-error-detail .err-col-tag {
      background: #f1f5f9;
      color: #475569;
      padding: 0.12rem 0.45rem;
      border-radius: 3px;
      font-family: "Fira Code", "Cascadia Code", monospace;
      font-size: 0.68rem;
      border: 1px solid #e2e8f0;
    }

    .file-error-detail .err-hint {
      margin-top: 0.3rem;
      padding: 0.45rem 0.65rem;
      background: #fffbeb;
      border: 1px solid #fde68a;
      border-radius: 6px;
      font-size: 0.75rem;
      color: #92400e;
      display: flex;
      align-items: center;
      gap: 0.4rem;
    }

    .file-error-detail .err-hint-icon {
      font-size: 0.85rem;
      flex-shrink: 0;
    }

    .file-item .name, .file-item-row .name { font-weight: 500; flex: 1; }

    .file-item .meta, .file-item-row .meta {
      color: var(--text-muted);
      font-size: 0.75rem;
      margin: 0 0.75rem;
    }

    .badge {
      font-size: 0.7rem;
      padding: 0.15rem 0.5rem;
      border-radius: 9999px;
      font-weight: 600;
      margin-right: 0.5rem;
    }
    .badge.ok { background: #dcfce7; color: var(--success); }
    .badge.err { background: #fee2e2; color: var(--danger); }
    .badge.pending { background: #fef3c7; color: var(--warning); }

    /* ETA display */
    .eta-bar {
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: var(--radius);
      padding: 0.75rem 1rem;
      margin-top: 1rem;
      font-size: 0.85rem;
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }
    .eta-bar .eta-spinner {
      width: 14px; height: 14px;
      border: 2px solid #93c5fd;
      border-top-color: var(--primary);
      border-radius: 50%;
      animation: spin 0.6s linear infinite;
      flex-shrink: 0;
    }
    .eta-bar .eta-progress {
      flex: 1;
      height: 6px;
      background: #dbeafe;
      border-radius: 3px;
      overflow: hidden;
    }
    .eta-bar .eta-progress .eta-fill {
      height: 100%;
      background: var(--primary);
      border-radius: 3px;
      transition: width 0.3s ease;
    }
    .eta-bar .eta-text {
      color: var(--text);
      white-space: nowrap;
    }
    .eta-bar .eta-time {
      font-weight: 600;
      color: var(--primary);
    }

    .btn-remove {
      background: none; border: none; color: var(--danger);
      cursor: pointer; font-size: 1.1rem; padding: 0 0.25rem;
    }

    /* Options */
    .options-row {
      display: flex;
      gap: 1.5rem;
      flex-wrap: wrap;
      align-items: center;
      margin-bottom: 1rem;
    }

    .options-row label {
      font-size: 0.85rem;
      display: flex;
      align-items: center;
      gap: 0.35rem;
    }

    select, input[type="text"] {
      padding: 0.35rem 0.5rem;
      border: 1px solid var(--border);
      border-radius: 4px;
      font-size: 0.85rem;
    }

    /* Buttons */
    .btn {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      padding: 0.5rem 1.2rem;
      border: none;
      border-radius: var(--radius);
      font-size: 0.835rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s;
      letter-spacing: 0.01em;
    }
    .btn-primary {
      background: var(--primary);
      color: white;
      box-shadow: 0 1px 2px rgba(37,99,235,0.25), 0 2px 8px rgba(37,99,235,0.2);
    }
    .btn-primary:hover {
      background: var(--primary-hover);
      box-shadow: 0 2px 4px rgba(37,99,235,0.3), 0 4px 12px rgba(37,99,235,0.25);
      transform: translateY(-1px);
    }
    .btn-primary:disabled { background: #93c5fd; cursor: not-allowed; box-shadow: none; transform: none; }
    .btn-secondary {
      background: #fff;
      color: var(--text-secondary);
      border: 1px solid var(--border);
      box-shadow: var(--shadow-sm);
    }
    .btn-secondary:hover { background: #f8fafc; border-color: var(--border-strong); color: var(--text); }
    .btn-danger { background: var(--danger); color: white; }
    .btn-danger:hover { background: #dc2626; }

    .actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

    /* Results */
    .results-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 1rem;
      margin-bottom: 1rem;
    }

    .stat-card {
      background: #fff;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 1rem;
      text-align: center;
      box-shadow: var(--shadow-sm);
    }
    .stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); line-height: 1; }
    .stat-card .label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.35rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

    /* Coverage bar */
    .coverage-bar-container { margin-bottom: 0.5rem; }
    .coverage-label {
      font-size: 0.8rem;
      display: flex;
      justify-content: space-between;
      margin-bottom: 0.2rem;
    }
    .coverage-bar {
      height: 8px;
      background: #e2e8f0;
      border-radius: 4px;
      overflow: hidden;
    }
    .coverage-bar .fill {
      height: 100%;
      background: var(--primary);
      border-radius: 4px;
      transition: width 0.4s ease;
    }

    /* Log */
    .log-box {
      background: #1e293b;
      color: #e2e8f0;
      border-radius: var(--radius);
      padding: 1rem;
      font-family: "Fira Code", "Cascadia Code", monospace;
      font-size: 0.78rem;
      max-height: 200px;
      overflow-y: auto;
      line-height: 1.7;
    }
    .log-box .log-ok { color: #4ade80; }
    .log-box .log-skip { color: #fbbf24; }
    .log-box .log-dedup { color: #818cf8; }
    .log-box .log-done { color: #38bdf8; }

    /* AI section */
    .ai-summary {
      background: #fffbeb;
      border: 1px solid #fde68a;
      border-radius: var(--radius);
      padding: 1rem;
      font-size: 0.85rem;
      white-space: pre-wrap;
    }

    /* Spinner */
    .spinner {
      display: inline-block;
      width: 16px; height: 16px;
      border: 2px solid rgba(255,255,255,0.3);
      border-top-color: white;
      border-radius: 50%;
      animation: spin 0.6s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .hidden { display: none !important; }

    /* (sidebar rules removed — layout is now top-nav) */

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

    /* ── Summary Query Builder styles ── */
    #tab-sqb {
      font-family: "Syne", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }
    #tab-sqb .sq-mono {
      font-family: "DM Mono", "Fira Code", "Cascadia Code", monospace;
    }

    /* sq-header removed — now part of unified site-header */

    /* Steps bar */
    .sq-steps {
      display: flex;
      gap: 0.5rem;
      flex-wrap: wrap;
      background: #f0f4ff;
      border: 1px solid #dbeafe;
      border-radius: 10px;
      padding: 1rem 1.25rem;
      margin-bottom: 1.5rem;
    }
    .sq-step {
      display: flex;
      align-items: flex-start;
      gap: 0.5rem;
      flex: 1;
      min-width: 180px;
      font-size: 0.8rem;
      color: #334155;
      line-height: 1.4;
    }
    .sq-step-num {
      width: 22px; height: 22px;
      border-radius: 50%;
      background: #3b82f6;
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.7rem;
      font-weight: 700;
      flex-shrink: 0;
    }
    .sq-step strong { color: #1e293b; }

    /* Join key info box */
    .sq-joinkey {
      background: #1e293b;
      border-radius: 10px;
      padding: 1rem 1.25rem;
      margin-bottom: 1.5rem;
      color: #cbd5e1;
      font-size: 0.8rem;
      line-height: 1.6;
    }
    .sq-joinkey-label {
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: #64748b;
      margin-bottom: 0.4rem;
      font-weight: 600;
    }
    .sq-joinkey code {
      background: #334155;
      color: #93c5fd;
      padding: 0.15rem 0.4rem;
      border-radius: 4px;
      font-family: "DM Mono", "Fira Code", monospace;
      font-size: 0.78rem;
    }
    .sq-joinkey .sq-joinkey-note {
      margin-top: 0.5rem;
      font-size: 0.75rem;
      color: #94a3b8;
    }

    /* Output info chips */
    .sq-output-info {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-bottom: 1.5rem;
    }
    .sq-output-chip {
      font-size: 0.75rem;
      padding: 0.3rem 0.7rem;
      border-radius: 999px;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 0.3rem;
    }
    .sq-output-chip.blue { background: #dbeafe; color: #1e40af; }
    .sq-output-chip.purple { background: #ede9fe; color: #5b21b6; }
    .sq-output-chip.amber { background: #fef3c7; color: #92400e; }
    .sq-output-chip.red { background: #fee2e2; color: #991b1b; }

    /* Upload cards */
    .sq-upload-grid {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      margin-bottom: 1.5rem;
    }
    .sq-upload-card {
      border: 2px dashed #e2e8f0;
      border-radius: 10px;
      padding: 1rem 1.25rem;
      display: flex;
      align-items: center;
      gap: 1rem;
      cursor: pointer;
      transition: all 0.2s;
      background: #fff;
      position: relative;
    }
    .sq-upload-card:hover {
      border-color: #93c5fd;
      background: #f8faff;
    }
    .sq-upload-card.dragover {
      border-color: #3b82f6;
      background: #eff6ff;
    }
    .sq-upload-card.uploaded {
      border-style: solid;
      border-color: #86efac;
      background: #f0fdf4;
    }
    .sq-upload-card.uploaded:hover {
      background: #dcfce7;
    }
    .sq-upload-card.has-error {
      border-style: solid;
      border-color: #fca5a5;
      background: #fef2f2;
    }

    .sq-upload-icon {
      width: 42px; height: 42px;
      border-radius: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.2rem;
      flex-shrink: 0;
    }
    .sq-upload-icon.account { background: #dbeafe; color: #2563eb; }
    .sq-upload-icon.serv_agree { background: #ede9fe; color: #7c3aed; }
    .sq-upload-icon.agent { background: #fef3c7; color: #d97706; }
    .sq-upload-icon.ldc_xref { background: #d1fae5; color: #059669; }
    .sq-upload-icon.market_detail { background: #fce7f3; color: #db2777; }

    .sq-upload-info { flex: 1; min-width: 0; }
    .sq-upload-title {
      font-size: 0.9rem;
      font-weight: 600;
      color: #1e293b;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
    }
    .sq-upload-desc {
      font-size: 0.78rem;
      color: #64748b;
      margin-top: 0.15rem;
    }
    .sq-upload-file-info {
      font-size: 0.75rem;
      color: #16a34a;
      margin-top: 0.25rem;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 0.3rem;
    }

    .sq-badge-req {
      font-size: 0.65rem;
      padding: 0.12rem 0.45rem;
      border-radius: 999px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .sq-badge-req.required { background: #fee2e2; color: #dc2626; }
    .sq-badge-req.optional { background: #f1f5f9; color: #64748b; }

    .sq-badge-base {
      font-size: 0.6rem;
      padding: 0.12rem 0.45rem;
      border-radius: 999px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      background: #dbeafe;
      color: #1d4ed8;
    }

    .sq-badge-ext {
      font-size: 0.68rem;
      padding: 0.1rem 0.4rem;
      border-radius: 4px;
      font-weight: 600;
      font-family: "DM Mono", "Fira Code", monospace;
      background: #f1f5f9;
      color: #475569;
      border: 1px solid #e2e8f0;
    }

    .sq-upload-action {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-shrink: 0;
    }
    .sq-upload-action .sq-drop-text {
      font-size: 0.8rem;
      color: #94a3b8;
      font-weight: 500;
    }
    .sq-upload-card.uploaded .sq-drop-text { display: none; }
    .sq-upload-card .sq-file-remove {
      display: none;
      background: none;
      border: none;
      color: #ef4444;
      cursor: pointer;
      font-size: 1.1rem;
      padding: 0.2rem;
    }
    .sq-upload-card.uploaded .sq-file-remove { display: inline-flex; }
    .sq-upload-card input[type="file"] { display: none; }

    /* Build section */
    .sq-build-section {
      display: flex;
      align-items: center;
      gap: 1rem;
      flex-wrap: wrap;
      margin-bottom: 1.5rem;
    }
    .sq-btn-build {
      padding: 0.7rem 2rem;
      background: linear-gradient(135deg, #3b82f6, #2563eb);
      color: #fff;
      border: none;
      border-radius: 10px;
      font-size: 0.9rem;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.2s;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      font-family: inherit;
    }
    .sq-btn-build:hover { background: linear-gradient(135deg, #2563eb, #1d4ed8); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
    .sq-btn-build:disabled { background: #94a3b8; cursor: not-allowed; box-shadow: none; }
    .sq-btn-build .spinner {
      width: 14px; height: 14px;
      border: 2px solid rgba(255,255,255,0.3);
      border-top-color: #fff;
      border-radius: 50%;
      animation: spin 0.6s linear infinite;
    }
    .sq-btn-preview {
      padding: 0.7rem 1.5rem;
      background: #f1f5f9;
      color: #334155;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s;
      font-family: inherit;
    }
    .sq-btn-preview:hover { background: #e2e8f0; }
    .sq-btn-preview:disabled { color: #94a3b8; cursor: not-allowed; }
    .sq-build-hint {
      font-size: 0.78rem;
      color: #94a3b8;
      font-style: italic;
    }

    /* Error banner */
    .sq-error-banner {
      display: flex;
      align-items: center;
      gap: 1rem;
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-left: 5px solid #dc2626;
      border-radius: 10px;
      padding: 1rem 1.5rem;
      margin-bottom: 1.5rem;
      box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
      animation: slideDown 0.3s ease-out;
    }
    .sq-error-banner.hidden { display: none; }
    .sq-error-icon {
      width: 40px;
      height: 40px;
      background: #fee2e2;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.2rem;
      color: #dc2626;
      flex-shrink: 0;
    }
    .sq-error-content {
      flex: 1;
      min-width: 0;
    }
    .sq-error-content strong {
      display: block;
      color: #991b1b;
      font-size: 0.9rem;
      font-weight: 700;
      margin-bottom: 0.2rem;
    }
    .sq-error-content p {
      color: #b91c1c;
      font-size: 0.82rem;
      line-height: 1.5;
      margin: 0;
      word-break: break-word;
    }
    .sq-error-close {
      background: #fee2e2;
      border: none;
      color: #dc2626;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      font-size: 1.1rem;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0.7;
      transition: all 0.15s;
      flex-shrink: 0;
    }
    .sq-error-close:hover { opacity: 1; background: #fecaca; }
    @keyframes slideDown {
      from { opacity: 0; transform: translateY(-10px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* Table preview */
    .table-wrapper {
      overflow-x: auto;
      margin-top: 1rem;
      max-height: 350px;
      overflow-y: auto;
      border: 1px solid var(--border);
      border-radius: var(--radius);
    }
    .table-wrapper table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.78rem;
    }
    .table-wrapper th, .table-wrapper td {
      padding: 0.4rem 0.6rem;
      border-bottom: 1px solid var(--border);
      text-align: left;
      white-space: nowrap;
    }
    .table-wrapper th {
      background: #f1f5f9;
      position: sticky;
      top: 0;
      font-weight: 600;
    }
    .table-wrapper tr:hover td { background: #f8fafc; }

    /* ── Account Lookup tab ── */
    #tab-acct .al-req {
      font-size: 0.65rem;
      padding: 0.12rem 0.45rem;
      border-radius: 999px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      background: #fee2e2;
      color: #dc2626;
      margin-left: 0.4rem;
      vertical-align: middle;
    }
    #tab-acct .al-hint {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin-bottom: 0.75rem;
      line-height: 1.6;
    }
    #tab-acct .al-hint code {
      background: #f1f5f9;
      color: #1e40af;
      padding: 0.1rem 0.4rem;
      border-radius: 4px;
      font-family: "DM Mono", "Fira Code", "Cascadia Code", monospace;
      font-size: 0.75rem;
      margin: 0 0.1rem;
    }
    #tab-acct .al-input-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1.25rem;
    }
    @media (max-width: 760px) {
      #tab-acct .al-input-grid { grid-template-columns: 1fr; }
    }
    #tab-acct .al-sub-label {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 0.5rem;
    }
    #tab-acct .al-drop-small {
      padding: 1.5rem 1rem;
    }
    #tab-acct .al-drop-small .icon {
      font-size: 1.8rem;
    }
    #tab-acct .al-textarea {
      width: 100%;
      min-height: 160px;
      padding: 0.6rem 0.75rem;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      font-family: "DM Mono", "Fira Code", "Cascadia Code", monospace;
      font-size: 0.82rem;
      resize: vertical;
      line-height: 1.5;
    }
    #tab-acct .al-textarea:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    }
    #tab-acct .al-file-info {
      margin-top: 0.6rem;
      padding: 0.55rem 0.75rem;
      background: #f0fdf4;
      border: 1px solid #bbf7d0;
      border-radius: var(--radius);
      font-size: 0.82rem;
      color: #166534;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    #tab-acct .al-file-check { color: #16a34a; font-weight: 700; }
    #tab-acct .al-file-name { font-weight: 600; }
    #tab-acct .al-file-size { color: var(--text-muted); font-size: 0.75rem; }
    #tab-acct .al-file-remove {
      margin-left: auto;
      background: none;
      border: none;
      color: #dc2626;
      cursor: pointer;
      font-size: 1rem;
      padding: 0 0.25rem;
    }
    #tab-acct .al-error {
      margin-top: 1rem;
      padding: 0.75rem 1rem;
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-left: 4px solid #dc2626;
      border-radius: var(--radius);
      color: #991b1b;
      font-size: 0.85rem;
    }
    #tab-acct .al-legend {
      display: flex;
      gap: 1rem;
      flex-wrap: wrap;
      margin: 0.5rem 0 0.75rem;
      font-size: 0.78rem;
      color: var(--text-muted);
    }
    #tab-acct .al-legend-item {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
    }
    #tab-acct .al-swatch {
      display: inline-block;
      width: 14px;
      height: 14px;
      border-radius: 3px;
      border: 1px solid rgba(0,0,0,0.1);
    }
    #tab-acct .al-swatch-match { background: #ffffff; }
    #tab-acct .al-swatch-dup { background: #fff59d; }
    #tab-acct .al-swatch-nf { background: #fca5a5; }

    #tab-acct .table-wrapper tr.al-row-dup td { background: #fff59d; }
    #tab-acct .table-wrapper tr.al-row-dup:hover td { background: #fde68a; }
    #tab-acct .table-wrapper tr.al-row-nf td { background: #fca5a5; }
    #tab-acct .table-wrapper tr.al-row-nf:hover td { background: #f87171; }

    #tab-acct .btn-secondary:disabled {
      background: #f1f5f9;
      color: #94a3b8;
      cursor: not-allowed;
      opacity: 0.7;
    }

    /* Sub-tab switcher inside tab 3 (Account Lookup / Contract Date Check) */
    #tab-acct .sub-tab-bar {
      display: inline-flex;
      gap: 0.25rem;
      padding: 0.3rem;
      background: #f1f5f9;
      border: 1px solid var(--border);
      border-radius: 999px;
      margin-bottom: 1.25rem;
    }
    #tab-acct .sub-tab-btn {
      background: transparent;
      border: none;
      padding: 0.45rem 1.1rem;
      font-size: 0.82rem;
      font-weight: 600;
      color: #64748b;
      cursor: pointer;
      border-radius: 999px;
      transition: all 0.15s ease;
      font-family: inherit;
    }
    #tab-acct .sub-tab-btn:hover {
      color: #1e293b;
      background: #e2e8f0;
    }
    #tab-acct .sub-tab-btn.active {
      background: #524eec;
    color: #ffffff;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }
    #tab-acct .sub-tab-panel {
      display: none;
    }
    #tab-acct .sub-tab-panel.active {
      display: block;
    }

    /* ── ESG Change Confirmation tab (re-uses .al-* styles) ── */
    #tab-esg .al-req {
      font-size: 0.65rem;
      padding: 0.12rem 0.45rem;
      border-radius: 999px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      background: #fee2e2;
      color: #dc2626;
      margin-left: 0.4rem;
      vertical-align: middle;
    }
    #tab-esg .al-hint {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin-bottom: 0.75rem;
      line-height: 1.6;
    }
    #tab-esg .al-hint code {
      background: #f1f5f9;
      color: #1e40af;
      padding: 0.1rem 0.4rem;
      border-radius: 4px;
      font-family: "DM Mono", "Fira Code", "Cascadia Code", monospace;
      font-size: 0.75rem;
      margin: 0 0.1rem;
    }
    #tab-esg .al-file-info {
      margin-top: 0.6rem;
      padding: 0.55rem 0.75rem;
      background: #f0fdf4;
      border: 1px solid #bbf7d0;
      border-radius: var(--radius);
      font-size: 0.82rem;
      color: #166534;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    #tab-esg .al-file-check { color: #16a34a; font-weight: 700; }
    #tab-esg .al-file-name { font-weight: 600; }
    #tab-esg .al-file-size { color: var(--text-muted); font-size: 0.75rem; }
    #tab-esg .al-file-remove {
      margin-left: auto;
      background: none;
      border: none;
      color: #dc2626;
      cursor: pointer;
      font-size: 1rem;
      padding: 0 0.25rem;
    }
    #tab-esg .al-error {
      margin-top: 1rem;
      padding: 0.75rem 1rem;
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-left: 4px solid #dc2626;
      border-radius: var(--radius);
      color: #991b1b;
      font-size: 0.85rem;
    }

    /* ── Tax Rate Confirmation tab ── */
    #tab-trc .al-req {
      font-size: 0.65rem;
      padding: 0.12rem 0.45rem;
      border-radius: 999px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      background: #fee2e2;
      color: #dc2626;
      margin-left: 0.4rem;
      vertical-align: middle;
    }
    #tab-trc .al-hint {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin-bottom: 0.75rem;
      line-height: 1.6;
    }
    #tab-trc .al-hint code {
      background: #f1f5f9;
      color: #1e40af;
      padding: 0.1rem 0.4rem;
      border-radius: 4px;
      font-family: "DM Mono", "Fira Code", "Cascadia Code", monospace;
      font-size: 0.75rem;
      margin: 0 0.1rem;
    }
    #tab-trc .al-input-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1.25rem;
    }
    @media (max-width: 760px) {
      #tab-trc .al-input-grid { grid-template-columns: 1fr; }
    }
    #tab-trc .al-sub-label {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 0.5rem;
    }
    #tab-trc .al-drop-small {
      padding: 1.5rem 1rem;
    }
    #tab-trc .al-drop-small .icon {
      font-size: 1.8rem;
    }
    #tab-trc .al-textarea {
      width: 100%;
      min-height: 160px;
      padding: 0.6rem 0.75rem;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      font-family: "DM Mono", "Fira Code", "Cascadia Code", monospace;
      font-size: 0.82rem;
      resize: vertical;
      line-height: 1.5;
    }
    #tab-trc .al-textarea:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    }
    #tab-trc .al-file-info {
      margin-top: 0.6rem;
      padding: 0.55rem 0.75rem;
      background: #f0fdf4;
      border: 1px solid #bbf7d0;
      border-radius: var(--radius);
      font-size: 0.82rem;
      color: #166534;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    #tab-trc .al-file-check { color: #16a34a; font-weight: 700; }
    #tab-trc .al-file-name { font-weight: 600; }
    #tab-trc .al-file-size { color: var(--text-muted); font-size: 0.75rem; }
    #tab-trc .al-file-remove {
      margin-left: auto;
      background: none;
      border: none;
      color: #dc2626;
      cursor: pointer;
      font-size: 1rem;
      padding: 0 0.25rem;
    }
    #tab-trc .al-error {
      margin-top: 1rem;
      padding: 0.75rem 1rem;
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-left: 4px solid #dc2626;
      border-radius: var(--radius);
      color: #991b1b;
      font-size: 0.85rem;
    }
    #tab-trc .al-legend {
      display: flex;
      gap: 1rem;
      flex-wrap: wrap;
      font-size: 0.78rem;
      color: var(--text-muted);
    }
    #tab-trc .al-legend-item {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
    }
    #tab-trc .al-swatch {
      display: inline-block;
      width: 14px;
      height: 14px;
      border-radius: 3px;
      border: 1px solid rgba(0,0,0,0.1);
    }
    #tab-trc .al-swatch-match { background: #ffffff; }
    #tab-trc .al-swatch-nf   { background: #fca5a5; }
    #tab-trc .table-wrapper tr.al-row-nf td { background: #fca5a5; }
    #tab-trc .table-wrapper tr.al-row-nf:hover td { background: #f87171; }
    #tab-trc .btn-secondary:disabled {
      background: #f1f5f9;
      color: #94a3b8;
      cursor: not-allowed;
      opacity: 0.7;
    }
    /* Status badge inside results table */
    .trc-status {
      display: inline-block;
      padding: 0.15rem 0.55rem;
      border-radius: 999px;
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.02em;
    }
    .trc-status-match { background: #dcfce7; color: #166534; }
    .trc-status-nf    { background: #fee2e2; color: #991b1b; }

    /* ── ESG Token Tools tab ── */
    #tab-ett .sub-tab-bar {
      display: inline-flex;
      gap: 0.25rem;
      padding: 0.3rem;
      background: #f1f5f9;
      border: 1px solid var(--border);
      border-radius: 999px;
      margin-bottom: 1.25rem;
    }
    #tab-ett .sub-tab-btn {
      background: transparent;
      border: none;
      padding: 0.45rem 1.1rem;
      font-size: 0.82rem;
      font-weight: 600;
      color: #64748b;
      cursor: pointer;
      border-radius: 999px;
      transition: all 0.15s ease;
      font-family: inherit;
    }
    #tab-ett .sub-tab-btn:hover {
      color: #1e293b;
      background: #e2e8f0;
    }
    #tab-ett .sub-tab-btn.active {
      background: #524eec;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }
    #tab-ett .sub-tab-panel { display: none; }
    #tab-ett .sub-tab-panel.active { display: block; }

    #tab-ett .ett-req {
      font-size: 0.65rem;
      padding: 0.12rem 0.45rem;
      border-radius: 999px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      background: #fee2e2;
      color: #dc2626;
      margin-left: 0.4rem;
      vertical-align: middle;
    }
    #tab-ett .ett-hint {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin-bottom: 0.75rem;
      line-height: 1.6;
    }
    #tab-ett .ett-hint code {
      background: #f1f5f9;
      color: #1e40af;
      padding: 0.1rem 0.4rem;
      border-radius: 4px;
      font-family: "DM Mono", "Fira Code", monospace;
      font-size: 0.75rem;
      margin: 0 0.1rem;
    }
    #tab-ett .ett-file-info {
      margin-top: 0.6rem;
      padding: 0.55rem 0.75rem;
      background: #f0fdf4;
      border: 1px solid #bbf7d0;
      border-radius: var(--radius);
      font-size: 0.82rem;
      color: #166534;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    #tab-ett .ett-file-check { color: #16a34a; font-weight: 700; }
    #tab-ett .ett-file-name  { font-weight: 600; }
    #tab-ett .ett-file-size  { color: var(--text-muted); font-size: 0.75rem; }
    #tab-ett .ett-file-remove {
      margin-left: auto;
      background: none;
      border: none;
      color: #dc2626;
      cursor: pointer;
      font-size: 1rem;
      padding: 0 0.25rem;
    }
    #tab-ett .ett-error {
      margin-top: 1rem;
      padding: 0.75rem 1rem;
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-left: 4px solid #dc2626;
      border-radius: var(--radius);
      color: #991b1b;
      font-size: 0.85rem;
    }
    #tab-ett .ett-service-row {
      display: flex;
      gap: 1.5rem;
      margin-bottom: 0.5rem;
      font-size: 0.9rem;
      font-weight: 600;
    }
    #tab-ett .ett-service-row label {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      cursor: pointer;
    }
    #tab-ett .ett-input-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1.25rem;
      margin-top: 1rem;
    }
    @media (max-width: 760px) {
      #tab-ett .ett-input-grid { grid-template-columns: 1fr; }
    }
    #tab-ett .ett-sub-label {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 0.5rem;
    }
    #tab-ett .ett-drop-small { padding: 1.5rem 1rem; }
    #tab-ett .ett-drop-small .icon { font-size: 1.8rem; }
    #tab-ett .ett-textarea {
      width: 100%;
      min-height: 160px;
      padding: 0.6rem 0.75rem;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      font-family: "DM Mono", "Fira Code", monospace;
      font-size: 0.82rem;
      resize: vertical;
      line-height: 1.5;
    }
    #tab-ett .ett-textarea:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
    }
    #tab-ett .ett-col-picker {
      margin-top: 0.6rem;
      font-size: 0.8rem;
      color: var(--text-muted);
      display: flex;
      align-items: center;
      gap: 0.3rem;
    }
    #tab-ett .ett-col-picker select {
      border: 1px solid var(--border);
      border-radius: 4px;
      padding: 0.2rem 0.5rem;
      font-size: 0.8rem;
      font-family: inherit;
      background: #fff;
    }
    #tab-ett .ett-legend {
      display: flex;
      gap: 1rem;
      flex-wrap: wrap;
      margin: 0.5rem 0 0.5rem;
      font-size: 0.78rem;
      color: var(--text-muted);
    }
    #tab-ett .ett-legend-item {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
    }
    #tab-ett .ett-swatch {
      display: inline-block;
      width: 14px;
      height: 14px;
      border-radius: 3px;
      border: 1px solid rgba(0,0,0,0.1);
    }
    #tab-ett .ett-swatch-clean  { background: #ffffff; }
    #tab-ett .ett-swatch-warn   { background: #fff59d; }
    #tab-ett .ett-swatch-nf     { background: #fca5a5; }
    #tab-ett .ett-swatch-exempt { background: #bbf7d0; }
    #tab-ett .ett-swatch-blank  { background: #f1f5f9; }

    #tab-ett .ett-copy-bar {
      margin: 0.5rem 0 0.75rem;
    }

    /* Result table row colors */
    #tab-ett .table-wrapper tr.ett-row-warn td    { background: #fff59d; }
    #tab-ett .table-wrapper tr.ett-row-warn:hover td { background: #fde68a; }
    #tab-ett .table-wrapper tr.ett-row-nf td      { background: #fca5a5; }
    #tab-ett .table-wrapper tr.ett-row-nf:hover td   { background: #f87171; }
    #tab-ett .table-wrapper tr.ett-row-exempt td  { background: #f0fdf4; }
    #tab-ett .table-wrapper tr.ett-row-exempt:hover td { background: #dcfce7; }
    #tab-ett .table-wrapper tr.ett-row-blank td   {
      background: #f8fafc;
      color: transparent;
      padding: 0.25rem 0.75rem;
    }
    #tab-ett .ett-blank-ph {
      color: #cbd5e1;
      font-style: italic;
      font-size: 0.75rem;
    }

    /* Small grey badge for multi-match / combined row indicators */
    #tab-ett .ett-badge {
      display: inline-block;
      background: #e2e8f0;
      color: #64748b;
      font-size: 0.7rem;
      padding: 0.1rem 0.4rem;
      border-radius: 999px;
      margin-left: 0.3rem;
      font-weight: 500;
      vertical-align: middle;
    }

    #tab-ett .btn-secondary:disabled {
      background: #f1f5f9;
      color: #94a3b8;
      cursor: not-allowed;
      opacity: 0.7;
    }

/* ── ESG SA Mapping tab ─────────────────────────────────────────────────────── */

#tab-sam .sam-file-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }
#tab-sam .sam-file-zone { border: 2px dashed var(--border); border-radius: var(--radius-md, 8px); padding: 1.1rem 0.75rem; display: flex; flex-direction: column; align-items: center; gap: 0.45rem; text-align: center; cursor: pointer; transition: border-color .18s, background .18s; user-select: none; }
#tab-sam .sam-file-zone:hover { border-color: var(--primary, #2563eb); background: #eff6ff; }
#tab-sam .sam-file-zone.loaded { border-color: #16a34a; background: #f0fdf4; border-style: solid; }
#tab-sam .sam-file-icon { font-size: 1.75rem; line-height: 1; }
#tab-sam .sam-file-label { font-weight: 600; font-size: 0.85rem; color: var(--text, #1e293b); }
#tab-sam .sam-file-status { font-size: 0.73rem; color: var(--text-muted, #64748b); word-break: break-all; max-width: 160px; }
#tab-sam .sam-svc-row { display: flex; gap: 2rem; margin-bottom: 1rem; align-items: center; }
#tab-sam .sam-svc-row label { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; font-size: 1rem; cursor: pointer; }
#tab-sam .sam-acct-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.45rem; flex-wrap: wrap; }
#tab-sam .sam-acct-label { font-weight: 600; font-size: 0.88rem; color: var(--text, #1e293b); }
#tab-sam .sam-hint { color: var(--text-muted, #64748b); font-size: 0.8rem; font-weight: 400; }
#tab-sam .sam-textarea { width: 100%; min-height: 130px; font-family: 'DM Mono', monospace; font-size: 0.82rem; border: 1px solid var(--border, #e2e8f0); border-radius: var(--radius-md, 8px); padding: 0.6rem 0.75rem; resize: vertical; box-sizing: border-box; line-height: 1.5; }
#tab-sam .sam-status { color: var(--text-muted, #64748b); font-size: 0.85rem; margin-left: 0.5rem; }
#tab-sam .sam-stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 0.85rem; }
#tab-sam .sam-stat-card { background: #fff; border: 1px solid var(--border, #e2e8f0); border-radius: var(--radius-md, 8px); padding: 1rem 0.75rem; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
#tab-sam .sam-stat-num { font-size: 1.65rem; font-weight: 700; color: var(--primary, #2563eb); line-height: 1.1; }
#tab-sam .sam-stat-lbl { font-size: 0.76rem; color: var(--text-muted, #64748b); margin-top: 0.25rem; }
#tab-sam .sam-banner { padding: 0.65rem 1rem; border-radius: var(--radius-md, 8px); font-size: 0.875rem; margin-bottom: 0.85rem; display: none; }
#tab-sam .sam-banner.sam-banner-ok   { display: block; background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
#tab-sam .sam-banner.sam-banner-warn { display: block; background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
#tab-sam .sam-banner.sam-banner-info { display: block; background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
#tab-sam .sam-export-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
#tab-sam .sam-table-wrap { overflow-x: auto; border: 1px solid var(--border, #e2e8f0); border-radius: var(--radius-md, 8px); max-height: 420px; overflow-y: auto; }
#tab-sam .sam-table { border-collapse: collapse; font-size: 0.77rem; min-width: 100%; white-space: nowrap; }
#tab-sam .sam-table th { background: #f1f5f9; border: 1px solid var(--border, #e2e8f0); padding: 0.4rem 0.65rem; font-weight: 600; position: sticky; top: 0; z-index: 1; font-size: 0.75rem; }
#tab-sam .sam-table td { border: 1px solid #e9ecef; padding: 0.32rem 0.65rem; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
#tab-sam .sam-row-ok      { background: #fff; }
#tab-sam .sam-row-nf      { background: #fef2f2; }
#tab-sam .sam-row-flagged { background: #fffbeb; outline: 2px solid #f59e0b; outline-offset: -2px; }
#tab-sam .sam-row-blank   { background: #f8fafc; }
#tab-sam .sam-cell-hard   { color: #2563eb; font-style: italic; }
#tab-sam .sam-preview-note { font-size: 0.82rem; color: #1e293b; font-weight: 500; background: #f1f5f9; border-left: 3px solid #2563eb; border-radius: 4px; padding: 0.5rem 0.75rem; margin-bottom: 0.85rem; }
#tab-sam .sam-acct-file-info { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius-md, 8px); padding: 0.45rem 0.75rem; margin-bottom: 0.45rem; font-size: 0.82rem; }
#tab-sam .sam-acct-file-info .sam-fn { font-weight: 600; color: #166534; word-break: break-all; }
#tab-sam .sam-acct-file-info label { display: flex; align-items: center; gap: 0.4rem; color: var(--text, #1e293b); font-weight: 500; white-space: nowrap; }
#tab-sam .sam-acct-file-info select { font-size: 0.82rem; border: 1px solid var(--border, #e2e8f0); border-radius: 6px; padding: 0.2rem 0.5rem; background: #fff; cursor: pointer; max-width: 260px; }
#tab-sam .sam-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: var(--radius-md, 8px); padding: 0.65rem 1rem; font-size: 0.875rem; margin-top: 0.5rem; line-height: 1.5; }
#sam-toast { position: fixed; bottom: 1.75rem; right: 1.75rem; background: #1e293b; color: #f8fafc; padding: 0.65rem 1.1rem; border-radius: 8px; font-size: 0.84rem; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 2000; max-width: 340px; }
#sam-toast.sam-toast-visible { opacity: 1; }

@media (max-width: 640px) {
  #tab-sam .sam-stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Prospect / Renewal Mapper  (#tab-prm)
   ═══════════════════════════════════════════════════════════════════════════ */

#tab-prm .prm-hint {
  font-size: 0.82rem; color: var(--text-secondary, #475569); margin-bottom: 0.75rem;
}

/* ── Mode toggle ── */
#tab-prm .prm-mode-toggle { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
#tab-prm .prm-mode-btn {
  padding: 0.45rem 1.25rem; border-radius: 20px; border: 2px solid var(--border, #e2e8f0);
  background: #fff; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  color: var(--text-secondary, #475569); transition: all .15s;
}
#tab-prm .prm-mode-btn:hover { border-color: #93c5fd; color: #1d4ed8; }
#tab-prm .prm-mode-btn.prm-mode-active {
  background: #eff6ff; border-color: #2563eb; color: #1d4ed8; font-weight: 600;
}
#tab-prm .prm-mode-desc {
  font-size: 0.8rem; color: var(--text-secondary, #475569);
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 0.5rem 0.75rem; line-height: 1.5;
}

/* ── Drop zone ── */
#tab-prm .prm-dz {
  border: 2px dashed #cbd5e1; border-radius: 10px; background: #f8fafc;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 2rem 1rem; cursor: pointer; transition: all .15s;
  text-align: center;
}
#tab-prm .prm-dz:hover, #tab-prm .prm-dz.prm-dz-over {
  border-color: #2563eb; background: #eff6ff;
}
#tab-prm .prm-dz-icon { color: #94a3b8; }
#tab-prm .prm-dz:hover .prm-dz-icon, #tab-prm .prm-dz.prm-dz-over .prm-dz-icon { color: #2563eb; }
#tab-prm .prm-dz-text { font-size: 0.85rem; color: #64748b; }
#tab-prm .prm-dz-label { font-size: 0.78rem; color: #94a3b8; font-style: italic; }

#tab-prm .prm-dz.prm-dz-sm { padding: 1rem 0.75rem; gap: 0.25rem; }
#tab-prm .prm-dz.prm-dz-sm .prm-dz-text { font-size: 0.78rem; }

#tab-prm .prm-dz-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 0.5rem;
}
#tab-prm .prm-dz-group-label {
  font-size: 0.8rem; font-weight: 600; color: var(--text, #0f172a);
  margin-bottom: 0.35rem; display: flex; flex-direction: column; gap: 0.1rem;
}
#tab-prm .prm-col-hint { font-weight: 400; color: #94a3b8; font-size: 0.73rem; font-style: italic; }

/* ── Banners ── */
#tab-prm .prm-banner {
  padding: 0.65rem 1rem; border-radius: 8px; font-size: 0.82rem; line-height: 1.6;
  margin-bottom: 0.75rem;
}
#tab-prm .prm-banner-danger { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
#tab-prm .prm-banner-warn   { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
#tab-prm .prm-banner-info   { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── Stat cards ── */
#tab-prm .prm-stat-cards {
  display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem;
}
#tab-prm .prm-stat {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 0.6rem 1rem; min-width: 90px; text-align: center;
}
#tab-prm .prm-stat.prm-stat-ok     { background: #f0fdf4; border-color: #86efac; }
#tab-prm .prm-stat.prm-stat-blue   { background: #eff6ff; border-color: #93c5fd; }
#tab-prm .prm-stat.prm-stat-warn   { background: #fffbeb; border-color: #fde68a; }
#tab-prm .prm-stat.prm-stat-danger { background: #fef2f2; border-color: #fecaca; }
#tab-prm .prm-stat.prm-stat-muted  { background: #f1f5f9; border-color: #cbd5e1; }
#tab-prm .prm-sv { font-size: 1.35rem; font-weight: 700; color: #0f172a; line-height: 1.1; }
#tab-prm .prm-sl { font-size: 0.7rem; color: #64748b; margin-top: 0.15rem; }

/* ── Panels ── */
#tab-prm .prm-panel {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 0.85rem 1rem; margin-bottom: 0.75rem;
}
#tab-prm .prm-panel.prm-panel-blue { background: #eff6ff; border-color: #bfdbfe; }
#tab-prm .prm-panel.prm-panel-warn { background: #fffbeb; border-color: #fde68a; }
#tab-prm .prm-panel-hdr {
  font-size: 0.85rem; font-weight: 600; color: #0f172a; margin-bottom: 0.5rem;
}

/* ── Auto-populated list ── */
#tab-prm .prm-auto-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
#tab-prm .prm-auto-list li { font-size: 0.82rem; color: #1e40af; }
#tab-prm .prm-auto-col { font-weight: 600; font-style: italic; }

/* ── Mapped / skipped columns grid ── */
#tab-prm .prm-col-grid {
  display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.25rem;
}
#tab-prm .prm-col-item {
  font-size: 0.75rem; background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 4px; padding: 0.15rem 0.5rem; color: #166534;
  display: flex; align-items: center; gap: 0.25rem;
}
#tab-prm .prm-col-item.prm-col-skip {
  background: #fffbeb; border-color: #fde68a; color: #92400e;
}
#tab-prm .prm-col-src  { color: #475569; }
#tab-prm .prm-col-tgt  { color: #166534; font-weight: 600; }
#tab-prm .prm-override-note { font-size: 0.7rem; color: #1d4ed8; font-style: italic; }

/* ── Preview table ── */
#tab-prm .prm-tbl-wrap {
  overflow-x: auto; max-height: 320px; overflow-y: auto;
  border: 1px solid #e2e8f0; border-radius: 6px; margin-top: 0.5rem;
}
#tab-prm .prm-tbl {
  border-collapse: collapse; font-size: 0.75rem; white-space: nowrap;
  min-width: 100%;
}
#tab-prm .prm-tbl th, #tab-prm .prm-tbl td {
  padding: 0.3rem 0.6rem; border: 1px solid #e2e8f0;
}
#tab-prm .prm-tbl thead th { position: sticky; top: 0; z-index: 1; font-weight: 600; font-size: 0.72rem; }
#tab-prm .prm-th-mapped { background: #dcfce7; color: #166534; }
#tab-prm .prm-th-auto   { background: #dbeafe; color: #1e40af; font-style: italic; }
#tab-prm .prm-th-blank  { background: #f1f5f9; color: #94a3b8; }
#tab-prm .prm-th-status { background: #f8fafc; color: #475569; font-weight: 600; min-width: 90px; }
#tab-prm .prm-tbl tbody tr:hover { background: #f8fafc; }
#tab-prm .prm-row-fail    td { background: #fef2f2 !important; }
#tab-prm .prm-row-matched td { background: #fffbeb !important; }

/* ── Legend ── */
#tab-prm .prm-legend { font-size: 0.74rem; color: #64748b; margin-bottom: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
#tab-prm .prm-leg { font-size: 1rem; }
#tab-prm .prm-leg-green { color: #16a34a; }
#tab-prm .prm-leg-blue  { color: #2563eb; }
#tab-prm .prm-leg-gray  { color: #94a3b8; }

/* ── Status badges ── */
#tab-prm .prm-badge {
  display: inline-block; font-size: 0.7rem; padding: 0.1rem 0.45rem;
  border-radius: 3px; font-weight: 600; white-space: nowrap;
}
#tab-prm .prm-badge-green  { background: #dcfce7; color: #166534; }
#tab-prm .prm-badge-yellow { background: #fef3c7; color: #92400e; }
#tab-prm .prm-badge-red    { background: #fee2e2; color: #b91c1c; cursor: help; }
#tab-prm .prm-badge-renewal{ background: #ede9fe; color: #5b21b6; }

/* ── Download row ── */
#tab-prm .prm-dl-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

/* ── Button loading spinner ── */
#tab-prm .btn.prm-loading { pointer-events: none; }
#tab-prm .btn.prm-loading::before {
  content: "";
  display: block;
  flex-shrink: 0;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  animation: prm-spin 0.65s linear infinite;
}
#tab-prm .btn-secondary.prm-loading::before { border-color: rgba(100,116,139,0.3); border-top-color: #475569; }
@keyframes prm-spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  #tab-prm .prm-dz-grid { grid-template-columns: 1fr; }
  #tab-prm .prm-stat-cards { gap: 0.4rem; }
  #tab-prm .prm-stat { min-width: 70px; padding: 0.5rem 0.6rem; }
}