:root {
  /* Marca */
  --brand: #006397;
  --brand-hover: #004b73;
  --brand-deep: #082436;
  --brand-cyan: #73c5f0;
  --brand-cyan-mid: #3aa6de;
  --brand-soft: #eaf6fc;
  --brand-soft-border: #bde3f7;

  /* Superfícies & Texto */
  --bg: #f2f7fb;
  --surface: #ffffff;
  --surface-alt: #f6fafd;
  --table-head: #edf5fb;
  --border: #d5e4ef;
  --text: #0a2233;
  --muted: #546e82;

  /* Estados Semânticos */
  --success: #047857;
  --success-bg: #ecfdf5;
  --warning: #a15206;
  --warning-bg: #fff8e6;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --neutral-bg: #eef3f7;

  /* Geometria & Sombra */
  --radius: 10px;
  --shadow: 0 2px 6px rgba(0, 62, 98, 0.06), 0 1px 2px rgba(8, 36, 54, 0.04);
}

/* Paletas de Cores Opcionais (Administrador / Colaborador Autorizado) */
:root[data-theme="midnight_slate"] {
  --brand: #1e3a5f;
  --brand-hover: #142843;
  --brand-deep: #0b1729;
  --brand-cyan: #5ca4d6;
  --brand-cyan-mid: #3a7cb0;
  --brand-soft: #eef3f9;
  --brand-soft-border: #bfd0e6;
  --bg: #f1f4f8;
  --surface-alt: #f7f9fc;
  --table-head: #eaeff6;
  --border: #d0dae7;
}

:root[data-theme="emerald_academic"] {
  --brand: #0f6b58;
  --brand-hover: #0a4e40;
  --brand-deep: #062c24;
  --brand-cyan: #52c4a8;
  --brand-cyan-mid: #239b7e;
  --brand-soft: #eaf7f3;
  --brand-soft-border: #b6e3d6;
  --bg: #f2f8f6;
  --surface-alt: #f6fbf9;
  --table-head: #eaf4f0;
  --border: #cfe4dd;
}

:root[data-theme="royal_indigo"] {
  --brand: #4338ca;
  --brand-hover: #312e81;
  --brand-deep: #1e1b4b;
  --brand-cyan: #818cf8;
  --brand-cyan-mid: #6366f1;
  --brand-soft: #eef2ff;
  --brand-soft-border: #c7d2fe;
  --bg: #f4f5fc;
  --surface-alt: #f8f9fe;
  --table-head: #eceffe;
  --border: #d5dbf7;
}

:root[data-theme="crimson_usp"] {
  --brand: #881337;
  --brand-hover: #640d27;
  --brand-deep: #3b0817;
  --brand-cyan: #fb7185;
  --brand-cyan-mid: #e11d48;
  --brand-soft: #fff1f4;
  --brand-soft-border: #fecdd3;
  --bg: #faf4f6;
  --surface-alt: #fdf8f9;
  --table-head: #f8ecef;
  --border: #ead2d8;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 92% 0%, rgba(115, 197, 240, 0.16), transparent 42%);
  color: var(--text);
  line-height: 1.45;
}

.hidden { display: none !important; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 0.82rem; }
.muted { color: var(--muted); }
.pre-wrap { white-space: pre-wrap; }

/* Header & Tabs */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(0, 75, 115, 0.06);
}

.brand-rail, .modal-rail {
  height: 4px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand) 28%, var(--brand-cyan) 28%, var(--brand-cyan) 100%);
}

