/*
 * Authenticated workbench.
 *
 * This is the single authoritative style source for the workbench shell,
 * sidebar, account rail, material summary, and drawing workspace. Global
 * tokens, authentication screens, and shared dialogs remain in styles.css.
 */

body:not(.auth-locked) .topbar {
  display: none;
}

.workspace {
  grid-template-columns: 328px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.workspace-sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar-brand {
  min-height: 88px;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-brand .app-identity {
  width: 100%;
  gap: 10px;
}

.sidebar-brand .app-logo {
  width: 64px;
  height: 44px;
}

.sidebar-brand .app-title-zh {
  font-size: 19px;
  letter-spacing: -0.02em;
}

.sidebar-brand .app-title-en {
  font-size: 10px;
}

.sidebar-brand .app-title-en-line {
  column-gap: 7px;
}

.sidebar-brand .app-version {
  padding: 1px 5px;
  font-size: 9px;
}

.form-panel {
  position: static;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.form-panel > .field-group {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 15px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.form-panel > .field-group + .field-group {
  margin-top: 0;
  padding-top: 8px;
  border-top: 0;
}

.field-disclosure-summary {
  min-height: 34px;
  font-size: 15px;
}

.field-disclosure-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  box-sizing: border-box;
  border-radius: 8px;
  padding: 5px;
  background: rgba(47, 107, 53, 0.08);
}

.field-disclosure[open] > .field-disclosure-summary .field-disclosure-icon {
  background: rgba(47, 107, 53, 0.14);
}

.field-disclosure-content {
  padding-top: 7px;
}

.field-disclosure-meta {
  padding: 1px 6px;
  font-size: 10px;
}

.form-panel .grid,
.marking-dimension-groups {
  gap: 9px;
}

.form-panel .grid.three,
.form-panel .grid.four {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#middle-straight-length-field:not([hidden]) {
  grid-column: 1 / -1;
}

#middle-straight-length-field[hidden] {
  display: none;
}

.dimension-block + .dimension-block {
  margin-top: 12px;
  padding-top: 12px;
}

.dimension-block h3,
.marking-dimension-group legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.marking-dimension-groups {
  grid-template-columns: minmax(0, 1fr);
}

.marking-radius-row {
  margin-top: 12px;
}

.line-embedding-options {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.line-embedding-option {
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 9px 2px;
}

.line-embedding-copy strong {
  font-size: 13px;
}

.line-embedding-copy span {
  line-height: 1.4;
}

.display-effect-scope {
  margin: 0 0 10px;
  border-left: 3px solid var(--green);
  border-radius: 0 6px 6px 0;
  padding: 7px 9px;
  background: rgba(47, 107, 53, 0.07);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
}

.advanced-feature-heading {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.paving-color-section {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.paving-color-warning {
  margin: 0;
  border-left: 3px solid #c99323;
  border-radius: 0 6px 6px 0;
  padding: 7px 9px;
  background: #fff8df;
  color: #72520b;
  font-size: 11px;
  line-height: 1.5;
}

.paving-color-option {
  margin-top: 7px;
  border-top: 1px solid var(--line);
}

.display-effect-option input[type="checkbox"] {
  width: 44px;
  min-height: 24px;
  height: 24px;
  flex: 0 0 44px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  background: var(--surface-soft);
  cursor: pointer;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}

.display-effect-option input[type="checkbox"]::after {
  width: 18px;
  height: 18px;
  display: block;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(19, 39, 24, 0.25);
  content: "";
  transition: transform 120ms ease-out;
}

.display-effect-option input[type="checkbox"]:checked {
  border-color: var(--green);
  background: var(--green);
}

.display-effect-option input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.paving-color-status {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.display-effect-options {
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.display-effect-option {
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 7px 2px;
}

.display-effect-option > span {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 2px;
  overflow: hidden;
}

.display-effect-option strong {
  color: var(--ink);
  font-size: 13px;
}

.display-effect-option small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.display-effect-option.is-future-control {
  opacity: 0.62;
}

.goal-display-settings {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-quiet);
}

.goal-display-settings legend {
  padding: 0 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.goal-display-settings:disabled {
  opacity: 0.58;
}

.goal-spec-source {
  border-radius: 6px;
  padding: 7px 8px;
  background: rgba(47, 107, 53, 0.08);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

#custom-goal-fields[hidden] {
  display: none;
}

.display-effect-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.display-effect-footer .compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 11px;
}

.display-effect-diagnostics {
  margin-top: 9px;
  border: 1px solid #e4bf62;
  border-radius: 7px;
  padding: 8px 9px;
  background: #fff8df;
  color: #72520b;
  font-size: 11px;
  line-height: 1.45;
}

.form-panel label {
  gap: 5px;
  font-size: 12px;
}

.form-panel input,
.form-panel select {
  min-height: 38px;
  border-color: var(--line-strong);
  border-radius: var(--radius-control);
  padding: 0 10px;
  background-color: var(--surface-quiet);
}

.form-panel input:focus,
.form-panel select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 107, 53, 0.11);
}

.geometry-result {
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 8px 10px;
  overflow: visible;
  line-height: 1.45;
  white-space: normal;
}

.form-footer {
  bottom: 0;
  margin: auto 0 0;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.98);
}

.actions {
  gap: 8px;
}

.actions button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-control);
  padding: 0 10px;
}

.result-panel {
  min-width: 0;
  gap: 14px;
}

@media (min-width: 980px) {
  body:not(.auth-locked) .workbench-shell {
    --workbench-gutter: max(14px, calc((100vw - 1760px) / 2));
    width: min(1760px, calc(100vw - 28px));
    height: calc(100dvh - 28px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 68px;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
    position: relative;
    margin: 14px auto;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  body:not(.auth-locked) .workbench-shell > .workspace {
    height: auto;
    min-width: 0;
    min-height: 0;
    grid-column: 1;
    grid-row: 1;
    align-self: stretch;
    align-items: stretch;
    overflow: hidden;
    margin: 0;
    padding: 14px 0 32px 14px;
  }

  .workspace {
    grid-template-columns: 328px minmax(0, 1fr);
  }

  .workspace-sidebar {
    height: 100%;
  }

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

  body:not(.auth-locked) .workbench-shell > .system-menu-wrap {
    min-width: 0;
    min-height: 0;
    height: auto;
    grid-column: 2;
    grid-row: 1;
    align-self: stretch;
  }

  .workbench-rail {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-left: 1px solid var(--line);
    background: var(--surface);
  }

  .workbench-account-button,
  .workbench-settings-button {
    width: 100%;
    flex: 0 0 auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
  }

  .workbench-account-button {
    min-height: 104px;
    display: inline-flex;
    position: relative;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 16px 5px 10px;
    font-weight: 700;
  }

  .workbench-settings-button {
    height: 58px;
    display: inline-grid;
    place-items: center;
  }

  .workbench-settings-button img {
    width: 20px;
    height: 20px;
  }

  .workbench-account-button:hover,
  .workbench-account-button:focus-visible,
  .workbench-settings-button:hover,
  .workbench-settings-button:focus-visible {
    outline: none;
    background: var(--surface-soft);
    box-shadow: inset 3px 0 0 var(--green);
  }

  .workbench-account-button .account-status-dot {
    top: 17px;
    left: 39px;
  }

  .workbench-account-button .account-trigger-label {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
    text-align: center;
  }

  .workbench-shell .account-drawer {
    width: 312px;
    right: calc(var(--workbench-gutter) + 68px);
  }

  .workbench-shell .account-drawer-backdrop {
    right: var(--workbench-gutter);
  }

  body:not(.auth-locked) .workbench-shell > .legal-notice {
    position: absolute;
    right: 68px;
    bottom: 4px;
    left: 342px;
    z-index: 2;
    margin: 0;
    pointer-events: none;
  }
}

.material-deck {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.material-deck__grid {
  display: grid;
  grid-template-columns: 1fr 1.06fr 0.9fr 1.65fr 1.65fr;
  gap: 12px;
}

.material-card {
  min-width: 0;
  min-height: 106px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 12px 13px 13px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(30, 46, 31, 0.055);
}

.material-card__heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.material-card__icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  box-sizing: border-box;
  border-radius: 10px;
  padding: 5px;
  background: var(--green-soft);
}

.material-card__label {
  min-width: 0;
  color: #536054;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
}

.material-card__value {
  margin-top: auto;
  padding-top: 12px;
  color: var(--ink);
  font-size: clamp(18px, 1.35vw, 23px);
  font-weight: 700;
  line-height: 1.1;
}

.material-amount {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.material-unit {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72em;
  font-weight: 600;
}

.material-options {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  margin-top: auto;
  padding-top: 10px;
}

.material-option {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 4px;
  padding-right: 9px;
  text-align: left;
}

.material-option + .material-option {
  padding-right: 0;
  padding-left: 9px;
  border-left: 1px solid var(--line);
}

.material-option span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.material-option strong {
  max-width: 100%;
  color: var(--ink);
  font-size: clamp(15px, 1.05vw, 18px);
  line-height: 1.15;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.material-card[data-summary-card="glueQty"] .material-option:last-child strong {
  font-size: clamp(13px, 0.92vw, 16px);
}

.material-deck__grid > .empty-state {
  min-height: 106px;
  display: grid;
  grid-column: 1 / -1;
  place-items: center;
  padding: 16px;
  border-style: solid;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(30, 46, 31, 0.045);
}

.drawing-panel,
.drawing-grid {
  min-width: 0;
  min-height: 0;
}

.drawing-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawing-grid {
  height: 100%;
}

.drawing-workspace {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  margin: 0;
}

.drawing-toolbar {
  min-height: 54px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0;
}

.drawing-tabs {
  min-width: 0;
  display: flex;
  gap: 2px;
  border-radius: 999px;
  padding: 4px;
  background: #eff2ed;
}

.drawing-tab {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.drawing-tab:hover:not(:disabled) {
  color: var(--green);
}

.drawing-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--green);
  box-shadow: 0 2px 8px rgba(30, 46, 31, 0.08);
}

.drawing-tab:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.drawing-toolbar__actions,
.drawing-controls {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.drawing-toolbar .status-pill {
  min-width: auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 14px;
}

.drawing-tool {
  min-width: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 0 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.drawing-tool:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.drawing-tool[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.drawing-tool[data-action="drag"],
.drawing-tool[data-action="reset"] {
  min-width: 68px;
}

.drawing-tool__icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.drawing-tool[aria-pressed="true"] .drawing-tool__icon {
  filter: brightness(0) invert(1);
}

.drawing-canvas {
  min-height: 440px;
  height: clamp(440px, calc(100dvh - 390px), 760px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-panel);
  padding: clamp(28px, 3vw, 44px);
  background: #f7f8f5;
  touch-action: none;
}

.drawing-canvas.is-drag-enabled {
  cursor: grab;
}

.drawing-canvas.is-dragging {
  cursor: grabbing;
}

.drawing-paper {
  height: min(calc(100% - 8px), 720px);
  max-width: 92%;
  aspect-ratio: 297 / 210;
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(216, 221, 210, 0.72);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(26, 39, 27, 0.14);
  transform-origin: center center;
  transition: transform 120ms ease-out;
  will-change: transform;
}

.drawing-sheet-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  cursor: zoom-in;
  user-select: none;
}

.drawing-sheet-image[hidden] {
  display: none;
}

.drawing-canvas.is-drag-enabled .drawing-sheet-image {
  cursor: grab;
}

.drawing-canvas.is-dragging .drawing-sheet-image {
  cursor: grabbing;
}

.action-button__icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

@media (min-width: 1280px) {
  .material-card__label {
    white-space: nowrap;
  }
}

@media (min-width: 980px) and (max-width: 1279px) {
  .workspace {
    grid-template-columns: 312px minmax(0, 1fr);
  }

  .material-deck__grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .material-card--metric {
    grid-column: span 2;
  }

  .material-card--wide {
    grid-column: span 3;
  }
}

@media (max-width: 979px) {
  body:not(.auth-locked) .workbench-shell {
    width: calc(100vw - 20px);
    position: relative;
  }

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

  .workspace-sidebar,
  .form-panel {
    overflow: visible;
  }

  body:not(.auth-locked) .workbench-shell > .system-menu-wrap {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 45;
  }

  .workbench-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .workbench-account-button,
  .workbench-settings-button {
    width: 44px;
    height: 44px;
    display: inline-grid;
    position: relative;
    place-items: center;
    border: 0;
    background: transparent;
  }

  .workbench-account-button .account-trigger-label {
    width: 1px;
    height: 1px;
    position: absolute;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .workbench-settings-button {
    border-top: 1px solid var(--line);
  }

  .workbench-settings-button img {
    width: 19px;
    height: 19px;
  }

  .material-deck__grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .material-card--metric {
    grid-column: span 2;
  }

  .material-card--wide {
    grid-column: span 3;
  }
}

@media (min-width: 980px) {
  .drawing-canvas {
    min-height: 0;
    height: 100%;
    padding: 24px 30px;
  }
}

@media (max-width: 700px) {
  .material-deck {
    padding: 10px;
    border-radius: 18px;
  }

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

  .material-card--metric,
  .material-card--wide {
    grid-column: auto;
  }

  .material-card--wide:last-child {
    grid-column: 1 / -1;
  }

  .drawing-panel {
    border-radius: 18px;
    padding: 10px;
  }

  .drawing-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .drawing-toolbar__actions {
    justify-content: space-between;
  }

  .drawing-canvas {
    min-height: 380px;
    height: 62vh;
    padding: 14px;
  }
}

@media (max-width: 560px) {
  body:not(.auth-locked) .workbench-shell {
    width: calc(100vw - 16px);
  }

  .workspace {
    gap: 10px;
    margin-top: 8px;
  }

  .form-panel .grid.two,
  .form-panel .grid.three,
  .form-panel .grid.four {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar-brand {
    padding-right: 58px;
  }

  .material-deck__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .material-card--wide:last-child {
    grid-column: auto;
  }

  .material-card {
    min-height: 100px;
  }

  .drawing-controls {
    flex-wrap: wrap;
  }
}
