:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --surface: rgba(255, 255, 255, .92);
    --border: #e1e5ef;
    --text: #172033;
    --muted: #667085;
    --brand: #5b5fc7;
    --brand-dark: #474aa6;
    --danger: #c9362b;
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 80% -10%, #e7e9ff 0, transparent 35%), var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
button, input, textarea, select { font: inherit; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; display: flex; flex-direction: column; gap: 30px; background: #11182a; color: white; }
.brand { display: flex; align-items: center; gap: 12px; color: white; }
.brand span:last-child { display: grid; gap: 2px; }
.brand small { color: #9da8c2; }
.brand-mark { width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 12px; background: linear-gradient(135deg, #787cff, #4e53bb); color: white; font-weight: 800; box-shadow: 0 8px 30px #5b5fc766; }
.brand-mark.large { width: 58px; height: 58px; border-radius: 17px; font-size: 20px; }
nav { display: grid; gap: 8px; }
nav a { padding: 12px 14px; border-radius: 10px; color: #cbd3e6; font-weight: 600; }
nav a:hover, nav a.active { color: white; background: #ffffff12; }
.sidebar form { margin-top: auto; }
main { width: min(1240px, 100%); padding: 34px 42px 60px; }
.topbar, .panel-heading, .actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar { margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.04em; }
h2 { margin-bottom: 6px; letter-spacing: -.025em; }
.eyebrow { margin-bottom: 6px; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.muted, small { color: var(--muted); }
.user-chip, .status { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: #ebedff; color: #45499d; font-size: 12px; font-weight: 700; }
.status.new { background: #e8f2ff; color: #1765ad; }
.status.reviewing { background: #fff4d8; color: #855d00; }
.status.resolved { background: #e2f7e9; color: #18723c; }
.status.archived { background: #edf0f5; color: #596274; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.metrics article, .panel { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 14px 50px #27375d0a; }
.metrics article { padding: 22px; display: grid; gap: 9px; }
.metrics strong { font-size: 34px; }
.metrics span { color: var(--muted); font-weight: 600; }
.panel { padding: 24px; }
.panel-heading { margin-bottom: 22px; }
.button { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; cursor: pointer; font-weight: 700; text-align: center; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { color: var(--brand); background: #eef0ff; }
.button.ghost { color: inherit; background: transparent; border-color: var(--border); }
.button.danger { color: white; background: var(--danger); }
.full { width: 100%; }
.list { display: grid; }
.list > a { display: grid; grid-template-columns: 100px 1fr auto; align-items: center; gap: 14px; padding: 16px 4px; border-top: 1px solid var(--border); color: var(--text); }
.list > a:first-child { border-top: 0; }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); }
.notice { margin-bottom: 20px; padding: 14px 16px; border-radius: 12px; }
.notice.success { color: #176b3a; background: #e2f7e9; border: 1px solid #bce8ca; }
.notice.error { color: #9e2a22; background: #fff0ef; border: 1px solid #f3c4c0; }
.notice ul { margin-bottom: 0; }
.form-grid, .detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid label { display: grid; align-content: start; gap: 7px; font-weight: 700; }
.form-grid label small { font-weight: 400; }
.span-2 { grid-column: 1 / -1; }
input, textarea, select { width: 100%; border: 1px solid #ccd2df; border-radius: 10px; padding: 11px 12px; color: var(--text); background: white; }
input:focus, textarea:focus, select:focus { outline: 3px solid #5b5fc72b; border-color: var(--brand); }
textarea { resize: vertical; }
.code-input, code, .json-preview { font-family: "Cascadia Code", Consolas, monospace; }
.field-check { align-self: end; min-height: 44px; }
.check { display: flex !important; align-items: center; grid-template-columns: none !important; }
.check input { width: auto; }
.actions { justify-content: flex-end; padding-top: 8px; }
.actions form { margin: 0; }
.filter-form { display: flex; align-items: center; gap: 8px; }
.feedback-filter { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(4, minmax(135px, 1fr)) auto; align-items: end; gap: 12px; margin-bottom: 22px; }
.feedback-filter label { display: grid; gap: 7px; font-weight: 700; }
.feedback-filter .actions { flex-direction: row; padding: 0; }
.json-preview { max-height: 580px; overflow: auto; padding: 20px; border-radius: 12px; background: #11182a; color: #dce4f8; line-height: 1.55; }
.draft-integrity { display: grid; gap: 6px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #f7f8fc; }
.draft-integrity span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.draft-integrity code { overflow-wrap: anywhere; font-size: 12px; }
.message { padding: 20px; border-radius: 12px; background: #f7f8fc; white-space: pre-wrap; line-height: 1.6; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #dfe2ff, transparent 35%), #f5f6fa; }
.login-card { width: min(440px, 100%); padding: 36px; border: 1px solid var(--border); border-radius: 22px; background: white; box-shadow: 0 25px 80px #25345e20; }
.login-card h1 { margin: 18px 0 10px; }
.stack { display: grid; gap: 16px; margin-top: 24px; }
.stack label { display: grid; gap: 7px; font-weight: 700; }
.security-steps { display: grid; gap: 10px; padding-left: 22px; color: var(--muted); line-height: 1.55; }
.secret-box { display: grid; gap: 7px; margin: 20px 0; padding: 18px; border: 1px dashed #aeb5c8; border-radius: 12px; background: #f7f8fc; }
.secret-box span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.secret-box code { overflow-wrap: anywhere; color: var(--text); font-size: 18px; letter-spacing: .12em; }
.provisioning-details { margin-bottom: 20px; color: var(--muted); }
.provisioning-details code { display: block; margin-top: 10px; overflow-wrap: anywhere; padding: 12px; border-radius: 8px; background: #f7f8fc; }
.security-form { max-width: 420px; }
.security-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.security-actions form { padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: #f9faff; }
.security-actions h3 { margin: 0; }
.danger-zone { border-color: #f1c2be !important; background: #fff8f7 !important; }
.recovery-panel { margin-bottom: 22px; border-color: #f0d38b; background: #fffdf5; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.recovery-codes code { padding: 12px; border: 1px solid #e2d39f; border-radius: 8px; background: white; text-align: center; font-size: 16px; letter-spacing: .08em; }
.token-reveal { margin-bottom: 22px; border-color: #f0d38b; background: #fffdf5; }
.token-reveal > code { display: block; overflow-wrap: anywhere; padding: 16px; border: 1px solid #e2d39f; border-radius: 10px; background: white; font-size: 15px; }
.ability-grid { display: grid; gap: 10px; margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: 12px; }
.ability-grid legend { padding: 0 7px; font-weight: 700; }
.token-list-panel { margin-top: 22px; }
.token-list { display: grid; gap: 14px; }
.token-list article { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: #f9faff; }
.token-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.token-summary > div { display: grid; gap: 5px; }
.token-list details { margin-top: 12px; }
.token-list summary { cursor: pointer; color: var(--danger); font-weight: 700; }
.revoke-form { margin-top: 14px; }
.audit-filter { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr)) auto; align-items: end; gap: 12px; margin-bottom: 22px; }
.audit-filter label { display: grid; gap: 7px; font-weight: 700; }
.audit-filter .actions { padding: 0; }
.audit-list { display: grid; gap: 12px; }
.audit-list article { padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: #f9faff; }
.audit-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.audit-summary > div { display: grid; gap: 4px; }
.audit-list details { margin-top: 12px; }
.audit-list summary { cursor: pointer; color: var(--brand); font-weight: 700; }
.audit-list pre { overflow: auto; margin-bottom: 0; padding: 14px; border-radius: 9px; background: #11182a; color: #dce4f8; }
@media (max-width: 860px) {
    .shell { display: block; min-height: 100vh; }
    .sidebar { position: static; width: 100%; height: auto; padding: 18px; gap: 16px; }
    .sidebar nav { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
    .sidebar form { margin-top: 0; }
    main { padding: 24px 18px 48px; }
    .metrics { grid-template-columns: 1fr; }
    .feedback-filter { grid-template-columns: 1fr 1fr; }
    .feedback-filter .search-field, .feedback-filter .actions { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
    .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar nav a { padding: 9px 5px; text-align: center; font-size: 12px; }
    .sidebar .button { padding: 8px 12px; }
    .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .topbar, .panel-heading, .actions { align-items: stretch; flex-direction: column; }
    .list > a { grid-template-columns: 1fr; }
    .user-chip { align-self: flex-start; }
    .security-actions, .recovery-codes { grid-template-columns: 1fr; }
    .audit-filter { grid-template-columns: 1fr; }
    .feedback-filter { grid-template-columns: 1fr; }
    .feedback-filter .search-field, .feedback-filter .actions { grid-column: auto; }
}
