:root {
  --paper: #f5f6f2;
  --surface: #fbfbf7;
  --line: #2f3532;
  --muted-line: #9aa19d;
  --text: #151917;
  --muted: #66706b;
  --soft: #e6e9e2;
  --soft-2: #d6dcd4;
  --ink: #232a28;
  --green: #3dde16;
  --green-dark: #159400;
  --amber: #f1c232;
  --red: #e32014;
  --blue: #3f80ff;
  --cyan: #48c4d8;
  --shadow: 0 18px 48px rgba(18, 24, 20, 0.12);
  --survey-col-1: 6%;
  --survey-col-2: 6%;
  --survey-col-3: 12%;
  --survey-col-4: 15%;
  --survey-col-5: 13%;
  --survey-col-6: 10%;
  --survey-col-7: 9%;
  --survey-col-8: 8%;
  --survey-col-9: 13%;
  --survey-col-10: 8%;
  --survey-cols: var(--survey-col-1) var(--survey-col-2) var(--survey-col-3) var(--survey-col-4) var(--survey-col-5) var(--survey-col-6) var(--survey-col-7) var(--survey-col-8) var(--survey-col-9) var(--survey-col-10);
  --survey-row-height: 34px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: Bahnschrift, Aptos, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(47, 53, 50, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(47, 53, 50, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 26px 26px;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
  min-height: 42px;
  cursor: pointer;
  transition:
    background 140ms ease,
    transform 140ms ease,
    border-color 140ms ease;
}

button:hover {
  background: #fff;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

input {
  width: 100%;
  border: 1px solid var(--muted-line);
  background: #fff;
  padding: 7px 9px;
  min-height: 35px;
  color: var(--text);
}

svg {
  display: block;
}

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

.nav-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 12px;
  border-right: 2px solid var(--line);
  background: #e9ece4;
  z-index: 3;
}

.brand-block {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-bottom: 12px;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--green);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.brand-copy {
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-button {
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 9px 5px;
  min-height: 66px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.nav-button svg,
.icon-button svg,
.reopen-button svg,
.export-list svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button span {
  font-size: 11px;
  text-transform: uppercase;
}

.nav-button.active {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.tour-launch-button {
  border-color: rgba(47, 53, 50, 0.35);
  background: #f6ffe9;
  color: var(--ink);
}

.console {
  min-width: 0;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.job-context {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.eyebrow,
.section-header,
.sync-label {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.job-context .eyebrow {
  font-size: 11px;
  color: var(--muted);
}

.job-context strong {
  font-size: 24px;
  line-height: 1;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.job-actions button {
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.job-actions .file-button {
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  justify-self: end;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  font-size: 18px;
}

.status-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: var(--green);
}

.status-dot.warn {
  background: var(--amber);
}

.status-dot.off {
  background: var(--red);
}

.status-dot.red {
  background: var(--red);
}

.status-dot.blink-slow {
  animation: blinkStatus 1s ease-in-out infinite;
}

.status-dot.blink-medium {
  animation: blinkStatus 0.55s ease-in-out infinite;
}

.status-dot.blink-fast {
  animation: blinkStatus 0.25s ease-in-out infinite;
}

@keyframes blinkStatus {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.18;
  }
}

.qc-pill,
.system-time,
.cloud-pill {
  display: grid;
  grid-template-columns: auto;
  align-items: center;
  gap: 2px;
  min-height: 38px;
  padding: 0 4px;
  border: 0;
  background: transparent;
}

.system-time,
.cloud-pill {
  min-width: 86px;
}

.qc-pill span,
.system-time span,
.cloud-pill span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.qc-pill strong,
.system-time strong,
.cloud-pill strong {
  color: var(--ink);
  font-size: 19px;
  line-height: 1;
}

.system-time strong {
  font-variant-numeric: tabular-nums;
}

.cloud-pill {
  min-height: 38px;
  text-align: left;
}

.cloud-pill:hover {
  background: transparent;
  transform: none;
}

.cloud-pill.connected strong {
  color: var(--green-dark);
}

.cloud-pill.error strong {
  color: var(--red);
}

.battery {
  position: relative;
  display: grid;
  place-items: center;
  width: 50px;
  height: 24px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.battery::after {
  content: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.live-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: auto minmax(275px, 1fr);
  gap: 18px;
  align-items: stretch;
  min-height: calc(100vh - 128px);
}

.pipe-panel,
.toolface-panel,
.survey-panel,
.trajectory-panel,
.form-panel,
.tool-status-panel,
.lifecycle-panel,
.export-panel,
.market-gap-panel {
  border: 2px solid var(--line);
  background: rgba(251, 251, 247, 0.94);
}

.pipe-panel,
.toolface-panel {
  min-height: 438px;
}

.pipe-panel {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.toolface-panel {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.survey-panel {
  grid-column: 3 / 5;
  grid-row: 1 / 3;
}

.trajectory-panel {
  grid-column: 1 / 3;
  grid-row: 2 / 3;
}

.pipe-panel {
  display: grid;
  grid-template-rows: auto auto;
  align-content: space-evenly;
  gap: 18px;
  padding: 13px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.icon-button {
  display: inline-grid;
  width: 36px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  border-radius: 4px;
}

.pipe-counter {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 170px;
  min-height: 206px;
  margin: 0 auto;
  border: 2px solid var(--line);
  background: #fff;
}

.pipe-counter.small {
  width: 68px;
  min-height: 84px;
  margin: 0;
}

.pipe-counter strong {
  font-size: 66px;
  font-weight: 500;
  line-height: 0.95;
}

.pipe-counter.small strong {
  font-size: 44px;
}

.pipe-counter span:last-child {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.pipe-bit-depth {
  display: grid;
  gap: 4px;
  justify-items: center;
  width: calc(100% - 18px);
  padding: 12px 8px 8px;
  border-bottom: 1px solid var(--muted-line);
}

.pipe-bit-depth > span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.pipe-bit-depth strong {
  font-size: 28px;
  line-height: 1;
}

.pipe-bit-depth em {
  font-size: 13px;
  font-style: normal;
}

.top-notch {
  position: absolute;
  top: -2px;
  width: 36px;
  height: 13px;
  background: var(--line);
}

.rod-controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  justify-items: center;
}

.rod-controls button {
  min-height: 66px;
  font-size: 48px;
  line-height: 1;
}

.rod-controls button {
  width: 100%;
}

.rod-controls button[data-action="rod-partial"] {
  min-height: 46px;
  font-size: 18px;
}

.rod-controls [data-action="rod-full"] {
  order: 1;
}

.rod-controls #pipeMinus,
.rod-controls [data-action="rod-decrease"] {
  order: 2;
}

.rod-controls [data-action="rod-full"] {
  grid-column: 1 / 4;
}

.rod-controls [data-action="rod-decrease"] {
  grid-column: 4 / 7;
}

.rod-controls [data-fraction="0.25"] {
  order: 3;
  grid-column: 1 / 3;
}

.rod-controls [data-fraction="0.5"] {
  order: 4;
  grid-column: 3 / 5;
}

.rod-controls [data-fraction="0.75"] {
  order: 5;
  grid-column: 5 / 7;
}

.readout,
.automation-grid div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--muted-line);
  background: #fff;
}

.readout span,
.automation-grid span {
  min-width: 0;
  color: var(--muted);
}

.good {
  color: var(--green-dark);
}

.toolface-panel {
  display: grid;
  align-content: center;
  gap: 24px;
  padding: 18px;
}

.toolface {
  --tf-angle: 0deg;
  --pointer-radius: 98px;
  --hour-radius: 130px;
  position: relative;
  display: grid;
  width: min(100%, 300px);
  aspect-ratio: 1;
  place-items: center;
  margin: 0 auto;
  border: 2px solid var(--line);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, transparent 0 36%, var(--line) 36.3% 36.8%, transparent 37%),
    #fff;
}

.toolface::before,
.toolface::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.toolface::before {
  inset: 38px;
  border: 1.5px solid var(--line);
}

.toolface::after {
  inset: 8px;
  border: 1px solid rgba(47, 53, 50, 0.35);
}

.hour {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 21px;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(var(--hour-radius) * -1)) rotate(calc(var(--angle) * -1));
  transform-origin: center;
}

.pointer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-bottom: 25px solid #cfd4cf;
  filter: drop-shadow(0 0 0 var(--line));
  transform: translate(-50%, -50%) rotate(var(--tf-angle)) translateY(calc(var(--pointer-radius) * -1));
  transform-origin: center;
  transition: transform 700ms ease;
}

.toolface strong {
  font-size: 78px;
  font-weight: 500;
  line-height: 1;
  z-index: 1;
}

.primary-actions,
.decision-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.primary-actions:has(button:only-child) {
  grid-template-columns: 1fr;
}

.primary-actions button,
.decision-row button,
.export-list button {
  min-height: 58px;
  font-size: 20px;
  background: #fff;
}

.distance-block {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 2px solid var(--line);
  background: #fff;
}

.distance-block.small {
  min-width: 230px;
}

.distance-block span {
  color: var(--muted);
}

.distance-block strong {
  font-size: 50px;
  line-height: 1;
  font-weight: 500;
}

.distance-block em {
  font-size: 28px;
  font-style: normal;
}

.survey-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.table-scroll {
  overflow-x: auto;
  min-height: 0;
}

.survey-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 0;
  background: #fff;
}

.survey-table th,
.survey-table td {
  height: var(--survey-row-height);
  border: 1px solid var(--muted-line);
  padding: 4px 6px;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.survey-table th {
  background: #f0f1ec;
  font-weight: 500;
}

.survey-table th:nth-child(1),
.survey-table td:nth-child(1) {
  width: var(--survey-col-1);
}

.survey-table th:nth-child(2),
.survey-table td:nth-child(2) {
  width: var(--survey-col-2);
}

.survey-table th:nth-child(3),
.survey-table td:nth-child(3) {
  width: var(--survey-col-3);
}

.survey-table th:nth-child(4),
.survey-table td:nth-child(4) {
  width: var(--survey-col-4);
  text-align: left;
}

.survey-table th:nth-child(5),
.survey-table td:nth-child(5) {
  width: var(--survey-col-5);
}

.survey-table th:nth-child(6),
.survey-table td:nth-child(6) {
  width: var(--survey-col-6);
}

.survey-table th:nth-child(7),
.survey-table td:nth-child(7) {
  width: var(--survey-col-7);
}

.survey-table th:nth-child(8),
.survey-table td:nth-child(8) {
  width: var(--survey-col-8);
}

.survey-table th:nth-child(9),
.survey-table td:nth-child(9) {
  width: var(--survey-col-9);
}

.survey-table th:nth-child(10),
.survey-table td:nth-child(10) {
  width: var(--survey-col-10);
}

.survey-table tr.pending td {
  background: #f7ffe9;
}

.survey-table tr.current-row td {
  background: #e9ffe1;
  box-shadow: inset 0 2px 0 var(--green-dark), inset 0 -2px 0 var(--green-dark);
}

.survey-table tr.pending-row td {
  color: var(--muted);
  font-style: italic;
}

.survey-table tr.entry-row td {
  background: #eef2ec;
  color: var(--ink);
  font-weight: 600;
}

.survey-table tr.reopen-pending-row td {
  background: #f1f2ed;
  color: #74796f;
  box-shadow: inset 3px 0 0 var(--muted);
}

.survey-table tr.reopen-pending-row .survey-action-cell {
  color: transparent;
}

.survey-table tr.survey-selectable-row {
  cursor: pointer;
}

.survey-table tr.selected-survey-row td {
  background: #fff5cc;
  box-shadow: inset 0 2px 0 #d59d16, inset 0 -2px 0 #d59d16;
}

.survey-table tr.selected-survey-row td:first-child {
  box-shadow: inset 4px 0 0 #d59d16, inset 0 2px 0 #d59d16, inset 0 -2px 0 #d59d16;
}

.survey-table tr.selected-survey-row:focus-visible td {
  outline: 2px solid #d59d16;
  outline-offset: -2px;
}

.row-action-heading,
.survey-action-cell {
  text-align: right;
}

.survey-action-cell {
  padding-right: 6px;
}

.reopen-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-color: var(--muted-line);
  background: #fff;
  color: var(--ink);
}

.reopen-button:hover,
.reopen-button:focus-visible {
  border-color: var(--green-dark);
  color: var(--green-dark);
}

.reopen-button svg {
  width: 16px;
  height: 16px;
}

.last-static {
  display: grid;
  text-align: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: visible;
}

.last-static > span {
  padding: 8px 10px;
  background: #f1f2ed;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-align: left;
}

.static-values {
  display: grid;
  grid-template-columns: var(--survey-cols);
  width: 100%;
  min-width: 0;
}

.static-values > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: var(--survey-row-height);
  min-height: var(--survey-row-height);
  padding: 0 6px;
  border-top: 1px solid var(--muted-line);
  border-right: 1px solid var(--muted-line);
  border-bottom: 1px solid var(--muted-line);
  background: #fff;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.static-input {
  width: 100%;
  height: calc(var(--survey-row-height) - 8px);
  min-height: 0;
  padding: 2px 4px;
  border: 1px solid transparent;
  background: #fff;
  text-align: center;
  line-height: 1.1;
}

.static-input:focus {
  border-color: var(--green-dark);
  outline: 0;
  box-shadow: inset 0 -2px 0 var(--green-dark);
}

.static-values > *:last-child {
  border-right: 0;
}

.decision-row {
  padding: 14px;
}

.decision-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.secondary {
  background: #f4f5f0;
}

.trajectory-panel {
  min-width: 0;
}

.sync-label {
  padding: 5px 8px;
  background: #e8f4ff;
  color: #1e5aa8;
  font-size: 10px;
}

.profile-chart {
  padding: 14px;
  background: #fff;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.profile-chart.panning {
  cursor: grabbing;
}

.profile-chart svg {
  width: 100%;
  height: auto;
  min-height: 180px;
}

.profile-chart path {
  fill: none;
}

.profile-chart path[hidden] {
  display: none;
}

.terrain {
  stroke: #787f7a;
  stroke-width: 2;
  stroke-dasharray: 7 7;
}

.planned {
  stroke: var(--blue);
  stroke-width: 6;
  opacity: 0.55;
}

.actual {
  stroke: var(--green-dark);
  stroke-width: 5;
}

.profile-grid line {
  stroke: rgba(47, 53, 50, 0.22);
  stroke-width: 1;
}

.profile-axis {
  color: var(--muted);
  font-size: 11px;
}

.profile-axis line {
  stroke: rgba(47, 53, 50, 0.52);
  stroke-width: 1;
}

.profile-axis text {
  fill: currentColor;
  dominant-baseline: middle;
}

.profile-axis-line {
  stroke: var(--line);
  stroke-width: 1.4;
}

.profile-axis-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 500;
}

.profile-chart circle {
  fill: var(--surface);
  stroke: var(--line);
  stroke-width: 3;
}

.profile-chart circle[data-survey-uid] {
  cursor: pointer;
}

.profile-current {
  fill: var(--green);
  stroke: var(--line);
  stroke-width: 3;
}

.profile-point {
  fill: var(--surface);
  stroke: var(--line);
  stroke-width: 2;
}

.profile-point-selected {
  fill: #fff2b0;
  stroke: #d59d16;
  stroke-width: 4;
}

.automation-grid {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.toast-line {
  margin: 0 14px 14px;
  min-height: 42px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

@media (min-width: 1121px) and (orientation: landscape) {
  body:has(.view[data-view-panel="live"].active) {
    overflow: hidden;
  }

  body:has(.view[data-view-panel="live"].active) .console {
    height: 100vh;
    overflow: hidden;
    padding: 12px;
  }

  .topbar {
    min-height: 58px;
    margin-bottom: 12px;
    padding: 8px 12px;
  }

  .live-layout {
    height: calc(100vh - 94px);
    min-height: 0;
    gap: 12px;
    grid-template-rows: minmax(0, 0.55fr) minmax(0, 0.45fr);
  }

  .pipe-panel,
  .toolface-panel,
  .survey-panel,
  .trajectory-panel {
    min-height: 0;
    overflow: hidden;
  }

  .pipe-panel {
    gap: 10px;
    padding: 10px;
  }

  .pipe-counter {
    max-width: 150px;
    min-height: clamp(145px, 24vh, 190px);
  }

  .pipe-counter strong {
    font-size: clamp(44px, 7vh, 60px);
  }

  .pipe-bit-depth {
    gap: 3px;
    padding: 10px 6px 7px;
  }

  .pipe-bit-depth strong {
    font-size: clamp(22px, 3.2vh, 28px);
  }

  .rod-controls {
    gap: 6px;
  }

  .rod-controls button {
    min-height: clamp(42px, 7vh, 58px);
  }

  .rod-controls button {
    font-size: clamp(34px, 6vh, 46px);
  }

  .rod-controls button[data-action="rod-partial"] {
    min-height: clamp(32px, 5vh, 42px);
    font-size: 17px;
  }

  .toolface-panel {
    align-content: space-evenly;
    gap: 10px;
    padding: 10px;
  }

  .toolface {
    --pointer-radius: clamp(72px, 11.2vh, 96px);
    --hour-radius: clamp(96px, 14.8vh, 128px);
    width: min(100%, clamp(220px, 32vh, 292px));
  }

  .hour {
    font-size: clamp(16px, 2.2vh, 20px);
  }

  .toolface strong {
    font-size: clamp(54px, 8vh, 74px);
  }

  .primary-actions {
    gap: 8px;
  }

  .primary-actions button,
  .decision-row button {
    min-height: clamp(40px, 6vh, 50px);
    font-size: clamp(16px, 2.2vh, 20px);
  }

  .survey-panel {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  .section-header {
    min-height: 34px;
  }

  .table-scroll {
    min-height: 0;
    overflow: auto;
  }

  .survey-table th,
  .survey-table td {
    padding: 4px 6px;
    font-size: 12px;
  }

  .last-static > span {
    padding: 5px 8px;
  }

  .static-values > * {
    height: var(--survey-row-height);
    min-height: var(--survey-row-height);
    padding: 0 4px;
  }

  .static-input {
    height: calc(var(--survey-row-height) - 8px);
    min-height: 0;
    padding: 2px 4px;
  }

  .decision-row {
    padding: 8px;
  }

  .trajectory-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .profile-chart {
    min-height: 0;
    padding: 8px;
  }

  .profile-chart svg {
    height: 100%;
    min-height: 0;
  }

}

.fullscreen-survey,
.setup-layout,
.reports-layout {
  display: grid;
  gap: 16px;
}

.fullscreen-survey {
  grid-template-rows: auto minmax(0, 1fr);
  min-height: calc(100vh - 128px);
}

.fullscreen-survey > .survey-toolbar,
.fullscreen-survey > .survey-panel {
  grid-column: 1;
  grid-row: auto;
}

.survey-toolbar {
  display: block;
  min-width: 0;
}

.survey-pipe-panel {
  grid-column: auto;
  grid-row: auto;
  grid-template-columns: minmax(170px, 220px) minmax(280px, 1fr);
  grid-template-rows: auto;
  align-items: center;
  min-height: 0;
  padding: 12px 14px;
}

.expanded {
  min-height: 0;
}

.expanded .table-scroll {
  min-height: 0;
  background:
    linear-gradient(#fff 39px, transparent 40px) 0 0 / 100% 40px,
    #fff;
}

.setup-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.entry-point-panel {
  grid-column: 1 / -1;
}

.form-panel,
.tool-status-panel,
.lifecycle-panel,
.export-panel,
.market-gap-panel {
  padding: 14px;
}

.form-panel h2,
.export-panel h2,
.market-gap-panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 500;
}

.form-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 14px;
}

.form-panel-heading h2 {
  margin: 0;
}

.form-panel-heading .job-actions {
  margin-left: auto;
}

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

label {
  min-width: 0;
}

.field-grid label {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--muted-line);
  background: #fff;
}

.field-grid span {
  min-height: 35px;
  padding: 8px 9px;
  background: var(--soft-2);
}

.field-grid input {
  border: 0;
}

.field-grid input[readonly] {
  background: #f0f1ec;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(21, 25, 23, 0.52);
  z-index: 20;
}

.modal-backdrop.open {
  display: flex;
}

.tour-layer,
.tour-start-prompt {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 32;
}

.tour-layer.open,
.tour-start-prompt.open {
  display: block;
}

.tour-layer {
  pointer-events: none;
  background: rgba(21, 25, 23, 0.18);
}

.tour-layer.open .tour-card {
  pointer-events: auto;
}

.tour-layer.open .tour-highlight {
  pointer-events: none;
}

.tour-highlight {
  position: fixed;
  left: var(--tour-x, 18px);
  top: var(--tour-y, 18px);
  width: var(--tour-w, 0);
  height: var(--tour-h, 0);
  border: 2px solid var(--green-dark);
  background: rgba(61, 222, 22, 0.08);
  box-shadow:
    0 0 0 9999px rgba(21, 25, 23, 0.34),
    0 0 0 6px rgba(61, 222, 22, 0.16);
  transition:
    left 180ms ease,
    top 180ms ease,
    width 180ms ease,
    height 180ms ease;
}

.tour-card,
.tour-start-card {
  position: fixed;
  width: min(430px, calc(100vw - 28px));
  border: 2px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tour-card {
  left: var(--tour-card-x, 24px);
  top: var(--tour-card-y, 24px);
  padding: 16px;
}

.tour-start-prompt {
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(21, 25, 23, 0.34);
  z-index: 34;
  pointer-events: none;
}

.tour-start-prompt.open {
  display: grid;
}

.tour-start-card {
  position: static;
  padding: 18px;
  pointer-events: auto;
}

.tour-card h2,
.tour-start-card h2 {
  margin: 4px 0 8px;
  font-size: 24px;
  font-weight: 500;
}

.tour-card p,
.tour-start-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.tour-step-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tour-progress {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
  margin: 14px 0;
}

.tour-progress span {
  height: 4px;
  background: var(--soft-2);
}

.tour-progress span.active {
  background: var(--green-dark);
}

.tour-actions,
.tour-finish-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.tour-actions button,
.tour-finish-actions button {
  min-height: 36px;
  padding: 0 12px;
}

.tour-finish-actions {
  justify-content: stretch;
}

.tour-finish-actions[hidden] {
  display: none;
}

.tour-finish-actions button:first-child {
  flex: 1 1 100%;
}

.tour-card.is-finish .tour-actions {
  display: none;
}

.bore-modal {
  width: min(1180px, 100%);
  max-height: 92vh;
  overflow: auto;
  border: 2px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border-bottom: 2px solid var(--line);
  background: #e9ece4;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header-actions button:not(.icon-button) {
  min-height: 34px;
  padding: 0 14px;
}

.modal-header h2 {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 500;
}

.bore-manager-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  padding: 14px;
}

.manager-panel {
  min-width: 0;
  padding: 14px;
  border: 2px solid var(--line);
  background: rgba(251, 251, 247, 0.94);
}

.manager-panel .section-header {
  margin: -14px -14px 14px;
}

.manager-panel h3 {
  margin: 14px 0 10px;
  font-size: 16px;
  font-weight: 500;
}

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

.field-grid.compact label {
  grid-template-columns: 122px minmax(0, 1fr);
}

.bore-list {
  display: grid;
  gap: 8px;
  min-height: 168px;
  max-height: 360px;
  overflow: auto;
}

.bore-list-item {
  display: grid;
  gap: 4px;
  justify-items: start;
  min-height: 64px;
  padding: 10px;
  text-align: left;
}

.bore-list-item.selected {
  border-color: var(--green-dark);
  background: #e9ffe1;
}

.bore-list-item span,
.empty-state,
.import-preview p {
  color: var(--muted);
}

.manager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.file-button {
  display: inline-grid;
  min-height: 42px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.plan-modal {
  width: min(1120px, calc(100vw - 28px));
}

.login-modal {
  width: min(440px, calc(100vw - 28px));
}

.cloud-login-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.cloud-login-form label {
  display: grid;
  gap: 5px;
}

.cloud-login-form span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cloud-login-form p {
  margin: 0;
  color: var(--muted);
}

.plan-preview-summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

.plan-table-wrap {
  max-height: min(62vh, 560px);
  overflow: auto;
  background: #fff;
}

.plan-preview-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.plan-preview-table th,
.plan-preview-table td {
  height: 42px;
  padding: 6px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.plan-preview-table th {
  background: #e9ece4;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.plan-preview-table th:nth-child(1),
.plan-preview-table th:nth-child(2),
.plan-preview-table th:nth-child(3),
.plan-preview-table th:nth-child(4) {
  width: 120px;
}

.plan-preview-table input {
  width: 100%;
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid rgba(47, 53, 50, 0.28);
  background: #fbfbf7;
  font: inherit;
}

.plan-preview-table input:focus {
  outline: 2px solid rgba(58, 123, 213, 0.24);
  border-color: var(--blue);
}

.plan-actions {
  justify-content: flex-end;
  padding: 14px;
  margin-top: 0;
  border-top: 2px solid var(--line);
  background: #e9ece4;
}

.danger {
  border-color: rgba(155, 55, 42, 0.65);
  color: #8f2f23;
}

.import-preview {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.tool-status-panel {
  grid-column: 1 / -1;
}

.tool-status-panel .section-header {
  margin: -14px -14px 14px;
}

.tool-status-panel .section-header button {
  min-height: 30px;
  padding: 0 24px;
  border-radius: 999px;
}

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

.cloud-admin-panel[hidden] {
  display: none;
}

.cloud-admin-panel {
  grid-column: 1 / -1;
}

.cloud-user-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.cloud-user-form select,
.cloud-bore-project-field select {
  min-height: 35px;
  padding: 7px 9px;
  border: 1px solid var(--muted-line);
  background: #fff;
  font: inherit;
}

.cloud-user-form button {
  min-height: 35px;
}

.cloud-bore-project-help {
  grid-column: 1 / -1;
  margin: -2px 0 4px;
  padding: 9px 10px;
  border: 1px solid rgba(155, 55, 42, 0.35);
  background: #fff6ee;
  color: #7d372b;
  font-size: 13px;
  line-height: 1.35;
}

.cloud-user-list {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.cloud-user-list div {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 88px minmax(120px, 0.9fr) auto;
  gap: 10px;
  min-height: 34px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--muted-line);
  background: #fff;
}

.cloud-user-list.superadmin div {
  grid-template-columns: minmax(120px, 1.1fr) minmax(0, 1fr) minmax(0, 1fr) 88px minmax(120px, 0.9fr) auto;
}

.cloud-user-list span {
  color: var(--muted);
}

.cloud-user-list code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-family: "Roboto Mono", "Courier New", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.cloud-user-list .cloud-password-empty {
  color: var(--muted);
  font-size: 12px;
}

.cloud-user-delete {
  min-height: 30px;
  padding: 0 12px;
  border-color: #b44;
  color: #8b1e1e;
}

.cloud-user-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.cloud-user-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.cloud-user-delete:disabled {
  border-color: var(--muted-line);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

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

.segmented button {
  min-height: 34px;
  border-radius: 999px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--muted-line);
  background: #fff;
}

.toggle-row input {
  appearance: none;
  width: 100%;
  height: 100%;
  border: 0;
  background:
    linear-gradient(90deg, transparent 0 38%, var(--green) 38% 58%, transparent 58%),
    var(--soft-2);
}

.toggle-row input:not(:checked) {
  background:
    linear-gradient(90deg, transparent 0 42%, var(--red) 42% 58%, transparent 58%),
    var(--soft-2);
}

.toggle-row span {
  padding: 8px 12px;
}

.reports-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(270px, 0.8fr);
}

.lifecycle-panel {
  grid-row: span 2;
}

.lifecycle-panel .section-header {
  margin: -14px -14px 0;
}

.lifecycle {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 14px 0 0;
  list-style: none;
  counter-reset: step;
}

.lifecycle li {
  counter-increment: step;
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  padding: 0 0 28px;
}

.lifecycle li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  background: var(--surface);
  font-size: 20px;
}

.lifecycle li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 42px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.lifecycle strong,
.lifecycle span {
  grid-column: 2;
}

.lifecycle strong {
  align-self: end;
  font-size: 22px;
}

.lifecycle span {
  margin-top: -22px;
  align-self: start;
  color: var(--muted);
}

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

.export-list button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  padding: 0 12px;
  font-size: 16px;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .nav-rail {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 2px solid var(--line);
  }

  .brand-block {
    grid-auto-flow: column;
    align-items: center;
    justify-items: start;
    margin: 0 8px 0 0;
  }

  .nav-button {
    min-width: 82px;
  }

  .topbar,
  .live-layout,
  .bore-manager-grid,
  .setup-layout,
  .reports-layout {
    grid-template-columns: 1fr;
  }

  .live-layout {
    grid-template-rows: none;
    min-height: 0;
  }

  .status-cluster {
    justify-content: center;
    justify-self: center;
  }

  .pipe-panel,
  .toolface-panel {
    min-height: 0;
  }

  .pipe-panel,
  .toolface-panel,
  .survey-panel,
  .trajectory-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .pipe-panel {
    grid-template-columns: minmax(170px, 0.35fr) minmax(240px, 0.65fr);
    grid-template-rows: auto;
    align-items: center;
    justify-content: center;
  }

  .tool-status-panel {
    grid-column: auto;
  }
}

@media (max-width: 700px) {
  .console {
    padding: 10px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    padding: 10px;
  }

  .job-context {
    grid-column: 1 / -1;
  }

  .mode-pill {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    padding: 0;
  }

  .status-cluster {
    grid-column: 2;
    grid-row: 2;
    flex-wrap: nowrap;
    justify-content: flex-end;
    justify-self: end;
  }

  .job-context strong {
    font-size: 20px;
  }

  .form-panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-panel-heading .job-actions {
    justify-content: flex-end;
    width: 100%;
  }

  .pipe-panel,
  .field-grid,
  .field-grid.compact,
  .tool-grid,
  .cloud-user-form,
  .export-list {
    grid-template-columns: 1fr;
  }

  .cloud-user-list div {
    grid-template-columns: 1fr;
  }

  .toolface {
    --pointer-radius: 92px;
    --hour-radius: 119px;
    width: 280px;
  }

  .hour {
    font-size: 18px;
  }

  .toolface strong {
    font-size: 62px;
  }

  .distance-block strong {
    font-size: 40px;
  }

  .primary-actions,
  .decision-row,
  .decision-row.three {
    grid-template-columns: 1fr;
  }

  .survey-pipe-panel {
    grid-template-columns: 1fr;
  }

  .field-grid label {
    grid-template-columns: 1fr;
  }

  .field-grid.compact label {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .lifecycle span {
    margin-top: -16px;
  }
}
