:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --text: #172026;
  --muted: #66737d;
  --line: #dbe2e6;
  --accent: #146c75;
  --accent-dark: #0d535a;
  --danger: #b42318;
  --warn: #9a5b00;
  --ok: #067647;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.logout-form {
  margin-left: auto;
}

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

.login-panel {
  max-width: 420px;
  margin: 48px auto 0;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.login-form .field {
  display: grid;
  gap: 6px;
}

.login-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 650;
  background: #eaf3f4;
  color: var(--accent-dark);
}

.status-pill-muted {
  background: #eef1f3;
  color: var(--muted);
  font-weight: 600;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.audit-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 650;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 17px;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 14px;
}

.alert-ok {
  background: #ecfdf3;
  border-color: #abefc6;
  color: var(--ok);
}

.alert-error {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

.audit-form textarea {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.audit-form-upload {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-row-end {
  margin-top: 10px;
}

.parse-preview {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
}

.parse-preview.hidden {
  display: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
button {
  min-height: 42px;
  border-radius: 6px;
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 12px;
}

button {
  border: 0;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--line);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

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

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

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 24px 0 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.section-head a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #edf2f4;
  color: #314049;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge-running,
.badge-queued,
.badge-cancelling {
  background: #fff3cd;
  color: var(--warn);
}

.progress-step {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: #eaf3f4;
  color: var(--accent-dark);
}

.progress-meta .progress-step {
  margin-right: 8px;
}

.badge-finished,
.badge-info {
  background: #dcfae6;
  color: var(--ok);
}

.badge-failed,
.badge-error {
  background: #fee4e2;
  color: var(--danger);
}

.badge-cancelled {
  background: #f3e8ff;
  color: #7c3aed;
}

.badge-warning {
  background: #fff3cd;
  color: var(--warn);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric span,
.muted {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.metric strong {
  font-size: 22px;
}

.metric-accent {
  border-color: #b8dde1;
  background: linear-gradient(180deg, #ffffff, #f3fafb);
}

.metric-accent strong {
  color: var(--accent-dark);
}

.brief-panel {
  margin-bottom: 16px;
}

.brief-panel-ok p {
  margin: 0;
  color: var(--ok);
}

.brief-head {
  margin-bottom: 18px;
}

.brief-section {
  margin-top: 20px;
}

.brief-section:first-of-type {
  margin-top: 0;
}

.brief-section-title {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.brief-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.brief-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.brief-card-p0 {
  border-left: 4px solid var(--danger);
}

.brief-card-p1 {
  border-left: 4px solid var(--warn);
}

.brief-card-blocker,
.brief-card-блокер {
  border-left: 4px solid #7c3aed;
  background: #faf8ff;
}

.brief-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.brief-priority {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf2f4;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brief-rule {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.brief-card h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.brief-scope {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.brief-task {
  margin: 0;
  line-height: 1.45;
}

.brief-urls {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 12px;
}

.brief-urls a {
  color: var(--accent-dark);
}

.brief-table-wrap {
  margin-top: 0;
}

.brief-table-wrap table {
  min-width: 520px;
}

.brief-llm-panel {
  margin-bottom: 16px;
}

.brief-llm-final {
  border-color: #b8dde1;
  background: linear-gradient(180deg, #ffffff, #f3fafb);
}

.brief-markdown {
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 14px;
}

.brief-markdown-accent {
  font-size: 15px;
  font-weight: 500;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.break {
  overflow-wrap: anywhere;
}

.error {
  color: var(--danger);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.progress-panel {
  margin-bottom: 16px;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 700;
}

.progress-line {
  height: 8px;
  background: #edf2f4;
  border-radius: 999px;
  overflow: hidden;
}

.progress-line-lg {
  height: 12px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #1aa0ac);
  border-radius: 999px;
  transition: width 0.4s ease;
}

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

@keyframes progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.progress-meta,
.progress-detail {
  margin-top: 8px;
  font-size: 13px;
}

.progress-meta strong {
  display: block;
  margin-bottom: 2px;
}

.progress-cell {
  min-width: 220px;
}

.progress-cell .progress-meta .muted {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.tz-compliance-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tz-compliance-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #e8ecef);
  font-size: 14px;
}

.tz-compliance-item.tz-fail strong {
  color: #b42318;
}

.tz-compliance-item.tz-warn strong {
  color: #b54708;
}

.tz-compliance-item.tz-pass strong {
  color: #027a48;
}

.hidden {
  display: none !important;
}

.mono-sm {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.activity-feed {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.activity-item {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7fafb;
  border: 1px solid #e6eef0;
  font-size: 13px;
  animation: live-flash 0.45s ease;
}

.activity-item strong {
  color: var(--accent-dark);
}

.activity-item .muted {
  font-size: 12px;
}

@keyframes live-flash {
  from {
    background: #e7f4f5;
  }
  to {
    background: #f7fafb;
  }
}

tr.live-row-new td {
  animation: live-flash 0.8s ease;
}

#run-live-panel.is-polling .progress-panel {
  box-shadow: 0 0 0 1px rgba(20, 108, 117, 0.08);
}

.report-viewer-panel {
  margin-bottom: 18px;
}

.report-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.report-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.report-tab {
  border: 1px solid var(--line);
  background: #f8fafb;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.report-tab.is-active {
  background: #e7f4f5;
  border-color: #b9d9dd;
  color: var(--accent-dark);
}

.report-tab-count {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 500;
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.report-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.report-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.report-filter input,
.report-filter select {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}

.report-table-host {
  position: relative;
}

.report-table-wrap {
  max-height: min(62vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.report-table-wrap.is-loading {
  opacity: 0.55;
}

.report-table-wrap table.report-grid {
  width: auto;
  min-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.report-table-wrap col.col-url {
  width: 300px;
}

.report-table-wrap col.col-page-type {
  width: 96px;
}

.report-table-wrap col.col-schema {
  width: 200px;
}

.report-table-wrap col.col-status {
  width: 62px;
}

.report-table-wrap col.col-severity {
  width: 88px;
}

.report-table-wrap col.col-rule {
  width: 124px;
}

.report-table-wrap col.col-field {
  width: 88px;
}

.report-table-wrap col.col-line {
  width: 96px;
}

.report-table-wrap col.col-evidence {
  width: 300px;
}

.report-table-wrap col.col-task {
  width: 380px;
}

.report-table-wrap col.col-visible,
.report-table-wrap col.col-markup {
  width: 160px;
}

.report-table-wrap col.col-raw-json {
  width: 480px;
}

.report-table-wrap col.col-default {
  width: 140px;
}

.report-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f5;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #4b5c66;
  white-space: nowrap;
  vertical-align: bottom;
}

.report-table-wrap td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf1f3;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.45;
}

.report-table-wrap tbody tr:nth-child(even) td {
  background: #fafcfd;
}

.report-table-wrap tbody tr:hover td {
  background: #f2f8f9;
}

.report-table-wrap .col-url {
  width: 300px;
}

.report-table-wrap .report-url-link {
  display: block;
  word-break: break-all;
  font-size: 12px;
  line-height: 1.4;
  color: var(--accent-dark);
  text-decoration: none;
}

.report-table-wrap .report-url-link:hover {
  text-decoration: underline;
}

.report-table-wrap .col-page-type {
  width: 96px;
  font-size: 12px;
}

.report-table-wrap .col-schema {
  width: 200px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.report-table-wrap .col-status {
  width: 62px;
  text-align: center;
  white-space: nowrap;
}

.report-table-wrap .col-severity {
  width: 88px;
  white-space: nowrap;
}

.report-table-wrap .col-rule {
  width: 124px;
  font-size: 12px;
  word-break: break-word;
}

.report-table-wrap .col-field {
  width: 88px;
  font-size: 12px;
  word-break: break-word;
}

.report-table-wrap .col-line {
  width: 96px;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #4b5c66;
}

.report-table-wrap .col-evidence {
  width: 300px;
}

.report-table-wrap .col-task {
  width: 380px;
}

.report-table-wrap .col-visible,
.report-table-wrap .col-markup {
  width: 160px;
  font-size: 12px;
}

.report-table-wrap .col-raw-json {
  width: 480px;
}

.report-table-wrap .col-default {
  width: 140px;
}

.report-table-wrap .report-cell-text {
  display: block;
  word-break: normal;
  overflow-wrap: anywhere;
}

.report-json-preview {
  margin: 0;
  max-width: 640px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
  color: #24343d;
}

.report-pager {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 720px) {
  .form-row,
  .metrics {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 16px;
  }
}
