:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: #172033;
  background: #f4f6f9;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-width: 320px;
  margin: 0;
  background: #f4f6f9;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

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

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 400px);
  padding: 40px;
  border: 1px solid #dfe4ec;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 45px rgb(25 38 61 / 9%);
}

.brand {
  color: #1565c0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.brand select {
  width: auto;
  min-width: 132px;
  padding: 8px 30px 8px 10px;
  border: 1px solid #b9c9dc;
  border-radius: 7px;
  color: #075dab;
  background-color: #fff;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
}

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

.topbar-company-name {
  flex-shrink: 0;
  max-width: 210px;
  overflow: hidden;
  color: #172033;
  font-size: 1.2rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h1 { margin: 12px 0 4px; font-size: 1.8rem; }
.subtitle { margin: 0; color: #687386; }

form {
  display: grid;
  gap: 10px;
  margin-top: 30px;
}

label, .search-field span {
  color: #3c4657;
  font-size: 0.86rem;
  font-weight: 650;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cbd2dc;
  border-radius: 8px;
  outline: none;
  background: #fff;
}

input:focus, select:focus {
  border-color: #1565c0;
  box-shadow: 0 0 0 3px rgb(21 101 192 / 14%);
}

form button {
  margin-top: 10px;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #1565c0;
  font-weight: 700;
}

button:disabled { cursor: default; opacity: 0.55; }

.error {
  padding: 10px 12px;
  border-radius: 7px;
  color: #a51d2d;
  background: #fff0f2;
  font-size: 0.9rem;
}

.success {
  padding: 10px 12px;
  border-radius: 7px;
  color: #176336;
  background: #ebf8f0;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
  padding: 0 max(24px, calc((100vw - 1500px) / 2));
  border-bottom: 1px solid #dfe4ec;
  background: #fff;
}

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

.main-navigation {
  display: flex;
  align-self: stretch;
  align-items: center;
  gap: 4px;
}

.main-navigation a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  border-bottom: 3px solid transparent;
  color: #465267;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.main-navigation a:hover { color: #0f5ca8; }

.main-navigation a.active {
  border-bottom-color: #1565c0;
  color: #0f5ca8;
}

.topbar-global-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.topbar-global-actions .secondary-button {
  padding: 7px 10px;
  white-space: nowrap;
}

.navigation-toggle { display: none; }

.operation-feedback {
  position: fixed;
  top: 76px;
  right: 18px;
  z-index: 1000;
  display: grid;
  width: min(430px, calc(100vw - 36px));
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid #b9cbe3;
  border-radius: 9px;
  background: #eef5ff;
  box-shadow: 0 10px 30px rgb(25 38 61 / 18%);
}

.operation-feedback span { color: #536176; }
.operation-feedback.success { border-color: #b9dfc7; }
.operation-feedback.error { border-color: #efbdc4; }

.secondary-button {
  padding: 8px 13px;
  border: 1px solid #cbd2dc;
  border-radius: 7px;
  color: #253147;
  background: #fff;
}

.secondary-button.danger-button {
  border-color: #b42318;
  color: #b42318;
}

.secondary-button.danger-button:hover:not(:disabled) { background: #fff1f0; }

.content {
  width: min(1240px, calc(100% - 48px));
  margin: 36px auto;
}

.settings-content { width: min(980px, calc(100% - 48px)); }

.settings-form {
  gap: 18px;
  margin-top: 22px;
}

.settings-section {
  padding: 20px;
  border: 1px solid #dfe4ec;
  border-radius: 10px;
  background: #fff;
}

.settings-section legend {
  padding: 0 7px;
  color: #253147;
  font-size: 1rem;
  font-weight: 750;
}

.settings-section-title {
  margin: 0 0 18px;
  color: #253147;
  font-size: 1rem;
  font-weight: 750;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.settings-grid label { display: grid; gap: 7px; }

.settings-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px 20px;
  margin-bottom: 18px;
}

.settings-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-checks input { width: auto; }
.settings-help { margin: 0 0 16px; color: #687386; font-size: 0.86rem; }
.settings-actions { display: flex; justify-content: flex-end; }
.settings-actions button { min-width: 140px; }

#machines-list { display: grid; gap: 18px; }
.cutting-machine-card { position: relative; }
.cutting-machine-options { margin: 18px 0 0; }
.cutting-machine-group { margin-top: 18px; border-top: 1px solid #dfe4ec; padding-top: 12px; }
.cutting-machine-group summary { cursor: pointer; font-weight: 700; }
.cutting-machine-group[open] summary { margin-bottom: 14px; }
.cutting-machine-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.cutting-machine-card input[type="radio"] { width: auto; }

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.search-field {
  display: grid;
  width: min(380px, 100%);
  gap: 7px;
}

.browse-filters {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 14px;
  width: min(700px, 100%);
}

.browse-tools {
  display: flex;
  align-items: end;
  gap: 14px;
}

.browse-tools > button {
  padding: 11px 16px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #1565c0;
  font-weight: 700;
  white-space: nowrap;
}

.material-browse-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  align-items: end;
  gap: 14px;
  margin: -4px 0 22px;
  padding: 16px;
  border: 1px solid #dfe4ec;
  border-radius: 10px;
  background: #f8fafc;
}

.material-browse-filters .search-field { width: 100%; }

.material-browse-checks {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 40px;
}

.focus-dialog.material-model-filter-dialog { width: min(980px, calc(100% - 32px)); }

.model-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-height: 62vh;
  margin-top: 18px;
  overflow: auto;
}

.model-filter-grid label {
  display: grid;
  gap: 7px;
}

.model-filter-mode { margin-top: 18px; }

.table-wrapper {
  overflow-x: auto;
  border: 1px solid #dfe4ec;
  border-radius: 10px;
  background: #fff;
}

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }

th, td {
  padding: 13px 15px;
  border-bottom: 1px solid #e8ebf0;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #5d687a;
  background: #fafbfc;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }

.row-actions { display: flex; gap: 6px; }

.row-actions button:first-child {
  padding: 8px 13px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: #1565c0;
}

.empty-message {
  margin: 0;
  padding: 40px;
  color: #687386;
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 18px;
  color: #5d687a;
  font-size: 0.9rem;
}

.editor-content { max-width: 1240px; }

.material-form { margin-top: 22px; }

#material-fields { display: grid; }

.editor-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid #cbd2dc;
  background: #fff;
}

.material-form .editor-tabs button {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: #4b5668;
  background: transparent;
  font-weight: 650;
}

.material-form .editor-tabs button.active {
  border-bottom-color: #1565c0;
  color: #1565c0;
}

.tab-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding-top: 18px;
}

.form-section {
  min-width: 0;
  margin: 0;
  padding: 24px;
  border: 1px solid #dfe4ec;
  border-radius: 10px;
  background: #fff;
}

.form-section legend {
  padding: 0 7px;
  color: #253147;
  font-size: 1.05rem;
  font-weight: 700;
}

.wide-group { grid-column: 1 / -1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.form-grid label {
  display: grid;
  align-content: start;
  gap: 7px;
}

.form-field > span {
  color: #3c4657;
  font-size: 0.86rem;
  font-weight: 650;
}

.range-control {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 46px;
  align-items: center;
  gap: 9px;
}

.range-control input[type="range"] {
  min-width: 0;
  height: 28px;
  padding: 0;
  border: 0;
  box-shadow: none;
  accent-color: #1565c0;
  cursor: pointer;
}

.range-control output {
  padding: 4px 5px;
  border: 1px solid #cbd2dc;
  border-radius: 5px;
  background: #f7f9fc;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.range-control:has(input:disabled) { opacity: 0.55; }
.range-control input:disabled { cursor: default; }

.material-color-input {
  min-height: 38px;
  padding: 3px;
  cursor: pointer;
}

.material-color-input:disabled { cursor: default; }

.check-field {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-weight: 500;
}

.check-field input, .choice-field input {
  width: auto;
  margin: 0;
  padding: 0;
  box-shadow: none;
}

.choice-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #dfe4ec;
  border-radius: 8px;
}

.choice-field legend {
  padding: 0 5px;
  color: #3c4657;
  font-size: 0.82rem;
  font-weight: 650;
}

.choice-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.texture-map, .address-modes {
  display: grid;
  gap: 12px;
}

.mask-select { min-height: 150px; }

.rc-panel {
  display: block;
}

.material-rc-view {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 610px;
  border-bottom: 1px solid #dfe4ec;
  background: #fffef7;
}

.material-rc-navigation {
  padding: 14px 0;
  border-right: 1px solid #bfc9d6;
  background: #e5f5fb;
}

.material-rc-navigation button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  color: #172033;
  background: transparent;
  text-align: left;
  font-size: 0.84rem;
  font-weight: 600;
}

.material-rc-navigation button:hover,
.material-rc-navigation button.active {
  background: #fff;
  color: #0d4f94;
  font-weight: 700;
}

.material-rc-content { min-width: 0; }

.rc-view {
  min-width: 0;
}

.rc-source {
  margin: 0 0 10px;
  color: #687386;
  font-size: 0.82rem;
}

.rc-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid #dfe4ec;
  border-radius: 8px;
  background: #fbfaf3;
}

.rc-dialog {
  position: relative;
  min-width: 100%;
  color: #20242b;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

.rc-control {
  position: absolute;
  box-sizing: border-box;
}

.rc-group {
  z-index: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #aeb4bc;
}

.rc-group legend {
  margin-left: 8px;
  padding: 0 4px;
  background: #fbfaf3;
  font-size: 12px;
  white-space: nowrap;
}

.rc-label {
  z-index: 1;
  display: flex;
  align-items: center;
  overflow: visible;
  white-space: nowrap;
}

.rc-edit, .rc-combo {
  z-index: 2;
  min-width: 0;
  padding: 1px 4px;
  border: 1px solid #aeb4bc;
  border-radius: 2px;
  background: #fff;
  font: inherit;
}

.rc-check, .rc-radio {
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: visible;
  white-space: nowrap;
}

.rc-check input, .rc-radio input {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  padding: 0;
  box-shadow: none;
}

.rc-image {
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.rc-image img, .rc-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.rc-image img {
  object-fit: contain;
}

.rc-missing-image {
  border: 1px dashed #b6bbc3;
  color: #727985;
  font-size: 11px;
}

.relation-section {
  display: grid;
  gap: 16px;
}

.relation-search {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(280px, 2fr) auto;
  gap: 10px;
  align-items: center;
}

.relation-search button {
  margin: 0;
  padding: 10px 16px;
}

.relation-table input {
  min-width: 180px;
  padding: 8px 10px;
}

.relation-table button {
  margin: 0;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  padding: 18px 0;
  background: #f4f6f9;
}

.form-actions button {
  padding: 10px 18px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: #1565c0;
  font-weight: 700;
}

.duplicate-relations {
  justify-self: end;
  padding: 12px 14px;
  border: 1px solid #dfe4ec;
  border-radius: 8px;
  background: #fff;
}

.defaults-content { max-width: 800px; }

.defaults-form { margin-top: 24px; }

.defaults-fields {
  display: grid;
  gap: 12px;
}

.default-field {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.door-defaults-section { margin-top: 20px; }

.door-default-assign-all {
  margin-top: 14px;
  margin-left: 194px;
}

.defaults-link {
  justify-self: start;
  grid-column: 1 / -1;
}

.storage-content { max-width: 1240px; }

.cabinet-content { max-width: 1500px; }

.cabinet-panel {
  min-height: 570px;
  padding: 12px 0;
}

#cabinet-form > .editor-tabs button {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: #4b5668;
  background: transparent;
  font-weight: 650;
}

#cabinet-form > .editor-tabs button.active {
  border-bottom-color: #1565c0;
  color: #1565c0;
}

.cabinet-rc-stage { background: #fffef5; }

.cabinet-view-layout { min-height: 610px; }

.cabinet-view-layout .system-view-content { padding-top: 12px; }

.cabinet-preview {
  display: block;
  background: #fffef7;
}

.rc-material-control {
  z-index: 3;
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.rc-material-control > select {
  min-width: 0;
  width: calc(100% - 28px);
  height: 100%;
  margin: 0;
  padding: 0 3px;
  border: 1px solid #b9bec5;
  border-radius: 0;
  background: #fff;
  font: inherit;
}

.rc-material-control > select:disabled {
  color: #777;
  background: #f1f1f1;
}

.material-lock-button {
  flex: 0 0 28px;
  width: 28px;
  height: 100%;
  min-height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 20px 20px;
}

.material-lock-button:hover { background-color: #e8eef5; }

.cabinet-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  padding: 16px;
}

.cabinet-field-grid label {
  display: grid;
  gap: 5px;
  text-transform: capitalize;
}

.cabinet-model-stage { background: #fffef7; }

.cabinet-model-list {
  z-index: 2;
  margin: 0;
  padding: 2px;
  border: 1px solid #8d99a8;
  border-radius: 0;
  background: #fff;
  font: inherit;
}

.cabinet-model-list option { padding: 2px 4px; }

.model-filter-note {
  display: block;
  overflow: visible;
  white-space: normal;
  line-height: 1.15;
}

td .secondary-button + .secondary-button { margin-left: 6px; }

.storage-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.storage-row-actions .secondary-button + .secondary-button { margin-left: 0; }

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

.storage-actions > button, .storage-toolbar > button {
  margin: 0;
  padding: 9px 13px;
}

.storage-actions > button:not(.secondary-button) {
  border: 1px solid #1565c0;
  border-radius: 7px;
  color: #fff;
  background: #1565c0;
  font-weight: 700;
}

.storage-actions > .danger-button {
  background: #fff;
  border-color: #b42318;
  color: #b42318;
}

.storage-actions > .danger-button:hover:not(:disabled) {
  background: #fff1f0;
}

.storage-toolbar {
  margin: 0 0 16px;
}

.pack-web-setting {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: -8px 0 18px;
  padding: 9px 11px;
  border: 1px solid #dfe4ec;
  border-radius: 8px;
  background: #f8fafc;
  color: #536176;
}

.pack-web-setting code {
  overflow: hidden;
  color: #253147;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-web-setting code.overridden { color: #a15c00; }
.pack-web-setting button:first-of-type { margin-left: auto; }

.storage-toolbar input[type="file"] {
  width: min(430px, 100%);
  padding: 7px;
}

.storage-breadcrumbs {
  min-height: 38px;
  margin-bottom: 8px;
  color: #687386;
}

.storage-breadcrumbs button {
  padding: 4px 0;
  border: 0;
  color: #1565c0;
  background: transparent;
  font-weight: 650;
}

.storage-name {
  color: #1565c0;
  font-weight: 650;
  cursor: pointer;
}

.catalog-preview-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 56px;
  padding: 3px;
  border: 1px solid #cbd2dc;
  border-radius: 7px;
  color: #1565c0;
  background: #f8fafc;
  font-size: 1.5rem;
  cursor: pointer;
}

.catalog-preview-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.catalog-preview-button:hover:not(:disabled) {
  border-color: #1565c0;
  background: #eef5ff;
}

.cabinet-editor {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  grid-template-rows: 52px 1fr;
  overflow: hidden;
  background: #fff;
}

body.cabinet-editor-open { overflow: hidden; }

.cabinet-editor[hidden] { display: none; }

.cabinet-editor > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  border-bottom: 1px solid #ccd3dc;
  background: #f4f6f9;
}

.cabinet-editor iframe {
  grid-row: 2;
  grid-column: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
}

.cabinet-editor-loading {
  grid-row: 2;
  grid-column: 1;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: #fff;
  color: #25364d;
}

.cabinet-editor-loading[hidden] { display: none; }

.cabinet-editor-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #d7e2ef;
  border-top-color: #1f67b1;
  border-radius: 50%;
  animation: cabinet-editor-spin 0.8s linear infinite;
}

body.is-saving { overflow: hidden; }

.machines-saving {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgb(255 255 255 / 88%);
  color: #25364d;
}

.machines-saving[hidden] { display: none; }

@keyframes cabinet-editor-spin {
  to { transform: rotate(360deg); }
}

.system-content {
  max-width: 1500px;
  font-size: 0.88rem;
}

.system-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 9px;
  margin-bottom: 18px;
}

.system-toolbar label {
  display: grid;
  min-width: 310px;
  gap: 5px;
}

.system-toolbar button,
.system-toolbar .button-link {
  min-height: 39px;
  margin: 0;
  padding: 9px 14px;
}

.system-toolbar > button:not(.secondary-button) {
  border: 1px solid #1565c0;
  border-radius: 7px;
  color: #fff;
  background: #1565c0;
  font-weight: 700;
}

.system-form,
.model-form { margin-top: 0; }

.system-content > .editor-tabs {
  gap: 0;
  border: 1px solid #cbd2dc;
  border-width: 1px 0;
  background: #f7f8fa;
}

.system-content > .editor-tabs button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  margin: 0;
  padding: 6px 12px;
  border: 0;
  border-right: 1px solid #d9dee6;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: #263244;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 600;
}

.system-content > .editor-tabs button.active {
  border-bottom-color: #1565c0;
  background: #fff;
  color: #0d4f94;
}

.system-content > .editor-tabs img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.system-view-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 610px;
  border-bottom: 1px solid #dfe4ec;
  background: #fffef7;
}

.system-view-navigation {
  padding: 14px 0;
  border-right: 1px solid #bfc9d6;
  background: #e5f5fb;
}

.system-view-navigation button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  color: #172033;
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
}

.system-view-navigation button:hover,
.system-view-navigation button.active {
  background: #fff;
  color: #0d5da8;
  font-weight: 700;
}

.system-view-content {
  min-width: 0;
  padding: 14px 18px 24px;
}

.system-view-content > h2 {
  margin: 0 0 12px;
  color: #111827;
  font-size: 1.35rem;
}

.system-view-images {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 15px;
  padding: 12px;
  border: 1px solid #d7d9d2;
  background: #fffef7;
}

.system-view-images img {
  max-width: min(260px, 100%);
  height: clamp(80px, 11vw, 165px);
  object-fit: contain;
}

.rc-stage-scroller {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #d7d9d2;
  background: #fffef7;
}

.rc-stage {
  position: relative;
  width: 100%;
  min-width: 760px;
  max-width: 1164px;
  aspect-ratio: 582 / 395;
  color: #111;
  background: #fffef7;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: clamp(11px, 1.05vw, 15px);
}

.rc-stage > * { position: absolute; }

.rc-group {
  border: 1px solid #cfd2cc;
  background: transparent;
  pointer-events: none;
}

.rc-group > span {
  position: absolute;
  top: -0.75em;
  left: 8px;
  padding: 0 4px;
  background: #fffef7;
  font-weight: 500;
  white-space: nowrap;
}

.rc-image,
.rc-marker {
  display: block;
  object-fit: contain;
}

.rc-marker { z-index: 2; }

.material-rc-stage .rc-upload-image {
  z-index: 3;
  padding: 0;
  border: 1px solid #b9bec5;
  background: #fff;
  cursor: pointer;
}

.material-rc-stage .rc-upload-image:hover,
.material-rc-stage .rc-upload-image:focus-visible {
  border-color: #276749;
  outline: 2px solid rgb(39 103 73 / 20%);
  outline-offset: 1px;
}

.material-rc-stage .rc-upload-image-empty {
  background: repeating-conic-gradient(#f3f4f6 0 25%, #fff 0 50%) 50% / 12px 12px;
}

.rc-text {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.rc-text-l { justify-content: flex-start; }
.rc-text-c { justify-content: center; }

.rc-stage > input[type="number"],
.rc-stage > .rc-bound-input {
  z-index: 3;
  min-height: 0;
  margin: 0;
  padding: 1px 4px;
  border: 1px solid #b9bec5;
  border-radius: 0;
  background: #fff;
  font: inherit;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 7%);
  appearance: textfield;
}

.rc-stage > .rc-bound-range {
  z-index: 3;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 4px;
}

.rc-stage > .rc-bound-range input[type="range"] { height: 100%; }

.rc-stage > .rc-bound-range output {
  align-self: stretch;
  padding: 0 2px;
  border-radius: 0;
  font-size: 0.78em;
  line-height: inherit;
}

.rc-stage > .material-color-input {
  z-index: 3;
  min-height: 0;
  margin: 0;
  padding: 1px;
  border: 1px solid #b9bec5;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  appearance: auto;
}

.rc-stage > select.rc-bound-input {
  padding: 0 3px;
  appearance: auto;
}

.rc-stage > input[type="number"]::-webkit-inner-spin-button,
.rc-stage > input[type="number"]::-webkit-outer-spin-button { appearance: none; }

.rc-choice {
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: visible;
  line-height: 1;
  white-space: nowrap;
}

.rc-choice input {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  box-shadow: none;
}

.material-rc-stage .rc-command {
  z-index: 3;
  min-height: 0;
  margin: 0;
  padding: 1px 4px;
  border: 1px solid #b9bec5;
  border-radius: 2px;
  color: #333;
  background: #f6f6f6;
  font: inherit;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-top: 16px;
}

.system-grid .form-section {
  padding: 14px;
  border-color: #d7d9d2;
  border-radius: 3px;
  background: #fffef7;
}

.system-grid .form-section legend { font-size: 0.95rem; }
.system-grid .form-grid { gap: 11px 14px; }
.system-grid input,
.system-grid select { min-height: 34px; padding: 7px 9px; }

.mechanized-editor {
  display: grid;
  gap: 14px;
  padding-top: 16px;
}

.fixture-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.fixture-row {
  margin: 0;
  padding: 14px;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
}

.model-content { max-width: 1200px; }
.model-form { margin-top: 18px; }
.model-options { display: flex; flex-wrap: wrap; gap: 16px 28px; }

.model-rc-content > h2 {
  margin: 18px 22px 10px;
  color: #111827;
  font-size: 1.35rem;
}

.model-rc-content .rc-stage-scroller {
  border-right: 0;
  border-left: 0;
}

.focus-dialog {
  width: min(620px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 24px;
  border: 1px solid #cbd2dc;
  border-radius: 12px;
  box-shadow: 0 18px 55px rgb(25 38 61 / 20%);
}

.focus-dialog::backdrop { background: rgb(15 23 42 / 35%); }
.focus-dialog form { margin: 0; }
.focus-dialog h2 { margin: 0 0 12px; }

.dialog-fields {
  display: grid;
  max-height: 60vh;
  gap: 10px;
  overflow: auto;
}

.dialog-fields label { display: grid; gap: 5px; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

.dialog-actions button { margin: 0; }

.color-sample {
  display: inline-block;
  width: 42px;
  height: 24px;
  border: 1px solid #9aa5b1;
}

.piece-editor-content { max-width: 1100px; }
.piece-editor-content fieldset { margin: 0 0 18px; padding: 18px; }
.piece-editor-content label { display: grid; gap: 5px; }

.piece-general-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
}

.piece-general-grid legend { grid-column: 1 / -1; }
.piece-general-grid .check-group { grid-column: 1 / -1; }
.check-group, .check-grid { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.check-group label, .check-grid label, .piece-edge-grid section > label { display: flex; align-items: center; gap: 7px; }
.piece-line-toolbar { display: flex; gap: 18px; margin-bottom: 18px; }
.piece-line-toolbar label { min-width: 260px; }

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

.piece-edge-grid section { padding: 14px; border: 1px solid #d7dfe9; }
.piece-edge-grid h3 { margin: 0 0 12px; }
.piece-edge-grid section > label + label { margin-top: 8px; }

.machining-content { max-width: 1600px; }
.machining-table { overflow-x: auto; }
.machining-table table { min-width: 1450px; }
.machining-table th, .machining-table td { padding: 5px; }
.machining-table input, .machining-table select { min-width: 72px; padding: 6px; }
.machining-table [data-field=tipo] { min-width: 170px; }
.machining-table [data-field=cod_parte] { min-width: 220px; }
.machining-table [data-field=macro] { min-width: 140px; }

.piece-rc-stage {
  min-width: 760px;
  max-width: 1072px;
  aspect-ratio: 536 / 422;
  background: #fffef7;
  font-size: clamp(10px, 1.15vw, 14px);
}

.piece-rc-stage > [data-rc] { position: absolute; }
.piece-rc-stage .rc-text { padding-right: 4px; }
.piece-rc-stage .rc-bound-input,
.piece-rc-stage select.rc-bound-input {
  min-height: 0;
  margin: 0;
  padding: 1px 4px;
  border: 1px solid #aeb5bd;
  border-radius: 0;
  font: inherit;
}

.piece-rc-stage .piece-color {
  min-height: 0;
  margin: 0;
  padding: 1px 3px;
  border: 1px solid #aeb5bd;
  border-radius: 0;
  background: #fff;
}

.piece-separator { border-top: 2px solid #333; }

.piece-rc-stage .rc-command {
  z-index: 5;
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1px 3px;
  border: 1px solid #9da5af;
  border-radius: 2px;
  color: #111;
  background: #f5f5f5;
  font: inherit;
  line-height: 1;
}

.piece-rc-stage .icon-command { padding: 0; }
.piece-rc-stage .icon-command img { width: 100%; height: 100%; object-fit: contain; }

.hinge-filter-content { max-width: 1220px; }
.hinge-stage-scroller { margin-top: 22px; }

.hinge-rc-stage {
  min-width: 880px;
  max-width: 1172px;
  aspect-ratio: 586 / 281;
  font-size: clamp(10px, 1.05vw, 14px);
}

.hinge-rc-stage > [data-rc] { position: absolute; }

.hinge-rc-stage .rc-bound-input,
.hinge-rc-stage .rc-list {
  z-index: 3;
  min-height: 0;
  margin: 0;
  padding: 1px 4px;
  border: 1px solid #aeb5bd;
  border-radius: 0;
  background: #fff;
  font: inherit;
}

.hinge-rc-stage .rc-list {
  padding: 2px;
  overflow: auto;
}

.hinge-rc-stage .rc-command {
  z-index: 5;
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1px 3px;
  border: 1px solid #9da5af;
  border-radius: 2px;
  color: #111;
  background: #f5f5f5;
  font: inherit;
  line-height: 1;
}

.hinge-filter-grid {
  z-index: 4;
  display: flex;
  min-height: 0;
  flex-direction: column;
  border: 1px solid #aeb5bd;
  background: #fff;
}

.hinge-filter-header,
.hinge-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 24px;
  align-items: center;
}

.hinge-filter-header {
  flex: 0 0 auto;
  min-height: 24px;
  border-bottom: 1px solid #aeb5bd;
  background: #ececec;
  font-weight: 600;
  text-align: center;
}

.hinge-filter-rows { overflow: auto; }
.hinge-filter-row { border-bottom: 1px solid #d7d9dd; }

.hinge-filter-row input {
  min-width: 0;
  height: 25px;
  margin: 0;
  padding: 2px 4px;
  border: 0;
  border-right: 1px solid #d7d9dd;
  border-radius: 0;
  box-shadow: none;
  appearance: textfield;
}

.hinge-filter-row button {
  height: 25px;
  margin: 0;
  padding: 0;
  border: 0;
  color: #8f1e2d;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.piece-edge-tabs {
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: stretch;
}

.piece-edge-tabs button {
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #aeb5bd;
  border-radius: 2px 2px 0 0;
  color: #111;
  background: #ececec;
  font: inherit;
}

.piece-edge-tabs button + button { border-left: 0; }
.piece-edge-tabs button.active { border-bottom-color: #fff; background: #fff; font-weight: 700; }

.piece-edge-canvas {
  z-index: 3;
  display: block;
  border: 1px solid #9da5af;
  background: #fff;
  cursor: crosshair;
  touch-action: manipulation;
}

.piece-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #9da5af;
  background: #fff;
}

.piece-preview img { width: 100%; height: 100%; object-fit: contain; }

.piece-editor-content .piece-rotation {
  z-index: 3;
  min-width: 0;
  margin: 0;
  padding: 10px 8px 4px;
  border: 1px solid #aeb5bd;
  border-radius: 0;
  background: transparent;
  pointer-events: auto;
}

.piece-rotation legend {
  width: auto;
  margin: 0;
  padding: 0 4px;
  font: inherit;
  font-weight: 400;
}

.rotation-options {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.rotation-options label { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.rotation-options input { width: 14px; height: 14px; margin: 0; }
.piece-cancel { text-decoration: none; }

.api-test-content { max-width: 980px; }

.api-test-warning {
  padding: 12px 14px;
  border: 1px solid #d8a226;
  border-radius: 6px;
  background: #fff8df;
  color: #664b08;
}

.api-test-form,
.api-test-response {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #ccd3dc;
  border-radius: 8px;
  background: #fff;
}

.api-test-form .form-field {
  display: grid;
  gap: 7px;
}

.material-import-source { margin-top: 16px; }
.material-import-progress { margin-top: 18px; }
.material-import-progress progress { width: 100%; height: 18px; }
#import-preview .table-wrapper { max-height: 520px; }
.material-import-details { margin-top: 18px; }
.material-import-details .page-heading { align-items: center; }
.material-import-details pre { max-height: 360px; }

.api-test-credentials {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.api-test-json {
  width: 100%;
  min-height: 420px;
  padding: 12px;
  border: 1px solid #cbd2dc;
  border-radius: 8px;
  outline: none;
  resize: vertical;
  font: 14px/1.45 Consolas, "Courier New", monospace;
}

.api-test-json:focus {
  border-color: #1565c0;
  box-shadow: 0 0 0 3px rgb(21 101 192 / 14%);
}

.api-test-response pre {
  min-height: 90px;
  overflow: auto;
  padding: 14px;
  border-radius: 6px;
  background: #17202a;
  color: #f4f6f7;
  white-space: pre-wrap;
}

@media (max-width: 1500px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 64px;
    padding: 12px 14px;
  }
  .navigation-toggle { display: block; margin-left: auto; }
  .main-navigation, .topbar-global-actions {
    display: none;
    width: 100%;
  }
  .navigation-open .main-navigation {
    display: grid;
    order: 3;
  }
  .navigation-open .main-navigation a {
    height: auto;
    min-height: 42px;
    border-bottom: 0;
    border-left: 3px solid transparent;
  }
  .navigation-open .main-navigation a.active { border-left-color: #1565c0; }
  .navigation-open .topbar-global-actions {
    display: flex;
    order: 4;
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 1050px) {
  .material-browse-filters { grid-template-columns: repeat(2, minmax(170px, 1fr)); }
  .model-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .login-card { padding: 28px; }
  .content { width: min(100% - 28px, 1240px); margin-top: 24px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .browse-filters { align-items: stretch; flex-direction: column; }
  .browse-tools { align-items: stretch; flex-direction: column; }
  .material-browse-filters, .model-filter-grid { grid-template-columns: 1fr; }
  .material-browse-checks { align-items: flex-start; flex-direction: column; gap: 0; }
  .tab-panel { grid-template-columns: 1fr; }
  .wide-group { grid-column: auto; }
  .relation-search { grid-template-columns: 1fr; }
  .default-field { grid-template-columns: 1fr; gap: 6px; }
  .door-default-assign-all { width: 100%; margin-left: 0; }
  .storage-actions, .storage-toolbar { align-items: stretch; flex-direction: column; }
  .pack-web-setting { align-items: stretch; flex-direction: column; }
  .pack-web-setting code { white-space: normal; overflow-wrap: anywhere; }
  .pack-web-setting button:first-of-type { margin-left: 0; }
  .system-grid { grid-template-columns: 1fr; }
  .system-toolbar label { min-width: 100%; }
  .system-view-layout { grid-template-columns: 1fr; }
  .system-view-navigation {
    display: flex;
    overflow-x: auto;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid #bfc9d6;
  }
  .system-view-navigation button { width: auto; white-space: nowrap; }
  .material-rc-view { grid-template-columns: 1fr; }
  .material-rc-navigation {
    display: flex;
    overflow-x: auto;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid #bfc9d6;
  }
  .material-rc-navigation button { width: auto; white-space: nowrap; }
  .system-view-images img { height: 105px; }
  .piece-general-grid, .piece-edge-grid { grid-template-columns: 1fr; }
  .piece-line-toolbar { flex-direction: column; }
  .api-test-credentials { grid-template-columns: 1fr; }
  .settings-grid, .settings-checks { grid-template-columns: 1fr; }
}
