/* ============================================================
   AI-Tools — Modern UI Stylesheet
   ============================================================ */

:root {
  /* Colour palette */
  --bg:           #f0f2f5;
  --bg-subtle:    #f7f8fa;
  --card:         #ffffff;
  --border:       #e2e6ed;
  --border-hover: #c4cad5;
  --text:         #1a1d23;
  --text-secondary:#5f6773;
  --muted:        #8b929e;
  --primary:      #3b6ce7;
  --primary-hover:#2d55c4;
  --primary-weak: #eaf0ff;
  --primary-ring: rgba(59, 108, 231, 0.2);
  --report-color:  #0d9488;
  --report-hover:  #0f766e;
  --report-weak:   #f0fdfa;
  --report-border: #99f6e4;
  --report-ring:   rgba(13, 148, 136, 0.2);
  --ok:           #16a34a;
  --ok-bg:        #ecfdf5;
  --ok-border:    #bbf7d0;
  --warn:         #ca8a04;
  --warn-bg:      #fefce8;
  --warn-border:  #fef08a;
  --bad:          #dc2626;
  --bad-bg:       #fef2f2;
  --bad-border:   #fecaca;
  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06);
  --shadow:       0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:    0 8px 30px rgba(0,0,0,.08);
  --transition:   150ms ease;
}

/* ===== Dark mode variables ===== */
[data-theme="dark"] {
  --bg:            #0f1117;
  --bg-subtle:     #171b26;
  --card:          #1e2235;
  --border:        #2c3356;
  --border-hover:  #44507a;
  --text:          #e2e6f0;
  --text-secondary:#8b95ae;
  --muted:         #5c6480;
  --primary-weak:  rgba(59, 108, 231, 0.18);
  --primary-ring:  rgba(59, 108, 231, 0.35);
  --report-weak:   rgba(13, 148, 136, 0.15);
  --report-border: rgba(99, 246, 228, 0.18);
  --report-ring:   rgba(13, 148, 136, 0.35);
  --ok-bg:         rgba(22, 163, 74, 0.14);
  --ok-border:     rgba(187, 247, 208, 0.18);
  --warn-bg:       rgba(202, 138, 4, 0.14);
  --warn-border:   rgba(254, 240, 138, 0.18);
  --bad-bg:        rgba(220, 38, 38, 0.14);
  --bad-border:    rgba(254, 202, 202, 0.18);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.4);
  --shadow:        0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:     0 8px 30px rgba(0,0,0,.55);
}

/* Hardcoded white overrides */
[data-theme="dark"] input:hover,
[data-theme="dark"] select:hover,
[data-theme="dark"] textarea:hover { background: #252a42; }
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus { background: #252a42; }

/* Select chevron in dark mode */
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b95ae' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6 6.5-6'/%3E%3C/svg%3E");
}

/* Table header */
[data-theme="dark"] thead th { background: rgba(59,108,231,0.18); }
[data-theme="dark"] tbody tr:hover { background: rgba(255,255,255,0.04); }

/* Tabs active backgrounds */
[data-theme="dark"] #tab-r-fulltext:checked ~ .tab-nav label[for="tab-r-fulltext"] { background: rgba(99,102,241,0.18); }
[data-theme="dark"] #tab-r-rob:checked ~ .tab-nav label[for="tab-r-rob"] { background: rgba(217,119,6,0.18); }

/* Pane headers */
[data-theme="dark"] .pane-header-screening {
  background: linear-gradient(135deg, rgba(59,108,231,0.16) 0%, rgba(59,108,231,0.08) 100%);
  border-color: rgba(59,108,231,0.3);
}
[data-theme="dark"] .pane-header-report {
  background: linear-gradient(135deg, rgba(13,148,136,0.16) 0%, rgba(13,148,136,0.08) 100%);
  border-color: rgba(13,148,136,0.3);
}

/* WIP badge */
[data-theme="dark"] .wip-badge {
  background: rgba(245,158,11,0.14);
  color: #fbbf24;
  border-color: rgba(251,191,36,0.22);
}

/* Chart card images — keep white background for chart readability */
[data-theme="dark"] .chart-card img { background: #fff; }
[data-theme="dark"] .lightbox-content img { background: #fff; }

/* How-to badge */
[data-theme="dark"] .how-to-badge { border-color: rgba(59,108,231,0.3); }

/* Naming/summary backgrounds */
[data-theme="dark"] .naming-guide > summary { background: var(--bg-subtle); }
[data-theme="dark"] .naming-table th { background: rgba(59,108,231,0.18); }
[data-theme="dark"] .meta-table thead th { background: rgba(59,108,231,0.18); }
[data-theme="dark"] .meta-table tbody tr:hover { background: rgba(255,255,255,0.04); }

/* Provider btn active tint */
[data-theme="dark"] .provider-btn.active {
  background: rgba(59,108,231,0.14);
}

/* Dark mode toggle button */
.btn-dark-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-dark-toggle:hover {
  background: var(--primary-weak);
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== CSS Radio Tab System ===== */
.tab-radio { display: none; }
.tab-pane { display: none; }
#tab-r-screening:checked  ~ main #pane-screening  { display: block; }
#tab-r-fulltext:checked   ~ main #pane-fulltext   { display: block; }
#tab-r-rob:checked        ~ main #pane-rob        { display: block; }
#tab-r-report:checked     ~ main #pane-report     { display: block; }
#tab-r-validation:checked ~ main #pane-validation { display: block; }

/* Active tab — Screening TIAB (blue) */
#tab-r-screening:checked ~ .tab-nav label[for="tab-r-screening"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-weak);
}
#tab-r-screening:checked ~ .tab-nav label[for="tab-r-screening"] .tab-btn-sub {
  color: var(--primary);
  opacity: 0.75;
}

/* Active tab — Texto Completo (indigo) */
#tab-r-fulltext:checked ~ .tab-nav label[for="tab-r-fulltext"] {
  color: #6366f1;
  border-bottom-color: #6366f1;
  background: #eef2ff;
}
#tab-r-fulltext:checked ~ .tab-nav label[for="tab-r-fulltext"] .tab-btn-sub {
  color: #6366f1;
  opacity: 0.75;
}

