* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #eef1f5;
  color: #111827;
}

.page {
  padding: 36px;
}

.container {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
}

.page-subtitle {
  margin: 8px 0 0;
  color: #6b7280;
  font-size: 15px;
}

.card {
  width: 100%;
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  margin-bottom: 24px;
  overflow: visible;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 14px 14px 0 0;
}

.card-title {
  margin: 0;
  font-size: 20px;
}

.card-body {
  padding: 22px;
}

.header-sections {
  display: grid;
  gap: 16px;
}

.header-section {
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fbfcfe;
}

.header-section-title {
  display: none;
}

.header-section-last {
  background: #ffffff;
}

.header-section-last textarea {
  min-height: 110px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.form-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.header-section .form-grid {
  gap: 16px 20px;
}

.form-row-full {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: 7px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
  color: #374151;
}

select,
input,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  outline: none;
}

select::placeholder,
input::placeholder,
textarea::placeholder {
  font-family: inherit;
  font-size: 14px;
  color: #6b7280;
  opacity: 1;
}

select:focus,
input:focus,
textarea:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.field-warning {
  border-color: #dc2626 !important;
  background: #fef2f2 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

.field-warning-message {
  margin-top: 7px;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
}

.field-help-text {
  margin-top: 7px;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
}

.new-client-field,
.new-job-field {
  width: 100%;
}

.select-new-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: start;
  width: 100%;
}

.combo {
  position: relative;
  width: 100%;
}

.combo-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  padding: 9px 11px;
}

.combo-input::placeholder {
  font-family: inherit;
  font-size: 14px;
  color: #6b7280;
  opacity: 1;
}

.combo.combo-open .combo-input {
  border-color: #94a3b8;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

.combo.combo-open .combo-input.field-warning {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

.combo-list {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  max-height: 240px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-top: 0;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  z-index: 1000;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
}

.combo.combo-open .combo-list {
  display: block;
}

.combo-option {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  background: #ffffff;
  color: #374151;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
}

.combo-option:hover,
.combo-option:focus {
  background: #f1f5f9;
  color: #111827;
  outline: none;
}

.combo-option-hidden {
  display: none;
}

.combo-empty {
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: #6b7280;
}

.button {
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button-primary {
  background: #DC0830;
  color: #ffffff;
}

.button-primary:hover {
  background: #b80729;
}

.button-primary:disabled:hover {
  background: #DC0830;
}

.button-secondary {
  background: #e5e7eb;
  color: #111827;
  border: 1px solid #d1d5db;
}

.button-secondary:hover {
  background: #d1d5db;
}

.button-danger,
.button-new-active {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.button-danger:hover,
.button-new-active:hover {
  background: #fee2e2;
}

.toggle-new-button {
  width: 64px;
}

.hidden {
  display: none !important;
}

.order-lines {
  display: grid;
  gap: 16px;
}

.line-card {
  border: 1px solid #dbe2ea;
  border-radius: 14px;
  background: #ffffff;
  overflow: visible;
}

.line-card-header {
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 14px 14px 0 0;
}

.line-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.line-card-body {
  padding: 16px;
}

.line-product-row {
  margin-bottom: 18px;
}

.product-existing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: start;
  width: 100%;
}

.product-new-fields {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
}

.product-new-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.product-new-header label {
  margin-bottom: 0;
}

.product-new-toggle-button {
  width: 64px;
  min-height: 38px;
}

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

.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding-top: 23px;
}

.checkbox-wrap input {
  width: 18px;
  height: 18px;
  min-height: auto;
  accent-color: #DC0830;
}

.checkbox-wrap span {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
}

.line-values-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.line-tax-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.line-field {
  min-width: 0;
}

.line-net-input,
.line-gross-input {
  background: #f8fafc;
  color: #374151;
  font-weight: 700;
}

.line-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  border-radius: 0 0 14px 14px;
}

.taxable-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.taxable-input {
  width: 18px;
  height: 18px;
  min-height: auto;
  accent-color: #DC0830;
}

.taxable-text {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
}

.add-line-row {
  margin-top: 16px;
}

.add-line-button {
  min-width: 130px;
}

.totals {
  margin-top: 22px;
  margin-left: auto;
  max-width: 430px;
  padding: 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: grid;
  grid-template-columns: max-content minmax(210px, 1fr);
  align-items: center;
  gap: 10px 20px;
  font-size: 16px;
}

.totals-label {
  text-align: right;
  color: #4b5563;
  font-weight: 700;
  white-space: nowrap;
}

.totals-label label {
  margin: 0;
  color: #4b5563;
  font-size: 16px;
  font-weight: 700;
}

.totals-value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  text-align: right;
  min-width: 110px;
  font-weight: 800;
  color: #111827;
}

