:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d7dde7;
  --primary: #176b87;
  --primary-strong: #0d4f67;
  --accent: #b84e2f;
  --critical: #d92d20;
  --major: #f79009;
  --minor: #667085;
  --info: #1570ef;
  --critical-bg: #fee4e2;
  --major-bg: #fef0c7;
  --minor-bg: #eaecf0;
  --info-bg: #d1e9ff;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(23, 107, 135, 0.08), rgba(246, 248, 251, 0) 300px),
    var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 32px 28px 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.05;
}

.header-status {
  min-width: 180px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  gap: 22px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 0 28px 32px;
}

.sidebar,
.results {
  min-width: 0;
}

.upload-panel,
.rules-panel,
.results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 18px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 20px;
  border: 2px dashed #98a2b3;
  border-radius: 8px;
  background: #f9fafb;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.is-dragover {
  border-color: var(--primary);
  background: #eef8fb;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  position: relative;
  display: block;
  width: 54px;
  height: 54px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0;
}

.drop-icon::before {
  content: "+";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -56%);
  font-size: 34px;
  line-height: 1;
}

.drop-title {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.drop-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--text);
}

.primary-button {
  width: 100%;
  height: 46px;
  margin-top: 16px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:disabled {
  background: #98a2b3;
  cursor: not-allowed;
}

.rules-panel {
  margin-top: 18px;
  padding: 18px;
}

.rules-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.rules-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.results {
  overflow: hidden;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric {
  padding: 18px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.tabs,
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.tab,
.filter,
.jump-button,
.export-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.tab,
.filter,
.export-button {
  height: 36px;
  padding: 0 14px;
}

.export-button {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.export-button:disabled {
  border-color: var(--line);
  color: #98a2b3;
  cursor: not-allowed;
}

.tab.is-active,
.filter.is-active {
  border-color: var(--primary);
  background: #e8f4f8;
  color: var(--primary-strong);
}

.tab-panel {
  display: none;
  min-height: 520px;
}

.tab-panel.is-active {
  display: block;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 520px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.document-view {
  max-height: 68vh;
  overflow: auto;
  padding: 20px;
  background: #eef1f5;
}

.page {
  max-width: 840px;
  margin: 0 auto 18px;
  padding: 36px 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.08);
}

.page-label {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.paragraph {
  position: relative;
  margin: 0 0 10px;
  white-space: pre-wrap;
  line-height: 1.55;
  font-family: "Times New Roman", Times, serif;
  font-size: 17px;
}

.paragraph.is-heading {
  font-weight: 800;
}

.paragraph.is-list {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  padding-left: 18px;
}

.list-marker {
  color: var(--primary-strong);
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  text-align: right;
}

.table-wrap {
  margin: 12px 0 16px;
  overflow-x: auto;
}

.document-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-family: "Times New Roman", Times, serif;
  font-size: 15px;
}

.document-table td {
  min-width: 120px;
  border: 1px solid #8a93a3;
  padding: 7px 8px;
  vertical-align: top;
}

.document-table .paragraph {
  margin-bottom: 4px;
  font-size: 15px;
  line-height: 1.25;
}

.paragraph.is-caption {
  color: #243044;
}

.paragraph mark {
  border-radius: 3px;
  padding: 1px 2px;
  cursor: help;
}

.paragraph mark[data-severity="critical"] {
  background: var(--critical-bg);
  box-shadow: inset 0 -2px 0 var(--critical);
}

.paragraph mark[data-severity="major"] {
  background: var(--major-bg);
  box-shadow: inset 0 -2px 0 var(--major);
}

.paragraph mark[data-severity="minor"] {
  background: var(--minor-bg);
  box-shadow: inset 0 -2px 0 var(--minor);
}

.paragraph mark[data-severity="info"] {
  background: var(--info-bg);
  box-shadow: inset 0 -2px 0 var(--info);
}

.paragraph.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.issue-list {
  display: grid;
  gap: 12px;
  max-height: 62vh;
  overflow: auto;
  padding: 18px;
}

.issue-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.issue-card[data-severity="critical"] {
  border-left-color: var(--critical);
}

.issue-card[data-severity="major"] {
  border-left-color: var(--major);
}

.issue-card[data-severity="minor"] {
  border-left-color: var(--minor);
}

.issue-card[data-severity="info"] {
  border-left-color: var(--info);
}

.issue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.severity {
  border-radius: 999px;
  padding: 4px 9px;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.severity[data-severity="critical"] {
  background: var(--critical);
}

.severity[data-severity="major"] {
  background: var(--major);
}

.severity[data-severity="minor"] {
  background: var(--minor);
}

.severity[data-severity="info"] {
  background: var(--info);
}

.jump-button {
  height: 30px;
  padding: 0 10px;
}

.issue-card h3 {
  margin: 10px 0 6px;
  font-size: 17px;
}

.issue-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.issue-card .recommendation {
  margin-top: 8px;
  color: #344054;
}

.issue-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.issue-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.issue-card dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.metadata {
  margin: 0;
  max-height: 68vh;
  overflow: auto;
  padding: 18px;
  color: #344054;
  background: #f9fafb;
  font-size: 13px;
  line-height: 1.5;
}

.issue-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(430px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(23, 32, 51, 0.18);
  color: var(--text);
  overflow: hidden;
  pointer-events: none;
}

.issue-tooltip table {
  width: 100%;
  border-collapse: collapse;
}

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

.issue-tooltip tr:last-child th,
.issue-tooltip tr:last-child td {
  border-bottom: 0;
}

.issue-tooltip th {
  width: 105px;
  background: #f6f8fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.issue-tooltip td {
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 920px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .summary-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .metric:nth-child(2) {
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .app-header,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .page {
    padding: 24px 20px;
  }

  .issue-card dl {
    grid-template-columns: 1fr;
  }
}