/* Active tab — Risco de Viés (amber) */
#tab-r-rob:checked ~ .tab-nav label[for="tab-r-rob"] {
  color: #d97706;
  border-bottom-color: #d97706;
  background: #fffbeb;
}
#tab-r-rob:checked ~ .tab-nav label[for="tab-r-rob"] .tab-btn-sub {
  color: #d97706;
  opacity: 0.75;
}

/* Active tab — Report (teal) */
#tab-r-report:checked ~ .tab-nav label[for="tab-r-report"] {
  color: var(--report-color);
  border-bottom-color: var(--report-color);
  background: var(--report-weak);
}
#tab-r-report:checked ~ .tab-nav label[for="tab-r-report"] .tab-btn-sub {
  color: var(--report-color);
  opacity: 0.75;
}

/* Active tab — Validation (violet) */
#tab-r-validation:checked ~ .tab-nav label[for="tab-r-validation"] {
  color: #7c3aed;
  border-bottom-color: #7c3aed;
  background: #f5f3ff;
}
#tab-r-validation:checked ~ .tab-nav label[for="tab-r-validation"] .tab-btn-sub {
  color: #7c3aed;
  opacity: 0.75;
}
[data-theme="dark"] #tab-r-validation:checked ~ .tab-nav label[for="tab-r-validation"] {
  background: rgba(124,58,237,0.18);
}

/* ===== WIP pane ===== */
.wip-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  gap: 16px;
}
.wip-icon {
  color: var(--muted);
  opacity: 0.55;
  margin-bottom: 4px;
}
.wip-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.wip-badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  animation: wip-pulse 1.6s ease-in-out infinite;
}
@keyframes wip-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}
.wip-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.wip-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.7;
}
.wip-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  align-items: flex-start;
}
.wip-feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.wip-feature-item svg { color: var(--ok); flex-shrink: 0; }

/* ===== Top Bar ===== */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.logo {
  height: 36px;
  width: 36px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.brand h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.3px;
}
.subtitle {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.2px;
}

/* Server status badge */
.server-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.server-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.server-badge.online {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}
.server-badge.online .dot { background: var(--ok); }
.server-badge.offline {
  color: var(--muted);
  background: var(--bg-subtle);
  border-color: var(--border);
}
.server-badge.offline .dot { background: var(--muted); }

/* ===== Container ===== */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* ===== Grid ===== */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .grid-2col { grid-template-columns: 1fr; }
}

