/* ===== XML Feed Reader — Base Styles ===== */

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

:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e2e4e9;
  --color-text: #1a1d23;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-secondary: #f3f4f6;
  --color-secondary-hover: #e5e7eb;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-warning: #d97706;
  --color-info: #0369a1;
  --color-drop-hover: #eff6ff;
  --color-drop-border: #93c5fd;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Mono', 'Cascadia Code', Consolas, monospace;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 600;
  font-size: 16px;
}

.logo-icon {
  font-size: 20px;
}

.header-nav {
  margin-left: auto;
}

.nav-hint {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ===== Main ===== */

.app-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
}

/* ===== Footer ===== */

.app-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 16px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ===== Landing Page ===== */

.landing-page {
  max-width: 900px;
  margin: 0 auto;
}

.landing-hero {
  text-align: center;
  margin-bottom: 40px;
}

.landing-hero h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* ===== Input Cards ===== */

.input-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 48px;
}

.input-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.input-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

.input-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 80px;
}

.input-divider span {
  font-size: 14px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
}

/* ===== Drop Zone ===== */

.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 12px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-drop-border);
  background: var(--color-drop-hover);
}

.drop-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.drop-text {
  font-size: 15px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.drop-or {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.upload-limits {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 8px;
}

.upload-limits-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
  opacity: 0.8;
}

/* ===== URL Form ===== */

.url-form {
  margin-bottom: 16px;
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.url-field {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.2s;
  outline: none;
}

.url-field:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.url-hints {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ===== Buttons ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

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

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-secondary-hover);
}

/* ===== Progress Bar ===== */

.progress-bar-wrap {
  height: 6px;
  background: var(--color-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-info {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ===== Status Messages ===== */

.upload-status,
.download-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
}

.status-error {
  background: #fef2f2;
  color: var(--color-error);
  border: 1px solid #fecaca;
}

.status-success {
  background: #f0fdf4;
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

.status-info {
  background: #eff6ff;
  color: var(--color-info);
  border: 1px solid #bfdbfe;
}

/* ===== Features List ===== */

.features-list {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow);
}

.features-list h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-text-muted);
}

.features-list ul {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}

.features-list li {
  font-size: 14px;
  color: var(--color-text-muted);
  padding-left: 20px;
  position: relative;
}

.features-list li::before {
  content: "✓";
  color: var(--color-success);
  position: absolute;
  left: 0;
  font-weight: 600;
}

/* ===== Utilities ===== */

.hidden {
  display: none !important;
}

/* ===== Responsive ===== */

@media (max-width: 680px) {
  .input-cards {
    grid-template-columns: 1fr;
  }

  .input-divider {
    padding-top: 0;
  }

  .features-list ul {
    grid-template-columns: 1fr;
  }

  .landing-hero h1 {
    font-size: 24px;
  }
}

/* ===== Download extras ===== */

.save-btn {
  display: inline-flex;
  margin-top: 10px;
  width: 100%;
  justify-content: center;
}

.status-link {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.status-link:hover {
  opacity: 0.8;
}

/* Невідомий розмір — пульсуюча смуга */
@keyframes pulse-bar {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}
.progress-bar.unknown {
  animation: pulse-bar 1.2s ease-in-out infinite;
}

/* ===== File Info Page ===== */

.file-info-page {
  max-width: 640px;
  margin: 0 auto;
}

.file-info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.file-info-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.file-info-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.file-info-subtitle {
  font-size: 15px;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}

.file-meta-table {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
  text-align: left;
}

.file-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.file-meta-row:last-child {
  border-bottom: none;
}

.file-meta-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  min-width: 100px;
  padding-top: 1px;
}

.file-meta-value {
  font-size: 14px;
  color: var(--color-text);
  flex: 1;
  word-break: break-all;
}

.file-meta-value.filename {
  font-weight: 500;
}

.file-meta-value.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-muted);
}

.size-bytes {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-left: 6px;
}

.source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
}

.source-upload {
  background: #eff6ff;
  color: var(--color-primary);
}

.source-download {
  background: #f0fdf4;
  color: var(--color-success);
}

.url-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-muted);
  word-break: break-all;
}

.file-info-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  max-width: 320px;
}

.large-file-notice {
  margin-top: 20px;
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  font-size: 13px;
  color: #92400e;
  text-align: left;
}

/* ===== Summary Page ===== */

.summary-page {
  max-width: 960px;
  margin: 0 auto;
}

