:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  color: #142235;
  background: #eef4f8;
  letter-spacing: 0;
  --ink: #142235;
  --muted: #6f8194;
  --line: #d7e1e9;
  --blue: #1598d0;
  --blue-dark: #0a6f9d;
  --cyan: #63d5ed;
  --surface: #ffffff;
  --danger: #ca4a4a;
  --warning: #d08a24;
  --success: #16865d;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1040px; background: #eef4f8; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
.hidden { display: none !important; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; background: #eaf2f7; }
.auth-box { width: 390px; padding: 34px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--blue); box-shadow: 0 20px 50px rgba(29, 70, 97, .12); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 800; border-radius: 6px; }
.auth-box h1 { margin: 24px 0 8px; font-size: 26px; }
.auth-box p { color: var(--muted); line-height: 1.7; }
label { display: grid; gap: 8px; min-width: 0; }
label > span { color: #52667b; font-size: 13px; font-weight: 700; }
input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 5px; padding: 0 12px; color: var(--ink); background: #fff; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21, 152, 208, .12); }
textarea { width: 100%; min-height: 112px; resize: vertical; border: 1px solid var(--line); border-radius: 5px; padding: 11px 12px; color: var(--ink); background: #fff; outline: none; line-height: 1.6; }
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21, 152, 208, .12); }
select { min-height: 36px; border: 1px solid var(--line); border-radius: 5px; padding: 0 34px 0 10px; color: var(--ink); background: #fff; outline: none; }
select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21, 152, 208, .12); }
.auth-box button, .form-band button, .dialog-actions button { min-height: 42px; padding: 0 18px; border-radius: 5px; background: var(--blue); color: #fff; font-weight: 800; }
.auth-box button { margin-top: 18px; width: 100%; }
.form-status { min-height: 22px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.form-status.error { color: var(--danger); }
.form-status.success { color: var(--success); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #102235; color: #fff; padding: 24px 16px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: #8fa9bd; }
nav { display: grid; gap: 6px; padding-top: 22px; }
nav button, .logout { text-align: left; border-radius: 5px; padding: 12px 14px; color: #a9becf; background: transparent; font-weight: 700; }
nav button:hover, nav button.active { color: #fff; background: #1a3e57; }
.logout { margin-top: auto; border: 1px solid rgba(255,255,255,.16); }

.workspace { min-width: 0; padding: 0 30px 40px; }
.topbar { height: 108px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar p { margin: 0 0 6px; color: var(--blue-dark); font-size: 11px; font-weight: 800; }
.topbar h1 { margin: 0; font-size: 26px; }
.secondary { background: #fff !important; color: #315067 !important; border: 1px solid var(--line) !important; }
.publish { background: #153d55 !important; }
.topbar button { min-height: 38px; padding: 0 15px; border-radius: 5px; }

.view { display: none; padding-top: 26px; }
.view.active { display: block; }
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 18px 20px; background: #fff; border-left: 3px solid var(--blue); border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 8px; font-size: 24px; }
.workflow-outcome-metrics { grid-template-columns: repeat(5, minmax(130px, 1fr)); margin-bottom: 8px; }
.workflow-metric-note { margin: 0 0 18px; }
.form-band, .table-band, .result-band { margin-bottom: 18px; padding: 22px; background: #fff; border: 1px solid var(--line); }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-title span, .section-title strong { display: block; }
.section-title span { margin-bottom: 4px; color: var(--blue-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.section-title strong { font-size: 18px; }
.section-title small { color: var(--muted); }
.section-tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.scope-switch { display: inline-flex; border: 1px solid var(--line); background: #f5f9fc; }
.scope-switch button { min-height: 34px; padding: 7px 12px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted); }
.scope-switch button:last-child { border-right: 0; }
.scope-switch button.active { background: var(--blue-dark); color: #fff; }
.section-note { margin: -8px 0 18px; padding: 10px 12px; border-left: 3px solid var(--cyan); background: #f2f9fc; color: #52667b; font-size: 13px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.order-form-grid { grid-template-columns: 100px 150px 180px 120px minmax(220px, 1fr) 140px; align-items: end; }
.wide { grid-column: span 2; }
.order-form-grid .wide { grid-column: auto; }
.provider-section { padding: 18px 0; border-top: 1px solid var(--line); }
.provider-section h2 { margin: 0 0 16px; font-size: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.danger-button { min-height: 42px; padding: 0 18px; border-radius: 5px; background: #fff !important; color: var(--danger) !important; border: 1px solid #efcaca !important; font-weight: 800; }
.code-editor { min-height: 430px; font-family: Consolas, "Microsoft YaHei UI", monospace; font-size: 13px; background: #f6fafc; }
.test-output { min-height: 150px; max-height: 420px; overflow: auto; margin: 18px 0 0; padding: 16px; border: 1px solid var(--line); background: #102235; color: #dcecf6; white-space: pre-wrap; line-height: 1.6; }

.created-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.created-code { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 14px; border: 1px solid var(--line); background: #f6fafc; }
.created-code strong, .created-code code { display: block; }
.created-code code { margin-top: 6px; color: var(--blue-dark); font-size: 16px; font-weight: 800; }
.created-code button { min-height: 34px; }
.search { width: 260px; min-height: 36px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 10px; text-align: left; color: #60758a; background: #f3f7fa; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 10px; border-bottom: 1px solid #e5edf2; vertical-align: top; }
td code { color: #315067; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 4px; background: #eaf0f4; color: #53687a; font-size: 11px; font-weight: 800; }
.status.active { background: #def5ea; color: var(--success); }
.status.new { background: #e5f3fa; color: var(--blue-dark); }
.status.processing { background: #edf0fb; color: #586ba0; }
.status.expired, .status.revoked, .status.exhausted { background: #fae7e5; color: var(--danger); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 190px; }
.row-actions button { padding: 5px 8px; border-radius: 4px; background: #eaf2f7; color: #315067; }
.row-actions button.danger { color: var(--danger); }
.row-actions button.approve { background: #def5ea; color: var(--success); }
.empty-row { padding: 34px; text-align: center; color: var(--muted); }
.candidate-tools { display: flex; align-items: center; gap: 8px; }
.candidate-table-scroll table { min-width: 1220px; }
.candidate-table-scroll th:nth-child(2), .candidate-table-scroll td:nth-child(2) { width: 250px; }
.candidate-table-scroll th:nth-child(3), .candidate-table-scroll td:nth-child(3) { width: 310px; }
.candidate-question { max-height: 88px; overflow: auto; line-height: 1.6; }
.candidate-detail summary { color: #264b63; font-weight: 800; cursor: pointer; }
.candidate-detail p { max-height: 220px; margin: 10px 0 0; overflow: auto; color: #52667b; line-height: 1.65; white-space: pre-wrap; }
.candidate-error { display: block; max-width: 180px; margin-top: 7px; color: var(--danger); line-height: 1.45; }
.candidate-actions { min-width: 120px; }
.muted-text { color: var(--muted); font-size: 12px; }

dialog { width: 430px; border: 1px solid var(--line); border-radius: 6px; padding: 0; box-shadow: 0 24px 70px rgba(9, 39, 57, .25); }
.wide-dialog { width: min(920px, calc(100vw - 60px)); }
dialog::backdrop { background: rgba(12, 32, 48, .45); }
dialog form { display: grid; gap: 14px; padding: 24px; }
dialog h2, dialog p { margin: 0; }
dialog p { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 13px 16px; border-radius: 5px; background: #102235; color: #fff; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1380px) {
  .order-form-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .order-form-grid .wide { grid-column: span 2; }
  .workflow-outcome-metrics { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}
.diagnostic-result small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.diagnostic-pass {
  color: #0f8f61;
}

.diagnostic-fail {
  color: #c43f4f;
}