/* ===== Card ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  letter-spacing: -0.2px;
}
.card-title svg {
  color: var(--primary);
  flex-shrink: 0;
}

/* ===== Form Fields ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field:last-child { margin-bottom: 0; }
.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.field small { color: var(--muted); font-size: 12px; }

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
  width: 100%;
}
input:hover, select:hover, textarea:hover {
  border-color: var(--border-hover);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
textarea { resize: vertical; min-height: 72px; }

/* Number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* Select arrow */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235f6773' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6 6.5-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Provider selector */
.provider-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.provider-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}
.provider-btn:hover {
  border-color: var(--primary);
  background: var(--surface-1);
}
.provider-btn.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.provider-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
}
.openai-badge  { background: #10a37f; }
.claude-badge  { background: #d97706; }
.gemini-badge  { background: #4f46e5; }
.provider-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.provider-btn.active .provider-name { color: var(--primary); }
.provider-config.hidden { display: none; }

/* Parameters */
.param-group { margin-top: 8px; }
.param-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field.half { margin-bottom: 0; }

.field-warning {
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
  color: var(--bad);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 8px;
}

/* Help tooltips */
.help { display:inline-flex; align-items:center; margin-left:6px; position:relative; }
.help .icon { width:16px; height:16px; border-radius:50%; background: var(--primary-weak); color: var(--text); border:1px solid var(--border); font-size:11px; line-height:16px; text-align:center; cursor:help; }
.help .tip { display:none; position:absolute; left:50%; transform: translateX(-50%); bottom: 125%; background: var(--card); color: var(--text); border:1px solid var(--border); padding:8px 10px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); width: 260px; z-index: 50; font-weight: 400; font-size: 12px; }
.help:hover .tip, .help:focus-within .tip { display:block; }

/* ===== Criteria Lists ===== */
.criteria-section { margin-bottom: 16px; }
.criteria-section:last-child { margin-bottom: 0; }
.criteria-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.criteria-header > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.criteria-list { display: flex; flex-direction: column; gap: 8px; }
.criteria-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.criteria-row input { margin-bottom: 0; }

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}
.btn-icon:hover {
  background: var(--primary-weak);
  border-color: var(--primary);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--muted);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover {
  background: var(--bad-bg);
  border-color: var(--bad-border);
  color: var(--bad);
}

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  background: var(--bg-subtle);
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
}
.dropzone:hover, .dropzone.hover {
  border-color: var(--primary);
  background: var(--primary-weak);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone-content p {
  margin: 6px 0 0;
  color: var(--text-secondary);
}
.dropzone-content .hint {
  color: var(--muted);
  font-size: 12px;
}

.upload-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  min-height: 24px;
}
.upload-meta span {
  color: var(--text-secondary);
  font-size: 13px;
}
.output-name-wrap {
  margin-top: 8px;
}
.output-name-wrap .inline-field {
  margin-top: 4px;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.output-name-wrap .inline-field input {
  min-width: 180px;
  flex: 1;
}
.output-ext-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.inline-field select { width: auto; min-width: 180px; }

.columns-status {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}

.preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
}

/* Table */
.table-scroll { overflow-x: auto; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
thead th {
  background: var(--primary-weak);
  color: var(--text);
  font-weight: 600;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: var(--bg-subtle); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-border); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad);  border: 1px solid var(--bad-border); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 2px 8px var(--primary-ring);
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--primary-weak);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 10px 12px;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--text);
}

.btn-danger {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}
.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* ===== Actions Card ===== */
.actions-card { padding: 16px 24px; }
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.save-hint {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}

/* ===== Error Banner ===== */
.error-banner {
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
  color: var(--bad);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
}

/* ===== Payload / Code ===== */
.payload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.payload-header .card-title { margin-bottom: 0; }

code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Menlo', monospace;
  font-size: 12px;
}

.code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Menlo', monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  margin-top: 12px;
}

/* ===== Progress ===== */
.progress-track {
  position: relative;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 8px;
}
.progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #7baaf7);
  border-radius: 999px;
  transition: width 300ms ease;
}

.progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.progress-elapsed {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.1px;
}

.progress-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.log-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.log-toggle-row .muted {
  font-size: 13px;
  color: var(--muted);
}

/* ===== Footer ===== */
.footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--border);
}

/* ===== Advanced Settings (collapsible) ===== */
#advancedCard { padding: 0; }
#advancedCard details { padding: 0; }
#advancedCard details > summary {
  padding: 20px 24px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  margin-bottom: 0;
}
#advancedCard details > summary::-webkit-details-marker { display: none; }
#advancedCard details > summary::after {
  content: '▸';
  margin-left: auto;
  font-size: 14px;
  color: var(--muted);
  transition: transform var(--transition);
}
#advancedCard details[open] > summary::after { transform: rotate(90deg); }
#advancedCard details[open] > summary { border-bottom: 1px solid var(--border); }

.clickable { cursor: pointer; }