/* File bar */
.file-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.file-bar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-bar-icon { font-size: 18px; }
.file-bar-name { font-weight: 600; font-size: 15px; }
.file-bar-size { font-size: 13px; color: var(--color-text-muted); }

.mode-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.mode-small { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }
.mode-large { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Stats row */
.summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
}

.stat-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Actions */
.summary-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn-outline:hover {
  background: #eff6ff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Section cards */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.section-count {
  display: inline-block;
  background: var(--color-secondary);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
}

.section-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-left: auto;
}

/* Item tag */
.item-tag-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.item-tag-badge {
  background: #eff6ff;
  color: var(--color-primary);
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid #bfdbfe;
}

.item-tag-hint {
  font-size: 13px;
  color: var(--color-text-muted);
}

.tag-override-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.override-label {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--color-bg);
}

.num-col { text-align: right; white-space: nowrap; }

.field-name {
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--color-text);
}

.attr-name { color: #7c3aed; }

/* Fill rate bar */
.fill-rate-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.fill-bar-bg {
  width: 80px;
  height: 6px;
  background: var(--color-secondary);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.fill-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.fill-pct {
  font-size: 13px;
  font-weight: 500;
  min-width: 42px;
  text-align: right;
  color: var(--color-text);
}
.fill-full { color: var(--color-success); }
.fill-low  { color: var(--color-warning); }

.example-cell { max-width: 280px; }
.example-value {
  font-size: 13px;
  color: var(--color-text-muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Params grid */
.params-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.param-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 4px 12px;
}

.param-name { font-size: 13px; font-weight: 500; }
.param-count {
  font-size: 11px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 600;
}

/* Sample items */
.samples-list { display: flex; flex-direction: column; gap: 8px; }

.sample-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.sample-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--color-bg);
  list-style: none;
  font-size: 14px;
  user-select: none;
}

.sample-item-header::-webkit-details-marker { display: none; }
.sample-item[open] .sample-item-header { border-bottom: 1px solid var(--color-border); background: #eff6ff; }

.sample-idx { font-size: 12px; color: var(--color-text-muted); font-weight: 600; min-width: 28px; }
.sample-id  { font-size: 12px; color: var(--color-text-muted); font-family: var(--font-mono); }
.sample-name { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-price { font-size: 13px; color: var(--color-success); font-weight: 600; white-space: nowrap; }

.sample-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.sample-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.sample-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sample-table .sk {
  width: 160px;
  padding: 4px 12px 4px 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  vertical-align: top;
  white-space: nowrap;
}
.sample-table .sv {
  padding: 4px 0;
  word-break: break-word;
}

.sample-pictures { display: flex; flex-direction: column; gap: 4px; }
.picture-url {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--color-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Error card */
.error-card {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  margin-bottom: 24px;
}
.error-icon { font-size: 40px; margin-bottom: 12px; }
.error-card h2 { margin-bottom: 8px; font-size: 18px; }
.error-card p { color: var(--color-text-muted); margin-bottom: 16px; }
.tag-override-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Responsive */
@media (max-width: 680px) {
  .summary-stats { grid-template-columns: repeat(2, 1fr); }
  .summary-actions { flex-direction: column; }
  .file-bar { flex-direction: column; align-items: flex-start; }
}

/* ===== Reader Page ===== */

.reader-page {
  max-width: 1080px;
  margin: 0 auto;
}

/* Large file notice */
.large-file-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 16px;
}

/* Toolbar */
.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
}
.search-clear:hover { color: var(--color-text); }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.total-label {
  font-size: 13px;
  color: var(--color-text-muted);
}

.per-page-select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

/* Table wrap */
.reader-table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* Reader table */
.reader-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}

.reader-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg);
  white-space: nowrap;
}

.reader-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.reader-table thead th.sortable:hover { color: var(--color-primary); }
.reader-table thead th.sorted { color: var(--color-primary); }

.sort-icon { font-style: normal; }

.reader-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.reader-table tbody tr:last-child td { border-bottom: none; }

