:root {
  --bg-top: #f3ead6;
  --bg-bottom: #efe3c8;
  --card: #fffaf0;
  --card-border: #ddcfae;
  --text-main: #2f2517;
  --text-muted: #6f5f45;
  --accent: #2b8a78;
  --accent-dark: #206c5f;
  --accent-soft: #d9f0ea;
  --warn: #b45a2c;
  --table-head: #efe4c8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  font-family: "Manrope", "Trebuchet MS", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 100% 0%, rgba(43, 138, 120, 0.12), transparent 35%),
    radial-gradient(circle at 0% 100%, rgba(180, 90, 44, 0.13), transparent 45%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--card-border);
  background: rgba(255, 248, 233, 0.85);
  backdrop-filter: blur(4px);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.brand h1 {
  margin: 0;
  letter-spacing: 0.08em;
  font-size: 32px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.nav {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav button {
  border: 1px solid var(--card-border);
  background: #fff6df;
  color: var(--text-main);
  text-align: left;
  border-radius: 8px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.15;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.nav button:hover {
  transform: translateX(2px);
}

.nav button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-item-main {
  font-weight: 700;
}

.nav-item-child {
  margin-left: 6px;
  padding-left: 6px;
}

.nav-icon {
  width: 14px;
  text-align: center;
}

.nav-group {
  border: 1px dashed #d8c9a6;
  border-radius: 10px;
  padding: 5px;
  background: rgba(255, 250, 236, 0.7);
}

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
  padding: 2px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  color: var(--text-muted);
}

.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 14px;
}

.sidebar-footer a {
  color: var(--accent-dark);
  text-decoration: none;
}

.workspace {
  padding: 16px;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.workspace-header h2 {
  margin: 0;
  font-size: 32px;
}

.workspace-header p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  padding: 10px 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  border-color: var(--card-border);
  background: #fff6df;
  color: var(--text-main);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.status-box {
  margin-top: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
}

.status-box.success {
  background: var(--accent-soft);
  border: 1px solid #b8dcd3;
}

.status-box.error {
  background: #f9ddd0;
  border: 1px solid #e0b29b;
  color: #6f2f1e;
}

.hidden {
  display: none !important;
}

.content-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 420px);
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

.content-grid.orders-mode {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  align-items: stretch;
}

.content-grid.orders-mode > .card {
  min-height: 0;
  height: 100%;
}

.content-grid.orders-mode .table-wrap {
  height: 100%;
  max-height: none;
}

.content-grid.hidden {
  display: none;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.list-filters {
  margin: -2px 0 10px;
  padding: 8px;
  border: 1px solid #e2d5b5;
  border-radius: 10px;
  background: #fffef8;
}

.content-grid.orders-mode .list-filters {
  margin: 0 0 6px;
  padding: 5px 6px;
  border-radius: 8px;
}

.order-list-filters-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  align-items: end;
}

.content-grid.orders-mode .order-list-filters-grid {
  gap: 4px 6px;
}

.order-list-filters-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.content-grid.orders-mode .order-list-filters-grid label {
  gap: 2px;
  font-size: 11px;
}

.order-list-filters-grid input,
.order-list-filters-grid select {
  border: 1px solid #ccb98e;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  background: #fffef8;
}

.content-grid.orders-mode .order-list-filters-grid input,
.content-grid.orders-mode .order-list-filters-grid select {
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 12px;
}

.content-grid.orders-mode .list-filters .actions {
  gap: 6px;
}

.content-grid.orders-mode .list-filters .btn {
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  max-height: none;
  min-height: 0;
  height: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #e8dbbd;
  padding: 10px 8px;
  vertical-align: middle;
  font-size: 14px;
}

.content-grid.orders-mode th,
.content-grid.orders-mode td {
  padding: 6px 7px;
  font-size: 13px;
}

th {
  background: var(--table-head);
  position: sticky;
  top: 0;
}

tr.selected {
  background: #f2ead5;
}

.folder-row td {
  background: #fcf5e3;
  font-weight: 600;
}

.tree-cell {
  white-space: nowrap;
}

.dragging-row {
  opacity: 0.55;
}

.drop-target td {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: #eaf6f2 !important;
}

.root-drop-row td {
  background: #f4ecda;
  color: #6b5b40;
  font-size: 12px;
  font-style: italic;
}

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

.table-actions button {
  border: 1px solid #ccb98e;
  border-radius: 8px;
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
}

.table-actions button.delete {
  border-color: #c9957b;
  color: #7b2f0d;
}

.form-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.form-fields {
  display: grid;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 14px;
  color: var(--text-muted);
}

.field-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.9;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #ccb98e;
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  background: #fffdf7;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
}

.checkbox-field input {
  width: auto;
}

.form-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.line-section {
  margin-top: 6px;
  border: 1px solid #e3d4b2;
  border-radius: 10px;
  padding: 10px;
  background: #fffdf7;
}

#order-editor-form .line-section {
  margin-top: 4px;
  border: 1px solid #d9c39a;
  border-radius: 12px;
  padding: 9px;
  background: #fffefb;
  box-shadow: 0 2px 8px rgba(79, 61, 28, 0.08);
}