.tier-selector {
  padding: 16px 24px 0;
}
.tier-selector .field { max-width: 280px; }
.tier-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}
.tier-hint a {
  color: var(--primary);
  text-decoration: none;
}
.tier-hint a:hover { text-decoration: underline; }

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 16px 24px 24px;
}
.advanced-grid .field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

/* ===== Tab Navigation ===== */
.tab-nav {
  background: var(--card);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.tab-nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 2px;
  align-items: stretch;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  font-family: inherit;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  margin-bottom: -2px;
  text-decoration: none;
  user-select: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-btn svg { color: inherit; flex-shrink: 0; transition: color var(--transition); }
.tab-btn:hover { color: var(--text); background: var(--bg); }
.tab-btn-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.tab-btn-title { font-size: 14px; font-weight: 600; line-height: 1; }
.tab-btn-sub { font-size: 11px; color: var(--text-secondary); font-weight: 400; line-height: 1; transition: color var(--transition); }

/* ===== Pane Banner Headers ===== */
.pane-header {
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--border);
}
.pane-header-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pane-header-content { flex: 1; min-width: 0; }
.pane-header-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 5px;
  line-height: 1.2;
}
.pane-header-desc {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  color: var(--text-secondary);
}

.pane-header-screening {
  background: linear-gradient(135deg, var(--primary-weak) 0%, #dce8ff 100%);
  border-color: #c5d8ff;
}
.pane-header-screening .pane-header-icon { background: var(--primary); color: #fff; }
.pane-header-screening .pane-header-title { color: var(--primary); }

.pane-header-report {
  background: linear-gradient(135deg, var(--report-weak) 0%, #ccfbf0 100%);
  border-color: var(--report-border);
}
.pane-header-report .pane-header-icon { background: var(--report-color); color: #fff; }
.pane-header-report .pane-header-title { color: var(--report-color); }

/* ===== Workflow Step Dividers ===== */
.step-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}
.step-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.step-divider-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.step-divider-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  white-space: nowrap;
}

/* ===== Report Pane ===== */
.report-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.report-file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.report-file-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.report-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 500;
}
.report-file-size { color: var(--muted); font-size: 12px; white-space: nowrap; }

.naming-guide {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.naming-guide > summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--bg-subtle);
}
.naming-guide > summary::-webkit-details-marker { display: none; }
.naming-guide > summary::after { content: ' ▸'; font-size: 11px; color: var(--muted); }
.naming-guide[open] > summary::after { content: ' ▾'; }
.naming-guide-body { padding: 12px 14px; }
.naming-table { font-size: 12px; width: 100%; border-collapse: collapse; }
.naming-table th, .naming-table td { padding: 6px 8px; border: 1px solid var(--border); text-align: left; }
.naming-table th { background: var(--primary-weak); font-weight: 600; }

.report-log { max-height: 400px; overflow: auto; margin-top: 0; }

