:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dde3ec;
  --text: #1c2534;
  --muted: #6b7787;
  --primary: #2b6cf6;
  --primary-dark: #1d55cc;
  --danger: #d64545;
  --warning-bg: #fff7e6;
  --warning-border: #f0c36d;
  --danger-bg: #fdeaea;
  --danger-border: #e79a9a;
  --ok: #2e9e5b;
  --warn: #d98b1f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  background: #14304f;
  color: #fff;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 11px;
  font-size: 12px;
  background: rgba(255, 255, 255, .16);
}
.badge-ok { background: #1f7a45; }
.badge-err { background: #a32f2f; }
.badge-muted { background: rgba(255, 255, 255, .16); }

.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfd;
}
.card-head h2 { font-size: 15px; margin: 0; }
.card-head.collapsible { cursor: pointer; user-select: none; }
.card-body { padding: 14px 16px; }
.card-body h3 { font-size: 13px; margin: 0 0 8px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 12px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 5px; }
.label { font-size: 12px; color: var(--muted); font-weight: 600; }
.label-second { margin-top: 6px; }
.value-box {
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: #fbfcfe;
  font-size: 13px;
  min-height: 36px;
  word-break: break-word;
}

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(43, 108, 246, .28);
  border-color: var(--primary);
}

textarea {
  min-height: 240px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: #eef1f6;
  color: var(--text);
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef1f6; border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-copy { padding: 4px 9px; font-size: 12px; }

.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.muted { color: var(--muted); font-size: 12.5px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.notice {
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 13px;
  margin: 10px 0;
  border: 1px solid transparent;
}
.notice-warning { background: var(--warning-bg); border-color: var(--warning-border); }
.notice-danger { background: var(--danger-bg); border-color: var(--danger-border); }
.notice-ok { background: #eaf7ef; border-color: #a9d9bd; }

/* ---------- Статистика ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.stat {
  background: #f8fafd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
}
.stat .stat-value { font-size: 19px; font-weight: 700; }
.stat .stat-label { font-size: 11.5px; color: var(--muted); }
.stat.stat-warn .stat-value { color: var(--warn); }
.stat.stat-err .stat-value { color: var(--danger); }
.stat.stat-ok .stat-value { color: var(--ok); }

.issues {
  margin-top: 12px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.issues table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.issues td, .issues th { padding: 6px 9px; border-bottom: 1px solid var(--border); text-align: left; }

/* ---------- Таблица предпросмотра ---------- */
.table-wrap {
  overflow: auto;
  max-height: 620px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table#preview-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table#preview-table th, table#preview-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
table#preview-table thead th {
  position: sticky;
  top: 0;
  background: #f2f5fa;
  z-index: 2;
  white-space: nowrap;
}
table#preview-table td.cell-long { background: #fdeaea; }
table#preview-table td.cell-url { max-width: 320px; word-break: break-all; }
table#preview-table td.cell-text { max-width: 360px; }
.status-ok { color: var(--ok); font-weight: 600; }
.status-warning { color: var(--warn); font-weight: 600; }
.status-error { color: var(--danger); font-weight: 600; }

.pager { justify-content: center; }

/* ---------- Прогресс ---------- */
.progress { margin-top: 12px; }
.progress-bar {
  height: 12px;
  background: #e7ecf3;
  border-radius: 7px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width .25s ease;
}
.progress-text { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ---------- Файлы ---------- */
.files { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}
.file-main { display: flex; flex-direction: column; gap: 3px; min-width: 260px; }
.file-name { font-weight: 600; font-size: 13px; }
.file-sub { font-size: 12px; color: var(--muted); }
.file-campaign { font-size: 12.5px; }
.file-hash { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }
.file-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tech { margin-top: 16px; }
.tech summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.tech-body {
  margin-top: 9px;
  background: #f8fafd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow: auto;
}

.upload-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}
.upload-panel h3 { margin-top: 0; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 20px 30px;
}
