:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #dce3e6;
  --text: #1d2529;
  --muted: #66747b;
  --accent: #087c9b;
  --accent-dark: #065f76;
  --warn: #9b6a08;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 56px;
  padding: 0 22px;
  background: #0b7896;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.brand { color: #fff; font-size: 22px; font-weight: 800; letter-spacing: 0; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar a, .topbar button { color: #fff; }
.inline-form { display: inline; }
.inline-form button { background: transparent; border: 0; cursor: pointer; font: inherit; padding: 0; }
.ai-meter {
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 6px;
  padding: 7px 10px;
  font-weight: 700;
  white-space: nowrap;
}
.page { width: min(1320px, calc(100% - 32px)); margin: 22px auto 60px; }
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}
h1, h2 { margin: 0 0 8px; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
p { color: var(--muted); }
.panel, .table-wrap, .metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.narrow { max-width: 560px; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; }
th { color: #36474f; font-size: 12px; text-transform: uppercase; }
.center-col { text-align: center; }
.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}
.button.secondary { background: #edf3f5; color: var(--accent-dark); }
.secondary-button { background: #edf3f5; color: var(--accent-dark); }
button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.form-grid p { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; color: var(--text); }
.form-grid p:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.form-grid p:has(input[type="checkbox"]) label {
  margin: 0;
}
.form-grid p:has(input[required]) label::after,
.form-grid p:has(textarea[required]) label::after,
.form-grid p:has(select[required]) label::after {
  content: " *";
  color: #c62828;
  font-weight: 800;
}
.readonly-field input {
  background: #eef3f5;
  color: var(--muted);
}
.required-note {
  grid-column: 1 / -1;
  color: var(--muted);
}
.required-note span { color: #c62828; font-weight: 800; }
.compact-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.compact-form p { margin: 0; }
.compact-form label { display: block; margin-bottom: 5px; color: var(--muted); }
.form-grid.two-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }
input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #bcc9ce;
  border-radius: 4px;
  padding: 8px 9px;
  font: inherit;
}
input[type="checkbox"] {
  width: auto;
  min-height: 0;
  transform: scale(1.1);
  accent-color: var(--accent);
}
textarea { resize: vertical; }
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.hint {
  margin-top: -2px;
  font-size: 13px;
  line-height: 1.35;
}
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #edf3f5;
  color: var(--accent-dark);
  font-size: 12px;
  cursor: help;
}
.tooltip::after {
  content: attr(data-tooltip);
  display: none;
  position: absolute;
  top: 24px;
  left: 0;
  max-width: 320px;
  width: max-content;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 6px 22px rgba(0,0,0,.14);
  color: var(--text);
  line-height: 1.35;
  z-index: 20;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
}
.tooltip:hover::after,
.tooltip:focus::after {
  display: block;
}
.tag {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 12px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.suggestion {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}
.suggestion h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.suggestion-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.suggestion-option input {
  margin-top: 3px;
}
.suggestion-option span {
  display: grid;
  gap: 4px;
}
.suggestion-option em,
.suggestion-option small {
  color: var(--muted);
  font-style: normal;
}
.text-preview {
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f1f4f5;
  padding: 12px;
  border-radius: 6px;
}
.review-image {
  width: 100%;
  max-height: 640px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  margin-bottom: 14px;
}
.expedient {
  min-height: 420px;
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.metric span { display: block; color: var(--muted); margin-bottom: 4px; }
.metric strong { font-size: 22px; }
.message { padding: 10px 12px; border-radius: 6px; background: #eef7f0; color: #1d5d2a; }
.message.error { background: #fff2f2; color: #8d1f1f; }
.back-button {
  margin-bottom: 16px;
  background: #edf3f5;
  color: var(--accent-dark);
}
.divergence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.divergence p { flex-basis: 100%; margin: 0; }

@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr; gap: 10px; padding: 12px 16px; }
  .topbar nav { flex-wrap: wrap; }
  .grid.two, .grid.three, .grid.four, .form-grid.two-cols { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