.item-row {
  cursor: pointer;
  transition: background 0.1s;
}
.item-row:hover td { background: #f0f7ff; }

.col-rownum { width: 48px; color: var(--color-text-muted); font-size: 12px; text-align: right; }
.col-id { width: 100px; }
.col-name { min-width: 220px; }
.col-vendor { width: 140px; }
.col-price { width: 110px; }
.col-avail { width: 110px; }

.id-code {
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  background: var(--color-bg);
  padding: 1px 5px;
  border-radius: 3px;
}

.item-name { font-weight: 500; }
.currency { font-size: 12px; color: var(--color-text-muted); }
.no-value { color: var(--color-border); }

.avail-badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.avail-yes { background: #f0fdf4; color: var(--color-success); }
.avail-no  { background: #fef2f2; color: var(--color-danger); }

.table-loading,
.table-empty,
.table-error {
  text-align: center;
  padding: 40px !important;
  color: var(--color-text-muted);
  font-size: 14px;
}
.table-error { color: var(--color-danger); }

/* Pagination */
.pagination-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.1s;
  line-height: 1;
}
.page-btn:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-ellipsis { padding: 0 4px; color: var(--color-text-muted); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 460px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.1s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--color-secondary); color: var(--color-text); }

.modal-body {
  overflow-y: auto;
  padding: 20px 24px;
  flex: 1;
}

.modal-section { margin-bottom: 20px; }
.modal-section:last-child { margin-bottom: 0; }

.modal-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.modal-table .sk {
  width: 160px;
  padding: 4px 12px 4px 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  vertical-align: top;
  white-space: nowrap;
}
.modal-table .sv {
  padding: 4px 0;
  word-break: break-word;
}

.modal-pictures { display: flex; flex-direction: column; gap: 4px; }
.modal-pic-url {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--color-primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.modal-pic-url:hover { text-decoration: underline; }

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.copy-hint {
  font-size: 13px;
  color: var(--color-success);
}

.modal-loading, .modal-error {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
  font-size: 14px;
}
.modal-error { color: var(--color-danger); }

.file-bar-actions { display: flex; gap: 8px; }

/* Responsive reader */
@media (max-width: 680px) {
  .reader-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: space-between; }
}

/* ===== Large-file mode additions ===== */

/* Disabled sort column in large-file mode */
.reader-table thead th.sort-disabled {
  cursor: default;
  opacity: 0.45;
}
.reader-table thead th.sort-disabled:hover {
  color: var(--color-text-muted);
}

/* Search truncation notice */
.search-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 10px;
}

/* Total label hints */
.label-hint {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: normal;
}

/* ===== Validation Page ===== */

.validation-page {
  max-width: 960px;
  margin: 0 auto;
}

/* Run panel */
.val-run-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.val-run-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.val-run-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
  max-width: 600px;
  line-height: 1.6;
}

.val-run-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Progress */
.val-progress {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress-bar-wrap {
  flex: 1;
  max-width: 320px;
  height: 6px;
  background: var(--color-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-anim {
  height: 100%;
  width: 40%;
  background: var(--color-primary);
  border-radius: 3px;
  animation: pbar-slide 1.4s ease-in-out infinite;
}

@keyframes pbar-slide {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}

.progress-label {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Verdict */
.val-verdict {
  font-size: 16px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius);
  display: inline-block;
  margin-bottom: 18px;
}

.val-verdict-ok   { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }
.val-verdict-fail { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }

/* Stat cards row */
.val-stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.val-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.val-stat-card.val-stat-ok   { border-color: #bbf7d0; background: #f0fdf4; }
.val-stat-card.val-stat-err  { border-color: #fecaca; background: #fef2f2; }
.val-stat-card.val-stat-warn { border-color: #fde68a; background: #fffbeb; }

.val-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
}
.val-stat-card.val-stat-ok   .val-stat-value { color: var(--color-success); }
.val-stat-card.val-stat-err  .val-stat-value { color: var(--color-danger); }
.val-stat-card.val-stat-warn .val-stat-value { color: #b45309; }

.val-stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Issue chips */
.val-issue-totals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.issue-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.chip-err  { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }
.chip-warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.chip-info { background: #eff6ff; color: var(--color-primary); border: 1px solid #bfdbfe; }

/* Issue sections */
.val-issue-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.val-section-err  { border-top: 3px solid var(--color-danger); }
.val-section-warn { border-top: 3px solid #f59e0b; }
.val-section-info { border-top: 3px solid var(--color-primary); }

.val-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 4px;
}

.val-section-title {
  font-size: 15px;
  font-weight: 600;
}

.val-section-count {
  background: var(--color-secondary);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}

.val-section-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 4px 20px 12px;
}

/* Issue table */
.val-table-wrap { overflow-x: auto; }

.val-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}

.val-table th {
  text-align: left;
  padding: 7px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg);
}

.val-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.val-table tr:last-child td { border-bottom: none; }

.th-code  { width: 70px; }
.th-item  { width: 200px; }
.th-msg   { }

.code-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.code-err  { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }
.code-warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.code-info { background: #eff6ff; color: var(--color-primary); border: 1px solid #bfdbfe; }

.iss-id {
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--color-bg);
  padding: 1px 5px;
  border-radius: 3px;
}
.iss-id-none { font-size: 12px; color: var(--color-text-muted); }
.iss-loc { font-size: 11px; color: var(--color-text-muted); margin-left: 4px; }
.iss-msg { line-height: 1.5; }

.iss-more-row td {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 10px;
  background: var(--color-bg);
}

/* All OK */
.val-all-ok {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  background: var(--color-surface);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-lg);
  color: var(--color-success);
  font-size: 16px;
  font-weight: 600;
  gap: 12px;
  box-shadow: var(--shadow);
}
.val-all-ok-icon { font-size: 48px; }

/* Error block */
.val-error-block {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 16px 20px;
  color: var(--color-danger);
  font-size: 14px;
}

/* Footer */
.val-footer { margin-top: 8px; }
.val-footer-inner {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--color-text-muted);
  padding: 4px 0;
}

/* Stats container */
#val-stats {
  margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 680px) {
  .val-stat-cards { grid-template-columns: repeat(2, 1fr); }
  .val-run-panel { padding: 20px; }
}

/* ===== Stage 8: Reader toolbar extras ===== */

.avail-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 2px;
}

