:root {
    color-scheme: light;
    --navy: #0f172a;
    --navy-soft: #1e293b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --surface: #ffffff;
    --background: #f4f6f8;
    --border: #e2e8f0;
    --text: #172033;
    --muted: #64748b;
    --success: #047857;
    --success-bg: #ecfdf5;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --warning: #9a6700;
    --warning-bg: #fffaeb;
    --radius: 12px;
    --shadow: 0 12px 32px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
    margin: 0;
    color: var(--text);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 28px; line-height: 1.25; letter-spacing: -.02em; }
h2 { margin-bottom: 4px; font-size: 18px; line-height: 1.4; }
form { margin: 0; }

.topbar { color: #fff; background: var(--navy); }
.topbar-inner { display: flex; align-items: center; gap: 30px; width: min(1180px, calc(100% - 40px)); min-height: 68px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-size: 16px; font-weight: 700; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: #fff; font-size: 16px; font-weight: 800; background: var(--primary); box-shadow: 0 8px 20px rgba(37, 99, 235, .3); }
.topbar nav a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 8px; color: #cbd5e1; }
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.logout-form { margin-left: auto; }

.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 56px; }
.surface { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 2px rgba(15, 23, 42, .03); }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading .actions { justify-content: flex-end; }
.page-description, .section-heading p, .push-action p, .token-notice p, .empty-state p { margin: 0; color: var(--muted); }
.eyebrow { margin-bottom: 5px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.section-card { margin-bottom: 20px; padding: 24px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.history-section { margin-top: 30px; }

.button, button, .button-secondary, .button-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #fff;
    font: inherit;
    font-weight: 650;
    line-height: 1;
    background: var(--primary);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}
.button:hover, button:hover { color: #fff; background: var(--primary-dark); }
.button:active, button:active, .button-secondary:active { transform: translateY(1px); }
.button-secondary { color: #334155; border-color: #cbd5e1; background: #fff; }
.button-secondary:hover { color: var(--navy); border-color: #94a3b8; background: #f8fafc; }
.button-ghost { min-height: 36px; color: #cbd5e1; border-color: #334155; background: transparent; }
.button-ghost:hover { color: #fff; border-color: #64748b; background: var(--navy-soft); }
.button-small { min-height: 32px; padding: 0 10px; border-radius: 7px; font-size: 13px; }
.button-block { width: 100%; min-height: 46px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

label { color: #334155; font-weight: 650; }
input, textarea, select {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    background: #fff;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.system-form { display: grid; gap: 10px; }
.system-form small { margin-top: -6px; color: var(--muted); }
.form-section-heading { margin-top: 16px; padding-top: 20px; border-top: 1px solid var(--border); }
.form-section-heading h2 { margin: 0 0 4px; font-size: 18px; }
.form-section-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.form-card { max-width: 760px; padding: 26px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; padding-top: 20px; border-top: 1px solid var(--border); }
.search-form { display: grid; grid-template-columns: auto minmax(220px, 380px) auto; align-items: center; gap: 12px; margin-bottom: 18px; padding: 14px 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: #475569; font-size: 12px; font-weight: 750; letter-spacing: .02em; background: #f8fafc; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
.table-actions { min-width: 255px; }
.table-actions form { display: inline-flex; }
.text-muted { color: var(--muted); }

.status { display: inline-flex; align-items: center; min-height: 25px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-success { color: var(--success); background: var(--success-bg); }
.status-danger { color: var(--danger); background: var(--danger-bg); }
.status-muted { color: #475569; background: #f1f5f9; }

.message { margin-bottom: 20px; padding: 12px 14px; border: 1px solid #bfdbfe; border-radius: 9px; color: #1e40af; background: #eff6ff; }
.message-error { color: var(--danger); border-color: #fecdca; background: var(--danger-bg); }
.message-warning { color: var(--warning); border-color: #fedf89; background: var(--warning-bg); }
.token-notice { display: grid; gap: 14px; margin-bottom: 20px; padding: 18px; border: 1px solid #a7f3d0; border-radius: var(--radius); background: var(--success-bg); }
.code-actions { display: flex; align-items: flex-start; gap: 10px; }
.code-block { flex: 1; min-width: 0; max-height: 116px; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 8px; color: #334155; font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; background: #f8fafc; }
.definition-grid { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px 20px; margin: 0; }
.definition-grid dt { color: var(--muted); }
.definition-grid dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.empty-state { padding: 26px; border: 1px dashed #cbd5e1; border-radius: 10px; text-align: center; background: #f8fafc; }
.push-action { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; padding: 18px 24px; }

.login-page { min-height: 100vh; background: linear-gradient(145deg, #eef4ff 0%, #f8fafc 48%, #eef2f7 100%); }
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 36px; border: 1px solid rgba(226, 232, 240, .9); border-radius: 16px; background: rgba(255, 255, 255, .96); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand h1 { margin: 0; font-size: 25px; }
.login-brand .eyebrow { margin: 0 0 2px; }
.login-description { margin: 18px 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 9px; }
.login-form input { margin-bottom: 8px; min-height: 46px; }
.login-form button { margin-top: 8px; }
.login-footnote { margin: 22px 0 0; color: #94a3b8; font-size: 12px; text-align: center; }

@media (max-width: 720px) {
    .topbar-inner, .container { width: min(100% - 28px, 1180px); }
    .topbar-inner { gap: 12px; min-height: 62px; }
    .brand span:last-child { display: none; }
    .topbar nav a { padding: 0 8px; }
    .container { padding-top: 24px; }
    .page-heading, .push-action { align-items: stretch; flex-direction: column; }
    .page-heading > .button, .page-heading > .button-secondary { align-self: flex-start; }
    .page-heading .actions { justify-content: flex-start; }
    .search-form { grid-template-columns: 1fr; }
    .definition-grid { grid-template-columns: 1fr; gap: 4px; }
    .definition-grid dd { margin-bottom: 10px; }
    .code-actions { flex-direction: column; }
    .code-actions .button-secondary { width: 100%; }
    .section-card, .form-card { padding: 18px; }
    .login-card { padding: 28px 22px; }
    h1 { font-size: 24px; }
}