.editor-sections-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(640px, 100%), 1fr));
  gap: 10px;
  align-items: start;
}

.editor-sections-row .line-section {
  margin-top: 6px;
}

.editor-sections-col {
  display: grid;
  gap: 10px;
  align-content: start;
}

.line-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#order-editor-form .line-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: -2px -2px 10px;
  padding: 4px 6px 8px;
  border-bottom: 1px solid #eadcbe;
}

#order-editor-form .line-section-header.line-section-header-actions-left {
  justify-content: flex-start;
}

.line-section-header h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.client-cars-list {
  display: grid;
  gap: 6px;
}

.client-car-item {
  border: 1px solid #e5d8b8;
  border-radius: 8px;
  background: #fff;
  padding: 7px 8px;
  font-size: 13px;
}

.line-table th,
.line-table td {
  padding: 4px 3px;
  border-bottom: 1px solid #eadfc5;
  font-size: 12px;
  vertical-align: middle;
  white-space: nowrap;
}

.line-table th {
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-table td {
  overflow: visible;
  position: relative;
}

#order-editor-form .line-table-wrap {
  border: 1px solid #ecdfc2;
  border-radius: 10px;
  background: #fffefb;
  overflow-x: hidden;
  overflow-y: visible;
  max-height: none;
  position: relative;
}

.line-table {
  table-layout: fixed;
  width: 100%;
  min-width: 100%;
}

.line-table-services {
  min-width: 0;
}

.line-table-parts {
  min-width: 0;
}

.line-table-lifts {
  min-width: 0;
}

.line-table-assignments {
  min-width: 0;
}

.line-table th {
  position: static;
}

.table-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.content-grid.orders-mode .table-stack {
  gap: 0;
}

.table-stack-main {
  line-height: 1.2;
}

.content-grid.orders-mode .table-stack-main {
  line-height: 1.1;
}

.table-stack-sub {
  line-height: 1.2;
  font-size: 12px;
  color: var(--text-muted);
}

.content-grid.orders-mode .table-stack-sub {
  line-height: 1.1;
  font-size: 11px;
}

.line-table select,
.line-table input {
  width: 100%;
  min-width: 0;
  border: 1px solid #ccb98e;
  border-radius: 7px;
  padding: 4px 5px;
  font: inherit;
  background: #fffdf7;
}

.lookup-combo {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px;
  align-items: center;
  z-index: 1;
}

.lookup-combo.compact {
  width: 100%;
}

.lookup-combo:focus-within {
  z-index: 5000;
}

.lookup-combo-input {
  width: 100%;
  min-width: 0;
  border: 1px solid #ccb98e;
  border-radius: 7px;
  padding: 5px 6px;
  font: inherit;
  background: #fffdf7;
}