.avail-filter-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== Upload progress bar ===== */

.upload-progress {
  margin-top: 12px;
}

.upload-progress .progress-bar-wrap {
  height: 8px;
  background: var(--color-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.upload-progress .progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 0.15s ease;
}

.upload-progress .progress-bar.bar-indeterminate {
  animation: pbar-slide 1.2s ease-in-out infinite;
  width: 40% !important;
}

.upload-progress .progress-info {
  margin-top: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ===== Analyzing page ===== */

.analyzing-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  padding: 40px 20px;
}

.analyzing-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 48px 48px 40px;
  text-align: center;
  max-width: 440px;
  width: 100%;
}

.analyzing-spinner {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.spinner-ring {
  width: 52px;
  height: 52px;
  border: 4px solid var(--color-secondary);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

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

.analyzing-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--color-text);
}

.analyzing-filename {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary);
  margin: 0 0 4px;
  word-break: break-all;
}

.analyzing-size {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0 0 28px;
}

.analyzing-progress {
  margin-bottom: 20px;
}

.analyzing-bar-wrap {
  height: 6px;
  background: var(--color-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.analyzing-bar-anim {
  height: 100%;
  width: 40%;
  background: var(--color-primary);
  border-radius: 3px;
  animation: pbar-slide 1.5s ease-in-out infinite;
}

.analyzing-status {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
  transition: opacity 0.3s;
}

.analyzing-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0;
  opacity: 0.7;
}

/* ─── 404 / Error page ───────────────────────────────────────────────────── */

.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 16px;
}

.error-page-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 48px 40px 40px;
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.error-page-code {
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-primary);
  opacity: 0.18;
  margin-bottom: 8px;
}

.error-page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 12px;
}

.error-page-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0 0 28px;
}

.error-page-actions {
  display: flex;
  justify-content: center;
}

/* ─── Validation: per-code breakdown ─────────────────────────────────────── */

.code-breakdown {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cbd-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cbd-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 7px 12px;
}

.cbd-title-err  { background: #fef2f2; color: #b91c1c; border-bottom: 1px solid #fecaca; }
.cbd-title-warn { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; }
.cbd-title-info { background: #eff6ff; color: #1e40af; border-bottom: 1px solid #bfdbfe; }

.code-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.code-breakdown-table thead th {
  background: var(--color-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  padding: 6px 10px;
  text-align: left;
}

.code-breakdown-table tbody tr {
  border-top: 1px solid var(--color-border);
  transition: background 0.12s;
}

.code-breakdown-table tbody tr:hover {
  background: var(--color-secondary);
}

.code-breakdown-table td {
  padding: 7px 10px;
  vertical-align: middle;
}

.cbd-code   { width: 100px; white-space: nowrap; }
.cbd-desc   { color: var(--color-text-muted); }
.cbd-count  { width: 70px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ─── Validation: clickable item IDs in issue table ─────────────────────── */

.iss-id-link {
  cursor: pointer;
  border-bottom: 1px dashed currentColor;
  transition: opacity 0.12s;
}

.iss-id-link:hover {
  opacity: 0.7;
}

