* { box-sizing: border-box; }
body { font-family: -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0; background: #f5f7fa; color: #1f2937; }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
.page { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #0f172a; color: #e5e7eb; padding: 18px 0; position: sticky; top: 0; height: 100vh; }
.brand { padding: 0 20px 18px 20px; font-weight: 700; font-size: 18px; border-bottom: 1px solid #1e293b; }
.nav-list { list-style: none; padding: 8px 0; margin: 0; }
.nav-list li a { display: block; padding: 10px 20px; color: #cbd5e1; }
.nav-list li a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-list li a.active { background: #1d4ed8; color: #fff; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e5e7eb; padding: 10px 24px; display: flex; justify-content: flex-end; gap: 12px; align-items: center; }
.content { padding: 24px; max-width: 1100px; }
h1 { margin: 0 0 16px; font-size: 22px; }
h2 { margin: 16px 0 12px; font-size: 18px; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #f3f4f6; font-size: 14px; }
th { background: #f9fafb; font-weight: 600; }
.btn { display: inline-block; padding: 8px 14px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: 14px; }
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-secondary { background: #fff; color: #1f2937; border-color: #d1d5db; }
.btn-danger { background: #dc2626; color: #fff; }
.link-btn { background: none; border: none; color: #1d4ed8; cursor: pointer; padding: 0; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-control { width: 100%; max-width: 480px; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 14px; }
.dest-picker-inline { display: flex; gap: 6px; align-items: center; }
.dest-picker-inline .form-control { max-width: 220px; }
.alert { padding: 10px 14px; border-radius: 4px; margin: 8px 0; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-warn { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; background: #f3f4f6; padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 4px; word-break: break-all; }
.scopes { display: flex; flex-wrap: wrap; gap: 6px; }
.scope-tag { background: #e0e7ff; color: #1e3a8a; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.login-card { max-width: 360px; margin: 80px auto; background: #fff; padding: 28px; border: 1px solid #e5e7eb; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.muted { color: #6b7280; }
.workbar { display: flex; align-items: center; gap: 12px; background: #eef2ff; border: 1px solid #c7d2fe; padding: 8px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.workbar .code { padding: 2px 6px; }
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 18px; border-bottom: 1px solid #e5e7eb; padding-bottom: 10px; }
.subnav a { padding: 6px 12px; border-radius: 4px; background: #fff; border: 1px solid #d1d5db; font-size: 13px; }
.subnav a.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge-synced { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-drifted { background: #fde68a; color: #92400e; }
.badge-default { background: #e5e7eb; color: #374151; }

.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.tile { flex: 1 1 120px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 16px; }
.tile .n { font-size: 26px; font-weight: 600; line-height: 1.1; }
.tile .l { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; }
.tile.alarm .n { color: #991b1b; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: #10b981; }
.dot-bad { background: #ef4444; }

/* ── API trace panel (debug: shows every request/response) ───────────────── */
.apitrace { position: fixed; right: 16px; bottom: 0; z-index: 1000; width: min(620px, calc(100vw - 32px)); font-size: 13px; }
.apitrace-launcher { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 7px 14px; background: #0f172a; color: #e5e7eb; border: 1px solid #1e293b; border-bottom: none; border-radius: 8px 8px 0 0; cursor: pointer; box-shadow: 0 -2px 8px rgba(0,0,0,.12); }
.apitrace-launcher:hover { background: #1e293b; }
.apitrace-dot { width: 9px; height: 9px; border-radius: 999px; }
.apitrace-dot.ok { background: #10b981; }
.apitrace-dot.bad { background: #ef4444; }
.apitrace-count { background: #1d4ed8; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
.apitrace-chev { margin-left: 4px; opacity: .7; }
.apitrace-body { background: #fff; border: 1px solid #cbd5e1; border-bottom: none; border-radius: 8px 8px 0 0; box-shadow: 0 -6px 20px rgba(15,23,42,.18); max-height: 60vh; display: flex; flex-direction: column; }
.apitrace-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid #eef2f7; }
.apitrace-actions { display: flex; align-items: center; gap: 14px; }
.apitrace-toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; color: #334155; }
.apitrace-toggle input { margin: 0; cursor: pointer; }
.apitrace-empty { padding: 18px 14px; color: #6b7280; }
.apitrace-list { overflow-y: auto; }
.apitrace-row { border-bottom: 1px solid #f1f5f9; }
.apitrace-row.err { background: #fef6f6; }
.apitrace-rowhead { display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer; }
.apitrace-rowhead:hover { background: #f8fafc; }
.apitrace-method { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 11px; min-width: 50px; }
.apitrace-method.m-get { color: #1d4ed8; }
.apitrace-method.m-post { color: #047857; }
.apitrace-method.m-patch, .apitrace-method.m-put { color: #b45309; }
.apitrace-method.m-delete { color: #b91c1c; }
.apitrace-status { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.apitrace-status.s-ok { background: #d1fae5; color: #065f46; }
.apitrace-status.s-redir { background: #fef3c7; color: #92400e; }
.apitrace-status.s-err { background: #fee2e2; color: #991b1b; }
.apitrace-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; color: #334155; }
.apitrace-src { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; background: #f1f5f9; padding: 1px 6px; border-radius: 999px; }
.apitrace-meta { color: #94a3b8; font-size: 11px; white-space: nowrap; }
.apitrace-detail { padding: 4px 12px 12px; background: #fbfdff; }
.apitrace-section-label { display: flex; gap: 8px; align-items: baseline; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #475569; margin: 10px 0 4px; }
.apitrace-nobody { font-size: 12px; padding: 2px 0 4px; }
.apitrace-json { margin: 0; padding: 10px 12px; background: #0f172a; color: #e2e8f0; border-radius: 6px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }
