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

.sheet-link-button,
.open-map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.sheet-controls {
  gap: 10px;
  flex-wrap: wrap;
}

.sheet-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--text-muted);
  white-space: nowrap;
}

.sheet-summary span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.sheet-summary strong {
  color: var(--text-main);
}

.sheet-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  min-height: 0;
}

.sheet-table-panel,
.sheet-editor {
  min-height: 0;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  background: var(--surface-bg);
  box-shadow: var(--shadow);
}

.sheet-table-panel {
  overflow: hidden;
}

.sheet-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.location-sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.location-sheet th,
.location-sheet td {
  border-right: 1px solid var(--section-border);
  border-bottom: 1px solid var(--section-border);
  padding: 0;
  background: rgba(255, 255, 255, .02);
}

.location-sheet th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 42px;
  min-width: 76px;
  padding: 0 8px;
  background: var(--bg-panel);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 900;
}

.location-sheet .corner,
.location-sheet .row-heading {
  left: 0;
  z-index: 5;
  min-width: 72px;
  width: 72px;
  border-right-color: var(--border);
}

.location-sheet .corner {
  z-index: 6;
}

.location-sheet .row-heading {
  position: sticky;
  background: var(--bg-panel);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 900;
}

.point-cell {
  width: 76px;
  height: 54px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-main);
  position: relative;
}

.point-cell.structural-column {
  background: rgba(118, 129, 141, .14);
}

.point-cell strong,
.point-cell small {
  display: block;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.point-cell strong {
  font-size: 13px;
  line-height: 1;
}

.point-cell.prime-coordinate strong {
  position: relative;
  z-index: 2;
  padding: 2px 4px;
  border-radius: 3px;
  background: #cfd5db;
  box-shadow: inset 0 0 0 1px rgba(80, 92, 105, .16);
}

[data-theme="dark"] .point-cell.prime-coordinate strong {
  background: #59636d;
}

.point-cell .qa-pending-corner {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 7;
  width: 0;
  height: 0;
  border-top: 18px solid #ffd22e;
  border-left: 18px solid transparent;
  filter: drop-shadow(-1px 1px 0 rgba(117, 82, 0, .28));
  pointer-events: none;
}

.point-cell small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.point-cell::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 4px solid var(--grey-point);
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--point-fill);
}

.point-cell.done::before {
  border-color: var(--green);
  background: var(--green);
  box-shadow: none;
}

.point-cell.planned::before {
  border-color: var(--blue-location);
  border-right-color: transparent;
  background: transparent;
  box-shadow: none;
  animation: plannedRingSpin 1.8s linear infinite;
}

.point-cell.lift::before {
  border-color: var(--red);
  background: var(--point-fill);
  box-shadow: none;
}

.point-cell.lift::after {
  content: attr(data-lift-percent);
  position: absolute;
  top: 17px;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--red);
  font-size: 6px;
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
}

.point-cell.partial_blocked::before {
  border-color: var(--blocked-symbol);
  background: linear-gradient(90deg, var(--green) 0 50%, var(--blocked-symbol) 50% 100%);
  box-shadow: none;
}

.point-cell.attention::before {
  border-color: var(--yellow);
  background: var(--yellow);
  box-shadow: none;
}

.point-cell.problem::before {
  border-color: var(--red);
  background: var(--red);
  box-shadow: none;
  animation: problemLegendPulse 1.05s ease-in-out infinite;
}

.point-cell.blocked::before {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(45deg, transparent calc(50% - 1.8px), var(--blocked-symbol) calc(50% - 1.8px), var(--blocked-symbol) calc(50% + 1.8px), transparent calc(50% + 1.8px)),
    linear-gradient(-45deg, transparent calc(50% - 1.8px), var(--blocked-symbol) calc(50% - 1.8px), var(--blocked-symbol) calc(50% + 1.8px), transparent calc(50% + 1.8px));
  box-shadow: none;
}

.point-cell.blocked::after {
  content: none;
}

.point-cell.missing-column::before {
  width: 18px;
  height: 18px;
  border: 2px solid #111;
  background: linear-gradient(#111, #111) center / 9px 2px no-repeat #fff;
  box-shadow: none;
}

.point-cell[data-visible="false"] {
  opacity: 0;
  pointer-events: none;
}

.point-cell.selected {
  z-index: 8;
  background: rgba(226, 53, 44, .10);
  box-shadow: inset 0 0 0 3px #e2352c, 0 0 9px rgba(226, 53, 44, .42);
}

.point-cell:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
  z-index: 2;
}

.sheet-editor {
  overflow: auto;
  padding: 16px;
}