.topbar-inner {
  max-width: min(1760px, 96vw);
  margin: 0 auto;
  padding: 13px 22px 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand-logo-link { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { height: 44px; width: auto; display: block; }
.brand-divider { width: 1px; height: 36px; background: linear-gradient(180deg, transparent, var(--border), transparent); }
.brand-text h1 { margin: 0; font-size: 1.08rem; font-weight: 700; color: var(--brand-deep); letter-spacing: -0.01em; }
.subtitle { margin: 1px 0 0; font-size: 0.79rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mobile-nav-wrap { display: none; }

.tabs {
  max-width: min(1760px, 96vw);
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-top: 1px solid #edf4f9;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.tab.active .tab-count {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.tab:hover { color: var(--brand); background: var(--surface-alt); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab.admin-tab { color: #8a4b08; }
.tab.admin-tab.active { color: var(--brand); border-bottom-color: var(--brand-cyan-mid); }

/* Container & Footer */
.container {
  flex: 1 0 auto;
  width: 100%;
  max-width: min(1760px, 96vw);
  margin: 0 auto;
  padding: 22px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 12px;
}

.site-footer-inner {
  max-width: min(1760px, 96vw);
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* KPIs & Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.kpi-card:nth-child(3n) { border-top-color: var(--brand-cyan); }
.kpi-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 75, 115, 0.09); }
.kpi-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.kpi-value { margin-top: 6px; font-size: 1.75rem; font-weight: 700; color: var(--brand-deep); font-variant-numeric: tabular-nums; }
.kpi-sub { margin-top: 4px; font-size: 0.78rem; color: var(--muted); }

/* Compact Single-Row KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.kpi-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  padding: 7px 11px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.kpi-chip:nth-child(3) { border-left-color: var(--brand-cyan); }
.kpi-chip-label { font-size: 0.69rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.kpi-chip-val { font-size: 1.08rem; font-weight: 700; color: var(--brand-deep); font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-chip-sub { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.split-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: start;
}

.sidebar-sticky {
  position: sticky;
  top: 118px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, var(--surface-alt), #ffffff);
}

.card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--brand-deep);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand-cyan), var(--brand));
}

.card-body { padding: 16px 18px; }

/* Controls & Buttons */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  align-items: end;
}

.filter-search { grid-column: span 2; }
.filter-reset-wrap { display: flex; justify-content: flex-end; }
.filter-reset-wrap .btn { width: 100%; }

.input, .select, textarea {
  font: inherit;
  font-size: 0.88rem;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  width: 100%;
  min-width: 0;
}

textarea { resize: vertical; min-height: 76px; }

.input:focus, .select:focus, textarea:focus {
  outline: 2px solid rgba(115, 197, 240, 0.55);
  border-color: var(--brand);
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-field label {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.form-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-error { color: var(--danger); font-size: 0.84rem; font-weight: 600; margin: 10px 0 0; }

.btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); box-shadow: 0 2px 6px rgba(0, 99, 151, 0.25); }
.btn-secondary { background: #fff; color: var(--brand-deep); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--brand-soft); border-color: var(--brand-soft-border); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(0.92); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn-icon { background: transparent; border: none; font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.btn-icon:hover { background: var(--neutral-bg); color: var(--brand-deep); }
.btn-icon-sm { font-size: 1.1rem; padding: 1px 5px; }

.info-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--brand-soft-border);
  background: var(--brand-soft);
  color: var(--brand);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.73rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.info-icon-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Badges & Notices */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-public { background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-soft-border); }
.badge-admin { background: var(--warning-bg); color: var(--warning); border: 1px solid #f7d388; }
.badge-ok, .badge-livre { background: var(--success-bg); color: var(--success); }
.badge-uso { background: var(--brand-soft); color: var(--brand); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--neutral-bg); color: var(--muted); }

.front-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--brand-deep);
  white-space: nowrap;
}

.front-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.notice {
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-border);
  border-left: 4px solid var(--brand);
  color: var(--brand-deep);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.notice-compact { padding: 8px 12px; font-size: 0.81rem; }
