:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --line: #cfd8e3;
  --text: #17202a;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-strong: #0b5e58;
  --danger: #b42318;
  --warning: #a15c07;
  --ok: #287a36;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--text);
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover,
button.active,
.tab.active {
  border-color: var(--accent);
  background: #e6f4f2;
  color: var(--accent-strong);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  background: #101820;
  color: #fff;
  border-bottom: 4px solid var(--accent);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 290px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #5eead4;
  border-radius: 6px;
  font-weight: 800;
  color: #5eead4;
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.15;
}

.brand p {
  margin-top: 2px;
  color: #b9c5d2;
  font-size: 12px;
}

.project-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.project-bar input {
  min-width: 230px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 420px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px;
  overflow: auto;
}

.properties-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

.tool-grid,
.control-stack {
  display: grid;
  gap: 8px;
}

.tool-grid {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}

.tools-panel > label,
.properties-panel label {
  margin-bottom: 12px;
}

.checkline,
.mini-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkline input,
.mini-check input {
  width: auto;
}

.metric-card,
.summary-grid > div {
  display: grid;
  gap: 4px;
  padding: 10px;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric-card span,
.summary-grid span {
  color: var(--muted);
  font-size: 12px;
}

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

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #f8fafc;
}

#roadCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.canvas-hud {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.canvas-hud span {
  padding: 7px 10px;
  background: rgba(16, 24, 32, 0.86);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  min-width: 0;
  padding: 0 6px;
}

.tab-panel {
  display: none;
}

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

.section-head,
.select-row,
.layer-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.select-row {
  align-items: stretch;
}

.select-row label {
  flex: 1;
}

.layers-list {
  display: grid;
  gap: 10px;
}

.layer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.layer-title input {
  font-weight: 750;
}

.layer-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 84px 58px;
  gap: 8px;
  align-items: end;
}

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

.data-table,
.report-view table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  background: #edf2f7;
  color: #344256;
}

.compliance-list {
  display: grid;
  gap: 8px;
}

.compliance-item {
  border-left: 4px solid var(--muted);
  background: #f8fafc;
  padding: 10px;
  border-radius: 6px;
}

.compliance-item p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.compliance-item small {
  color: #475569;
}

.compliance-item.passed {
  border-left-color: var(--ok);
}

.compliance-item.warning {
  border-left-color: var(--warning);
}

.compliance-item.failed {
  border-left-color: var(--danger);
}

.notification-panel {
  display: grid;
  gap: 8px;
  padding: 10px 14px;
}

.notice {
  padding: 10px 12px;
  border: 1px solid #b7d8d4;
  background: #ecfdf9;
  color: #134e4a;
  border-radius: 6px;
  font-size: 13px;
}

.notice.error {
  display: grid;
  gap: 4px;
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.cut-view {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 96vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 180ms ease;
  z-index: 20;
  padding: 16px;
  overflow: auto;
}

.cut-view.open {
  transform: translateX(0);
}

.cut-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.cut-head p {
  margin-top: 4px;
  color: var(--muted);
}

.cut-canvas {
  min-height: 420px;
  display: grid;
  align-content: start;
  justify-items: stretch;
  gap: 2px;
  padding: 20px;
  background: #eef2f5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cut-canvas.has-failures {
  background: #fff1f2;
  border-color: #ef4444;
  box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.cut-canvas.has-warnings {
  background: #fff7ed;
  border-color: #f59e0b;
}

.cut-status {
  display: grid;
  gap: 3px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.cut-status span {
  color: var(--muted);
  font-size: 13px;
}

.cut-status.failed {
  border-color: #ef4444;
  background: #fee2e2;
  color: #991b1b;
}

.cut-status.failed span {
  color: #7f1d1d;
}

.cut-status.warning {
  border-color: #f59e0b;
  background: #ffedd5;
  color: #92400e;
}

.cut-status.passed {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.cut-section-stack {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.cut-layer {
  min-width: 220px;
  display: grid;
  place-items: center;
  gap: 2px;
  color: #fff;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.cut-layer.violates {
  outline: 3px solid #ef4444;
  outline-offset: -3px;
}

.cut-layer span {
  font-size: 12px;
}

.cut-controls,
.cut-compliance {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.cut-controls h3,
.cut-compliance h3 {
  margin: 0;
  font-size: 13px;
  color: #344256;
}

.cut-slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: end;
}

.cut-slider-row label {
  margin: 0;
}

.cut-slider-row input[type="range"] {
  padding: 0;
}

.cut-slider-row output {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  text-align: right;
}

.cut-layer-control {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.cut-layer-control > strong {
  font-size: 13px;
}

.fixed-note {
  color: var(--muted);
  font-size: 12px;
}

.cut-compliance-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-left: 4px solid #f59e0b;
  background: #fff7ed;
  border-radius: 6px;
}

.cut-compliance-item.failed {
  border-left-color: #ef4444;
  background: #fee2e2;
  color: #991b1b;
}

.cut-compliance-item span {
  color: inherit;
  font-size: 13px;
}

dialog {
  width: min(720px, 94vw);
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

dialog header,
.report-view header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.project-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.project-list article {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-list small {
  display: block;
  color: var(--muted);
}

.report-view {
  margin: 18px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-view h2 {
  margin-top: 18px;
}

.legal {
  padding: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 240px minmax(360px, 1fr);
  }

  .properties-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 520px;
  }
}

@media (max-width: 780px) {
  .topbar,
  .project-bar,
  .workspace {
    display: block;
  }

  .project-bar {
    margin-top: 12px;
  }

  .project-bar > * {
    margin: 4px 2px;
  }

  .canvas-wrap {
    height: 58vh;
  }

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

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

  .topbar,
  .workspace,
  .notification-panel,
  .cut-view,
  dialog {
    display: none !important;
  }

  .report-view {
    display: block !important;
    border: 0;
    margin: 0;
    padding: 0;
  }

  .report-view button {
    display: none;
  }

  table {
    page-break-inside: avoid;
  }
}
