/* ===== Variables ===== */
:root {
  --bg: #f6f7f9;
  --bg-card: #ffffff;
  --bg-soft: #f0f2f5;
  --border: #e3e6eb;
  --border-strong: #c8cdd4;
  --text: #1d2433;
  --text-muted: #6b7384;
  --text-soft: #8b93a3;
  --accent: #2962ff;
  --accent-hover: #1d4fd9;
  --accent-soft: #e7efff;
  --success: #1f7a3a;
  --success-soft: #e3f3e8;
  --danger: #c4302b;
  --danger-soft: #fbe7e6;
  --warning: #b8740a;
  --warning-soft: #fcefda;
  --muted: #9098a4;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ===== Layout ===== */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}
.topbar .brand-dot { color: var(--accent); }
.topbar .nav { display: flex; gap: 8px; }
.topbar .nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
}
.topbar .nav a:hover { background: var(--bg-soft); text-decoration: none; color: var(--text); }
.topbar .nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar .spacer { flex: 1; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

h1 { font-size: 22px; font-weight: 600; margin: 0 0 8px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:not(:disabled):hover { background: var(--accent-hover); }
.btn.secondary { background: white; color: var(--text); border-color: var(--border-strong); }
.btn.secondary:not(:disabled):hover { background: var(--bg-soft); }
.btn.ghost { background: transparent; color: var(--text-muted); }
.btn.ghost:not(:disabled):hover { background: var(--bg-soft); color: var(--text); }
.btn.danger { background: var(--danger); color: white; }
.btn.danger:not(:disabled):hover { background: #a8231f; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.lg { padding: 12px 24px; font-size: 15px; }

/* ===== Hero / Dropzone ===== */
.hero {
  text-align: center;
  padding: 32px 20px 20px;
}
.hero h1 { font-size: 26px; }
.hero p { color: var(--text-muted); margin: 0 0 24px; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-card);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-icon { font-size: 36px; margin-bottom: 8px; }
.dropzone-text { font-weight: 600; margin: 0 0 4px; }
.dropzone-hint { color: var(--text-muted); margin: 0; }
.upload-progress {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-top: 16px;
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tables ===== */
table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
}
table.list th, table.list td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
table.list th { font-weight: 600; color: var(--text-muted); background: var(--bg-soft); }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover { background: var(--bg-soft); }

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty .icon { font-size: 40px; opacity: 0.4; margin-bottom: 12px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red   { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.blue  { background: var(--accent-soft); color: var(--accent); }

/* ===== Check page ===== */
.file-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 4px;
}
.file-header .icon { font-size: 32px; }
.file-header .name { font-weight: 600; font-size: 15px; }
.file-header .meta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.section-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.section-picker label { color: var(--text-muted); font-size: 13px; }
.section-picker select {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: white;
  min-width: 280px;
}

.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.check-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.check-card .head { display: flex; align-items: center; gap: 10px; }
.check-card .head .icon { font-size: 20px; }
.check-card h2 { margin: 0; font-size: 15px; }
.check-card .desc { color: var(--text-muted); font-size: 13px; margin: 0; flex: 1; }
.check-card .footer { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.check-card.disabled { opacity: 0.6; }
.check-card .last-run { font-size: 13px; color: var(--text-muted); }
.check-card .last-run strong { color: var(--text); }

.progress {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}

/* ===== Stats ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.stat {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
}
.stat .v { font-size: 22px; font-weight: 600; }
.stat .l { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.stat.ok { background: var(--success-soft); } .stat.ok .v { color: var(--success); }
.stat.bad { background: var(--danger-soft); } .stat.bad .v { color: var(--danger); }
.stat.warn { background: var(--warning-soft); } .stat.warn .v { color: var(--warning); }
.stat.muted .v { color: var(--text-muted); }

/* ===== Results detail ===== */
.results-list .row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 30px 80px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 13px;
}
.results-list .row:last-child { border-bottom: 0; }
.results-list .num { color: var(--text-muted); font-size: 12px; }
.results-list .details { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.results-list .sheet { color: var(--text-soft); font-size: 12px; margin-top: 3px; }

.status-icon { font-size: 14px; line-height: 1; padding-top: 2px; }
.status-icon.green { color: var(--success); }
.status-icon.red   { color: var(--danger); }
.status-icon.gray  { color: var(--muted); }

details summary {
  cursor: pointer;
  padding: 8px 0;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}
details summary:hover { color: var(--text); }
details[open] summary { color: var(--text); margin-bottom: 6px; }

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

/* ===== Catalog ===== */
.catalog-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}
.section-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.section-list .item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.section-list .item:hover { background: var(--bg-soft); }
.section-list .item.active { background: var(--accent-soft); color: var(--accent); }
.section-list .item .name { font-weight: 500; font-size: 13px; }
.section-list .item .code { font-size: 11px; opacity: 0.7; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tabs .tab {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .tab .count { font-size: 11px; opacity: 0.7; margin-left: 4px; }

.items-table { width: 100%; border-collapse: collapse; }
.items-table th, .items-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
.items-table th { font-weight: 600; color: var(--text-muted); font-size: 12px; }
.items-table .actions { text-align: right; white-space: nowrap; }
.items-table textarea, .items-table input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  resize: vertical;
  min-height: 26px;
}
.items-table .num-col { width: 80px; }
.items-table .sheet-col { width: 200px; }

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(16, 24, 40, 0.2);
}
.modal h2 { margin: 0 0 16px; }
.modal .row { margin-bottom: 12px; }
.modal label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.modal input, .modal textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

.banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 10px;
}
.banner.info  { background: var(--accent-soft); color: var(--accent); }
.banner.warn  { background: var(--warning-soft); color: var(--warning); }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner.ok    { background: var(--success-soft); color: var(--success); }

.index-info details.index-details {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.index-info details.index-details summary {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}
.index-info table.list { font-size: 12px; background: white; border: 1px solid var(--border); }
.index-info table.list th, .index-info table.list td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.index-info table.list tbody tr:hover { background: var(--bg-soft); }
.index-info table.list tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }

/* ===== PDF viewer ===== */
.pdf-viewer-bg {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.pdf-viewer {
  background: white;
  width: 100%;
  max-width: 1200px;
  height: 95vh;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.pdf-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  gap: 12px;
  flex-wrap: wrap;
}
.pv-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.pv-page-info { font-size: 12px; }
.pv-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pv-controls .pv-spacer { width: 12px; }
.pv-page-input {
  font: inherit;
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  text-align: center;
}
.pv-of { color: var(--text-muted); font-size: 12px; margin-right: 6px; }
.pv-zoom { font-size: 12px; min-width: 44px; text-align: center; color: var(--text-muted); }

.pdf-viewer-canvas-wrap {
  flex: 1;
  overflow: auto;
  background: #525659;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.pv-canvas {
  background: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: block;
}
.pv-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: white;
}

a.sheet-link { color: var(--accent); text-decoration: none; border-bottom: 1px dashed currentColor; }
a.sheet-link:hover { background: var(--accent-soft); text-decoration: none; }

/* ===== Specifications result cards ===== */
.specs-list { display: flex; flex-direction: column; gap: 12px; }
.spec-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--bg-card);
}
.spec-card.spec-ok { border-left: 4px solid var(--success); }
.spec-card.spec-bad { border-left: 4px solid var(--danger); }
.spec-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.spec-name { font-weight: 600; font-size: 14px; }
.spec-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.spec-summary { color: var(--text-muted); font-size: 13px; margin-top: 8px; }
.spec-discrep { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.discrep-row {
  background: var(--bg-soft);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
}
.discrep-details { color: var(--text-muted); margin-top: 3px; font-size: 12px; }
.discrep-note { color: var(--text-soft); margin-top: 3px; font-size: 12px; font-style: italic; }