.notice-warn { background: var(--warning-bg); border-color: #f7d388; border-left-color: var(--warning); color: #5c3004; }
.notice-danger { background: var(--danger-bg); border-color: #fecaca; border-left-color: var(--danger); color: #7f1d1d; }
.notice-success { background: var(--success-bg); border-color: #a7f3d0; border-left-color: var(--success); color: #064e3b; }

/* Tables, Sorting & Sticky Actions */
.table-wrap { overflow-x: auto; position: relative; border: 1px solid #e4eef6; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }

th, td {
  padding: 9px 12px;
  border-bottom: 1px solid #e4eef6;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--table-head);
  color: var(--brand-hover);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody tr:hover { background: #f2f9fd; }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
tbody tr.selected-row { background: var(--brand-soft); }

.empty-cell { text-align: center; padding: 24px 12px; }

.sort-btn {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-btn:hover { color: var(--brand-deep); }
.sort-arrow { font-size: 0.72rem; opacity: 0.65; }
.sort-btn.active-sort .sort-arrow { opacity: 1; color: var(--brand); }

.table-sticky-actions.is-overflowing th:last-child,
.table-sticky-actions.is-overflowing td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: -6px 0 10px -6px rgba(8, 36, 54, 0.16);
}

.table-sticky-actions.is-overflowing th:last-child {
  background: var(--table-head);
  z-index: 3;
}

.table-sticky-actions.is-overflowing tbody tr:hover td:last-child {
  background: #f2f9fd;
}

.row-actions { display: inline-flex; gap: 5px; white-space: nowrap; align-items: center; flex-wrap: wrap; }

.work-cell-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 2px; }
.work-cell-title { font-size: 0.83rem; color: var(--text); line-height: 1.35; min-width: 220px; max-width: 580px; }
.venue-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.stack-badges { display: flex; flex-wrap: wrap; gap: 4px; }

/* Toasts */
.toast-area {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.toast {
  background: var(--brand-deep);
  border-left: 4px solid var(--brand-cyan);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(8, 36, 54, 0.25);
}

.toast.error { background: var(--danger); border-left-color: #fecaca; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 36, 54, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 22px 48px rgba(8, 36, 54, 0.28);
  display: flex;
  flex-direction: column;
}

.modal.modal-wide { max-width: min(1480px, 96vw); }

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-alt);
  position: sticky;
  top: 0;
  z-index: 4;
}

.modal-header-main { min-width: 0; flex: 1; }
.modal-header h2 { margin: 0; font-size: 1.04rem; color: var(--brand-deep); line-height: 1.3; }
.modal-subtitle { margin-top: 4px; font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.modal-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.modal-body { padding: 18px; }

/* Inner Modal Tabs & Collapsible Sections */
.modal-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.modal-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.modal-tab:hover { color: var(--brand); background: var(--surface-alt); }
.modal-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.collapsible-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--surface);
  overflow: hidden;
}

.collapsible-block > summary {
  padding: 10px 14px;
  background: var(--surface-alt);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--brand-deep);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
}

.collapsible-block > summary::-webkit-details-marker { display: none; }
.collapsible-block[open] > summary { border-bottom: 1px solid var(--border); }
.collapsible-body { padding: 12px 14px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.kv-item {
  border: 1px solid #e7f0f7;
  background: #fbfdff;
  border-radius: 7px;
  padding: 8px 10px;
}

.kv-item.kv-highlight { border-color: var(--danger); background: var(--danger-bg); }

.kv-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.kv-value { font-size: 0.85rem; color: var(--text); word-break: break-word; }

/* Batch Evidence Applicator */
.batch-evidence-bar {
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-border);
  border-left: 4px solid var(--brand);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.batch-evidence-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--brand-deep);
  margin: 0 0 8px;
}

.audit-edit-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface-alt);
}

.audit-edit-row.audit-missing {
  border-color: var(--danger);
  background: var(--danger-bg);
}

/* Ingestion Stages & Progress */
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--neutral-bg);
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-cyan-mid));
  transition: width 0.25s ease;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stage-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-card.stage-done { border-top: 3px solid var(--success); }
.stage-card.stage-error { border-top: 3px solid var(--danger); }
.stage-card.stage-running { border-top: 3px solid var(--brand-cyan-mid); }
.stage-card.stage-pending { border-top: 3px solid var(--border); }

.prompt-preview {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.76rem;
  background: #f8fbfe;
  max-height: 160px;
}

.checkbox-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* Dictionary Popover */
.dict-popover {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(410px, calc(100vw - 24px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--brand-soft-border);
  border-top: 4px solid var(--brand);
  border-radius: 10px;
  box-shadow: 0 18px 36px rgba(8, 36, 54, 0.25);
  z-index: 70;
}

.dict-popover-header {
  padding: 10px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--brand-deep);
}

.dict-popover-body {
  padding: 12px 14px;
  font-size: 0.81rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dict-popover-row strong { color: var(--brand-deep); }

/* Catalog Split Layout with Year Balloons on the Left */
.catalog-split-body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.year-pills-rail {
  flex: 0 0 96px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.year-pills-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0 4px 2px;
}

.year-pills-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.year-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 0.81rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.year-pill:hover {
  border-color: var(--brand-cyan-mid);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.year-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 99, 151, 0.22);
}

