.approval-nav-item {
  position: relative;
}

.approval-nav-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  place-items: center;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
}

.approval-has-unread {
  animation: approval-alert 1.2s ease-in-out infinite;
}

@keyframes approval-alert {
  0%, 100% { background-color: inherit; color: inherit; }
  50% { background-color: #fff1f2; color: #be123c; }
}

.approval-view {
  display: none;
}

.approval-view.active {
  display: block;
}

.approval-page-head,
.approval-list-toolbar,
.approval-document-row,
.approval-editor-head,
.approval-section-title,
.approval-line-row,
.approval-attachment-row,
.approval-template-row {
  display: flex;
  align-items: center;
}

.approval-page-head {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.approval-page-head h2,
.approval-editor-head h2 {
  margin: 4px 0;
}

.approval-page-head p,
.approval-section-title p {
  margin: 0;
  color: #718096;
}

.approval-page-actions,
.approval-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.approval-status-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(100px, 1fr));
  border: 1px solid #dce3ef;
  background: #fff;
}

.approval-status-tabs button {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-right: 1px solid #e5eaf2;
  background: transparent;
  color: #526174;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.approval-status-tabs button:last-child {
  border-right: 0;
}

.approval-status-tabs button.active {
  box-shadow: inset 0 -3px #5865ef;
  color: #263be5;
}

.approval-status-tabs b {
  min-width: 24px;
  padding: 2px 6px;
  border-radius: 12px;
  background: #edf0f6;
  font-size: 12px;
}

.approval-list-toolbar {
  gap: 10px;
  padding: 14px 0;
}

.approval-list-toolbar input {
  flex: 1;
}

.approval-list-toolbar select {
  width: min(260px, 35%);
}

.approval-list {
  min-height: 320px;
  border: 1px solid #dce3ef;
  background: #fff;
}

.approval-document-row {
  width: 100%;
  min-height: 80px;
  gap: 18px;
  padding: 14px 18px;
  border: 0;
  border-bottom: 1px solid #e8edf4;
  background: #fff;
  color: #172033;
  text-align: left;
  cursor: pointer;
}

.approval-document-row:hover,
.approval-document-row.unread {
  background: #f7f8ff;
}

.approval-document-row.unread .approval-document-main strong::after {
  content: "새 요청";
  margin-left: 8px;
  color: #e11d48;
  font-size: 11px;
}

.approval-document-status,
.approval-state {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 4px;
  background: #eef1f6;
  color: #526174;
  font-size: 12px;
  font-weight: 800;
}

