.authorization-workbench {
  --auth-ink: #17201e;
  --auth-muted: #68716e;
  --auth-line: #d8ddda;
  --auth-soft: #f3f5f3;
  --auth-paper: #fbfcfb;
  --auth-green: #2f7168;
  --auth-green-soft: #e4efec;
  --auth-red: #a3453c;
  --auth-red-soft: #f7e9e6;
  --auth-amber: #9a6a16;
  --auth-amber-soft: #f7f0df;
  color: var(--auth-ink);
}

.auth-command-header,
.auth-sensor,
.auth-task-toolbar,
.auth-drawer-panel > header,
.auth-policy-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.auth-command-header {
  padding: 3px 0 20px;
  border-bottom: 3px solid var(--auth-ink);
}

.auth-command-header h3 {
  margin: 2px 0 4px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(26px, 2.3vw, 36px);
  letter-spacing: -0.04em;
}

.auth-command-header > div > span,
.auth-task-toolbar span,
.auth-policy-dialog header span {
  color: var(--auth-muted);
}

.auth-command-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.auth-sensor {
  min-height: 126px;
  border-bottom: 1px solid var(--auth-line);
}

.auth-sensor-copy {
  flex: 1 1 50%;
  padding: 24px 24px 24px 0;
}

.auth-sensor-copy strong {
  display: block;
  max-width: 780px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(23px, 2vw, 32px);
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.auth-sensor-copy p {
  max-width: 820px;
  margin: 10px 0 0;
  color: var(--auth-muted);
  line-height: 1.7;
}

.auth-boundary {
  align-self: stretch;
  width: min(210px, 20%);
  padding: 24px 18px;
  border-left: 1px solid var(--auth-line);
}

.auth-boundary strong,
.auth-boundary span {
  display: block;
}

.auth-boundary span {
  margin-top: 8px;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.65;
}

.auth-boundary-readonly strong {
  color: #376c86;
}

.auth-boundary-write strong {
  color: var(--auth-red);
}

.auth-summary-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 20px 0;
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  background: var(--auth-paper);
}

.auth-summary-tabs button {
  position: relative;
  min-width: 0;
  padding: 17px 16px 16px;
  border: 0;
  border-right: 1px solid var(--auth-line);
  background: transparent;
  color: var(--auth-ink);
  text-align: left;
  cursor: pointer;
}

.auth-summary-tabs button:last-child {
  border-right: 0;
}

.auth-summary-tabs button::after {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 3px;
  background: transparent;
  content: "";
}

.auth-summary-tabs button:hover,
.auth-summary-tabs button.active {
  background: #fff;
}

.auth-summary-tabs button.active::after {
  background: var(--auth-red);
}

.auth-summary-tabs span,
.auth-summary-tabs strong,
.auth-summary-tabs small {
  display: block;
}

.auth-summary-tabs span {
  font-size: 12px;
  font-weight: 700;
}

.auth-summary-tabs strong {
  margin: 5px 0 3px;
  font-family: Georgia, serif;
  font-size: 27px;
  line-height: 1;
}

.auth-summary-tabs small {
  overflow: hidden;
  color: var(--auth-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-work-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.auth-task-panel,
.auth-guide-panel {
  padding: 0;
  overflow: hidden;
}

.auth-task-toolbar {
  padding: 20px;
  border-bottom: 1px solid var(--auth-line);
}

.auth-task-toolbar h4,
.auth-guide-panel h4 {
  margin: 0 0 4px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 19px;
}

.auth-task-toolbar label {
  width: min(340px, 42%);
}

.auth-task-toolbar input {
  width: 100%;
}

.auth-load-state,
.auth-empty-state {
  padding: 38px 24px;
  color: var(--auth-muted);
  text-align: center;
}

.auth-task-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.25fr) minmax(170px, 0.9fr) minmax(250px, 1.3fr) minmax(130px, 0.65fr);
  gap: 18px;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--auth-line);
  background: #fff;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.auth-task-row:last-child {
  border-bottom: 0;
}

.auth-task-row:hover {
  z-index: 1;
  background: #f8faf9;
  transform: translateY(-1px);
}

.auth-task-row h5,
.auth-task-row p {
  margin: 0;
}

.auth-task-row h5 {
  font-size: 16px;
}

.auth-task-row p,
.auth-task-row small {
  color: var(--auth-muted);
  line-height: 1.55;
}

.auth-task-identity,
.auth-task-account,
.auth-task-next {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.auth-task-source {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 4px 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #eef3f6;
  color: #496676;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-state-chip {
  display: inline-flex;
  width: fit-content;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--auth-amber-soft);
  color: var(--auth-amber);
  font-size: 11px;
  font-weight: 700;
}