.lookup-combo .field-picker-btn {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.lookup-combo .line-picker-btn {
  padding: 4px 6px;
  min-width: 28px;
  width: 28px;
  text-align: center;
}

.lookup-combo-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 6000;
  display: block;
  border: 1px solid #dac59b;
  border-radius: 8px;
  background: #fffdf7;
  box-shadow: 0 10px 18px rgba(40, 32, 14, 0.12);
  max-height: 220px;
  overflow: auto;
}

.line-section-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.order-settlements-summary {
  margin-top: 8px;
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.order-settlements-section .line-table {
  table-layout: auto;
}

.order-settlements-section .line-table td,
.order-settlements-section .line-table th {
  white-space: normal;
  word-break: break-word;
}

.lookup-combo-option {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #efe4cd;
  background: transparent;
  text-align: left;
  padding: 6px 8px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lookup-combo-option:last-child {
  border-bottom: 0;
}

.lookup-combo-option:hover,
.lookup-combo-option:focus-visible {
  background: #f5ecd7;
}

.lookup-combo-empty {
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px;
}

.quick-create-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.quick-create-form .form-fields {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: 8px;
}

.quick-create-form .form-actions {
  margin-top: 0;
  padding-top: 8px;
  border-top: 1px solid #e6d8b7;
  background: var(--card);
}

.line-table input.line-amount {
  background: #f8f1dd;
  color: #5f5238;
  font-weight: 600;
}

.money-form {
  display: grid;
  gap: 10px;
}

.money-form-grid {
  display: grid;
  gap: 8px;
}

.money-form-grid-top {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.money-form-grid-middle {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.money-form-grid-bottom {
  grid-template-columns: 1fr;
}

.order-totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.order-total-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-total-field span {
  font-size: 12px;
  color: var(--text-muted);
}

.order-total-field input {
  width: 100%;
  border: 1px solid #ccb98e;
  border-radius: 7px;
  padding: 5px 6px;
  font: inherit;
  background: #f8f1dd;
  color: #5f5238;
  font-weight: 600;
}

.line-picker-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.line-picker-wrap .line-picker-btn {
  padding: 5px 8px;
  min-width: 32px;
  width: 32px;
  text-align: center;
}

.line-lift-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.line-reserve-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.line-num-sm {
  min-width: 52px !important;
  max-width: 80px;
}

.line-num-md {
  min-width: 74px !important;
  max-width: 112px;
}

.line-remove {
  border: 1px solid #c9957b;
  border-radius: 8px;
  background: #fff;
  color: #7b2f0d;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 11px;
  white-space: nowrap;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f6edd9;
}

.preview-panel {
  border: 1px solid #dfcfaa;
  border-radius: 12px;
  padding: 10px;
  background: #fffdf7;
  max-height: none;
  min-height: 0;
  flex: 1;
  overflow: auto;
  display: grid;
  gap: 10px;
}

#entity-form {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#entity-form.hidden {
  display: none;
}

#form-fields {
  min-height: 0;
  overflow: auto;
}

#entity-form .form-fields {
  gap: 7px;
}

#entity-form .field {
  gap: 2px;
}

#entity-form .field label {
  font-size: 12px;
}

#entity-form .field input,
#entity-form .field textarea,
#entity-form .field select {
  border-radius: 7px;
  padding: 5px 7px;
  font-size: 13px;
}

#entity-form .line-section {
  padding: 8px;
}

#entity-form .form-actions {
  margin-top: 8px;
  gap: 6px;
}

.preview-panel.hidden {
  display: none;
}