.totals-value span {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 86px;
  min-width: 86px;
  min-height: 30px;
  padding: 3px 7px;
  line-height: 1.2;
  text-align: right;
}

.totals-input {
  width: 86px;
  min-width: 86px;
  min-height: 30px;
  padding: 3px 7px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
  box-shadow: none;
  appearance: textfield;
}

.totals-input:focus {
  border-color: #94a3b8;
  outline: none;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
  background: #ffffff;
}

.totals-input::placeholder {
  color: #111827;
  opacity: 1;
}

.totals-input::-webkit-outer-spin-button,
.totals-input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.gross-total-label,
.gross-total-value {
  font-size: 19px;
  color: #111827;
}

.tax-total-row,
.gross-total-row {
  display: contents;
}

.tax-total-hidden,
.gross-total-hidden {
  display: none;
}

.import-options {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  min-height: auto;
  accent-color: #DC0830;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1999;
  background: rgba(17, 24, 39, 0.55);
  cursor: not-allowed;
}

.confirm-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(760px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  transform: translate(-50%, -50%);
  z-index: 2000;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.confirm-close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
  font-family: inherit;
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
}

.confirm-close-button:hover,
.confirm-close-button:focus {
  background: #fee2e2;
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.confirm-close-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.confirm-title {
  padding-right: 44px;
  font-size: 16px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 8px;
}

.confirm-message {
  margin: 0 0 14px;
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
}

.planned-actions-summary {
  margin: 14px 0 16px;
  padding: 14px;
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  background: #f8fafc;
}

.planned-actions-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #111827;
}

.planned-actions-intro {
  margin: 6px 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: #4b5563;
}

.planned-actions-list {
  display: grid;
  gap: 10px;
}

.planned-action-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
}

.planned-action-badge {
  grid-row: span 2;
  align-self: start;
  min-width: 62px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 800;
  text-align: center;
}

.planned-action-badge-create {
  background: #ecfdf5;
  color: #065f46;
}

.planned-action-badge-update {
  background: #eff6ff;
  color: #1d4ed8;
}

.planned-action-badge-delete {
  background: #fef2f2;
  color: #991b1b;
}

.planned-action-badge-skip,
.planned-action-badge-skipped {
  background: #fffbeb;
  color: #92400e;
}

.planned-action-badge-reuse,
.planned-action-badge-existing {
  background: #f3f4f6;
  color: #374151;
}

.planned-action-badge-test {
  background: #f5f3ff;
  color: #6d28d9;
}

.planned-action-badge-other {
  background: #eef2ff;
  color: #3730a3;
}

.planned-action-title {
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 800;
  color: #111827;
}

.planned-action-description {
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
  color: #4b5563;
}

.planned-action-details {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(130px, max-content) minmax(0, 1fr);
  gap: 5px 12px;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
}

.planned-action-details dt {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
}

.planned-action-details dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: #111827;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
}

.planned-action-note {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 700;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.validation-summary {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.validation-title {
  font-weight: 800;
  margin-bottom: 8px;
}

.validation-summary ul {
  margin: 0;
  padding-left: 20px;
}

.validation-summary li {
  margin: 4px 0;
  font-size: 14px;
  font-weight: 700;
}

.message-box {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
}

.message-box-success {
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.message-box-error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding: 22px;
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.form-action-button {
  min-width: 140px;
}

@media (max-width: 850px) {
  .form-grid,
  .product-new-grid,
  .line-values-grid,
  .line-tax-grid {
    grid-template-columns: 1fr;
  }

  .select-new-wrap,
  .product-existing-layout {
    grid-template-columns: 1fr;
  }

  .toggle-new-button {
    width: 100%;
  }

  .checkbox-wrap {
    padding-top: 0;
  }
}

@media (max-width: 700px) {
  .page {
    padding: 18px;
  }

  .page-title {
    font-size: 26px;
  }

  .card-body {
    padding: 16px;
  }

  .header-section {
    padding: 14px;
  }

  .line-card-footer,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .line-card-footer .button,
  .form-action-button {
    width: 100%;
  }

  .totals {
    width: 100%;
    max-width: none;
    grid-template-columns: max-content minmax(160px, 1fr);
  }

  .totals-value span,
  .totals-input {
    width: 86px;
    min-width: 86px;
  }

  .confirm-panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

  .confirm-close-button {
    top: 10px;
    right: 10px;
  }

  .planned-action-card {
    grid-template-columns: 1fr;
  }

  .planned-action-badge {
    grid-row: auto;
    width: fit-content;
    min-width: 0;
  }

  .planned-action-details {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .planned-action-details dd {
    margin-bottom: 5px;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .confirm-actions .button {
    width: 100%;
  }
}