.auth-state-chip.is-ok {
  background: var(--auth-green-soft);
  color: var(--auth-green);
}

.auth-state-chip.is-danger {
  background: var(--auth-red-soft);
  color: var(--auth-red);
}

.auth-side-stack {
  display: grid;
  gap: 9px;
}

.auth-side-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.auth-side-line span:first-child {
  color: var(--auth-muted);
}

.auth-side-track {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8ece9;
}

.auth-side-track::after {
  display: block;
  width: var(--auth-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--auth-progress-color, var(--auth-green));
  content: "";
}

.auth-task-next strong {
  font-size: 12px;
}

.auth-row-open {
  justify-self: end;
  color: var(--auth-ink);
  font-size: 22px;
}

.auth-guide-panel section {
  padding: 20px;
  border-bottom: 1px solid var(--auth-line);
}

.auth-guide-panel section:last-child {
  border-bottom: 0;
}

.auth-guide-panel ol {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-guide-panel dl {
  display: grid;
  gap: 0;
  margin: 12px 0 0;
}

.auth-guide-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dotted var(--auth-line);
  font-size: 12px;
}

.auth-guide-panel dt {
  color: var(--auth-muted);
}

.auth-guide-panel dd {
  margin: 0;
  color: var(--auth-amber);
  font-weight: 700;
  text-align: right;
}

.auth-guide-panel p {
  margin: 10px 0 0;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.65;
}

.auth-detail-drawer {
  position: fixed;
  z-index: 150;
  inset: 0;
}

.auth-detail-drawer[hidden] {
  display: none;
}

.auth-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 22, 20, 0.48);
  backdrop-filter: blur(2px);
}

.auth-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(620px, 100vw);
  height: 100%;
  overflow: hidden;
  background: var(--auth-paper);
  box-shadow: -18px 0 55px rgba(15, 22, 20, 0.18);
  animation: auth-drawer-in 220ms ease both;
}

@keyframes auth-drawer-in {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.auth-drawer-panel > header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--auth-line);
}

.auth-drawer-panel > header h4 {
  margin: 2px 0 4px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 24px;
}

.auth-drawer-panel > header span {
  color: var(--auth-muted);
}

#authDetailBody {
  overflow: auto;
  padding: 22px 24px 100px;
}

.auth-detail-section {
  margin-bottom: 24px;
}

.auth-detail-section h5 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.auth-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-detail-grid div {
  padding: 12px;
  border: 1px solid var(--auth-line);
  border-radius: 7px;
  background: #fff;
}

.auth-detail-grid span,
.auth-detail-grid strong {
  display: block;
}

.auth-detail-grid span {
  margin-bottom: 5px;
  color: var(--auth-muted);
  font-size: 11px;
}

.auth-detail-grid strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.auth-serial-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 10px;
  align-items: stretch;
}

.auth-serial-card {
  padding: 14px;
  border: 1px solid var(--auth-line);
  border-radius: 8px;
  background: #fff;
}

.auth-serial-card span,
.auth-serial-card strong,
.auth-serial-card small {
  display: block;
}

.auth-serial-card span {
  color: var(--auth-muted);
  font-size: 11px;
}

.auth-serial-card strong {
  margin: 6px 0;
  font-size: 13px;
}

.auth-serial-card small {
  color: var(--auth-muted);
  line-height: 1.5;
}

.auth-serial-arrow {
  align-self: center;
  color: var(--auth-muted);
}

.auth-timeline {
  display: grid;
  gap: 0;
  border-left: 1px solid var(--auth-line);
  margin-left: 7px;
  padding-left: 18px;
}

.auth-timeline article {
  position: relative;
  padding: 0 0 18px;
}

.auth-timeline article::before {
  position: absolute;
  top: 3px;
  left: -23px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--auth-paper);
  border-radius: 50%;
  background: var(--auth-green);
  box-shadow: 0 0 0 1px var(--auth-green);
  content: "";
}

.auth-timeline strong,
.auth-timeline span {
  display: block;
}

.auth-timeline strong {
  font-size: 12px;
}

.auth-timeline span {
  margin-top: 4px;
  color: var(--auth-muted);
  font-size: 11px;
}

.auth-drawer-panel > footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--auth-line);
  background: rgba(251, 252, 251, 0.96);
  backdrop-filter: blur(12px);
}