.preview-empty {
  color: var(--text-muted);
  font-style: italic;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preview-row {
  display: flex;
  flex-direction: column;
  border: 1px solid #eadfc5;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.preview-row strong {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.preview-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preview-head-group {
  border: 1px solid #eadfc5;
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

.preview-head-group h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preview-head-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preview-head-item {
  border: 1px solid #eee2c7;
  border-radius: 7px;
  background: #fffefb;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-head-item > span {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
}

.preview-head-item > strong {
  font-size: 14px;
  line-height: 1.25;
  font-weight: 600;
  word-break: break-word;
}

.preview-section {
  border: 1px solid #eadfc5;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.preview-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-table th,
.preview-table td {
  padding: 6px;
  font-size: 12px;
  border-bottom: 1px solid #efe5cf;
}

.preview-table th {
  position: static;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 18, 12, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1200;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(1400px, 98vw);
  height: min(94vh, 980px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-card-picker {
  width: min(980px, 96vw);
  height: min(86vh, 760px);
}

.modal-card-picker-compact-catalog {
  width: min(840px, 94vw);
  height: min(78vh, 640px);
}

.modal-card-money-editor {
  width: min(920px, 95vw);
  height: min(80vh, 700px);
}

.modal-card-document {
  width: min(1300px, 97vw);
  height: min(92vh, 920px);
}

.modal-document-host {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  background: linear-gradient(180deg, #f9f1de 0%, #f5ebd5 100%);
}

.modal-document-host .form-card {
  height: 100%;
  min-height: 0;
  box-shadow: 0 4px 16px rgba(62, 49, 24, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--card-border);
  background: #f8f0dd;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 20px;
}

#order-editor-form {
  flex: 1;
  overflow: auto;
  padding: 14px 16px 18px;
  background: linear-gradient(180deg, #f9f1de 0%, #f5ebd5 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#order-editor-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: auto;
  overflow: visible;
}

.order-editor-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f9f1de;
  padding: 4px 0 8px;
  border-bottom: 1px solid #e6d7b5;
}

.order-editor-tab {
  border: 1px solid #ccb98e;
  border-radius: 9px;
  background: #fff7e2;
  color: var(--text-main);
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  cursor: pointer;
}

.order-editor-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}


.order-editor-panes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: auto;
  overflow: visible;
}

.order-editor-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: auto;
  overflow: visible;
}

.order-editor-pane.hidden {
  display: none;
}

.order-editor-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.order-editor-mid-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 10px;
  align-items: start;
}

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

.order-head-card {
  grid-column: span 6;
  border: 1px solid #d9c39a;
  border-radius: 12px;
  background: #fffefb;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(79, 61, 28, 0.08);
}

.order-head-card-wide {
  grid-column: 1 / -1;
}

.order-head-card-span-full {
  grid-column: 1 / -1;
}

.order-head-title {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.order-head-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.order-head-card .field label {
  font-size: 11px;
}

.order-head-card .field input,
.order-head-card .field select {
  font-size: 13px;
  padding: 6px 8px;
}

.order-head-card-wide .order-head-fields {
  grid-template-columns: 1fr;
}

#order-editor-fields .field label {
  font-size: 12px;
}

#order-editor-fields .field input,
#order-editor-fields .field select,
#order-editor-fields .field textarea {
  padding: 7px 9px;
}

#order-editor-fields .field textarea {
  min-height: 74px;
}

.field-picker-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 8px;
  row-gap: 4px;
  align-items: center;
}

.field-picker-wrap label {
  grid-column: 1 / -1;
}

.field-picker-wrap select,
.field-picker-wrap input,
.field-picker-wrap textarea {
  grid-column: 1 / 2;
}

.field-picker-btn {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  min-width: 32px;
  width: 32px;
  padding: 5px 8px;
  text-align: center;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
}

