:root {
  color-scheme: light;
  --page: #f3f1eb;
  --surface: #ffffff;
  --surface-soft: #f8f7f3;
  --ink: #18201a;
  --muted: #6c746e;
  --line: #dedfd8;
  --line-strong: #c8cbc3;
  --sidebar: #16211a;
  --sidebar-muted: #aebbb1;
  --accent: #e56732;
  --accent-dark: #ba4820;
  --accent-soft: #fce8dd;
  --green: #287950;
  --green-soft: #e6f3eb;
  --yellow: #9a6813;
  --yellow-soft: #fff3d5;
  --red: #b33a33;
  --red-soft: #fae7e4;
  --blue: #346c87;
  --blue-soft: #e7f0f4;
  --shadow: 0 18px 50px rgba(29, 38, 31, 0.12);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(229, 103, 50, 0.3);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  background: var(--sidebar);
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 30px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--sidebar-muted);
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-item.is-active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.nav-count {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  text-align: center;
}

.admin-subnav {
  display: grid;
  gap: 3px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.admin-subnav p {
  margin: 0 10px 7px;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-subnav-item {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 13px;
  text-align: left;
}

.admin-subnav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.admin-subnav-item.is-active {
  border-left-color: var(--accent);
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.sidebar-note {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 0;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.account-card {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.account-card[hidden] + .sidebar-note {
  margin-top: auto;
}

.account-card span,
.account-card small {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.account-card strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}

.demo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.main-content {
  min-width: 0;
  padding: 34px clamp(20px, 2vw, 36px) 56px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 5px;
  font-size: 20px;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 3px;
  font-size: 17px;
}

h4 {
  margin-bottom: 0;
  font-size: 15px;
}

.page-caption,
.section-toolbar p,
.form-section-heading p,
.settings-card small,
.field small {
  color: var(--muted);
}

.page-caption {
  margin-bottom: 0;
}

.global-message {
  margin: -12px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.global-message.is-error {
  border-color: rgba(179, 58, 51, 0.25);
  background: var(--red-soft);
  color: var(--red);
}

.global-message.is-success {
  border-color: rgba(40, 121, 80, 0.25);
  background: var(--green-soft);
  color: var(--green);
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover {
  background: var(--surface-soft);
}

.button-danger {
  border-color: rgba(179, 58, 51, 0.3);
  background: var(--red-soft);
  color: var(--red);
}

.button-danger:hover {
  border-color: var(--red);
  background: #f7d8d4;
}

.order-detail-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.archive-actions {
  text-align: right;
}

.button-small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.button-text {
  min-height: 34px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 650;
}

.button-text:hover {
  text-decoration: underline;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card span,
.metric-card small,
.metric-card strong {
  display: block;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  margin: 7px 0 3px;
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
}

.metric-card.metric-danger {
  background: var(--red-soft);
  border-color: rgba(179, 58, 51, 0.25);
}

.metric-card.metric-danger strong {
  color: var(--red);
}

.content-section,
.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.section-toolbar,
.settings-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.section-toolbar {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.section-toolbar p,
.settings-card-header p {
  margin-bottom: 0;
  font-size: 13px;
}

.compact-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
}

select,
input {
  min-height: 42px;
  padding: 8px 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
}

.compact-field select {
  width: auto;
  min-width: 185px;
  min-height: 38px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.orders-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

.orders-table th,
.orders-table td {
  padding: 15px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.orders-table th:first-child,
.orders-table td:first-child {
  padding-left: 18px;
}

.orders-table th:last-child,
.orders-table td:last-child {
  padding-right: 18px;
}

.orders-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.orders-table tbody tr:last-child td {
  border-bottom: 0;
}

.order-row:hover td {
  background: var(--surface-soft);
}

.priority-cell {
  min-width: 82px;
}

.priority-rank {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
}

.zone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.zone-red .zone-dot {
  background: var(--red);
}

.zone-green .zone-dot {
  background: var(--green);
}

.zone-overdue .zone-dot {
  background: #ffffff;
}

.zone-neutral .zone-dot {
  background: var(--line-strong);
}

.order-row.zone-red .priority-cell,
.order-row.zone-red .coefficient-cell {
  background: var(--red-soft);
  color: var(--red);
}

.order-row.zone-green .priority-cell,
.order-row.zone-green .coefficient-cell {
  background: var(--green-soft);
  color: var(--green);
}

.order-row.zone-neutral .priority-cell,
.order-row.zone-neutral .coefficient-cell {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.order-row.zone-overdue .priority-cell,
.order-row.zone-overdue .coefficient-cell {
  background: #111713;
  color: #ffffff;
}

.order-row.zone-overdue .priority-label {
  color: #c7d0c9;
}

.priority-label,
.cell-secondary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.coefficient-cell {
  min-width: 112px;
}

.coefficient-value {
  display: block;
  font-size: 20px;
  font-weight: 750;
  line-height: 1;
}

.order-title {
  min-width: 170px;
}

.order-title strong {
  display: block;
  margin-bottom: 3px;
}

.order-title span {
  color: var(--muted);
  font-size: 12px;
}

.time-cell {
  min-width: 125px;
}

.time-cell strong {
  display: block;
}

.stage-list {
  min-width: 195px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

.stage-chip:has(input:checked) {
  border-color: rgba(40, 121, 80, 0.25);
  background: var(--green-soft);
  color: var(--green);
}

.stage-chip input {
  width: 14px;
  height: 14px;
  min-height: 0;
  margin: 0;
  accent-color: var(--green);
}

.current-operation {
  display: grid;
  min-width: 190px;
  gap: 5px;
  justify-items: start;
}

.current-operation small,
.route-complete {
  color: var(--muted);
  font-size: 11px;
}

.current-stage-chip {
  border-color: rgba(229, 103, 50, 0.35);
  background: var(--accent-soft);
}

.status-badge {
  display: inline-flex;
  width: max-content;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-work {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-new,
.status-neutral {
  background: #eef0ec;
  color: #566058;
}

.status-ready,
.status-done {
  background: var(--green-soft);
  color: var(--green);
}

.status-warning {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.detail-row td {
  padding-top: 0;
  background: var(--surface-soft);
}

.order-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 16px;
  align-items: end;
  padding: 16px;
  border-left: 3px solid var(--accent);
}

.detail-block span,
.detail-block strong {
  display: block;
}

.detail-block span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 40px 22px !important;
  color: var(--muted);
  text-align: center !important;
}

.settings-layout {
  display: grid;
  gap: 16px;
  max-width: 1180px;
}

.settings-card {
  padding: 22px;
}

.settings-card-header {
  margin-bottom: 20px;
}

.pricing-settings-list {
  display: grid;
  gap: 24px;
}

.pricing-settings-group + .pricing-settings-group {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.pricing-settings-group h3 {
  margin-bottom: 14px;
  font-size: 15px;
}

.pricing-admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pricing-admin-field {
  min-width: 0;
}

.resource-settings-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.resource-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(130px, 0.8fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.resource-card-cutting {
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1.5fr);
}

.resource-card-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 8px;
}

.resource-add-block {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #fff;
}

.resource-add-block h3,
.resource-add-block h4 {
  margin-bottom: 12px;
}

.resource-add-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.6fr) auto;
  align-items: end;
  gap: 12px;
}

.resource-add-grid-cutting {
  grid-template-columns: minmax(220px, 1.2fr) minmax(120px, 0.5fr) minmax(120px, 0.5fr) auto;
}

.settings-panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 20px;
}

.settings-panel-actions p {
  margin: 0 auto 0 0;
  color: var(--green);
  font-size: 13px;
}

.profile-password-form {
  display: grid;
  gap: 16px;
}

.profile-password-form h3 {
  margin: 0;
}

.profile-session-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.profile-session-actions p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.invite-form,
.invite-result,
.access-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.invite-form > div:first-child p {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.invite-result,
.access-section {
  margin-top: 16px;
}

.invite-result > div {
  display: flex;
  gap: 8px;
  margin: 10px 0 6px;
}

.invite-result input {
  min-width: 0;
  flex: 1;
}

.invite-result small {
  color: var(--muted);
}

.access-user-list {
  display: grid;
  gap: 10px;
}

.access-user-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px auto auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.access-user-card > div:first-child {
  align-self: center;
}

.access-user-card strong,
.access-user-card small {
  display: block;
}

.access-user-card small {
  margin-top: 4px;
  color: var(--muted);
}

.invitation-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.invitation-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.invitation-list li:last-child {
  border-bottom: 0;
}

.invitation-list strong,
.invitation-list small {
  display: block;
}

.invitation-list small {
  margin-top: 3px;
  color: var(--muted);
}

.settings-grid,
.speed-grid {
  display: grid;
  gap: 16px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.speed-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.settings-actions p {
  margin-bottom: 0;
  color: var(--green);
  font-size: 13px;
}

.operation-settings-list {
  display: grid;
  gap: 12px;
}

.operation-setting-card,
.operation-add-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.operation-setting-heading,
.operation-setting-footer,
.operation-add-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.operation-setting-heading {
  margin-bottom: 14px;
}

.operation-setting-heading > strong {
  font-size: 15px;
}

.operation-settings-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(130px, 1fr));
  gap: 12px;
}

.operation-setting-footer {
  margin-top: 14px;
}

.operation-setting-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.operation-setting-footer small,
.operation-add-actions p,
.empty-inline {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.operation-add-block {
  margin-top: 18px;
  border-style: dashed;
  background: #ffffff;
}

.operation-add-block h3 {
  margin-bottom: 14px;
}

.operation-add-actions {
  margin-top: 14px;
}

.active-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.active-switch input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--accent);
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  font-size: 13px;
  font-weight: 650;
}

.field small {
  font-size: 12px;
  line-height: 1.4;
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 62px;
}

.input-with-unit > span {
  position: absolute;
  top: 50%;
  right: 11px;
  color: var(--muted);
  font-size: 12px;
  transform: translateY(-50%);
  pointer-events: none;
}

.view:not(.is-visible) {
  display: none;
}

.order-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.order-dialog::backdrop {
  background: rgba(16, 23, 18, 0.62);
  backdrop-filter: blur(3px);
}

.auth-dialog {
  width: min(470px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 28px;
  overflow-y: auto;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.auth-dialog::backdrop {
  background: rgba(16, 23, 18, 0.82);
  backdrop-filter: blur(5px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-brand strong,
.auth-brand small {
  display: block;
}

.auth-brand small {
  margin-top: 2px;
  color: var(--muted);
}

.auth-dialog h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 32px);
}

.auth-dialog #authContent > p:not(.eyebrow) {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 15px;
}

.auth-form .button-primary,
.auth-continue {
  width: 100%;
  margin-top: 4px;
}

.auth-error {
  margin-bottom: 16px;
  padding: 11px 12px;
  border: 1px solid #efb6b0;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
}

.totp-setup {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.totp-setup img {
  width: min(240px, 70vw);
  aspect-ratio: 1;
  border: 10px solid #ffffff;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 8px 30px rgba(29, 38, 31, 0.12);
}

.totp-setup > div {
  width: 100%;
  text-align: center;
}

.totp-setup span,
.totp-setup code {
  display: block;
}

.totp-setup span {
  color: var(--muted);
  font-size: 12px;
}

.totp-setup code {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.recovery-codes code {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 12px;
  text-align: center;
}

.order-dialog form {
  display: flex;
  max-height: calc(100vh - 32px);
  flex-direction: column;
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin-bottom: 0;
}

.dialog-footer {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.dialog-body {
  overflow-y: auto;
  padding: 22px;
}

.wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.wizard-progress {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 6px 12px;
  margin-bottom: 22px;
}

.wizard-progress > span {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wizard-progress > strong {
  font-size: 15px;
}

.wizard-progress-track {
  height: 4px;
  grid-column: 1 / -1;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}

.wizard-progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.form-error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(179, 58, 51, 0.25);
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
}

.form-section {
  margin-bottom: 28px;
}

.form-section-heading {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.form-section-heading > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.form-section-heading p {
  margin-bottom: 0;
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-wide {
  grid-column: span 1;
}

.field-full {
  grid-column: 1 / -1;
}

.auto-number-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.auto-number-note strong {
  font-size: 13px;
}

.auto-number-note span,
.route-order-quantity {
  color: var(--muted);
  font-size: 11px;
}

.route-order-quantity strong {
  color: var(--text);
}

.operation-selector {
  display: block;
}

.operation-add-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.operation-add-field {
  flex: 1;
}

.operation-add-row .button {
  min-height: 42px;
  white-space: nowrap;
}

.route-builder-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.route-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.route-step-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.route-step-copy {
  display: grid;
  gap: 4px;
}

.route-step-copy > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.route-step-copy input {
  min-height: 36px;
  padding: 7px 9px;
  font-weight: 700;
}

.route-step-copy small {
  display: block;
}

.route-step-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.route-step-actions {
  display: flex;
  gap: 6px;
}

.route-icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.route-icon-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.route-icon-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.route-remove-button:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.route-instance-label {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.operation-selector-contents {
  display: contents;
}

.operation-choice {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.operation-choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.operation-choice input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.operation-choice strong,
.operation-choice small {
  display: block;
}

.pricing-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.option-card {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.option-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-card input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.option-card strong,
.option-card small {
  display: block;
}

.option-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.pricing-toggle {
  width: fit-content;
  margin-bottom: 12px;
}

.compact-price-field {
  width: 180px;
}

.pricing-line {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: 9px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
}

.pricing-line strong {
  color: var(--ink);
}

.operation-choice strong {
  font-size: 13px;
}

.operation-choice small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.operation-panel {
  margin-top: 10px;
  padding: 16px;
  border-left: 3px solid var(--line-strong);
  background: var(--surface-soft);
}

.operation-details:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.operation-details > .form-section-heading {
  order: 0;
}

.operation-panel[data-operation-panel="print"] {
  order: 30;
}

.operation-panel[data-operation-panel="plotter"] {
  order: 40;
}

.operation-panel[data-operation-panel="laser"] {
  order: 50;
}

.catalog-operation-panels {
  display: contents;
}

.wizard-review {
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.wizard-review-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.wizard-review-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.wizard-review-facts > div {
  padding: 12px;
  border-radius: 10px;
  background: #fff;
}

.wizard-review-facts dt {
  color: var(--muted);
  font-size: 11px;
}

.wizard-review-facts dd {
  margin: 4px 0 0;
  font-weight: 750;
}

.wizard-review-route {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 24px;
}

.wizard-review-route li {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.wizard-review-route strong,
.wizard-review-route span {
  display: block;
}

.wizard-review-route span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.operation-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.operation-panel-title output {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
}

.duration-fields {
  display: grid;
  max-width: 360px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.duration-fields-with-repeat {
  max-width: 560px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.duration-fields-single {
  max-width: 360px;
  grid-template-columns: 1fr;
}

.postpress-fields {
  max-width: 760px;
}

.postpress-fields .field-wide {
  grid-column: 1 / -1;
}

.inline-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.calculation-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border-radius: 12px;
  background: var(--sidebar);
  color: #ffffff;
}

.calculation-summary span,
.calculation-summary strong {
  display: block;
}

.calculation-summary span {
  margin-bottom: 5px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.calculation-summary strong {
  font-size: 18px;
}

.calculation-summary p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 12px;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .main-content {
    padding-inline: 22px;
  }

  .pricing-admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .operation-selector {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .resource-settings-list {
    grid-template-columns: 1fr;
  }

  .resource-add-grid,
  .resource-add-grid-cutting {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .access-user-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid,
  .speed-grid,
  .operation-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .pricing-admin-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px 16px;
  }

  .brand {
    padding: 0 0 12px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
  }

  .admin-subnav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-top: 10px;
    padding-top: 10px;
  }

  .admin-subnav p {
    display: none;
  }

  .admin-subnav-item {
    width: auto;
    flex: 0 0 auto;
    border-left: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }

  .admin-subnav-item.is-active {
    border-bottom-color: var(--accent);
  }

  .sidebar-note {
    display: none;
  }

  .account-card {
    display: none;
  }

  .main-content {
    padding: 24px 16px 40px;
  }

  .page-header {
    align-items: center;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .metric-card {
    min-width: 150px;
  }

  .settings-grid,
  .speed-grid,
  .operation-settings-grid {
    grid-template-columns: 1fr;
  }

  .operation-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .operation-add-row {
    align-items: stretch;
    flex-direction: column;
  }

  .route-step {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .route-step-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .form-grid,
  .form-grid-three {
    grid-template-columns: 1fr;
  }

  .calculation-summary {
    grid-template-columns: 1fr;
  }

  .resource-card,
  .resource-card-cutting,
  .resource-add-grid,
  .resource-add-grid-cutting,
  .access-user-card,
  .wizard-review-facts {
    grid-template-columns: 1fr;
  }

  .resource-add-grid .button,
  .resource-add-grid-cutting .button {
    width: 100%;
  }

  .calculation-summary p {
    grid-column: 1;
  }
}

@media (max-width: 560px) {
  .nav-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .nav-item {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding-inline: 8px;
    font-size: 12px;
  }

  .nav-count {
    min-width: 24px;
    padding-inline: 6px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header .button {
    width: 100%;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .metric-card {
    min-width: 0;
  }

  .metric-card:last-child {
    grid-column: 1 / -1;
  }

  .section-toolbar,
  .settings-card-header,
  .settings-actions,
  .settings-panel-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-session-actions,
  .invite-result > div,
  .invitation-list li {
    align-items: stretch;
    flex-direction: column;
  }

  .recovery-codes {
    grid-template-columns: 1fr;
  }

  .compact-field {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-field select {
    width: 100%;
  }

  .orders-table {
    min-width: 0;
  }

  .orders-table thead {
    display: none;
  }

  .orders-table tbody,
  .orders-table tr,
  .orders-table td {
    display: block;
    width: 100%;
  }

  .orders-table tr {
    padding: 16px;
    border-bottom: 1px solid var(--line);
  }

  .orders-table td,
  .orders-table th:first-child,
  .orders-table td:first-child,
  .orders-table th:last-child,
  .orders-table td:last-child {
    padding: 7px 0;
    border: 0;
  }

  .orders-table td::before {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .detail-row {
    padding-top: 0 !important;
  }

  .detail-row td::before {
    display: none;
  }

  .order-detail {
    grid-template-columns: 1fr;
  }

  .stage-list,
  .order-title,
  .time-cell {
    min-width: 0;
  }

  .operation-selector {
    grid-template-columns: 1fr;
  }

  .duration-fields {
    grid-template-columns: 1fr 1fr;
  }

  .duration-fields-with-repeat,
  .operation-setting-heading,
  .operation-setting-footer,
  .operation-add-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .duration-fields-with-repeat {
    grid-template-columns: 1fr;
  }

  .dialog-header,
  .dialog-footer,
  .dialog-body {
    padding-inline: 16px;
  }

  .dialog-footer .button {
    flex: 1;
  }
}