.auth-confirm-dialog,
.auth-policy-dialog {
  width: min(620px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: var(--auth-ink);
  box-shadow: 0 28px 90px rgba(15, 22, 20, 0.28);
}

.auth-confirm-dialog::backdrop,
.auth-policy-dialog::backdrop {
  background: rgba(15, 22, 20, 0.54);
  backdrop-filter: blur(3px);
}

.auth-confirm-dialog form,
.auth-policy-dialog form {
  padding: 24px;
}

.auth-confirm-dialog h4,
.auth-policy-dialog h4 {
  margin: 3px 0;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 24px;
}

.auth-confirm-summary {
  display: grid;
  gap: 8px;
  margin: 20px 0;
  padding: 16px;
  border: 1px solid #e0b9b3;
  border-radius: 8px;
  background: var(--auth-red-soft);
}

.auth-confirm-summary div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
}

.auth-confirm-summary span {
  color: var(--auth-muted);
}

.auth-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.auth-danger-confirm {
  background: var(--auth-red) !important;
  border-color: var(--auth-red) !important;
}

.auth-policy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.auth-policy-grid label {
  display: grid;
  gap: 6px;
  color: var(--auth-muted);
  font-size: 12px;
}

.auth-policy-warning {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #ddcda9;
  border-radius: 8px;
  background: var(--auth-amber-soft);
}

.auth-policy-warning span {
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.6;
}

.auth-batch-select {
  width: 18px;
  height: 18px;
  accent-color: var(--auth-green);
}

@media (max-width: 1180px) {
  .auth-summary-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .auth-summary-tabs button:nth-child(3) {
    border-right: 0;
  }

  .auth-summary-tabs button:nth-child(-n + 3) {
    border-bottom: 1px solid var(--auth-line);
  }

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

  .auth-guide-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .auth-guide-panel section {
    border-right: 1px solid var(--auth-line);
    border-bottom: 0;
  }
}

@media (max-width: 760px) {
  .authorization-workbench {
    padding-bottom: 84px;
  }

  .auth-command-header {
    align-items: flex-start;
    padding-top: 8px;
  }

  .auth-command-header h3 {
    font-size: 25px;
  }

  .auth-command-header > div > span {
    font-size: 12px;
  }

  .auth-command-actions {
    flex-direction: column;
    width: 128px;
  }

  .auth-command-actions button {
    width: 100%;
    padding: 9px 10px;
    font-size: 11px;
  }

  .auth-sensor {
    display: block;
    padding: 18px 0;
  }

  .auth-sensor-copy {
    padding: 0 0 16px;
  }

  .auth-sensor-copy strong {
    font-size: 21px;
  }

  .auth-sensor-copy p {
    font-size: 12px;
  }

  .auth-boundary {
    display: inline-block;
    width: calc(50% - 3px);
    min-height: 104px;
    padding: 13px 12px;
    border: 1px solid var(--auth-line);
    vertical-align: top;
  }

  .auth-boundary + .auth-boundary {
    border-left: 0;
  }

  .auth-summary-tabs {
    display: flex;
    margin: 14px -14px;
    overflow-x: auto;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    scroll-snap-type: x mandatory;
  }

  .auth-summary-tabs button {
    flex: 0 0 142px;
    border-bottom: 0 !important;
    scroll-snap-align: start;
  }

  .auth-task-toolbar {
    display: grid;
    padding: 16px;
  }

  .auth-task-toolbar label {
    width: 100%;
  }

  .auth-task-row {
    grid-template-columns: 1fr auto;
    gap: 14px;
    padding: 17px 16px;
  }

  .auth-task-account {
    grid-column: 1;
  }

  .auth-side-stack {
    grid-column: 1 / -1;
  }

  .auth-task-next {
    grid-column: 1 / -1;
    padding-top: 10px;
    border-top: 1px dashed var(--auth-line);
  }

  .auth-row-open {
    grid-column: 2;
    grid-row: 1;
  }

  .auth-guide-panel {
    display: block;
  }

  .auth-guide-panel section {
    border-right: 0;
    border-bottom: 1px solid var(--auth-line);
  }

  .auth-guide-panel section:first-child {
    display: none;
  }

  .auth-drawer-panel {
    top: 8vh;
    width: 100%;
    height: 92vh;
    border-radius: 14px 14px 0 0;
    animation-name: auth-sheet-in;
  }

  @keyframes auth-sheet-in {
    from { transform: translateY(32px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .auth-drawer-panel > header,
  #authDetailBody,
  .auth-drawer-panel > footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .auth-detail-grid,
  .auth-policy-grid {
    grid-template-columns: 1fr;
  }

  .auth-serial-flow {
    grid-template-columns: 1fr;
  }

  .auth-serial-arrow {
    transform: rotate(90deg);
    justify-self: center;
  }

  #authBatchToggleBtn,
  #authPolicyBtn {
    display: none !important;
  }
}
