.budget-dialog-backdrop,
.budget-dialog-backdrop * {
  box-sizing: border-box;
}

.budget-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(15, 23, 42, .52);
  backdrop-filter: blur(1px);
}

.budget-edit-dialog {
  width: min(1024px, calc(100vw - 48px));
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 18px 54px rgba(15, 23, 42, .2);
  overflow: hidden;
}

.budget-edit-head {
  min-height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #edf1f6;
}

.budget-edit-head strong {
  color: #111827;
  font-size: 18px;
  font-weight: 800;
}

.budget-dialog-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #64748b;
  font-size: 20px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.budget-dialog-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.budget-edit-body {
  min-height: 0;
  padding: 18px 24px 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.budget-edit-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.budget-edit-section:first-child {
  flex-shrink: 0;
}

.budget-edit-section + .budget-edit-section {
  margin-top: 18px;
  flex: 1;
}

.budget-edit-section h3 {
  margin: 0 0 12px;
  color: #111827;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
  flex-shrink: 0;
}

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

.budget-edit-form-grid label,
.budget-edit-textarea {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 750;
}

.budget-edit-form-grid label.required > span::after {
  content: "*";
  margin-left: 3px;
  color: var(--danger);
}

.budget-edit-textarea textarea,
.budget-edit-table input {
  width: 100%;
  border: 1px solid #dbe4ee;
  border-radius: 4px;
  background: #fff;
  color: #111827;
  font-size: 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.budget-edit-form-grid .enterprise-select,
.budget-edit-table .enterprise-select {
  width: 100%;
}

.budget-edit-textarea textarea:focus,
.budget-edit-table input:focus {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px var(--theme-focus-ring);
}

.budget-edit-textarea {
  position: relative;
  margin-top: 14px;
}

.budget-edit-textarea textarea {
  min-height: 86px;
  resize: none;
  padding: 12px 14px 24px;
  line-height: 1.6;
}

.budget-edit-textarea em {
  position: absolute;
  right: 12px;
  bottom: 9px;
  color: #94a3b8;
  font-size: 12px;
  font-style: normal;
  font-weight: 500;
}

.budget-edit-table-wrap {
  border: 1px solid #edf1f6;
  border-radius: 4px;
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.budget-edit-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.budget-edit-table th,
.budget-edit-table td {
  height: 48px;
  padding: 8px 10px;
  border-right: 1px solid #edf1f6;
  border-bottom: 1px solid #edf1f6;
  text-align: center;
  vertical-align: middle;
}

.budget-edit-table th:last-child,
.budget-edit-table td:last-child {
  border-right: 0;
}

.budget-edit-table tbody tr:last-child td {
  border-bottom: 0;
}

.budget-edit-table th {
  background: #fbfcfe;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.budget-edit-table th i {
  color: var(--danger);
  font-style: normal;
}

.budget-edit-table th:nth-child(1) { width: 180px; }
.budget-edit-table th:nth-child(2) { width: 168px; }
.budget-edit-table th:nth-child(3) { width: 120px; }
.budget-edit-table th:nth-child(4) { width: 120px; }
.budget-edit-table th:nth-child(6) { width: 68px; }

.budget-edit-table input {
  height: 34px;
  padding: 0 10px;
  text-align: center;
}

.budget-edit-table td:nth-child(5) input {
  text-align: left;
}

.budget-row-delete {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  cursor: pointer;
}

.budget-row-delete:hover {
  background: var(--danger-soft);
  color: var(--danger-hover);
}

.budget-add-row-btn {
  height: 28px;
  margin-top: 8px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(var(--theme-primary-rgb), .42);
  border-radius: 4px;
  background: #fff;
  color: var(--theme-primary-active);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}

.budget-edit-total {
  height: 42px;
  margin-top: 8px;
  padding: 0 14px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  border: 1px solid #edf1f6;
  border-radius: 4px;
  background: #fbfcfe;
  flex-shrink: 0;
}

.budget-edit-total span {
  color: #111827;
  font-size: 14px;
  font-weight: 800;
}

.budget-edit-total strong {
  color: var(--theme-primary-active);
  font-size: 16px;
  font-weight: 800;
}

.budget-edit-foot {
  padding: 14px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #edf1f6;
  background: #fff;
}

.budget-edit-foot button {
  height: 36px;
  min-width: 96px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.budget-edit-cancel {
  border: 1px solid #dbe4ee;
  background: #fff;
  color: #334155;
}

.budget-edit-draft {
  border: 1px solid var(--theme-primary);
  background: #fff;
  color: var(--theme-primary-active);
}

.budget-edit-publish {
  border: 0;
  background: var(--theme-primary-active);
  color: #fff;
  box-shadow: none;
}

.budget-dialog-fade-enter-active,
.budget-dialog-fade-leave-active {
  transition: opacity 180ms ease;
}

.budget-dialog-fade-enter-active .budget-edit-dialog,
.budget-dialog-fade-leave-active .budget-edit-dialog {
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1), opacity 180ms ease;
}

.budget-dialog-fade-enter-from,
.budget-dialog-fade-leave-to {
  opacity: 0;
}

.budget-dialog-fade-enter-from .budget-edit-dialog,
.budget-dialog-fade-leave-to .budget-edit-dialog {
  opacity: 0;
  transform: scale3d(.96, .96, 1);
}

@media (max-width: 860px) {
  .budget-dialog-backdrop {
    align-items: flex-start;
    padding: 18px;
  }

  .budget-edit-dialog {
    width: 100%;
    max-height: calc(100vh - 36px);
  }

  .budget-edit-form-grid {
    grid-template-columns: 1fr;
  }

  .budget-edit-foot {
    flex-direction: column;
    gap: 10px;
  }

  .budget-edit-foot button {
    width: 100%;
  }
}

@media (max-width: 1366px), (max-height: 820px) {
  .budget-dialog-backdrop {
    padding: 14px;
  }

  .budget-edit-dialog {
    width: min(920px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
  }

  .budget-edit-head {
    min-height: 48px;
    padding: 0 18px;
  }

  .budget-edit-head strong {
    font-size: 16px;
  }

  .budget-dialog-close {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }

  .budget-edit-body {
    padding: 12px 18px 10px;
  }

  .budget-edit-section + .budget-edit-section {
    margin-top: 10px;
  }

  .budget-edit-section h3 {
    margin-bottom: 8px;
    font-size: 14px;
  }

  .budget-edit-form-grid {
    gap: 10px 16px;
  }

  .budget-edit-form-grid label,
  .budget-edit-textarea {
    gap: 5px;
    font-size: 12px;
  }

  .budget-edit-textarea {
    margin-top: 8px;
  }

  .budget-edit-textarea textarea {
    min-height: 58px;
    padding: 8px 12px 20px;
    line-height: 1.45;
  }

  .budget-edit-table th,
  .budget-edit-table td {
    height: 40px;
    padding: 6px 8px;
  }

  .budget-edit-table input {
    height: 30px;
    padding: 0 8px;
  }

  .budget-row-delete {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .budget-add-row-btn {
    height: 26px;
    margin-top: 6px;
    font-size: 12px;
  }

  .budget-edit-total {
    height: 34px;
    margin-top: 6px;
  }

  .budget-edit-total span,
  .budget-edit-foot button {
    font-size: 13px;
  }

  .budget-edit-total strong {
    font-size: 15px;
  }

  .budget-edit-foot {
    padding: 10px 18px 12px;
    gap: 8px;
  }

  .budget-edit-foot button {
    height: 32px;
    min-width: 88px;
  }
}

@media (max-height: 700px) {
  .budget-dialog-backdrop {
    padding: 8px;
  }

  .budget-edit-dialog {
    max-height: calc(100vh - 16px);
  }

  .budget-edit-body {
    padding: 10px 16px 8px;
  }

  .budget-edit-textarea textarea {
    min-height: 46px;
  }

  .budget-edit-table th,
  .budget-edit-table td {
    height: 36px;
  }

  .budget-edit-foot {
    padding: 8px 16px;
  }
}

@media (max-width: 760px) {
  .budget-dialog-backdrop {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }

  .budget-edit-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .budget-edit-head {
    min-height: 52px;
    padding: 0 14px;
  }

  .budget-edit-body {
    padding: 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .budget-edit-section + .budget-edit-section {
    margin-top: 14px;
  }

  .budget-edit-table-wrap {
    flex: 0 0 auto;
    max-height: none;
  }

  .budget-edit-total {
    height: auto;
    min-height: 42px;
    justify-content: space-between;
    padding: 8px 12px;
  }

  .budget-edit-foot {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }
}
