/* ============================================================
   DatasetForge — style.css
   Tema pulito e minimale. 8px grid. CSS variables.
============================================================ */

:root {
  /* Colors */
  --bg: #fafafa;
  --text: #1a1a1a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --success-hover: #15803d;
  --warning: #d97706;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --muted: #6b7280;
  --muted-light: #7d8590; /* UX-07: contrasto portato a ~4.5:1 (WCAG AA) */
  --surface: #ffffff;
  --surface-hover: #f3f4f6;
  --surface-sunken: #f9fafb;

  /* Lang pill colors */
  --lang-it: #16a34a;
  --lang-en: #2563eb;
  --lang-es: #ca8a04;
  --lang-fr: #7c3aed;

  /* Typography */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.85rem;
  --fs-base: 0.95rem;
  --fs-lg: 1.1rem;
  --fs-xl: 1.35rem;

  /* Spacing (8px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* Radius */
  --radius: 6px;
  --radius-sm: 4px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.18);

  /* Transitions */
  --t-fast: 120ms ease;
  --t-base: 180ms ease;
}

/* UX-01: focus-visible globale per accessibilità tastiera (WCAG 2.4.7) */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   RESET
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ============================================================
   HEADER
============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-left { flex-shrink: 0; min-width: 140px; }
.app-title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
.app-subtitle { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

.header-center { flex: 1; max-width: 560px; }
.search-bar {
  width: 100%;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  font-size: var(--fs-base);
  transition: border-color var(--t-base), background var(--t-base), box-shadow var(--t-base);
}
.search-bar:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.header-right { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

/* ============================================================
   BUTTONS
============================================================ */
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  position: relative;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.icon-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.icon-btn.primary:hover { background: var(--primary-hover); }
.icon-btn .btn-label { font-weight: 500; }

.theme-icon {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: inset -3px -2px 0 2px var(--bg);
}
[data-theme="dark"] .theme-icon {
  background: var(--warning);
  box-shadow: inset -4px -3px 0 2px var(--bg), inset 2px 1px 0 0 var(--bg);
}

.stat-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.stat-dot.screen { background: #2563eb; }
.stat-dot.dialog { background: #7c3aed; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.btn {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.success { background: var(--success); color: #fff; border-color: var(--success); }
.btn.success:hover { background: var(--success-hover); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--fs-sm);
  text-decoration: underline;
  padding: var(--sp-1) var(--sp-2);
}
.link-btn:hover { color: var(--text); }

.page-btn {
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
}
.page-btn:hover:not(:disabled) { background: var(--surface-hover); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-current { font-size: var(--fs-sm); color: var(--muted); min-width: 40px; text-align: center; }

.close-btn {
  background: none;
  border: none;
  font-size: var(--fs-lg);
  color: var(--muted);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  line-height: 1;
}
.close-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ============================================================
   FILTERS BAR
============================================================ */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filter { display: flex; flex-direction: column; gap: var(--sp-1); }
.filter-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.filter select, .filter input[type="text"] {
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
  min-width: 90px;
}
.filter select:focus, .filter input:focus { outline: none; border-color: var(--primary); }
.toggle-filter { flex-direction: row; align-items: center; gap: var(--sp-2); padding-bottom: var(--sp-2); }
.toggle-filter input { width: 16px; height: 16px; cursor: pointer; }

/* ============================================================
   TABLE
============================================================ */
#main-content { padding: var(--sp-3) var(--sp-4); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table thead th {
  text-align: left;
  padding: var(--sp-2);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table tbody td {
  padding: var(--sp-1) var(--sp-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--t-fast); cursor: pointer; }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.empty-row td { text-align: center; color: var(--muted); padding: var(--sp-6); cursor: default; }
.empty-row:hover { background: transparent; }

.col-id { width: 60px; text-align: right; }
.col-lang, .col-diff, .col-flags, .col-len { width: 70px; text-align: center; }
.col-q-score { width: 44px; text-align: center; }
.col-source { width: 100px; }
.col-q, .col-a { max-width: 280px; }

.cell-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Lang pill */
.lang-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
}
.lang-pill.it { background: var(--lang-it); }
.lang-pill.en { background: var(--lang-en); }
.lang-pill.es { background: var(--lang-es); }
.lang-pill.fr { background: var(--lang-fr); }
.lang-pill.unk { background: var(--muted-light); }

/* Short-answer badge */
.badge-short {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(217, 119, 6, 0.12);
  color: var(--warning);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Flag indicator in table */
.flag-indicator {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--danger);
  font-weight: 700;
  font-size: var(--fs-sm);
}
.flag-indicator {}

/* ============================================================
   PAGINATION
============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) 0;
}
.pagination-info { font-size: var(--fs-sm); color: var(--muted); }
.pagination-controls { display: flex; align-items: center; gap: var(--sp-2); }

/* ============================================================
   MODALS
============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-6) var(--sp-4);
  background: rgba(0, 0, 0, 0.4);
  overflow-y: auto;
  animation: fadeIn var(--t-fast);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  margin: auto;
  animation: slideUp var(--t-base);
}
.modal-lg { max-width: 700px; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: var(--fs-lg); font-weight: 700; }
.flag-detail-head { display: flex; flex-direction: column; gap: var(--sp-2); }

.modal-body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); max-height: 65vh; overflow-y: auto; }

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
}
.modal-footer .btn { flex: 0 0 auto; }
.modal-footer .btn.ghost { margin-left: auto; }

/* ============================================================
   FORM FIELDS
============================================================ */
.field { display: flex; flex-direction: column; gap: var(--sp-1); }
.field-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.textarea, .field textarea, .field input[type="text"] {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  font-family: var(--font);
}
.field textarea { resize: vertical; }
.field textarea:focus, .field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.field select {
  width: 100%;
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.readonly-area { background: var(--surface-sunken); color: var(--muted); resize: none; }

.char-count { font-size: var(--fs-xs); color: var(--muted-light); text-align: right; }
.char-count.warn { color: var(--warning); }

.inline-fields { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.inline-fields .field { flex: 1 1 120px; }

.read-box {
  padding: var(--sp-3);
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   TAG CHIPS
============================================================ */
.tag-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); min-height: 32px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.tag-chip button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1;
  padding: 0;
}
.tag-chip button:hover { color: var(--danger); }
.tag-input-row { margin-top: var(--sp-2); }

/* ============================================================
   BADGES ROW (flag detail)
============================================================ */
.badges-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.status-badge, .type-badge, .priority-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
}
.status-badge.open { background: rgba(37, 99, 235, 0.12); color: var(--primary); }
.status-badge.answered { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.status-badge.in_review { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.status-badge.resolved { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.status-badge.rejected { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.type-badge { background: rgba(107, 114, 128, 0.12); color: var(--muted); }
.priority-badge.P0 { background: var(--danger); color: #fff; }
.priority-badge.P1 { background: var(--warning); color: #fff; }
.priority-badge.P2 { background: var(--border-strong); color: var(--text); }
.priority-badge.P3 { background: var(--surface-hover); color: var(--muted); }

/* ============================================================
   FLAG THREAD
============================================================ */
.entry-ids-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.entry-id-link {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  color: var(--primary);
}
.entry-id-link:hover { background: var(--primary); color: #fff; }

.thread { display: flex; flex-direction: column; gap: var(--sp-3); }
.thread-msg { padding: var(--sp-3); background: var(--surface-sunken); border-radius: var(--radius-sm); }
.thread-msg-head { display: flex; gap: var(--sp-2); align-items: baseline; margin-bottom: var(--sp-2); font-size: var(--fs-xs); }
.thread-msg-author { font-weight: 700; color: var(--text); }
.thread-msg-time { color: var(--muted-light); }
.thread-msg-body { font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; }
.proposed-fix-box {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: rgba(22, 163, 74, 0.08);
  border-left: 3px solid var(--success);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  word-break: break-word;
}
.proposed-fix-label { font-size: var(--fs-xs); font-weight: 700; color: var(--success); margin-bottom: var(--sp-1); }

/* ============================================================
   FLAG PANEL (inside editor)
============================================================ */
.flag-panel { padding: var(--sp-3); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.flag-panel-title { font-size: var(--fs-sm); font-weight: 700; margin-bottom: var(--sp-3); color: var(--text); }

/* ============================================================
   FLAGS VIEW
============================================================ */
.flags-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.section-title { font-size: var(--fs-lg); font-weight: 700; }
.flags-filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.flags-filters select {
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.flags-toolbar .btn.primary { margin-left: auto; }

/* ============================================================
   STATS
============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); }
.stat-card { padding: var(--sp-4); background: var(--surface-sunken); border-radius: var(--radius); }
.stat-card-label { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.stat-card-value { font-size: var(--fs-xl); font-weight: 700; margin-top: var(--sp-1); }
.stat-section-title { font-size: var(--fs-base); font-weight: 700; margin-top: var(--sp-4); margin-bottom: var(--sp-2); }
.bar-row { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-1); font-size: var(--fs-sm); }
.bar-label { width: 90px; flex-shrink: 0; }
.bar-track { flex: 1; height: 18px; background: var(--surface-hover); border-radius: var(--radius-pill); overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: var(--radius-pill); transition: width 0.2s ease; }
.bar-value { width: 50px; flex-shrink: 0; text-align: right; color: var(--muted); }

/* ============================================================
   VALIDATE
============================================================ */
.validate-summary { font-size: var(--fs-lg); margin-bottom: var(--sp-3); }
.validate-summary .ok { color: var(--success); font-weight: 700; }
.validate-summary .err { color: var(--danger); font-weight: 700; }
.validate-error {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  transition: background var(--t-fast);
}
.validate-error:hover { background: var(--surface-hover); }
.validate-error-line { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; }
.validate-error-msgs { font-size: var(--fs-sm); color: var(--text); }
.progress-bar { width: 100%; height: 6px; background: var(--surface-hover); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: var(--sp-3); }
.progress-fill { height: 100%; background: var(--primary); transition: width 0.3s ease; }

/* ============================================================
   TOAST
============================================================ */
.toast-container {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 360px;
}
.toast {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  border-left: 4px solid var(--muted);
  animation: toastIn var(--t-base);
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ============================================================
   FLAG SYSTEM V2 — TYPE BADGES
============================================================ */
/* Colori: correction=ambra, question=blu, gap=verde, duplicate=viola,
   contradiction=rosso, quality=azzurro, language=indaco, safety=rosso scuro, note=grigio */
.type-badge.correction { background: rgba(217, 119, 6, 0.15); color: #b45309; }
.type-badge.question   { background: rgba(37, 99, 235, 0.12); color: var(--primary); }
.type-badge.gap        { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.type-badge.duplicate  { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.type-badge.contradiction { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.type-badge.quality    { background: rgba(6, 182, 212, 0.12); color: #0891b2; }
.type-badge.language   { background: rgba(79, 70, 229, 0.12); color: #4f46e5; }
.type-badge.safety     { background: rgba(127, 29, 29, 0.18); color: #991b1b; }
.type-badge.note       { background: rgba(107, 114, 128, 0.12); color: var(--muted); }

/* Type icon wrapper for table */
.type-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* ============================================================
   FLAG SYSTEM V2 — RESPONSE TYPE-SPECIFIC BOXES
============================================================ */
.flag-response-form { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-2); }
.flag-response-form .field { gap: var(--sp-1); }

/* knowledge box (blu) */
.knowledge-box {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: rgba(37, 99, 235, 0.06);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  word-break: break-word;
}
.knowledge-box-label { font-size: var(--fs-xs); font-weight: 700; color: var(--primary); margin-bottom: var(--sp-1); }

/* suggested entries list (gap type) */
.suggested-entries-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-2); }
.suggested-entry-card {
  padding: var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.suggested-entry-card .se-q { font-weight: 600; margin-bottom: var(--sp-1); }
.suggested-entry-card .se-a { color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.suggested-entry-card .se-lang {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-right: var(--sp-2);
  color: var(--muted);
}
.suggested-entry-card .se-add-btn {
  margin-top: var(--sp-2);
  padding: 2px 10px;
  font-size: var(--fs-xs);
  border: 1px solid var(--success);
  color: var(--success);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.suggested-entry-card .se-add-btn:hover { background: var(--success); color: #fff; }

/* keep_id / correct_id highlight */
.entry-highlight {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  background: rgba(22, 163, 74, 0.12);
  color: var(--success);
  border: 1px solid var(--success);
}
.entry-highlight.is-correct { background: rgba(22, 163, 74, 0.12); color: var(--success); border-color: var(--success); }
.entry-highlight.is-dup { background: rgba(220, 38, 38, 0.08); color: var(--danger); border-color: var(--danger); text-decoration: line-through; opacity: 0.7; }

/* severity badge */
.severity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
}
.severity-badge.low      { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.severity-badge.medium   { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.severity-badge.high     { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.severity-badge.critical { background: var(--danger); color: #fff; }

/* thread-msg extras for V2 fields */
.thread-msg-meta { margin-top: var(--sp-2); display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* ============================================================
   FLAG SYSTEM V2 — IMPORT MODAL
============================================================ */
.import-result { margin-top: var(--sp-3); font-size: var(--fs-sm); }
.import-result.ok { color: var(--success); font-weight: 600; }
.import-result.err { color: var(--danger); font-weight: 600; }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 900px) {
  .app-header { flex-wrap: wrap; gap: var(--sp-2); }
  .header-left { min-width: 100%; }
  .header-center { order: 3; min-width: 100%; max-width: none; }
  .header-right { flex-wrap: wrap; }
  .icon-btn .btn-label { display: none; }
}
@media (max-width: 600px) {
  .filters-bar { gap: var(--sp-2); }
  .filter { flex: 1 1 calc(50% - var(--sp-2)); }
  #main-content { padding: var(--sp-3); }
  .col-source { display: none; }
  .col-q, .col-a { max-width: 150px; }
}

/* ============================================================
   PRINT
============================================================ */
@media print {
  .app-header, .filters-bar, .pagination, .modal-overlay, .toast-container, #btn-new, #btn-stats, #btn-validate, #btn-export, #btn-flags { display: none !important; }
  body { background: #fff; }
  .table-wrap { border: none; box-shadow: none; }
  .data-table { font-size: 10pt; }
  .data-table tbody tr:hover { background: transparent; }
}

/* ============================================================
   GRAPH VIEW (DEC-012 Cytoscape.js, DEC-016 scope colors)
============================================================ */

/* Stats bar */
.g-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.g-stats-bar .stat-card {
  padding: var(--sp-3);
  text-align: center;
}

/* Two-column layout */
.g-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--sp-4);
  align-items: start;
}
@media (max-width: 1100px) {
  .g-layout { grid-template-columns: 1fr; }
}

.g-left, .g-right { display: flex; flex-direction: column; gap: var(--sp-4); }

/* Panel */
.g-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.g-panel-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
  flex-wrap: wrap;
}
.g-panel-title {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: 600;
  white-space: nowrap;
}
.g-mini-search {
  flex: 1 1 120px;
  min-width: 100px;
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}

/* Graph screens table */
.g-table-wrap { max-height: 300px; overflow-y: auto; }
.g-table-wrap table { font-size: var(--fs-sm); }
.g-table-wrap th, .g-table-wrap td { padding: 4px 8px; }
.g-table-wrap tbody tr { cursor: pointer; }
.g-table-wrap tbody tr:hover { background: var(--surface-hover); }

/* Type badges */
.gtype {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.gtype-screen { background: #dbeafe; color: #1e40af; }
.gtype-dialog { background: #ede9fe; color: #5b21b6; }

/* Scope badge (DEC-016) */
.scope-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.scope-graph { background: #dcfce7; color: #166534; }

/* Pagination in graph */
.g-pagination { padding: var(--sp-2) var(--sp-3); }

/* Path finder controls */
.g-path-controls {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3);
  flex-wrap: wrap;
}
.g-field { display: flex; flex-direction: column; gap: 2px; }
.g-field-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.g-field select { padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: var(--fs-sm); min-width: 140px; }
.g-arrow { font-size: var(--fs-lg); color: var(--muted); padding-bottom: 4px; }

/* Path results */
.g-path-output { padding: 0 var(--sp-3) var(--sp-3); max-height: 220px; overflow-y: auto; }
.g-path-summary, .g-search-summary { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--sp-2); }
.g-path { background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2); }
.g-path-header { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.g-path-chain { font-size: var(--fs-sm); line-height: 1.6; word-break: break-word; }
.g-path-node { display: inline-block; padding: 1px 6px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--radius-pill); color: #9a3412; font-weight: 600; cursor: pointer; }
.g-path-node:hover { background: #ffedd5; }
.g-hop-trigger { display: inline-block; padding: 0 4px; background: #f3f4f6; border-radius: var(--radius-sm); font-size: 10px; color: var(--muted); margin: 0 2px; }

/* Cytoscape container */
.g-cy-panel { display: flex; flex-direction: column; }
.cy-container {
  width: 100%;
  min-height: 500px;
  height: 60vh;
  background: var(--surface-sunken);
  position: relative;
}

/* Graph search results */
.g-search-results { padding: var(--sp-2) var(--sp-3); }
.g-search-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.g-search-item:hover { background: var(--surface-hover); }
.g-search-type { font-size: var(--fs-base); }
.g-search-label { font-weight: 600; }
.g-search-id { color: var(--muted); font-family: var(--mono); font-size: var(--fs-xs); }

/* Orphans view */
.g-orphans { padding: var(--sp-3); border-top: 1px solid var(--border); }
.g-orphans-group { margin-bottom: var(--sp-3); }
.g-orphans-title { font-size: var(--fs-sm); font-weight: 600; margin-bottom: 4px; }
.g-orphans-list { display: flex; flex-wrap: wrap; gap: 4px; }
.g-orphan-pill {
  display: inline-block;
  padding: 2px 8px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  cursor: pointer;
  color: #92400e;
}
.g-orphan-pill:hover { background: #fde68a; }

/* Screen detail modal */
.g-detail-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.g-detail-id { font-family: var(--mono); font-size: var(--fs-sm); color: var(--muted); }
.g-detail-section { margin-bottom: var(--sp-4); }
.g-detail-title { font-size: var(--fs-sm); font-weight: 600; margin-bottom: 4px; color: var(--text); }
.g-edge-list, .g-detail-items { display: flex; flex-wrap: wrap; gap: 4px; }
.g-edge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  cursor: pointer;
  color: #1e40af;
}
.g-edge-pill:hover { background: #dbeafe; }
.g-edge-action { font-weight: 600; color: var(--primary); }
.g-detail-item {
  padding: 4px 8px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-family: var(--mono);
}

/* Graph utility text colors */
.g-muted { color: var(--muted); font-size: var(--fs-sm); }
.g-err { color: var(--danger); font-size: var(--fs-sm); }

/* ============================================================
   GRAPH SCANNER (progress bar, diff cards, history table)
============================================================ */

/* Scanner panel + history panel spacing */
.g-scan-panel { margin-bottom: var(--sp-4); }
.g-scan-history-panel { margin-bottom: var(--sp-4); }
.g-scan-body { padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }

/* Progress bar */
.scan-progress { display: flex; flex-direction: column; gap: var(--sp-1); }
.scan-progress-row { display: flex; align-items: center; gap: var(--sp-2); }
.scan-progress-bar {
  flex: 1;
  height: 10px;
  background: var(--surface-hover);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.scan-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.2s ease;
}
.scan-progress-pct {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--primary);
  min-width: 42px;
  text-align: right;
}
.scan-progress-phase { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.scan-progress-meta { font-size: var(--fs-xs); color: var(--muted-light); min-height: 14px; }

/* Diff grid (stat cards) */
.scan-diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.scan-diff-grid .stat-card { padding: var(--sp-3); text-align: center; }

/* Collapsible diff sections */
.scan-section {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-2);
}
.scan-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.scan-section-summary::-webkit-details-marker { display: none; }
.scan-section-summary::before {
  content: "▸";
  color: var(--muted);
  transition: transform var(--t-fast);
  display: inline-block;
}
.scan-section[open] .scan-section-summary::before { transform: rotate(90deg); }
.scan-section-title { flex: 1; }
.scan-count-badge {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
}
.scan-count-badge.scan-count-zero { background: var(--muted-light); }
.scan-section-body { padding: var(--sp-2) var(--sp-3) var(--sp-3); }

/* Diff tables (compact) */
.scan-diff-table { font-size: var(--fs-sm); }
.scan-diff-table th, .scan-diff-table td { padding: 4px 8px; }
.scan-diff-table code { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text); }

/* Banners */
.scan-banner {
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
}
.scan-banner ul { margin-top: var(--sp-1); padding-left: var(--sp-5); }
.scan-banner-error { background: rgba(220, 38, 38, 0.08); border-left: 3px solid var(--danger); color: var(--danger); }
.scan-banner-warn { background: rgba(217, 119, 6, 0.08); border-left: 3px solid var(--warning); color: #92400e; }
.scan-error-list { margin-top: var(--sp-1); padding-left: var(--sp-5); }
.scan-pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}

/* Scan history table */
.scan-history-row { cursor: pointer; }
.scan-history-row:hover { background: var(--surface-hover); }
.scan-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
}
.scan-status-completed { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.scan-status-failed { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.scan-status-pending { background: rgba(37, 99, 235, 0.12); color: var(--primary); }

/* ============================================================
   AUTH GATE (DEC-017) — overlay di login API key
   ============================================================ */
#auth-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg, #f5f5f7);
}
.auth-card {
  background: #fff; border-radius: 14px; padding: 2.2rem 2rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  width: min(360px, 92vw); text-align: center;
}
.auth-card h2 { margin: 0 0 .4rem; font-size: 1.6rem; color: var(--primary, #1d4ed8); }
.auth-sub { margin: 0 0 1.4rem; color: #6b7280; font-size: .92rem; }
.auth-input {
  width: 100%; box-sizing: border-box; padding: .65rem .8rem;
  border: 1px solid #d1d5db; border-radius: 8px; font-size: .95rem;
  margin-bottom: .8rem;
}
.auth-input:focus { outline: none; border-color: var(--primary, #1d4ed8);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.15); }
.auth-btn {
  width: 100%; padding: .7rem; border: 0; border-radius: 8px;
  background: var(--primary, #1d4ed8); color: #fff; font-size: 1rem;
  cursor: pointer; font-weight: 600;
}
.auth-btn:hover { filter: brightness(1.07); }
.auth-error { color: var(--danger, #dc2626); font-size: .85rem; margin: .7rem 0 0; min-height: 1.1em; }


/* ============================================================
   GROUPS VIEW — multilingual
   ============================================================ */
.groups-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.group-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: var(--sp-3);
  transition: box-shadow .15s;
}
.group-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.group-card--complete { border-left: 3px solid var(--success, #16a34a); }
.group-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-2); }
.group-card-title { font-weight: 600; font-size: var(--fs-sm, 14px); color: var(--text, #1f2937); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-card-count { font-size: 12px; font-weight: 700; color: var(--muted, #6b7280); background: var(--bg-muted, #f3f4f6); padding: 2px 8px; border-radius: 9999px; }
.group-card-langs { display: flex; gap: 6px; flex-wrap: wrap; }
.lang-badge { font-size: 12px; padding: 3px 8px; border-radius: 6px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.lang-badge--it { background: rgba(34,197,94,.12); color: #15803d; }
.lang-badge--en { background: rgba(59,130,246,.12); color: #1d4ed8; }
.lang-badge--es { background: rgba(245,158,11,.12); color: #b45309; }
.lang-badge--fr { background: rgba(168,85,247,.12); color: #7e22ce; }
.lang-badge--missing { background: rgba(107,114,128,.08); color: var(--muted, #9ca3af); opacity: .5; }
.lang-badge:hover:not(.lang-badge--missing) { opacity: .75; }

/* ============================================================
   KEYBOARD SHORTCUTS — help overlay + row selection
============================================================ */

/* Tabella scorciatoie nell'help overlay */
.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.shortcut-table thead th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.shortcut-table tbody td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.shortcut-table tbody tr:last-child td { border-bottom: none; }
.shortcut-table td:first-child { white-space: nowrap; width: 120px; }

/* Elemento <kbd> — tasto tastiera */
kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.shortcut-note {
  margin-top: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--muted);
  font-style: italic;
}

/* Riga selezionata nella tabella entries (navigazione j/k) */
.data-table tbody tr.row-selected {
  background: rgba(37, 99, 235, 0.08);
}
.data-table tbody tr.row-selected:hover {
  background: rgba(37, 99, 235, 0.14);
}

/* ============================================================
   BATCH SELECTION — checkbox colonna + toolbar flottante
============================================================ */

/* Colonna checkbox nelle tabelle entries */
.col-check {
  width: 40px;
  text-align: center;
  /* l'header th eredita .data-table thead th (center via text-align qui) */
}
.col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle;
}
/* La cella checkbox non deve far aprire l'editor al click del solo box */
.data-table tbody td.col-check {
  cursor: default;
}

/* Toolbar flottante per azioni batch */
.batch-toolbar {
  position: fixed;
  bottom: var(--sp-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - var(--sp-6));
  flex-wrap: wrap;
  justify-content: center;
}
.batch-count {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  padding-right: var(--sp-2);
  border-right: 1px solid var(--border);
}
.batch-tag-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.batch-tag-input {
  width: 140px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  background: var(--surface);
  color: var(--text);
}
.batch-tag-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================================
   COVERAGE MODAL — progress, by_type, by_lang, uncovered list
============================================================ */

/* Progress bar globale coverage */
.cov-progress-wrap {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  background: var(--surface-sunken);
  border-radius: var(--radius);
}
.cov-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--sp-2);
}
.cov-progress-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cov-progress-pct {
  font-size: var(--fs-xl);
  font-weight: 700;
}

/* Breakdown per tipo */
.cov-type-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.cov-type-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cov-type-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.cov-type-name {
  font-weight: 600;
  font-size: var(--fs-sm);
  text-transform: capitalize;
}
.cov-type-stats {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
}
.cov-type-pct {
  font-weight: 700;
  margin-left: var(--sp-2);
}

/* Header lista uncovered (toggle) */
.cov-uncovered-header {
  margin-top: var(--sp-5);
}
.cov-toggle-uncovered {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-base);
  font-weight: 700;
  padding: 0;
}
.cov-arrow {
  display: inline-block;
  font-size: var(--fs-xs);
  transition: transform var(--t-fast);
}
.cov-uncovered-body {
  margin-top: var(--sp-2);
}
.cov-filter-input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  background: var(--surface);
  color: var(--text);
  margin-bottom: var(--sp-3);
}
.cov-filter-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Lista uncovered */
.cov-uncovered-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2);
  background: var(--surface-sunken);
}
.cov-uncovered-group {
  margin-bottom: var(--sp-3);
}
.cov-uncovered-group:last-child {
  margin-bottom: 0;
}
.cov-uncovered-group-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: var(--sp-1);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.cov-uncovered-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cov-uncovered-item {
  display: flex;
  gap: var(--sp-2);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  align-items: baseline;
}
.cov-uncovered-item:hover {
  background: var(--surface-hover);
}
.cov-u-id {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--primary);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 60px;
}
.cov-u-label {
  color: var(--text);
  word-break: break-word;
}

/* ============================================================
   COVERAGE TABS + GAPS VIEW
============================================================ */
/* Tab bar dentro il modal coverage */
.cov-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--sp-5);
  background: var(--surface-sunken);
}
.cov-tab {
  padding: var(--sp-3) var(--sp-4);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.cov-tab:hover { color: var(--text); }
.cov-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Toolbar gap: filtro tipo + paginazione */
.cov-gaps-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.cov-gaps-toolbar select {
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.cov-gaps-count { font-size: var(--fs-sm); color: var(--muted); margin-left: auto; }
.cov-gaps-pagination { display: flex; align-items: center; gap: var(--sp-2); }

/* Lista gap */
.cov-gap-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--sp-2);
}
.cov-gap-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.cov-gap-id {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--primary);
  font-weight: 600;
}
.cov-gap-label {
  font-size: var(--fs-sm);
  color: var(--text);
  word-break: break-word;
  flex: 1;
  min-width: 0;
}
.cov-gap-drafts {
  font-size: var(--fs-xs);
  color: var(--muted);
}
.cov-gap-use-btn {
  padding: 2px 10px;
  font-size: var(--fs-xs);
  border: 1px solid var(--success);
  color: var(--success);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
}
.cov-gap-use-btn:hover { background: var(--success); color: #fff; }
.cov-gap-use-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Badge tipo gap (colorato per kb_type) */
.gap-type-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.gap-type-badge.screens           { background: rgba(37, 99, 235, 0.12); color: var(--primary); }
.gap-type-badge.actions           { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.gap-type-badge.fields            { background: rgba(202, 138, 4, 0.15); color: var(--lang-es); }
.gap-type-badge.sections          { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.gap-type-badge.items             { background: rgba(6, 182, 212, 0.12); color: #0891b2; }
.gap-type-badge.state_conditions  { background: rgba(217, 119, 6, 0.15); color: var(--warning); }
.gap-type-badge.unk               { background: rgba(107, 114, 128, 0.12); color: var(--muted); }

/* ============================================================
   QUALITY SCORE BADGE (tabella entries) + breakdown modal
============================================================ */
/* Badge Q cliccabile nella tabella entries */
.q-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.q-badge:hover { box-shadow: var(--shadow-sm); }
.q-badge.A { background: rgba(22, 163, 74, 0.15); color: var(--success); border-color: rgba(22, 163, 74, 0.3); }
.q-badge.B { background: rgba(37, 99, 235, 0.12); color: var(--primary); border-color: rgba(37, 99, 235, 0.3); }
.q-badge.C { background: rgba(202, 138, 4, 0.15); color: var(--lang-es); border-color: rgba(202, 138, 4, 0.3); }
.q-badge.D { background: rgba(217, 119, 6, 0.18); color: var(--warning); border-color: rgba(217, 119, 6, 0.4); }
.q-badge.F { background: rgba(220, 38, 38, 0.15); color: var(--danger); border-color: rgba(220, 38, 38, 0.4); }
/* Evidenziazione grade basso (D/F → score < 50) */
.q-badge.low { font-weight: 800; border-width: 2px; }
.q-badge.loading { color: var(--muted-light); background: transparent; border-color: var(--border); cursor: default; font-size: var(--fs-xs); }
.q-badge.loading:hover { transform: none; box-shadow: none; }

/* Breakdown modal quality */
.q-breakdown-score { font-size: var(--fs-xl); font-weight: 700; }
.q-breakdown-grid { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-3); }
.q-breakdown-row { display: flex; flex-direction: column; gap: 2px; }
.q-breakdown-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-sm);
}
.q-breakdown-label { font-weight: 600; }
.q-breakdown-val { color: var(--muted); font-family: var(--mono); font-size: var(--fs-xs); }

/* ============================================================
   DARK MODE — [data-theme="dark"] override delle CSS variables
============================================================ */
[data-theme="dark"] {
  --bg: #0f1115;
  --text: #e5e7eb;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --success-hover: #16a34a;
  --warning: #f59e0b;
  --border: #2a2f37;
  --border-strong: #3a414c;
  --muted: #9ca3af;
  --muted-light: #6b7280;
  --surface: #1a1d24;
  --surface-hover: #232730;
  --surface-sunken: #16191f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

/* Fix elementi con colori hardcoded che non usano CSS variables */
[data-theme="dark"] .gtype-screen { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .gtype-dialog { background: #3b2d5e; color: #c4b5fd; }
[data-theme="dark"] .scope-graph { background: #14532d; color: #86efac; }
[data-theme="dark"] .g-path-node { background: #431407; border-color: #7c2d12; color: #fdba74; }
[data-theme="dark"] .g-path-node:hover { background: #7c2d12; }
[data-theme="dark"] .g-hop-trigger { background: #232730; color: var(--muted); }
[data-theme="dark"] .g-orphan-pill { background: #422006; border-color: #78350f; color: #fbbf24; }
[data-theme="dark"] .g-orphan-pill:hover { background: #78350f; }
[data-theme="dark"] .g-edge-pill { background: #172554; border-color: #1e40af; color: #93c5fd; }
[data-theme="dark"] .g-edge-pill:hover { background: #1e3a8a; }
[data-theme="dark"] .scan-banner-error { background: rgba(239, 68, 68, 0.12); }
[data-theme="dark"] .scan-banner-warn { background: rgba(245, 158, 11, 0.12); }
[data-theme="dark"] .type-badge.correction { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
[data-theme="dark"] .type-badge.question { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }
[data-theme="dark"] .type-badge.gap { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
[data-theme="dark"] .type-badge.duplicate { background: rgba(139, 92, 246, 0.18); color: #a78bfa; }
[data-theme="dark"] .type-badge.contradiction { background: rgba(239, 68, 68, 0.18); color: #f87171; }
[data-theme="dark"] .type-badge.quality { background: rgba(6, 182, 212, 0.18); color: #22d3ee; }
[data-theme="dark"] .type-badge.language { background: rgba(99, 102, 241, 0.18); color: #818cf8; }
[data-theme="dark"] .type-badge.safety { background: rgba(127, 29, 29, 0.3); color: #fca5a5; }
[data-theme="dark"] .type-badge.note { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .proposed-fix-box { background: rgba(34, 197, 94, 0.1); }
[data-theme="dark"] .knowledge-box { background: rgba(59, 130, 246, 0.08); }
[data-theme="dark"] .severity-badge.low { background: rgba(34, 197, 94, 0.18); }
[data-theme="dark"] .severity-badge.medium { background: rgba(245, 158, 11, 0.18); }
[data-theme="dark"] .severity-badge.high { background: rgba(239, 68, 68, 0.18); }
[data-theme="dark"] .status-badge.open { background: rgba(59, 130, 246, 0.18); }
[data-theme="dark"] .status-badge.answered { background: rgba(245, 158, 11, 0.18); }
[data-theme="dark"] .status-badge.in_review { background: rgba(139, 92, 246, 0.18); }
[data-theme="dark"] .status-badge.resolved { background: rgba(34, 197, 94, 0.18); }
[data-theme="dark"] .status-badge.rejected { background: rgba(239, 68, 68, 0.18); }

/* Quality badge + gap-type-badge dark mode adjustments */
[data-theme="dark"] .q-badge.A { background: rgba(34, 197, 94, 0.18); color: var(--success); }
[data-theme="dark"] .q-badge.B { background: rgba(59, 130, 246, 0.18); color: var(--primary); }
[data-theme="dark"] .q-badge.C { background: rgba(245, 158, 11, 0.18); color: var(--warning); }
[data-theme="dark"] .q-badge.D { background: rgba(245, 158, 11, 0.22); color: var(--warning); }
[data-theme="dark"] .q-badge.F { background: rgba(239, 68, 68, 0.18); color: var(--danger); }
[data-theme="dark"] .gap-type-badge.screens          { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }
[data-theme="dark"] .gap-type-badge.actions          { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
[data-theme="dark"] .gap-type-badge.fields           { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
[data-theme="dark"] .gap-type-badge.sections         { background: rgba(139, 92, 246, 0.18); color: #a78bfa; }
[data-theme="dark"] .gap-type-badge.items            { background: rgba(6, 182, 212, 0.18); color: #22d3ee; }
[data-theme="dark"] .gap-type-badge.state_conditions { background: rgba(245, 158, 11, 0.22); color: #fbbf24; }

/* Transizione morbida al cambio tema */
body, .app-header, .filters-bar, .modal-card, .table-wrap, .g-panel, .toast, .icon-btn, .btn, .page-btn {
  transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
}

/* Pulsante theme toggle — stesso stile icon-btn ma senza label */
#btn-theme { font-size: var(--fs-lg); padding: var(--sp-2) var(--sp-2); }

/* ============================================================
   JUMP-TO-PAGE — input numerico nella paginazione
============================================================ */
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.page-input {
  width: 52px;
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  text-align: center;
  -moz-appearance: textfield;
}
.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.page-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.page-sep { color: var(--muted-light); }
.page-total { font-weight: 600; color: var(--muted); }

/* ============================================================
   EDITOR DIRTY DIFF HIGHLIGHT
============================================================ */
.field-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Badge "MODIFICATO" rosso */
.dirty-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.5;
}

/* Bordo giallo sui textarea quando il contenuto differisce dall'originale */
.textarea.dirty {
  border-color: var(--warning);
  background: rgba(245, 158, 11, 0.06);
}

/* Stato dirty in fondo all'editor */
.editor-dirty-status {
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px dashed var(--border);
  font-size: var(--fs-xs);
  color: var(--muted);
  text-align: center;
}
.editor-dirty-status.has-dirty {
  color: var(--warning);
  font-weight: 600;
}

/* ── Translation panel ── */
.translations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.translation-item {
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg-alt, #f8f9fa);
}
.translation-item:hover {
  border-color: var(--primary, #4a90d9);
  cursor: pointer;
}
.translation-lang {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--primary, #4a90d9);
  margin-bottom: 3px;
}
.translation-q {
  font-size: 0.85rem;
  color: var(--text, #333);
  margin-bottom: 2px;
}
.translation-a {
  font-size: 0.8rem;
  color: var(--text-muted, #777);
}
