.debug-page { max-width: 1500px; }

.debug-page-heading { align-items: flex-end; }
.debug-heading-actions { display: flex; align-items: center; gap: 10px; }
.debug-access-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(90, 73, 195, .18);
  border-radius: 999px;
  color: #4d3eb6;
  background: #efecff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.debug-access-badge.admin { color: #fff; background: #4d3eb6; }

.debug-security-note {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin: 0 0 22px;
  padding: 15px 18px;
  border: 1px solid rgba(90, 73, 195, .13);
  border-radius: 18px;
  background: linear-gradient(115deg, #f1efff, #fffdf8);
}
.debug-security-note > span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: #4d3eb6;
  font-size: 20px;
}
.debug-security-note strong { display: block; margin-bottom: 3px; font-size: 13px; }
.debug-security-note p { margin: 0; color: var(--muted); font-size: 11px; }
.debug-security-note label { display: flex; align-items: center; gap: 7px; color: #535e62; font-size: 11px; font-weight: 800; }
.debug-security-note input { accent-color: #4d3eb6; }

.debug-step-creation {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 11px;
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid #cfc7ff;
  border-radius: 16px;
  background: #f1efff;
  cursor: pointer;
}
.debug-step-creation input { width: 19px; height: 19px; accent-color: #4d3eb6; }
.debug-step-creation span { display: grid; gap: 3px; }
.debug-step-creation strong { font-size: 12px; }
.debug-step-creation small { color: #615f72; font-size: 9px; line-height: 1.45; }
.url-debug-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 17px 18px;
  border: 1px solid #cfc7ff;
  border-radius: 20px;
  background: linear-gradient(135deg, #f0edff, #fffdf8);
  box-shadow: 0 10px 28px rgba(77, 62, 182, .08);
}
.url-debug-card > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: #4d3eb6; color: #fff; font-size: 19px; }
.url-debug-card > div { display: grid; gap: 4px; }
.url-debug-card small { color: #6b5ad0; font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.url-debug-card strong { font-size: 13px; }
.url-debug-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.url-debug-card button { min-height: 39px; padding: 9px 12px; border: 1px solid #cfc7ff; border-radius: 12px; background: #fff; color: #4d3eb6; font-size: 10px; font-weight: 900; }
.debug-generation-action {
  min-height: 43px;
  margin-top: 10px;
  border: 1px solid #6b5ad0;
  color: #4d3eb6;
  background: #f1efff;
}

.debug-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.debug-metric {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf9;
}
.debug-metric small { display: block; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.debug-metric strong { display: block; margin-top: 6px; overflow: hidden; font-size: 23px; line-height: 1.1; text-overflow: ellipsis; }
.debug-metric span { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }

.debug-workspace {
  display: grid;
  grid-template-columns: minmax(230px, 310px) minmax(0, 1fr);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fffdf9;
}
.debug-project-panel {
  padding: 17px;
  border-right: 1px solid var(--line);
  background: #f7f4ed;
}
.debug-project-panel > header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.debug-project-panel small, .debug-detail small { color: #6b5ad0; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.debug-project-panel h2 { margin: 3px 0 0; font-size: 18px; }
.debug-project-panel > header > span { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 10px; color: #4d3eb6; background: #e9e5ff; font-size: 11px; font-weight: 900; }
.debug-project-list { display: grid; gap: 8px; max-height: 620px; overflow: auto; }
.debug-project-button {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, .76);
  color: #26353a;
  text-align: left;
}
.debug-project-button:hover { border-color: #cfc7ff; }
.debug-project-button.active { border-color: #6b5ad0; background: #fff; box-shadow: 0 8px 20px rgba(77, 62, 182, .09); }
.debug-project-button strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.debug-project-button span { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 8px; }
.debug-project-button i { font-style: normal; font-weight: 850; }
.debug-status-failed { color: #a34336 !important; }
.debug-status-ready { color: #26734f !important; }

.debug-detail { min-width: 0; padding: 22px; overflow: auto; }
.debug-empty { display: grid; min-height: 420px; place-items: center; align-content: center; text-align: center; }
.debug-empty > span { color: #6b5ad0; font-size: 38px; }
.debug-empty h2 { margin: 10px 0 4px; font-size: 20px; }
.debug-empty p { margin: 0; color: var(--muted); font-size: 11px; }
.debug-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.debug-detail-header h2 { margin: 4px 0 5px; font-size: 22px; }
.debug-detail-header p { margin: 0; color: var(--muted); font-size: 10px; }
.debug-detail-header > span { padding: 7px 10px; border-radius: 10px; background: #edf6f1; color: #26734f; font-size: 9px; font-weight: 900; }
.debug-gate {
  margin: 16px 0;
  padding: 18px;
  border: 2px solid #6b5ad0;
  border-radius: 18px;
  background: linear-gradient(135deg, #f0edff, #fffdf9);
  box-shadow: 0 12px 30px rgba(77, 62, 182, .1);
}
.debug-gate header { display: flex; justify-content: space-between; gap: 12px; }
.debug-gate header small { color: #4d3eb6; }
.debug-gate header span { color: #4d3eb6; font-size: 9px; font-weight: 900; }
.debug-gate h3 { margin: 6px 0; font-size: 18px; }
.debug-gate > p { margin: 0; color: #59666a; font-size: 10px; line-height: 1.6; }
.debug-gate dl { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
.debug-gate dl div { padding: 7px 9px; border-radius: 10px; background: rgba(255,255,255,.78); }
.debug-gate dt { color: var(--muted); font-size: 7px; font-weight: 900; text-transform: uppercase; }
.debug-gate dd { margin: 2px 0 0; font-size: 9px; font-weight: 800; }
.debug-gate details { margin: 12px 0; }
.debug-gate summary { color: #4d3eb6; cursor: pointer; font-size: 10px; font-weight: 850; }
.debug-gate pre { max-height: 300px; padding: 12px; overflow: auto; border-radius: 12px; background: #181a24; color: #e8e7f4; font: 9px/1.55 ui-monospace, monospace; white-space: pre-wrap; word-break: break-word; }
.debug-visual-preview { display: grid; gap: 8px; margin: 14px 0; }
.debug-visual-preview img { display: block; width: 100%; max-height: 520px; object-fit: contain; border: 1px solid rgba(77,62,182,.22); border-radius: 16px; background: #151720; }
.debug-visual-preview figcaption { color: #59666a; font-size: 9px; line-height: 1.5; }
.debug-gate-actions { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr) auto; gap: 9px; margin-top: 14px; }
.debug-gate-actions button { min-height: 44px; }
.debug-gate-actions .debug-approve { color: #fff; background: #4d3eb6; }
.debug-gate-actions .debug-retry { border-color: #cfc7ff; color: #4d3eb6; background: #fff; }
.debug-gate-actions .debug-stop { border-color: #d8aaa3; color: #a34336; background: #fff8f6; }
.debug-token-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 16px 0; }
.debug-token {
  padding: 11px;
  border-radius: 13px;
  background: #f4f1e9;
}
.debug-token strong { display: block; font-size: 16px; }
.debug-token small { color: var(--muted); }
.debug-section-title { display: flex; justify-content: space-between; gap: 10px; margin: 20px 0 9px; }
.debug-section-title h3 { margin: 0; font-size: 15px; }
.debug-section-title span { color: var(--muted); font-size: 9px; }
.debug-stage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.debug-stage-card { padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.debug-stage-card strong { display: block; margin-bottom: 6px; font-size: 11px; }
.debug-stage-card span { color: var(--muted); font-size: 9px; }
.debug-operation-list { display: grid; gap: 8px; }
.debug-operation {
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 4px solid #6b5ad0;
  border-radius: 14px;
  background: #fff;
}
.debug-operation.error { border-left-color: #b24134; background: #fff8f6; }
.debug-operation header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.debug-operation header strong { color: #27775e; font-size: 12px; white-space: nowrap; }
.debug-operation h4 { margin: 8px 0 4px; font-size: 11px; }
.debug-operation p { margin: 0; color: var(--muted); font-size: 8px; }
.debug-operation > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}
.debug-operation > div span {
  padding: 5px 7px;
  border-radius: 8px;
  color: #4d3eb6;
  background: #f1efff;
  font-size: 8px;
  font-weight: 850;
}
.debug-operation-empty { margin: 0; padding: 20px; color: var(--muted); text-align: center; font-size: 10px; }
.debug-event-list { display: grid; gap: 7px; }
.debug-event {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.debug-event.error { border-color: rgba(178, 65, 52, .28); background: #fff8f6; }
.debug-event summary { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 11px; cursor: pointer; }
.debug-event time { color: var(--muted); font-size: 8px; }
.debug-event summary strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.debug-event summary span { color: var(--muted); font-size: 8px; }
.debug-event pre {
  max-height: 340px;
  margin: 0;
  padding: 13px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #181a24;
  color: #e8e7f4;
  font: 9px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1000px) {
  .debug-metrics { grid-template-columns: repeat(2, 1fr); }
  .debug-workspace { grid-template-columns: 240px minmax(0, 1fr); }
}

@media (max-width: 820px) {
  body.debug-enabled .mobile-nav { grid-template-columns: repeat(6, 1fr); }
  .debug-page-heading { align-items: stretch; }
  .debug-heading-actions { width: 100%; justify-content: space-between; }
  .debug-security-note { grid-template-columns: 42px 1fr; }
  .debug-security-note label { grid-column: 1 / -1; }
  .debug-workspace { display: block; }
  .debug-project-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .debug-project-list { display: flex; max-height: none; padding-bottom: 4px; overflow-x: auto; }
  .debug-project-button { min-width: 210px; }
  .debug-detail { padding: 16px; }
}

@media (max-width: 560px) {
  .url-debug-card { grid-template-columns: 38px 1fr; }
  .url-debug-card > button { grid-column: 1 / -1; width: 100%; }
  .debug-metrics { grid-template-columns: 1fr 1fr; }
  .debug-metric { padding: 13px; }
  .debug-metric strong { font-size: 18px; }
  .debug-token-row, .debug-stage-grid { grid-template-columns: 1fr 1fr; }
  .debug-event summary { grid-template-columns: 52px minmax(0, 1fr); }
  .debug-event summary span { grid-column: 2; }
  .debug-gate-actions { grid-template-columns: 1fr; }
}