.report-downloads { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.downloads-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.download-links { display: flex; flex-wrap: wrap; gap: 10px; }

/* ===== How-to Guide ===== */
.how-to-card { padding: 0; }
.how-to-card details > summary {
  padding: 20px 24px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  margin-bottom: 0;
}
.how-to-card details > summary::-webkit-details-marker { display: none; }
.how-to-card details > summary::after {
  content: '▸';
  margin-left: auto;
  font-size: 14px;
  color: var(--muted);
  transition: transform var(--transition);
}
.how-to-card details[open] > summary::after { transform: rotate(90deg); }
.how-to-card details[open] > summary { border-bottom: 1px solid var(--border); }
.how-to-badge {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary);
  border: 1px solid var(--primary-ring);
}
.how-to-body { padding: 20px 24px 24px; }
.how-to-steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.how-to-step {
  counter-increment: step;
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.how-to-step:last-child { margin-bottom: 0; }
.how-to-step::before {
  content: counter(step);
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.step-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.how-to-step p { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.how-to-step ul { font-size: 13px; color: var(--text-secondary); padding-left: 20px; margin-top: 4px; }
.how-to-step li { margin-bottom: 4px; }
.meta-table { font-size: 12px; width: 100%; border-collapse: collapse; margin-top: 8px; }
.meta-table th, .meta-table td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.meta-table thead th { background: var(--primary-weak); font-weight: 600; }
.meta-table tbody tr:hover { background: var(--bg-subtle); }

/* ===== API key help (inline disclosure under each apiKey input) ===== */
.api-help {
  margin: -4px 0 12px;
  padding: 0;
  font-size: 12.5px;
}
.api-help > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-weight: 500;
  padding: 4px 0;
}
.api-help > summary::-webkit-details-marker { display: none; }
.api-help > summary:hover { text-decoration: underline; }
.api-help-arrow {
  display: inline-block;
  font-size: 11px;
  transition: transform var(--transition);
}
.api-help[open] > summary .api-help-arrow { transform: rotate(90deg); }
.api-help-steps {
  list-style: decimal;
  padding-left: 22px;
  margin: 8px 0 6px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.api-help-steps li { margin-bottom: 4px; }
.api-help-steps code {
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}
.api-help-steps a { color: var(--primary); text-decoration: underline; }
.api-help-note {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Validation pane ===== */
.pane-header-validation {
  background: linear-gradient(135deg, #ede9fe 0%, #f5f3ff 100%);
  border-color: rgba(124, 58, 237, 0.25);
}
.pane-header-validation .pane-header-icon {
  background: #7c3aed;
  color: #fff;
}
[data-theme="dark"] .pane-header-validation {
  background: linear-gradient(135deg, rgba(124,58,237,0.18) 0%, rgba(124,58,237,0.08) 100%);
  border-color: rgba(124, 58, 237, 0.35);
}

.validation-providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 20px 0 24px;
}
.validation-provider-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 16px;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.validation-provider-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.validation-provider-card .provider-badge {
  display: inline-block;
  margin-bottom: 10px;
}
.validation-provider-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.validation-provider-card p {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.validation-link-card {
  text-align: center;
  padding: 48px 24px;
}
.validation-link-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #f5f3ff;
  color: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
[data-theme="dark"] .validation-link-icon {
  background: rgba(124, 58, 237, 0.18);
}
.validation-link-title {
  font-size: 22px;
  font-weight: 700;
  margin: 12px 0 8px;
  color: var(--text);
}
.validation-link-desc {
  max-width: 520px;
  margin: 0 auto 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.btn.disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: auto;
}
.btn.disabled:hover,
.btn[aria-disabled="true"]:hover {
  transform: none;
}
.validation-link-note {
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ===== Full-text pane ===== */
.pane-header-fulltext {
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border-color: rgba(99, 102, 241, 0.25);
}
.pane-header-fulltext .pane-header-icon {
  background: #6366f1;
  color: #fff;
}
[data-theme="dark"] .pane-header-fulltext {
  background: linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(99,102,241,0.08) 100%);
  border-color: rgba(99, 102, 241, 0.35);
}
.beta-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
  vertical-align: middle;
}
[data-theme="dark"] .beta-tag {
  background: rgba(124,58,237,0.18);
  color: #c4b5fd;
  border-color: rgba(124,58,237,0.35);
}

.ft-prompt-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.ft-file-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ft-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.ft-file-item .ft-file-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ft-file-item .ft-file-size {
  color: var(--muted);
  font-size: 12px;
}
.ft-file-item .ft-file-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}
.ft-file-item .ft-file-remove:hover {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

/* ===== Prompt preview modal ===== */
.ft-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ft-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.ft-modal-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(720px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.ft-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.ft-modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.ft-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 6px;
}
.ft-modal-close:hover { color: var(--text); }
.ft-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.ft-modal-note {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-left: 3px solid #6366f1;
  border-radius: 4px;
}
.ft-prompt-text {
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.55;
  max-height: 60vh;
  overflow-y: auto;
}
.ft-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ===== Results Sections (Charts + Tables stacked) ===== */
.results-section {
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}
.results-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.results-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.results-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.results-count {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  background: var(--primary-weak);
  color: var(--primary);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

/* ===== Charts Gallery ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.chart-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-subtle);
}
.chart-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.chart-card img {
  width: 100%;
  display: block;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #fff;
  padding: 8px;
}
.chart-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
}
.chart-label {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.chart-info-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  padding: 0;
  line-height: 1;
}
.chart-info-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chart-global-tip {
  position: fixed;
  z-index: 9999;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  width: 280px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  pointer-events: none;
  white-space: normal;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox.hidden { display: none !important; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
}
.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: min(90vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
  object-fit: contain;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.lightbox-caption {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all var(--transition);
  z-index: 2;
}
.lightbox-close:hover { background: var(--bad-bg); color: var(--bad); }

/* ===== Sheet table viewer ===== */
.sheet-selector-bar { margin-bottom: 16px; }
.sheet-table-wrap {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.sheet-table-wrap table { font-size: 12px; }
.sheet-table-wrap th { font-size: 11px; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .topbar-inner { padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .container { padding: 16px 14px 48px; }
  .card { padding: 18px; }
  .param-row { grid-template-columns: 1fr; }
  .action-row { flex-direction: column; align-items: stretch; }
  .save-hint { margin-left: 0; text-align: center; }
}