.catalog-table-column {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.catalog-split-body .table-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

/* Top Synchronized Horizontal Scrollbar */
.table-top-scroll {
  display: none;
  overflow-x: auto;
  overflow-y: hidden;
  height: 16px;
  margin-bottom: 5px;
  border: 1px solid #d9e6f2;
  border-radius: 6px;
  background: var(--surface-alt);
  scrollbar-width: thin;
  scrollbar-color: var(--brand-cyan-mid) var(--surface-alt);
}

.table-top-scroll.is-visible { display: block; }
.table-top-scroll-inner { height: 1px; }

/* Smart Exploratory Question Box */
.smart-ask-box {
  background: linear-gradient(180deg, #f8fbfe 0%, #f1f7fc 100%);
  border: 1px solid var(--brand-soft-border);
  border-left: 4px solid var(--brand);
  border-radius: 9px;
  padding: 11px 14px;
  margin-bottom: 14px;
}

.smart-ask-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.smart-ask-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-deep);
  margin-bottom: 4px;
}

.smart-ask-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.smart-ask-row .input {
  flex: 1 1 320px;
}

.smart-ask-note {
  margin: 0;
  font-size: 0.77rem;
  color: var(--muted);
  line-height: 1.38;
}

.smart-ask-results {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #d7e7f4;
}

.smart-ask-summary {
  font-size: 0.84rem;
  color: var(--brand-deep);
  margin-bottom: 10px;
}

.smart-ask-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.smart-ask-summary p { margin: 0; line-height: 1.45; }

.smart-ask-matches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.smart-ask-match {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
}

.smart-ask-match:hover {
  border-color: var(--brand);
  box-shadow: 0 3px 10px rgba(0, 99, 151, 0.12);
  transform: translateY(-1px);
}

.smart-ask-match-head {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-bottom: 5px;
}

.smart-ask-match-title {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--brand-deep);
  line-height: 1.3;
  margin-bottom: 5px;
}

.smart-ask-reasons {
  margin: 0;
  padding-left: 16px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.35;
}

/* Developer Watermark (UI Only) */
.dev-watermark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--brand-deep);
  font-size: 0.76rem;
  opacity: 0.88;
}

.dev-watermark a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

.dev-watermark a:hover { text-decoration: underline; }

/* Collaborator Granular Permissions & Modal BibTeX */
.collab-perm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.bibtex-box {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-alt);
  overflow: hidden;
}

.bibtex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.83rem;
}

.bibtex-pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--brand-deep);
  background: #fbfdff;
  user-select: all;
}

.topbar-theme-select {
  width: auto !important;
  max-width: 195px;
  padding: 4px 8px;
  font-size: 0.77rem;
}

.theme-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.theme-swatch-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

/* Breakpoints Responsivos */
@media (max-width: 1040px) {
  .split-workspace { grid-template-columns: 1fr; }
  .sidebar-sticky { position: static; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-search { grid-column: span 2; }
  .modal.modal-wide { max-width: calc(100vw - 24px); }
}

@media (max-width: 720px) {
  .topbar { position: static; }
  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .brand-divider, .subtitle { display: none; }
  .brand-logo { height: 34px; }
  .brand-text h1 { font-size: 0.96rem; }
  .topbar-actions { width: 100%; gap: 6px; }
  .tabs { display: none; }
  .mobile-nav-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 10px;
    border-top: 1px solid #edf4f9;
    background: var(--surface-alt);
  }
  .mobile-nav-label { font-size: 0.78rem; font-weight: 700; color: var(--brand-deep); white-space: nowrap; }
  .mobile-tab-select { flex: 1; min-width: 0; font-weight: 600; }
  .container { padding: 14px 12px 32px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 1.38rem; }
  .grid-2, .form-grid, .filter-grid { grid-template-columns: 1fr; }
  .filter-search { grid-column: span 1; }
  .catalog-split-body { flex-direction: column; gap: 10px; }
  .year-pills-rail { flex: none; width: 100%; padding: 8px 10px; }
  .year-pills-list { flex-direction: row; flex-wrap: wrap; }
  .year-pill { padding: 4px 11px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .input, .toolbar .select { width: 100%; }
  .table-sticky-actions.is-overflowing th:last-child,
  .table-sticky-actions.is-overflowing td:last-child {
    position: static;
    box-shadow: none;
  }
  .toast-area { left: 10px; right: 10px; bottom: 60px; max-width: none; }
}

.select-col {
  width: 36px;
  text-align: center;
  vertical-align: middle;
}

.paper-select-chk,
#chk-select-all-papers {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}

.quote-cell {
  font-style: italic;
  color: var(--brand-deep);
  min-width: 220px;
}

.diff-table td,
.diff-table th {
  vertical-align: top;
}
