:root {
  color-scheme: light;
  --ink: #172033;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #e5e9f0;
  --line-strong: #d8dee8;
  --paper: #fff;
  --bg: #f5f7fa;
  --primary: #2856d7;
  --primary-dark: #1f46b7;
  --primary-soft: #eef3ff;
  --success: #16875b;
  --success-soft: #eaf8f1;
  --warning: #b54708;
  --warning-soft: #fff5e8;
  --danger: #c9322c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, textarea { font: inherit; }
button { min-height: 38px; border: 0; border-radius: 8px; padding: 8px 14px; color: #fff; background: var(--primary); font-size: 14px; font-weight: 700; cursor: pointer; transition: background .16s ease, box-shadow .16s ease, transform .16s ease; }
button:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(40,86,215,.18); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: wait; box-shadow: none; }
button.secondary, button.quiet-button { color: var(--primary); background: var(--primary-soft); }
button.secondary:hover, button.quiet-button:hover { background: #e1e9ff; }
button.text-button { color: var(--muted); background: transparent; }
button.text-button:hover { color: var(--ink); background: rgba(255,255,255,.08); box-shadow: none; }
input, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; padding: 10px 12px; color: var(--ink); outline: none; transition: border-color .16s ease, box-shadow .16s ease; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(40,86,215,.1); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 23px; line-height: 1.25; letter-spacing: -.02em; }
h2 { margin-bottom: 0; font-size: 17px; line-height: 1.4; }

.eyebrow, .section-label { margin-bottom: 4px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.muted { color: var(--muted); line-height: 1.65; }
.compact-copy { margin-bottom: 16px; font-size: 13px; }
.topbar { min-height: 70px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 12px max(24px, calc((100vw - 1080px)/2)); color: #fff; background: #172a52; border-bottom: 1px solid rgba(255,255,255,.08); }
.topbar .eyebrow { color: #aebfe9; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; color: #fff; background: linear-gradient(145deg, #4979f0, #2856d7); box-shadow: inset 0 1px 0 rgba(255,255,255,.28); font-size: 18px; font-weight: 900; }
.brand-mark-large { width: 46px; height: 46px; margin-bottom: 20px; border-radius: 12px; font-size: 21px; }
.top-actions, .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar .quiet-button { color: #e7edff; background: rgba(255,255,255,.1); }
.topbar .quiet-button:hover { background: rgba(255,255,255,.16); }
.topbar .text-button { color: #c2cbe0; }
.page { width: min(1080px, calc(100% - 32px)); margin: 18px auto 42px; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.status-card, .panel { border: 1px solid var(--line); border-radius: 11px; background: var(--paper); box-shadow: 0 3px 12px rgba(16,24,40,.035); }
.status-card { min-width: 0; padding: 13px 15px; }
.status-card span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.status-card strong { display: block; overflow: hidden; color: var(--ink); font-size: 16px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.panel { padding: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); align-items: start; gap: 12px; }
.utility-grid { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 12px; margin-top: 12px; }
.panel.slim { padding: 15px 18px; }
.badge { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 25px; padding: 4px 9px; border-radius: 999px; color: var(--warning); background: var(--warning-soft); font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.ok { color: var(--success); background: var(--success-soft); }
.auth-summary { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.auth-summary .muted { max-width: 510px; margin-bottom: 0; font-size: 13px; }
.auth-actions { flex: 0 0 auto; }
.ready-line { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--success); font-size: 13px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.qr-panel { display: grid; place-items: center; min-height: 218px; margin-top: 16px; padding: 14px; border: 1px solid #dfe6f2; border-radius: 10px; background: #f8faff; text-align: center; }
.qr-frame { width: 176px; height: 176px; padding: 8px; border: 1px solid #ebeff5; border-radius: 8px; background: #fff; }
.qr-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.qr-loading { display: grid; place-items: center; width: 176px; height: 176px; border: 1px dashed #d6deed; border-radius: 8px; background: #fff; }
.spinner { width: 26px; height: 26px; border: 3px solid #dce5fb; border-top-color: var(--primary); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.qr-message { margin: 10px 0 0; color: var(--ink-soft); font-size: 13px; font-weight: 700; line-height: 1.5; }
.qr-message.success { color: var(--success); }
.qr-message.danger { color: var(--danger); }
.field-label { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.webhook-actions { margin-top: 10px; }
.health-panel { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.health-panel .panel-head { margin: 0; }
.error { min-height: 18px; color: var(--danger); }
.error-box { margin: 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.error-box.has-error { color: var(--danger); }
.advanced { padding-block: 17px; }
.advanced summary { color: var(--ink-soft); font-size: 13px; font-weight: 700; cursor: pointer; }
.advanced[open] summary { margin-bottom: 14px; }
.advanced-body .muted { margin-bottom: 10px; font-size: 12px; }
.advanced-actions { margin-top: 10px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: 380px; margin: 0; padding: 11px 14px; border-radius: 8px; color: #fff; background: #147b54; box-shadow: 0 10px 30px rgba(16,24,40,.18); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.danger { background: var(--danger); }
.stack { display: grid; gap: 8px; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 18%, #e8eeff 0, transparent 30%), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 18px 55px rgba(16,24,40,.1); }
.auth-card h1 { margin-bottom: 10px; font-size: 25px; }
.auth-card > .muted { margin-bottom: 22px; font-size: 13px; }
.login-form button { margin-top: 4px; }

@media (max-width: 860px) {
  .workspace-grid, .utility-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .topbar { align-items: flex-start; padding: 13px 16px; }
  .topbar h1 { font-size: 18px; }
  .brand-mark { width: 34px; height: 34px; }
  .top-actions { gap: 2px; }
  .page { width: min(100% - 20px, 1080px); margin-top: 10px; }
  .status-grid { gap: 8px; }
  .status-card { padding: 11px 12px; }
  .status-card strong { font-size: 14px; }
  .panel { padding: 15px; }
  .auth-summary { align-items: stretch; flex-direction: column; gap: 14px; }
  .auth-actions button, .webhook-actions button { flex: 1 1 auto; }
  .health-panel { align-items: flex-start; flex-direction: column; gap: 7px; }
}

@media (max-width: 390px) {
  .topbar .eyebrow { display: none; }
  .status-grid { grid-template-columns: 1fr; }
  .top-actions button { padding-inline: 9px; }
}