.calendar-panel {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.calendar-panel.hidden {
  display: none;
}

.catalog-picker-body {
  flex: 1;
  min-height: 0;
  padding: 10px 16px;
  overflow: auto;
}

.catalog-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.catalog-picker-row {
  border: 1px solid #e4d6b4;
  border-radius: 8px;
  background: #fffdf7;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.catalog-picker-row.compact {
  padding-top: 5px;
  padding-bottom: 5px;
  gap: 6px;
}

.catalog-picker-row.folder {
  background: #fcf6e8;
  font-weight: 700;
}

.catalog-picker-main {
  min-width: 0;
}

.catalog-picker-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-picker-hint {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.catalog-picker-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.catalog-picker-row.compact .catalog-picker-title {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

.catalog-picker-hint-inline {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.lift-picker-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.lift-picker-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.lift-picker-toolbar input {
  border: 1px solid #ccb98e;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  background: #fffef8;
}

.lift-picker-host {
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
  border: 1px solid #e6d7b5;
  border-radius: 8px;
  background: #fffdf7;
}

.lift-picker-grid .booking-corner {
  height: 58px;
}

.lift-picker-grid .booking-resource-head {
  height: 58px;
  justify-content: flex-start;
  padding: 10px 10px 6px;
  overflow: visible;
}

.lift-picker-grid .booking-resource-head strong {
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lift-picker-grid .booking-resource-head span {
  line-height: 1.2;
}

.lift-picker-entry {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 7px;
  border: 1px solid #8eb06e;
  background: #cde582;
  color: #1f3110;
  font-size: 11px;
  padding: 3px 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  user-select: none;
  cursor: pointer;
  z-index: 2;
}

.lift-picker-entry.is-selected {
  border-color: #2b8a79;
  box-shadow: 0 0 0 2px rgba(43, 138, 121, 0.22);
}

.lift-picker-entry-busy {
  border-color: #cd998e;
  background: #f3d5cd;
  color: #6d2c1f;
  z-index: 1;
  cursor: not-allowed;
}

.lift-picker-target-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.lift-picker-target-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 10px;
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.calendar-filters-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calendar-filters-grid {
  display: grid;
  gap: 8px;
}

.calendar-view-switch {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar-view-switch > span {
  font-size: 13px;
  color: var(--text-muted);
}

.calendar-view-switch-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.calendar-view-switch-buttons .btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.calendar-filters-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.calendar-filters-grid input,
.calendar-filters-grid select {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  background: #fffef8;
}

.calendar-mini {
  border: 1px solid #e3d5b5;
  border-radius: 8px;
  padding: 8px;
  background: #fff9eb;
}

.calendar-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.calendar-mini-head strong {
  text-transform: capitalize;
  font-size: 13px;
}

.calendar-mini-week,
.calendar-mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.calendar-mini-week span {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

.calendar-mini-cell {
  border: 1px solid #d7c79f;
  border-radius: 7px;
  background: #fffef8;
  min-height: 30px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.calendar-mini-cell.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}

.calendar-mini-cell.is-today {
  box-shadow: inset 0 0 0 1px #ce8e57;
}

.calendar-mini-empty {
  visibility: hidden;
  pointer-events: none;
}

.calendar-caption {
  color: var(--text-muted);
  font-size: 13px;
}

.calendar-days {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.booking-day-title {
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 16px;
}

.booking-layout {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 10px;
}

.booking-main {
  overflow-y: hidden;
  overflow-x: auto;
  border: 1px solid #e3d5b5;
  border-radius: 10px;
  background: #fffdf7;
  min-height: 0;
}

.booking-grid {
  display: grid;
  align-items: start;
  width: 100%;
}

.booking-multiday-wrap {
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid #e3d5b5;
  border-radius: 10px;
  background: #fffdf7;
  height: 100%;
  min-height: 0;
}

.booking-multiday-grid {
  display: inline-grid;
  min-width: 100%;
  align-items: start;
}

.booking-day-title-col {
  margin-bottom: 0;
  padding: 10px 8px;
  border-right: 1px solid #e7dbc0;
  border-bottom: 1px solid #e7dbc0;
  background: #f5edd8;
  font-size: 14px;
  text-align: center;
}

.booking-offday-head {
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #6f5b38;
}

.booking-offday-lane {
  border-right: 1px solid #e7dbc0;
  background: #fff9ec;
  padding: 8px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  align-content: start;
}

.booking-corner {
  height: 58px;
  border-right: 1px solid #e7dbc0;
  border-bottom: 1px solid #e7dbc0;
  background: #f5edd8;
}

.booking-resource-head {
  height: 58px;
  border-right: 1px solid #e7dbc0;
  border-bottom: 1px solid #e7dbc0;
  background: #f5edd8;
  padding: 8px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.booking-resource-head strong {
  font-size: 13px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.booking-resource-head span {
  font-size: 12px;
  color: var(--text-muted);
}

.booking-time-axis {
  position: relative;
  border-right: 1px solid #e7dbc0;
  background: linear-gradient(180deg, #f9f3e6 0%, #fdf8ee 100%);
}

.booking-time-label {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: #7d6f52;
}

.booking-lane {
  position: relative;
  border-right: 1px solid #e7dbc0;
  touch-action: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(119, 103, 74, 0.08) 0px,
      rgba(119, 103, 74, 0.08) 1px,
      transparent 1px,
      transparent 24px
    );
}

.booking-lane.drop-target {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(43, 138, 120, 0.14) 0px,
      rgba(43, 138, 120, 0.14) 1px,
      transparent 1px,
      transparent 24px
    );
}

.booking-lane.is-selecting {
  cursor: crosshair;
}

.booking-selection-box {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 8px;
  border: 1px dashed var(--accent-dark);
  background: rgba(43, 138, 120, 0.2);
  pointer-events: none;
  z-index: 5;
}

.booking-drop-preview {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 8px;
  border: 1px dashed #2d8a79;
  background: rgba(43, 138, 120, 0.24);
  pointer-events: none;
  z-index: 6;
}

.booking-day-boundary {
  border-right: 3px solid #ccb98e;
}

.booking-entry {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 6px 8px;
  font-size: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(28, 24, 18, 0.08);
  user-select: none;
}

.booking-entry.is-dragging {
  opacity: 0.55;
}

.booking-entry-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.booking-entry-sub {
  margin-top: 2px;
  font-size: 11px;
}

.booking-entry-foot {
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(20, 18, 14, 0.68);
}

.booking-entry-status {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.booking-entry.ok,
.booking-entry.muted {
  background: #b9dc44;
  border-color: #9ec139;
  color: #203300;
}

.booking-entry.warn {
  background: #7fd0eb;
  border-color: #67b9d4;
  color: #073746;
}

.booking-entry.danger {
  background: #f3b0a2;
  border-color: #de8f7f;
  color: #5f1f14;
}

.booking-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.assignments-services-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assignments-service-group {
  border: 1px solid #e7d9b8;
  border-radius: 10px;
  background: #fffef9;
  padding: 8px;
}

.assignments-service-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.assignments-service-title {
  font-weight: 700;
}

.assignments-service-meta {
  color: var(--text-muted);
  font-size: 12px;
}

.booking-offday {
  border: 1px dashed #d9c8a0;
  border-radius: 10px;
  background: #fff9ec;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.booking-offday-note {
  font-weight: 700;
  color: #6f5b38;
}

.calendar-offday-item {
  border: 1px solid #e7d8b8;
  border-radius: 8px;
  background: #fffef9;
  padding: 8px 10px;
  display: grid;
  gap: 2px;
  font-size: 13px;
}

.calendar-offday-item strong {
  font-size: 13px;
}

.settings-panel {
  margin-top: 0;
  min-height: 0;
  overflow: auto;
}

.settings-panel.hidden {
  display: none;
}

.settings-card {
  max-width: 1100px;
}

.settings-card-head h3 {
  margin: 0;
  font-size: 20px;
}

.settings-card-head p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.settings-workday-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.settings-workday-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 78px 1fr 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid #e4d5b4;
  border-radius: 10px;
  background: #fffdf7;
  padding: 8px;
}

.settings-workday-row.is-off {
  background: #f8f1de;
  opacity: 0.88;
}

.settings-workday-name {
  font-weight: 700;
  font-size: 13px;
}

.settings-workday-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.settings-workday-time {
  border: 1px solid #ccb98e;
  border-radius: 8px;
  padding: 6px 7px;
  font: inherit;
  background: #fffef8;
  width: 100%;
}

.settings-card-collapse {
  margin-top: 10px;
}

.settings-workday-columns {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 78px 1fr 1fr;
  gap: 8px;
  padding: 0 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.settings-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.report-card {
  max-width: none;
}

.report-filters {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.report-filters label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.report-filters input {
  border: 1px solid #ccb98e;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  background: #fffef8;
}

.report-table-wrap {
  margin-top: 10px;
  max-height: calc(100vh - 280px);
}

.selected-row {
  background: #eef5ff;
}

.car-catalog-card {
  max-width: none;
}

.car-catalog-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.car-catalog-block {
  border: 1px solid #e4d5b4;
  border-radius: 10px;
  background: #fffdf7;
  padding: 10px;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.car-catalog-block-brands {
  order: 1;
}

.car-catalog-block-models {
  order: 2;
}

.car-catalog-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.car-catalog-block-head h4 {
  margin: 0;
  font-size: 15px;
}

.car-catalog-table-wrap {
  max-height: 280px;
}

.car-catalog-form {
  display: grid;
  gap: 8px;
}

.car-catalog-form label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.car-catalog-form input,
.car-catalog-form select {
  border: 1px solid #ccb98e;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  background: #fffef8;
}

.car-catalog-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.car-catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.booking-side-card {
  border: 1px solid #e7dbc0;
  border-radius: 8px;
  padding: 10px;
  background: #fffdf8;
}

.booking-side-card h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.booking-wait-item {
  width: 100%;
  border: 1px solid #d8cda9;
  background: #f8f3e4;
  border-radius: 7px;
  padding: 8px;
  margin-bottom: 6px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
}

.booking-wait-item.is-dragging {
  opacity: 0.58;
}

.booking-wait-item strong {
  font-size: 13px;
}

.tag {
  font-size: 11px;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid transparent;
}

.tag.ok {
  background: #daf0e5;
  color: #1f5c42;
  border-color: #b8dcc8;
}

.tag.warn {
  background: #fde8cd;
  color: #7d4d09;
  border-color: #efd1a0;
}

.tag.danger {
  background: #f8d9cd;
  color: #7b2f18;
  border-color: #e6b8a6;
}

.tag.muted {
  background: #ece7db;
  color: #615541;
  border-color: #d8cfba;
}

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

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--card-border);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    height: auto;
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

  .table-wrap {
    max-height: 420px;
  }

  .order-list-filters-grid {
    grid-template-columns: 1fr;
  }

  .report-filters {
    align-items: stretch;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .preview-head-grid {
    grid-template-columns: 1fr;
  }

  .modal-card {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .order-head-card {
    grid-column: 1 / -1;
  }

  .order-head-fields {
    grid-template-columns: 1fr;
  }

  .order-editor-tabs {
    flex-wrap: wrap;
  }

  .editor-sections-row {
    grid-template-columns: 1fr;
  }

  .order-editor-top-row {
    grid-template-columns: 1fr;
  }

  .order-totals-grid {
    grid-template-columns: 1fr;
  }

  .calendar-filters-card {
    position: static;
  }

  .settings-workday-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .settings-workday-list {
    grid-template-columns: 1fr;
  }

  .car-catalog-grid {
    grid-template-columns: 1fr;
  }

  .settings-workday-columns {
    display: none;
  }

  .money-form-grid-top,
  .money-form-grid-middle {
    grid-template-columns: 1fr;
  }

  .booking-layout {
    grid-template-columns: 1fr;
  }

  .booking-main {
    min-width: 0;
  }
}
