:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #66737c;
  --line: #dce3e7;
  --accent: #008c78;
  --accent-2: #f0b429;
  --success: #18894f;
  --success-soft: #e2f6eb;
  --change: #f28c28;
  --change-soft: #fff0df;
  --danger: #c4362e;
  --cad: #192128;
  --cad-line: rgba(194, 218, 219, 0.18);
  --shadow: 0 18px 45px rgba(21, 31, 37, 0.08);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.has-modal {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto 14px;
  max-width: 1440px;
}

.topbar h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.15;
}

.brand-head {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: auto;
  max-height: 66px;
  object-fit: contain;
  object-position: left center;
  width: clamp(320px, 30vw, 420px);
}

h2 {
  font-size: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

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

.build-badge {
  align-items: center;
  background: #ffd36b;
  border: 1px solid #d39a14;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(211, 154, 20, 0.18);
  color: #172026;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  min-height: 32px;
  padding: 0 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

.file-button,
.ghost-file-button,
.ghost-button,
.primary-button {
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: inline-flex;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

.file-button {
  background: var(--ink);
  color: #fff;
  position: relative;
}

.file-button input {
  inset: 0;
  opacity: 0;
  position: absolute;
}

.ghost-file-button {
  background: #fff;
  color: var(--ink);
  overflow: hidden;
  position: relative;
}

.ghost-file-button input {
  inset: 0;
  opacity: 0;
  position: absolute;
}

.ghost-button {
  background: #fff;
  color: var(--ink);
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  justify-content: center;
  width: 100%;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 auto 14px;
  max-width: 1440px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  min-height: 38px;
  padding: 0 14px;
}

.tab.is-active {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

main {
  margin: 0 auto;
  max-width: 1440px;
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

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

.stat span,
.muted {
  color: var(--muted);
}

.stat span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.stat strong {
  font-size: 28px;
  line-height: 1;
}

.collapsible-panel {
  display: block;
  width: 100%;
}

.collapsible-panel > summary {
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 14px;
  font-weight: 800;
  justify-content: space-between;
  list-style: none;
  min-height: 46px;
  padding: 0 14px;
  user-select: none;
}

.collapsible-panel > summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel > summary::after {
  color: var(--muted);
  content: "▾";
  font-size: 12px;
  line-height: 1;
  transition: transform 0.18s ease;
}

.collapsible-panel[open] > summary::after {
  transform: rotate(180deg);
}

.stats-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}

.stats-panel .stats-grid {
  margin: 0;
  padding: 12px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.workbench,
.plan-layout,
.issues-layout,
.changes-layout {
  display: grid;
  gap: 14px;
}

.workbench {
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
}

.list-panel,
.detail-panel,
.plan-side,
.plan-panel,
.issues-layout > section,
.changes-layout > section,
.issue-form,
.change-form,
.report-preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.detail-panel {
  min-height: 640px;
}

.filters {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding: 12px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.circuit-list,
.plan-list,
.issues-list,
.changes-list {
  max-height: 580px;
  overflow: auto;
}

.history-panel {
  margin-top: 12px;
}

.history-list {
  max-height: 320px;
}

.circuit-row,
.plan-row,
.issue-row {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 12px;
  text-align: left;
  width: 100%;
}

.circuit-row,
.plan-row {
  border-left: 4px solid transparent;
}

.circuit-row:hover,
.circuit-row.is-active,
.plan-row:hover,
.plan-row.is-active {
  background: #eef6f4;
}

.circuit-row.is-changed,
.plan-row.is-changed {
  background: var(--change-soft);
  border-left-color: var(--change);
}

.circuit-row.is-done,
.plan-row.is-done {
  background: var(--success-soft);
  border-left-color: var(--success);
}

.circuit-row.is-active.is-changed,
.plan-row.is-active.is-changed {
  background: #ffe4c5;
}

.circuit-row.is-active.is-done,
.plan-row.is-active.is-done {
  background: #d6f0e1;
}

.row-main {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.row-code {
  font-size: 18px;
  font-weight: 900;
}

.row-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.row-note {
  background: #fff7d6;
  border: 1px solid #f1da91;
  border-radius: 6px;
  color: #5c4700;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  margin-top: 3px;
  padding: 6px 8px;
}

.pill,
.stage-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 8px;
}

.pill {
  background: #edf1f3;
  color: var(--ink);
}

.pill.warn {
  background: #fff4cf;
}

.pill.change {
  background: #ffe2bf;
  color: #8a3e00;
}

.pill.success {
  background: #d9f3e4;
  color: #0f6a37;
}

.pill.danger {
  background: #ffe0dc;
  color: var(--danger);
}

.detail-panel {
  padding: 18px;
}

.detail-header {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.detail-title {
  display: grid;
  gap: 4px;
}

.detail-code {
  font-size: 32px;
  font-weight: 950;
  line-height: 1;
}

.detail-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.media-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 18px 0;
}

.media-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  overflow: hidden;
}

.media-frame {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: #eef2f4;
  display: flex;
  justify-content: center;
  position: relative;
}

.media-frame img {
  height: 100%;
  object-fit: contain;
  padding: 10px;
  position: relative;
  width: 100%;
  z-index: 2;
}

.image-placeholder {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  position: absolute;
}

.media-card:not(.is-missing) .image-placeholder {
  display: none;
}

.media-card figcaption {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 10px;
}

.media-card figcaption span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.media-card figcaption strong {
  line-height: 1.3;
}

.info-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.info-box span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.info-box strong {
  display: block;
  min-height: 20px;
}

.notes-card {
  background: #fff8dd;
  border: 1px solid #eed891;
  border-radius: 8px;
  margin: 14px 0;
  padding: 12px;
}

.notes-card span {
  color: #806200;
  display: block;
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.notes-card p {
  color: #3b3008;
  font-weight: 750;
  line-height: 1.45;
  margin: 0;
}

.notes-card.is-empty {
  background: #f7fafb;
  border-color: var(--line);
}

.notes-card.is-empty span,
.notes-card.is-empty p {
  color: var(--muted);
}

.section-title {
  font-size: 14px;
  font-weight: 900;
  margin: 18px 0 10px;
  text-transform: uppercase;
}

.check-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-card {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
}

.check-card input {
  accent-color: var(--accent);
  min-height: auto;
  width: auto;
}

.detail-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.detail-actions button,
.detail-actions a {
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 0 10px;
  text-decoration: none;
}

.detail-actions a {
  background: #fff;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  height: 100%;
  justify-content: center;
  min-height: 360px;
}

.plan-layout {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.plan-side {
  padding: 12px;
}

.plan-side input {
  margin-bottom: 10px;
}

.plan-panel {
  padding: 14px;
}

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

.plan-select {
  min-height: 40px;
  min-width: 160px;
  width: auto;
}

.zoom-controls {
  display: inline-flex;
  gap: 6px;
}

.icon-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 40px;
  min-width: 42px;
  padding: 0 10px;
}

.plan-canvas {
  --plan-ui-scale: 1;
  aspect-ratio: 1.414 / 1;
  background:
    linear-gradient(var(--cad-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--cad-line) 1px, transparent 1px),
    var(--cad);
  background-size: 48px 48px, 48px 48px, auto;
  border-radius: 8px;
  border: 1px solid #2a3942;
  min-height: 520px;
  overflow: hidden;
  position: relative;
  overscroll-behavior: contain;
  touch-action: none;
  user-select: none;
}

.plan-stage {
  inset: 0;
  position: absolute;
  will-change: transform;
}

.plan-canvas.is-pdf-embed {
  aspect-ratio: auto;
  background: #f3f5f6;
  border-color: var(--line);
  min-height: 760px;
  touch-action: auto;
  user-select: auto;
}

.plan-pdf-frame {
  background: #fff;
  border: 0;
  display: block;
  height: 760px;
  width: 100%;
}

.plan-bg-canvas {
  background: #f4f6f6;
  box-shadow: 0 0 0 1px rgba(16, 24, 32, 0.16);
  opacity: 0.9;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.plan-loading {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  left: 50%;
  padding: 7px 10px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.plan-empty {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  left: 50%;
  padding: 8px 10px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.plan-marker {
  align-items: center;
  background: var(--accent-2);
  border: 2px solid #101820;
  border-radius: 999px;
  color: #101820;
  display: flex;
  font-size: 10px;
  font-weight: 950;
  height: 30px;
  justify-content: center;
  min-height: 30px;
  padding: 0;
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30px;
  z-index: 3;
}

.plan-marker.plan-dot {
  border: 1px solid rgba(16, 24, 32, 0.72);
  height: 13px;
  min-height: 13px;
  width: 13px;
}

.plan-marker.is-selected {
  background: #00d0aa;
  box-shadow: 0 0 0 5px rgba(0, 208, 170, 0.18);
  z-index: 4;
}

.plan-marker.is-changed {
  background: var(--change);
  box-shadow: 0 0 0 5px rgba(242, 140, 40, 0.2);
}

.plan-marker.is-done {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(24, 137, 79, 0.18);
  color: #fff;
}

.plan-marker.is-muted {
  opacity: 0.32;
}

.plan-marker.is-centroid {
  background: #00d0aa;
  box-shadow: 0 0 0 12px rgba(0, 208, 170, 0.18);
  height: 34px;
  min-height: 34px;
  width: 34px;
  z-index: 5;
}

.plan-marker.is-centroid.is-changed {
  background: var(--change);
  box-shadow: 0 0 0 12px rgba(242, 140, 40, 0.22);
}

.plan-marker.is-centroid.is-done {
  background: var(--success);
  box-shadow: 0 0 0 12px rgba(24, 137, 79, 0.2);
}

.plan-text-match {
  background: rgba(255, 210, 0, 0.28);
  border: max(1px, calc(2px / var(--plan-ui-scale))) solid rgba(255, 120, 0, 0.96);
  border-radius: max(2px, calc(4px / var(--plan-ui-scale)));
  box-shadow: 0 0 0 max(1px, calc(2px / var(--plan-ui-scale))) rgba(255, 180, 0, 0.14);
  cursor: pointer;
  opacity: 0.98;
  padding: 0;
  pointer-events: auto;
  position: absolute;
  box-sizing: border-box;
  z-index: 4;
}

.plan-text-match.is-changed {
  background: rgba(255, 180, 0, 0.2);
  border-color: rgba(255, 180, 0, 0.96);
  box-shadow:
    0 0 0 max(1px, calc(3px / var(--plan-ui-scale))) rgba(255, 180, 0, 0.2),
    0 0 max(8px, calc(18px / var(--plan-ui-scale))) rgba(255, 180, 0, 0.36);
}

.plan-text-match.is-done {
  background: rgba(24, 137, 79, 0.18);
  border-color: rgba(24, 137, 79, 0.95);
  box-shadow:
    0 0 0 max(1px, calc(3px / var(--plan-ui-scale))) rgba(24, 137, 79, 0.18),
    0 0 max(8px, calc(18px / var(--plan-ui-scale))) rgba(24, 137, 79, 0.28);
}

.plan-text-fallback {
  background: rgba(255, 122, 0, 0.22);
  border: max(1px, calc(3px / var(--plan-ui-scale))) solid rgba(255, 106, 0, 0.98);
  border-radius: max(3px, calc(7px / var(--plan-ui-scale)));
  box-shadow:
    0 0 0 max(1px, calc(3px / var(--plan-ui-scale))) rgba(255, 122, 0, 0.18),
    0 0 max(8px, calc(18px / var(--plan-ui-scale))) rgba(255, 106, 0, 0.3);
  box-sizing: border-box;
  cursor: pointer;
  height: 18px;
  left: 0;
  opacity: 0.98;
  padding: 0;
  pointer-events: auto;
  position: absolute;
  top: 0;
  transform: translate(-50%, -50%);
  width: 28px;
  z-index: 4;
}

.plan-text-fallback.is-rect {
  border-radius: 8px;
  transform: none;
}

.plan-text-fallback.is-label-highlight {
  background: rgba(255, 210, 0, 0.28);
  border: max(1px, calc(2px / var(--plan-ui-scale))) solid rgba(255, 120, 0, 0.96);
  border-radius: max(2px, calc(4px / var(--plan-ui-scale)));
  box-shadow: 0 0 0 max(1px, calc(2px / var(--plan-ui-scale))) rgba(255, 180, 0, 0.14);
}

.plan-text-fallback.is-changed {
  background: rgba(255, 180, 0, 0.24);
  border-color: rgba(255, 180, 0, 0.98);
  box-shadow:
    0 0 0 max(1px, calc(3px / var(--plan-ui-scale))) rgba(255, 180, 0, 0.18),
    0 0 max(8px, calc(18px / var(--plan-ui-scale))) rgba(255, 180, 0, 0.34);
}

.plan-text-fallback.is-done {
  background: rgba(24, 137, 79, 0.22);
  border-color: rgba(24, 137, 79, 0.96);
  box-shadow:
    0 0 0 max(1px, calc(3px / var(--plan-ui-scale))) rgba(24, 137, 79, 0.16),
    0 0 max(8px, calc(18px / var(--plan-ui-scale))) rgba(24, 137, 79, 0.28);
}

.plan-label {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  left: 12px;
  padding: 6px 8px;
  position: absolute;
  top: 12px;
  z-index: 4;
}

.app-toast {
  background: rgba(23, 32, 38, 0.96);
  border-radius: 999px;
  bottom: 20px;
  box-shadow: 0 10px 28px rgba(16, 24, 32, 0.22);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  left: 50%;
  max-width: min(92vw, 420px);
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 3000;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-toast[data-state="success"] {
  background: rgba(16, 110, 73, 0.96);
}

.app-toast[data-state="error"] {
  background: rgba(148, 28, 38, 0.96);
}

.issues-layout {
  grid-template-columns: minmax(0, 1fr) minmax(290px, 360px);
}

.issues-layout-merged {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
}

.issues-side-stack {
  display: grid;
  gap: 14px;
}

.section-divider {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 900;
  gap: 10px;
  margin: 16px 0 10px;
  text-transform: uppercase;
}

.section-divider::after {
  background: var(--line);
  content: "";
  flex: 1 1 auto;
  height: 1px;
}

.issues-layout > section,
.changes-layout > section,
.issue-form,
.change-form,
.report-preview {
  padding: 16px;
}

.changes-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
}

.issue-form,
.change-form {
  display: grid;
  gap: 12px;
}

.issue-form label,
.change-form label,
.contact-modal label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 900;
  gap: 5px;
  text-transform: uppercase;
}

.contact-card {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.contact-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.contact-card strong {
  line-height: 1.35;
}

.contact-card .ghost-button {
  justify-content: center;
}

.issue-row,
.change-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 12px;
}

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

.issue-body {
  color: var(--muted);
  margin: 0;
}

.issue-timestamps {
  display: grid;
  gap: 3px;
  margin-top: 6px;
}

.issue-photo {
  border-radius: 8px;
  display: block;
  margin-top: 8px;
  max-height: 180px;
  max-width: 100%;
}

.section-head,
.row-actions,
.form-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.row-actions {
  flex-wrap: wrap;
  margin-top: 10px;
}

.form-actions {
  align-items: stretch;
}

.form-actions > * {
  flex: 1;
}

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

.report-preview {
  line-height: 1.5;
}

.report-preview h3 {
  margin: 18px 0 8px;
}

.report-preview table {
  border-collapse: collapse;
  width: 100%;
}

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

.contact-backdrop {
  align-items: center;
  background: rgba(15, 24, 30, 0.52);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.contact-backdrop.is-open {
  display: flex;
}

.contact-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(10, 18, 24, 0.28);
  display: grid;
  gap: 12px;
  max-width: 560px;
  padding: 18px;
  width: min(100%, 560px);
}

.contact-warning {
  background: #ffe0dc;
  border: 1px solid #f1aaa3;
  border-radius: 8px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  margin: 0;
  padding: 10px;
}

.pdf-backdrop {
  align-items: center;
  background: rgba(15, 24, 30, 0.72);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 40;
}

.pdf-backdrop.is-open {
  display: flex;
}

.pdf-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(10, 18, 24, 0.32);
  display: grid;
  gap: 12px;
  grid-template-rows: auto minmax(0, 1fr);
  height: min(92vh, 980px);
  padding: 18px;
  width: min(96vw, 1240px);
}

.pdf-modal-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.pdf-modal-head .primary-button {
  width: auto;
}

.pdf-frame-wrap {
  background: #edf2f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 0;
  overflow: hidden;
}

.pdf-frame {
  background: #fff;
  border: 0;
  display: block;
  height: 100%;
  width: 100%;
}

@media (max-width: 980px) {
  .stats-grid,
  .workbench,
  .plan-layout,
  .issues-layout,
  .changes-layout,
  .media-grid,
  .detail-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .report-layout,
  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .brand-logo {
    max-height: 62px;
    width: min(300px, 78vw);
  }

  .pdf-modal {
    height: min(100vh - 16px, 1000px);
    padding: 12px;
    width: min(100vw - 16px, 1000px);
  }

  .plan-canvas.is-pdf-embed {
    min-height: 560px;
  }

  .plan-pdf-frame {
    height: 560px;
  }

  .pdf-modal-head,
  .detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .pdf-modal-head .report-actions {
    width: 100%;
  }

  .pdf-modal-head .report-actions > * {
    flex: 1;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }

  .list-panel,
  .detail-panel {
    min-height: auto;
  }

  .plan-toolbar {
    align-items: stretch;
  }

  .plan-toolbar .report-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    width: 100%;
  }

  .plan-toolbar .plan-select {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }

  .plan-toolbar .zoom-controls {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .plan-toolbar .zoom-controls .icon-button {
    min-width: 0;
    width: 100%;
  }

  .plan-toolbar #openPlanPdf {
    min-width: 0;
    white-space: nowrap;
  }

  .plan-canvas {
    aspect-ratio: auto;
    min-height: 64vh;
  }
}

@media (max-width: 640px) {
  .plan-toolbar .report-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .plan-toolbar #openPlanPdf {
    grid-column: 1 / -1;
    width: 100%;
  }

  .plan-canvas {
    min-height: 68vh;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .tabs,
  .stats-grid,
  .view:not(#viewReport),
  .report-actions {
    display: none;
  }

  #viewReport {
    display: block;
  }

  .report-preview {
    border: 0;
    box-shadow: none;
  }
}