.sheet-number-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.bolt-type-grid {
  display: grid;
  grid-template-columns: minmax(62px, 1.2fr) repeat(3, minmax(58px, 1fr));
  gap: 6px;
  align-items: center;
  margin: 14px 0;
}

.bolt-type-head,
.bolt-type-grid label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
}

.bolt-type-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.08;
}

.bolt-type-label small {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 850;
}

.bolt-type-grid input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text-main);
  padding: 6px 8px;
  outline: 0;
}

.bolt-type-grid input:not([readonly]):not(:disabled) {
  background: var(--editable-number-bg, #fff6cf);
  border-color: var(--editable-number-border, rgba(245, 185, 31, .58));
}

.bolt-type-grid input[readonly] {
  background: transparent;
  color: var(--text-muted);
  border-style: dashed;
  cursor: default;
}

.bolt-type-grid > :nth-child(8n+9),
.bolt-type-grid > :nth-child(8n+10),
.bolt-type-grid > :nth-child(8n+11),
.bolt-type-grid > :nth-child(8n+12) {
  background-color: var(--bolt-row-bg-alt, rgba(24, 32, 42, .070));
}

.bolt-type-grid > input[readonly]:nth-child(8n+10) {
  background-color: var(--bolt-row-bg-alt, rgba(24, 32, 42, .070));
}

.bolt-type-grid > :nth-child(n+5) {
  min-height: 36px;
}

.bolt-type-grid > label:nth-child(n+5) {
  padding: 5px 7px;
  border-radius: 6px;
}

.sheet-number-grid label,
.field,
.status-select {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.sheet-number-grid input,
.field textarea,
.status-select select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text-main);
  padding: 8px 10px;
  outline: 0;
}

.field textarea {
  resize: vertical;
  min-height: 112px;
}

.sheet-editor .quick-actions {
  margin: 14px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.sheet-editor .media-actions {
  grid-template-columns: repeat(2, 1fr);
  margin-top: -4px;
}

.sheet-editor .primary-button,
.sheet-editor .open-map-link {
  width: 100%;
  margin-top: 8px;
}

.sheet-editor section {
  margin-top: 18px;
}

.sheet-editor .history-list {
  max-height: 230px;
}

.axis-side-panel {
  display: grid;
  gap: 9px;
  padding: 11px;
  border: 1px solid rgba(22, 136, 232, .34);
  border-radius: 10px;
  background: rgba(22, 136, 232, .06);
}

.missing-column-notice {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid #9aa4af;
  border-radius: 9px;
  background: linear-gradient(135deg, #fff, #edf1f4);
  color: #111820;
}

.missing-column-notice[hidden] { display: none !important; }
.missing-column-notice strong { font-size: 15px; }
.missing-column-notice span { color: #55616d; font-size: 13px; font-weight: 700; line-height: 1.35; }

[data-theme="dark"] .missing-column-notice {
  border-color: #737e89;
  background: linear-gradient(135deg, #1b2229, #11171d);
  color: #f5f7f9;
}

[data-theme="dark"] .missing-column-notice span { color: #b8c1ca; }

.axis-side-panel[hidden] {
  display: none !important;
}

.axis-side-panel.pending {
  border-color: rgba(22, 136, 232, .78);
  box-shadow: 0 0 0 3px rgba(22, 136, 232, .12);
}

.axis-side-heading {
  display: grid;
  gap: 2px;
}

.axis-side-heading small,
.axis-side-tab small {
  color: var(--muted);
}

.axis-side-context {
  display: block;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 750;
  line-height: 1.2;
}

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

.axis-side-tab {
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 8px 9px;
  text-align: left;
}

.axis-side-tab.active {
  border-color: var(--blue);
  background: rgba(22, 136, 232, .13);
  box-shadow: inset 0 0 0 2px rgba(22, 136, 232, .22);
}

.axis-side-tab.empty:not(.active) {
  border-style: dashed;
}

.point-cell.axis-side-pending {
  outline: 3px solid rgba(22, 136, 232, .56);
  outline-offset: -3px;
  box-shadow: 0 0 14px rgba(22, 136, 232, .3);
}

.point-cell.axis-side-pending.selected {
  z-index: 8;
  outline: 3px solid #e2352c;
  outline-offset: -3px;
  background: rgba(226, 53, 44, .10);
  box-shadow: inset 0 0 0 2px #e2352c, 0 0 10px rgba(226, 53, 44, .52);
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .sheet-shell {
    min-height: 100vh;
  }

  .sheet-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sheet-table-panel {
    min-height: 58vh;
  }

  .sheet-scroll {
    max-height: 58vh;
  }

  .sheet-editor {
    min-height: auto;
  }

  .sheet-summary {
    width: 100%;
    justify-content: space-between;
  }
}
