@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* Matisse-inspired: warm cream, confident type, airy layout */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #fff8f0;
  color: #2c2c2c;
  line-height: 1.45;
}

.site-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  border-bottom: 1px solid #e8d5c0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.logo {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #e8472a;
  margin: 0;
  letter-spacing: -0.02em;
}

.logo::after {
  display: none;
}

.tagline {
  margin: 0;
  color: #9a8e84;
  font-size: 0.8rem;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.25rem;
  background: #fff8f0;
  border: 1px solid #e8d5c0;
  border-radius: 8px;
}

.tab-btn {
  border: 1px solid #e8d5c0;
  background: #fff;
  color: #2e86ab;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}

.tab-btn[aria-selected='true'] {
  background: linear-gradient(180deg, #fff4e6 0%, #fff 100%);
  border-color: #f4a259;
  color: #2c2c2c;
  box-shadow: inset 0 0 0 1px rgba(244, 162, 89, 0.25);
}

.tab-btn:focus-visible {
  outline: 3px solid rgba(46, 134, 171, 0.35);
  outline-offset: 2px;
}

.tab-panel[hidden] {
  display: none !important;
}

.panel {
  background: #fff;
  border: 1px solid #e8d5c0;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(44, 44, 44, 0.06);
}

.panel-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: #2e86ab;
}

.field-label {
  display: block;
  font-weight: 600;
  color: #2c2c2c;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

textarea,
input[type='text'],
input[type='date'] {
  width: 100%;
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid #e8d5c0;
  border-radius: 4px;
  background: #fff;
  color: #2c2c2c;
}

textarea:focus,
input:focus {
  outline: 2px solid #f4a259;
  outline-offset: 1px;
  border-color: #2e86ab;
}

textarea {
  resize: vertical;
  min-height: 200px;
}

.row-pdf {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.75rem 0 1rem;
}

.prompt-section {
  border: 1px dashed #e8d5c0;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.prompt-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.prompt-summary::-webkit-details-marker {
  display: none;
}

.prompt-summary::before {
  content: '▶';
  font-size: 0.7rem;
  color: #7a6e65;
  transition: transform 0.15s;
  flex-shrink: 0;
}

details[open] .prompt-summary::before {
  transform: rotate(90deg);
}

.prompt-summary-label {
  margin: 0;
}

.prompt-summary-hint {
  font-size: 0.85rem;
  font-weight: 400;
}

.prompt-body {
  padding: 0 0.85rem 0.85rem;
}

.prompt-hint {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.prompt-actions {
  display: flex;
  margin-top: 0.5rem;
}

.grid-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.field-span {
  grid-column: 1 / -1;
}

.models-fieldset {
  border: 1px dashed #e8d5c0;
  border-radius: 4px;
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
  cursor: pointer;
  color: #2c2c2c;
}

.check input {
  accent-color: #e8472a;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 4px;
  padding: 0.55rem 1.1rem;
  border: none;
  font-weight: 600;
}

.btn-primary {
  background: #e8472a;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: #2e86ab;
  border: 1px solid #2e86ab;
}

.btn-secondary:hover {
  background: #f4f6fb;
}

.muted {
  color: #7a6e65;
}

.error {
  color: #b91c1c;
  font-weight: 500;
}

.run-meta {
  margin: 0 0 1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.model-card {
  border: 1px solid #e8d5c0;
  border-radius: 6px;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  border-left-width: 5px;
}

/* Default slot border; slots 0–7 get distinct accents; higher slots stay default. */
.model-card[data-slot] {
  border-left-color: #b8a99a;
}

.model-card[data-slot='0'] {
  border-left-color: #9b59b6;
}

.model-card[data-slot='1'] {
  border-left-color: #27ae60;
}

.model-card[data-slot='2'] {
  border-left-color: #2e86ab;
}

.model-card[data-slot='3'] {
  border-left-color: #e8472a;
}

.model-card[data-slot='4'] {
  border-left-color: #8e44ad;
}

.model-card[data-slot='5'] {
  border-left-color: #16a085;
}

.model-card[data-slot='6'] {
  border-left-color: #d35400;
}

.model-card[data-slot='7'] {
  border-left-color: #34495e;
}

.card-head {
  padding: 0.65rem 0.85rem;
  background: linear-gradient(180deg, #f0f7fb 0%, #fff 100%);
  border-bottom: 1px solid #e8d5c0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.card-head h3 {
  margin: 0;
  font-size: 1rem;
  color: #2e86ab;
  flex: 1;
}

.badge-current {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #7a6e65;
  color: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.card-body {
  padding: 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.summary-lines {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 4rem;
}

.summary-lines.loading {
  color: #7a6e65;
  font-style: italic;
}

.card-stats {
  font-size: 0.85rem;
  color: #7a6e65;
  border-top: 1px solid #f0e6dc;
  padding-top: 0.5rem;
}

.card-stats strong {
  color: #2c2c2c;
}

.card-footer {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid #f0e6dc;
}

.cost-line {
  font-size: 0.85rem;
  color: #2c2c2c;
}

.cost-detail {
  font-size: 0.75rem;
  color: #7a6e65;
  margin-top: 0.15rem;
}

.stars {
  display: flex;
  gap: 0.15rem;
  margin: 0.35rem 0;
  user-select: none;
}

.star {
  font-size: 1.35rem;
  cursor: pointer;
  color: #c4b8ae;
  line-height: 1;
  background: none;
  border: none;
  padding: 0 0.1rem;
}

.star.active {
  color: #f4a259;
}

.notes-input {
  width: 100%;
  min-height: 3.5rem;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid #e8d5c0;
  border-radius: 4px;
  resize: vertical;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.btn-small {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
}

.log-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.session-total {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
}

.session-total strong {
  color: #e8472a;
}

.table-wrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid #e8d5c0;
  border-radius: 4px;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

.log-table th {
  position: sticky;
  top: 0;
  background: #fff8f0;
  color: #2e86ab;
  font-weight: 600;
  z-index: 1;
}

.log-table tbody tr:hover {
  background: #fffaf5;
}

.log-table tbody tr.log-row-clickable {
  cursor: pointer;
}

.log-table tbody tr.log-row-clickable:hover {
  background: #fff4e8;
}

.log-table .log-sl-col {
  width: 3rem;
  text-align: right;
  color: #8a7967;
  font-variant-numeric: tabular-nums;
}

.log-table .log-title-cell {
  color: #2e86ab;
  text-decoration: underline;
  text-decoration-color: #f4a259;
  text-underline-offset: 2px;
}

.log-table tfoot .log-grand-total-row td {
  background: #fff4e6;
  border-top: 2px solid #f4a259;
  font-size: 0.95rem;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(44, 44, 44, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-dialog {
  width: 100%;
  max-width: 720px;
  background: #fff;
  border: 1px solid #e8d5c0;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  margin-top: 1rem;
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

.modal-dialog--review {
  max-width: min(1160px, 96vw);
  max-height: min(92dvh, calc(100vh - 2rem));
  margin-top: 0.5rem;
  min-height: 0;
  flex-direction: row;
  overflow: hidden;
}

.modal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-pdf-drawer {
  display: flex;
  flex-direction: row-reverse;
  flex-shrink: 0;
  border-left: 1px solid #e8d5c0;
}

.modal-pdf-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 48px;
  background: #e31c1c;
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 1.25rem 0;
  transition: background 0.15s;
  flex-shrink: 0;
}

.modal-pdf-tab-btn:hover:not(:disabled) {
  background: #c41515;
}

.modal-pdf-tab-btn:disabled {
  background: #b0a9a4;
  cursor: not-allowed;
}

.modal-pdf-tab-btn:disabled .pdf-tab-icon {
  opacity: 0.5;
}

.pdf-tab-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: Georgia, 'Times New Roman', serif;
}

.modal-pdf-viewer {
  width: 0;
  overflow: hidden;
  transition: width 0.25s ease;
}

.modal-pdf-drawer.open .modal-pdf-viewer {
  width: 480px;
  max-width: 45vw;
}

#modal-pdf-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  min-width: 480px;
}

.modal-meta {
  padding: 0.65rem 1.25rem 0;
  font-size: 0.9rem;
  color: #7a6e65;
  line-height: 1.5;
}

.modal-run-total {
  margin: 0.35rem 1.25rem 0;
  font-size: 0.88rem;
}

.modal-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 1.25rem 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.modal-section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.log-review-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #e8d5c0;
  background: linear-gradient(180deg, #fff8f0 0%, #fff 100%);
}

.modal-nav {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.modal-nav-btn {
  border: 1px solid #e8d5c0;
  background: #fff;
  color: #2e86ab;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.modal-nav-btn:hover:not(:disabled) {
  background: #f4f6fb;
  border-color: #2e86ab;
}

.modal-nav-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: #e8472a;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.3;
}

.modal-close {
  flex-shrink: 0;
  border: none;
  background: #f0e6dc;
  color: #2c2c2c;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: #e8d5c0;
}

code {
  font-size: 0.85em;
  background: #f0e6dc;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
}

.err-inline {
  color: #b91c1c;
  font-size: 0.9rem;
}

.leaderboard-explainer,
.leaderboard-champion {
  margin: 0 0 0.75rem;
  line-height: 1.45;
}

.leaderboard-champion {
  font-weight: 600;
  color: #2c2c2c;
  padding: 0.5rem 0.65rem;
  background: linear-gradient(90deg, #fff4e6 0%, #fff 100%);
  border: 1px solid #f4a259;
  border-radius: 4px;
}

.leaderboard-row.rank-top {
  background: linear-gradient(90deg, #fff9f0 0%, #fff 100%);
  box-shadow: inset 3px 0 0 #f4a259;
}

.leaderboard-row.rank-top td {
  font-weight: 600;
}

.log-cohort-leader {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #f4a259;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  vertical-align: middle;
}

.model-tabs-wrap {
  margin-top: 0.25rem;
}

.model-tab-nav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  border-bottom: 2px solid #e8d5c0;
  margin-bottom: 0;
  -webkit-overflow-scrolling: touch;
}

.model-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem 0.55rem;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: #7a6e65;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.1s;
}

.model-tab-btn:hover {
  color: #2c2c2c;
  background: #fff4e6;
}

.model-tab-btn[aria-selected='true'] {
  color: #2c2c2c;
  font-weight: 700;
  border-bottom-color: #e8472a;
}

.model-tab-btn:focus-visible {
  outline: 2px solid rgba(232, 71, 42, 0.4);
  outline-offset: -2px;
}

.tab-name {
  font-weight: inherit;
}

.tab-badge {
  font-size: 0.68rem;
}

.tab-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid #e8d5c0;
  border-top-color: #e8472a;
  border-radius: 50%;
  animation: tab-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes tab-spin {
  to { transform: rotate(360deg); }
}

.tab-stars {
  color: #f4a259;
  font-size: 0.8rem;
  letter-spacing: -0.04em;
}

.tab-relevance {
  font-size: 0.8rem;
  font-weight: 600;
}

.tab-cost {
  color: #7a6e65;
  font-size: 0.8rem;
}

.relevance-bar {
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #f0e6dc;
  margin-bottom: 0.5rem;
}

.relevance-pill-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.relevance-pill {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  color: #fff;
  letter-spacing: 0.01em;
}

.relevance-pill--low  { background: #DC2626; }
.relevance-pill--mid  { background: #F59E0B; }
.relevance-pill--high { background: #16A34A; }

.relevance-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #2c2c2c;
}

.relevance-reason {
  font-size: 0.82rem;
  line-height: 1.4;
}

.model-tab-panels {
  border: 1px solid #e8d5c0;
  border-top: none;
  border-radius: 0 0 4px 4px;
  background: #fff;
}

.model-tab-panel {
  padding: 1rem 1.25rem 1.25rem;
}

.model-tab-panel .model-card {
  border: none;
  border-left: 5px solid #b8a99a;
  border-radius: 0;
  box-shadow: none;
  min-height: unset;
}

.model-tab-panel .model-card[data-slot='0'] { border-left-color: #9b59b6; }
.model-tab-panel .model-card[data-slot='1'] { border-left-color: #27ae60; }
.model-tab-panel .model-card[data-slot='2'] { border-left-color: #2e86ab; }
.model-tab-panel .model-card[data-slot='3'] { border-left-color: #e8472a; }
.model-tab-panel .model-card[data-slot='4'] { border-left-color: #8e44ad; }
.model-tab-panel .model-card[data-slot='5'] { border-left-color: #16a085; }
.model-tab-panel .model-card[data-slot='6'] { border-left-color: #d35400; }
.model-tab-panel .model-card[data-slot='7'] { border-left-color: #34495e; }

.card-head-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}

.model-or-id {
  font-size: 0.78rem;
}

.pdf-drop-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 0.75rem;
}

.pdf-file-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.pdf-file-item {
  border: 1px solid #e8d5c0;
  border-radius: 4px;
  padding: 0.65rem 0.85rem 0.75rem;
  background: #fffaf5;
}

.pdf-file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.pdf-file-name {
  font-size: 0.85rem;
  color: #7a6e65;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-file-remove {
  flex-shrink: 0;
  background: #f0e6dc;
  border: none;
  border-radius: 3px;
  width: 1.6rem;
  height: 1.6rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: #7a6e65;
}

.pdf-file-remove:hover {
  background: #e8d5c0;
  color: #2c2c2c;
}

.pdf-file-extracting {
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

.pdf-file-error {
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

.pdf-file-meta {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 1fr;
  gap: 0.65rem;
}

.field--key-points input {
  width: 100%;
  text-align: center;
}

.pdf-file-meta .field-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  display: block;
}

.pdf-file-meta input {
  font-size: 0.875rem;
  padding: 0.35rem 0.5rem;
}

.pdf-file-dup {
  margin-top: 0.55rem;
  padding: 0.5rem 0.7rem;
  background: #fff3cd;
  border: 1px solid #e6c564;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #6b4e00;
}

.pdf-file-dup-msg {
  flex: 1 1 auto;
  word-break: break-word;
}

.pdf-file-dup-view {
  flex: 0 0 auto;
}

.resume-banner {
  margin-bottom: 1rem;
  padding: 0.7rem 0.9rem;
  background: #fff3cd;
  border: 1px solid #e6c564;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: #6b4e00;
}

.resume-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.pdf-date-summary {
  margin: 0.75rem auto 1rem;
  padding: 0;
  background: #ffffff;
  border: 1px solid #5eead4;
  border-radius: 6px;
  font-size: 0.9rem;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(13, 148, 136, 0.12);
  width: fit-content;
  min-width: min(26rem, 100%);
  max-width: 100%;
}

.pdf-date-summary-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: #ffffff;
  padding: 0.65rem 0.9rem;
  background: #0d9488;
  border-bottom: 1px solid #0f766e;
}

.pdf-date-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.pdf-date-summary-table thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #134e4a;
  padding: 0.45rem 0.9rem;
  background: #ccfbf1;
  border-bottom: 1px solid #5eead4;
}

.pdf-date-summary-table thead th:last-child,
.pdf-date-summary-table tbody td:last-child,
.pdf-date-summary-table tfoot td:last-child {
  text-align: right;
}

.pdf-date-summary-table tbody td {
  padding: 0.45rem 0.9rem;
  color: #134e4a;
  border-bottom: 1px solid #d4f4ed;
}

.pdf-date-summary-table tbody tr:nth-child(even) td {
  background: #f0fdfa;
}

.pdf-date-summary-table tbody tr:hover td {
  background: #ccfbf1;
}

.pdf-date-summary-table tbody tr:last-child td {
  border-bottom: none;
}

.pdf-date-summary-table tbody tr.pdf-date-nodate td {
  color: #b43b1a;
  font-style: italic;
  background: #fff4ec;
}

.pdf-date-summary-table tbody tr.pdf-date-nodate:hover td {
  background: #ffe8d6;
}

.pdf-date-summary-table tfoot td {
  padding: 0.6rem 0.9rem;
  font-weight: 700;
  color: #ffffff;
  background: #0d9488;
  border-top: 2px solid #0f766e;
  letter-spacing: 0.02em;
}

.pdf-date-missing-hint {
  font-weight: 500;
  color: #ffd4b3;
  margin-left: 0.35rem;
}

@media (max-width: 640px) {
  .site-header {
    padding: 0.5rem 1rem;
    gap: 0.75rem;
  }

  .tagline {
    display: none;
  }

  .brand {
    gap: 0.4rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .logo {
    font-size: 2.15rem;
  }

  .tabs {
    gap: 0.35rem;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.55rem;
    font-size: 0.95rem;
  }

  .grid-meta {
    grid-template-columns: 1fr;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 0.35rem;
    align-items: stretch;
  }

  .modal-dialog {
    margin-top: 0;
    max-height: 100dvh;
    border-radius: 6px;
  }

  .modal-dialog--review {
    max-width: 100%;
    max-height: 100dvh;
    flex-direction: column;
  }

  .modal-pdf-drawer {
    border-left: none;
    border-top: 1px solid #e8d5c0;
    flex-direction: column-reverse;
  }

  .modal-pdf-tab-btn {
    width: auto;
    height: 52px;
    flex-direction: row;
    padding: 0 1rem;
    gap: 8px;
  }

  .modal-pdf-drawer.open .modal-pdf-viewer {
    width: auto;
    max-width: none;
    height: 40vh;
  }

  #modal-pdf-iframe {
    min-width: unset;
    height: 100%;
  }

  .log-review-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .modal-dialog--review {
    max-width: min(900px, 94vw);
  }

  .log-review-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

/* ── Run progress ───────────────────────────────────────────────── */

.run-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.run-progress-header .panel-title {
  margin: 0;
}

.run-article-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.run-article-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid #f0e8df;
}

.run-article-row:last-child {
  border-bottom: none;
}

.run-article-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.run-article-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e8d5c0;
  color: #7a6e65;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.run-article-info {
  flex: 1;
  min-width: 0;
}

.run-article-title-text {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.run-article-sub {
  font-size: 0.78rem;
  color: #9a8e84;
  margin-top: 1px;
}

.run-model-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.run-model-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
  line-height: 1.4;
}

.run-model-badge--pending {
  background: #e8e0d8;
  color: #9a8e84;
}

.run-model-badge--running {
  background: #2e86ab;
  color: #fff;
  animation: badge-pulse 1.1s ease-in-out infinite;
}

.run-model-badge--done {
  background: #2a7d4f;
  color: #fff;
}

.run-model-badge--error {
  background: #c0392b;
  color: #fff;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.run-article-actions {
  flex-shrink: 0;
}

.run-complete-bar {
  display: flex;
  justify-content: flex-end;
  padding-top: 1.25rem;
  margin-top: 0.5rem;
  border-top: 1px solid #e8d5c0;
}

/* ── Filter bar ─────────────────────────────────────────────────── */

.filter-bar {
  display: grid;
  grid-template-columns: 230px 1fr 1fr;
  gap: 1.5rem;
  margin: 0.75rem 0 0.25rem;
  padding: 1rem 1.25rem;
  background: #fafaf8;
  border: 1px solid #e8d5c0;
  border-radius: 6px;
}

.filter-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.filter-count {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

/* ── Calendar ───────────────────────────────────────────────────── */

.filter-calendar {
  width: 210px;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  gap: 0.25rem;
}

.cal-month-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e3a5f;
  flex: 1;
  text-align: center;
}

.cal-nav-btn {
  background: none;
  border: 1px solid #e8d5c0;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  color: #1e3a5f;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-nav-btn:hover:not(:disabled) {
  background: #eef2fb;
}

.cal-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  text-align: center;
}

.cal-day-hdr {
  font-size: 0.7rem;
  font-weight: 600;
  color: #7a6e65;
  padding: 0.15rem 0 0.3rem;
}

.cal-day {
  position: relative;
  font-size: 0.8rem;
  padding: 0.22rem 0;
  border-radius: 50%;
  line-height: 1.7;
  color: #d1d5db;
  cursor: default;
  min-width: 22px;
  user-select: none;
}

.cal-day--empty {
  visibility: hidden;
}

.cal-day--active {
  color: #1e3a5f;
  cursor: pointer;
}

.cal-day--active:hover {
  background: #eef2fb;
}

.cal-day--selected {
  background: #1e3a5f !important;
  color: #fff !important;
  cursor: pointer;
}

.cal-day--today::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f4a259;
}

.cal-tooltip {
  position: fixed;
  background: #1e3a5f;
  color: #fff;
  font-size: 0.78rem;
  padding: 0.28rem 0.55rem;
  border-radius: 4px;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  max-width: 300px;
}

/* ── Source toggles ─────────────────────────────────────────────── */

.filter-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-content: flex-start;
}

.source-toggle {
  position: relative;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.32rem 1.45rem 0.32rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.2;
  border: 1px solid #1e3a5f;
  white-space: nowrap;
}

.source-toggle--on {
  background: #1e3a5f;
  color: #fff;
}

.source-toggle--off {
  background: #fff;
  color: #1e3a5f;
}

.source-toggle:hover {
  filter: brightness(0.92);
}

.relevance-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.15rem 0;
  width: 88%;
}

.relevance-slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.relevance-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 10px;
  border-radius: 5px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(
    to right,
    #e8472a 0%,
    #f5a623 25%,
    #f5d623 50%,
    #7bc67e 75%,
    #2e7d32 100%
  );
}

.relevance-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #1e3a5f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: grab;
}

.relevance-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #1e3a5f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: grab;
}

.relevance-slider-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e3a5f;
  min-width: 2.4rem;
  text-align: left;
}

.relevance-slider-label--off {
  color: #aaa;
  font-weight: 400;
}


.source-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  background: #e8472a;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* ── Tag chips ──────────────────────────────────────────────────── */

.filter-tag-controls {
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  color: #7a6e65;
}

.filter-tag-link {
  color: #2e86ab;
  text-decoration: none;
}

.filter-tag-link:hover {
  text-decoration: underline;
}

.filter-tags {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-content: flex-start;
}

.tag-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.22rem 1.3rem 0.22rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
  border: 1px solid;
  user-select: none;
  margin-top: 4px;
}

.tag-chip--on {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}

.tag-chip--off {
  background: #fff;
  color: #1e3a5f;
  border-color: #2e6da4;
}

.tag-chip:hover {
  filter: brightness(0.93);
}

.tag-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.tag-chip--on .tag-badge {
  background: #e8472a;
  color: #fff;
}

.tag-chip--off .tag-badge {
  background: #9ca3af;
  color: #fff;
}

/* pinned chips — always dark blue bg, gold border */
.tag-chip--pinned {
  background: #1e3a5f !important;
  color: #fff !important;
  border-color: #c9a227 !important;
  border-width: 2px;
}

.tag-chip--pinned .tag-badge {
  background: #c9a227;
  color: #1e3a5f;
}

/* if pinned chip is also in active filter, keep red badge */
.tag-chip--pinned.tag-chip--on .tag-badge {
  background: #e8472a;
  color: #fff;
}

/* rare tags — muted appearance */
.tag-chip--rare {
  opacity: 0.55;
  font-style: italic;
}

/* pin button inside chip */
.chip-pin-btn {
  display: none;
  background: none;
  border: none;
  padding: 0;
  margin-right: 0.18rem;
  cursor: pointer;
  font-size: 0.65rem;
  line-height: 1;
  filter: grayscale(1) brightness(0.8);
  flex-shrink: 0;
  vertical-align: middle;
}

.tag-chip:hover .chip-pin-btn {
  display: inline;
}

.chip-pin-btn--active {
  display: inline !important;
  filter: none;
}

/* tag section label (above pinned row) */
.tag-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
  width: 100%;
}

/* rows within the tag cloud */
.tag-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

/* show-more / show-rare expand links */
.tag-expand-link {
  display: inline-block;
  font-size: 0.78rem;
  margin: 0.1rem 0 0.2rem;
}

/* ── Tags column in log table ───────────────────────────────────── */

.log-tags-cell {
  max-width: 220px;
}

.tag-chip-sm {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.08rem 0.32rem;
  border-radius: 3px;
  background: #eef2fb;
  color: #1e3a5f;
  margin: 1px 1px 0 0;
  white-space: nowrap;
}

.tag-chip-sm--none {
  background: #f0e6dc;
  color: #7a6e65;
}

@media (max-width: 900px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }
  .filter-calendar {
    width: 100%;
    max-width: 240px;
  }
}