.status-pending { background: #eef0ff; color: #3547e8; }
.status-approved { background: #e7f7ef; color: #047857; }
.status-revision { background: #fff4dc; color: #b45309; }
.status-rejected { background: #feecef; color: #be123c; }

.approval-document-main {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 5px;
}

.approval-document-main strong,
.approval-document-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-document-main small,
.approval-document-author small,
.approval-document-step small,
.approval-template-row small {
  color: #7a8798;
}

.approval-document-author,
.approval-document-step {
  display: grid;
  width: 150px;
  gap: 4px;
}

.approval-document-row time {
  width: 145px;
  color: #718096;
  font-size: 12px;
  text-align: right;
}

.approval-empty {
  padding: 70px 20px;
  color: #7a8798;
  text-align: center;
}

.approval-dialog {
  width: min(860px, calc(100vw - 30px));
  max-width: none;
  max-height: calc(100vh - 30px);
  padding: 0;
  border: 0;
  border-radius: 6px;
}

.approval-dialog::backdrop {
  background: rgb(15 23 42 / 56%);
}

.approval-dialog-shell {
  position: relative;
  max-height: calc(100vh - 30px);
  overflow: auto;
  padding: 30px;
  background: #fff;
}

.approval-dialog-close {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: 1px solid #d5dce8;
  background: #fff;
  color: #64748b;
  font-size: 26px;
  cursor: pointer;
}

.approval-editor-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-right: 44px;
}

#approval-editor-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

#approval-editor-form > label,
.approval-dynamic-fields label,
.approval-template-upload label {
  display: grid;
  gap: 7px;
  color: #273449;
  font-weight: 700;
}

.approval-dynamic-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.approval-dynamic-fields label:has(textarea) {
  grid-column: 1 / -1;
}

.approval-dynamic-fields label b {
  color: #dc2626;
}

.approval-form-section,
.approval-template-guide,
.approval-template-upload,
.approval-history {
  padding: 18px;
  border: 1px solid #dce3ef;
  background: #f8fafc;
}

.approval-form-section h3,
.approval-template-guide h3,
.approval-history h3 {
  margin: 0 0 12px;
}

.approval-meta-band {
  display: flex;
  gap: 16px;
  padding: 13px 16px;
  background: #f1f4f9;
}

.approval-meta-band span {
  color: #718096;
}

.approval-line-list {
  display: grid;
  gap: 7px;
}

.approval-line-row {
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid #dce3ef;
  background: #fff;
}

.approval-line-row > span {
  width: 28px;
  color: #5865ef;
  font-weight: 800;
  text-align: center;
}

.approval-line-row > div {
  display: grid;
  flex: 1;
}

.approval-line-row small {
  color: #7a8798;
}

.approval-line-row button,
.approval-attachment-row button {
  min-width: 34px;
  height: 34px;
  border: 1px solid #d5dce8;
  background: #fff;
  cursor: pointer;
}

.approval-line-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.approval-warning,
.approval-output-error {
  padding: 10px 12px;
  background: #fff7e6;
  color: #9a5b07;
}

.approval-attachment-list {
  display: grid;
  gap: 7px;
}

.approval-attachment-row {
  gap: 10px;
  padding: 9px 10px;
  background: #fff;
}

.approval-attachment-row a {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: #3547e8;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-file-picker {
  display: inline-flex;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px dashed #9aa9bf;
  background: #fff;
  cursor: pointer;
}

.approval-file-picker input {
  max-width: 280px;
  margin-left: 12px;
}

.approval-help {
  margin: 9px 0 0;
  color: #718096;
  font-size: 12px;
}

.approval-signature-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.approval-signature-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.approval-signature-preview {
  display: grid;
  place-items: center;
  width: 128px;
  height: 64px;
  border: 1px solid #dce3ef;
  background: #fff;
  color: #718096;
  font-size: 11px;
  text-align: center;
}

.approval-signature-preview img {
  max-width: 116px;
  max-height: 54px;
  object-fit: contain;
}

.approval-signature-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

.approval-signature-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.approval-history summary {
  cursor: pointer;
  font-weight: 800;
}

.approval-history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 16px;
}

.approval-history-row {
  display: grid;
  gap: 3px;
  padding: 9px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
}

.approval-history-row p {
  margin: 4px 0 0;
}

.approval-editor-actions {
  position: sticky;
  bottom: -30px;
  justify-content: flex-end;
  padding: 16px 0 0;
  background: #fff;
}

.approval-download {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.approval-template-dialog {
  width: min(980px, calc(100vw - 30px));
}

.approval-template-guide code {
  display: inline-block;
  margin: 2px;
  padding: 3px 6px;
  background: #eef0ff;
  color: #3547e8;
}

.approval-template-upload {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
  margin-top: 14px;
}

.approval-template-upload button,
.approval-template-upload .form-message {
  grid-column: 1 / -1;
}

.approval-template-list {
  display: grid;
  margin-top: 14px;
  border: 1px solid #dce3ef;
}

.approval-template-row {
  gap: 15px;
  padding: 13px;
  border-bottom: 1px solid #e5eaf2;
}

.approval-template-row > div {
  display: grid;
  width: 220px;
}

.approval-template-row > span {
  min-width: 0;
  flex: 1;
}

@media (max-width: 900px) {
  .approval-status-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .approval-document-author,
  .approval-document-step,
  .approval-document-row time {
    display: none;
  }

  .approval-dynamic-fields,
  .approval-history-grid,
  .approval-template-upload {
    grid-template-columns: 1fr;
  }

  .approval-template-upload button,
  .approval-template-upload .form-message {
    grid-column: auto;
  }
}

@media (max-width: 600px) {
  .approval-signature-section {
    grid-template-columns: 1fr;
  }

  .approval-signature-control {
    flex-wrap: wrap;
  }

  .approval-page-head,
  .approval-document-row {
    align-items: flex-start;
  }

  .approval-page-head {
    flex-direction: column;
  }

  .approval-status-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .approval-list-toolbar {
    display: grid;
  }

  .approval-list-toolbar select {
    width: 100%;
  }

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

  .approval-dialog-shell {
    max-height: 100dvh;
    padding: 22px 16px;
  }

  .approval-document-row {
    gap: 10px;
    padding: 12px;
  }

  .approval-document-status {
    font-size: 10px;
  }

  .approval-template-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .approval-template-row > div {
    width: auto;
  }
}
