:root {
    --bg: #f3f5f9;
    --panel: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --ok: #16a34a;
    --warn: #d97706;
    --bad: #dc2626;
    --info: #0284c7;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

.copy-src {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    border: 0;
    padding: 0;
}

.inline-details {
    display: inline-block;
    text-align: left;
}

.inline-details > summary {
    list-style: none;
    cursor: pointer;
}

.inline-details > summary::-webkit-details-marker {
    display: none;
}

.inline-details[open] > summary {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.edit-form {
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfe;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.edit-form .field {
    margin-top: 8px;
}

.record-value {
    display: block;
    max-width: 620px;
    overflow-wrap: anywhere;
}

.cname-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-weight: 400;
    font-size: 12.5px;
}

.cname-list .muted {
    margin: 0 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.poll-box {
    display: flex;
    align-items: center;
    gap: 9px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 9px;
    padding: 9px 12px;
    margin-bottom: 12px;
    font-size: 13px;
}

.poll-dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    animation: poll-pulse 1.4s ease-in-out infinite;
}

@keyframes poll-pulse {
    0%, 100% {
        opacity: .35;
        transform: scale(.85);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

.text-bad {
    color: var(--bad);
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: .92em;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 5px;
    word-break: break-all;
}

h1, h2, h3 {
    margin: 0;
    font-weight: 650;
    letter-spacing: -.01em;
}

h1 {
    font-size: 22px;
}

h2 {
    font-size: 16px;
}

/* ---------- 顶栏 ---------- */

.topbar {
    background: #0f172a;
    color: #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f8fafc;
    font-weight: 650;
    font-size: 15px;
    white-space: nowrap;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b82f6, #22d3ee);
    color: #04121f;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
}

.brand-mark-lg {
    width: 52px;
    height: 52px;
    font-size: 17px;
    border-radius: 14px;
}

.nav {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}

.nav a {
    color: #cbd5e1;
    padding: 7px 12px;
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
}

.nav a:hover {
    background: rgba(148, 163, 184, .15);
    color: #f8fafc;
    text-decoration: none;
}

.nav a.active {
    background: rgba(59, 130, 246, .22);
    color: #93c5fd;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    color: #cbd5e1;
    font-size: 13px;
    white-space: nowrap;
}

.topbar-user a {
    color: #e2e8f0;
    font-weight: 600;
}

.topbar-user a:hover {
    color: #fff;
}

.topbar-user .badge-info {
    background: rgba(59, 130, 246, .25);
    border-color: rgba(147, 197, 253, .4);
    color: #bfdbfe;
}

.logout-form {
    margin: 0;
}

.link-button {
    background: none;
    border: 0;
    padding: 2px 4px;
    margin-left: 4px;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 6px;
}

.link-button:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.link-button:focus-visible {
    outline: 2px solid rgba(37, 99, 235, .5);
    outline-offset: 2px;
}

/* ---------- 布局 ---------- */

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 26px 24px 48px;
    flex: 1;
}

.container-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 8vh;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 18px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-head .muted {
    margin: 4px 0 0;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 12px;
}

.strong {
    font-weight: 650;
    color: var(--text);
}

.pad {
    padding: 16px 20px;
}

.right {
    text-align: right;
}

.nowrap {
    white-space: nowrap;
}

.wrap {
    word-break: break-word;
}

/* ---------- 卡片 ---------- */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-head h2 {
    font-size: 15px;
}

.empty-state {
    text-align: center;
    padding: 52px 24px;
}

.empty-state h2 {
    margin-bottom: 6px;
}

.empty-state .btn {
    margin-top: 14px;
}

/* ---------- 统计 ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-top: 3px solid var(--primary);
}

.stat-warn {
    border-top-color: var(--warn);
}

.stat-bad {
    border-top-color: var(--bad);
}

.stat-label {
    color: var(--muted);
    font-size: 12.5px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -.02em;
}

/* ---------- 表格 ---------- */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: #f8fafc;
    font-weight: 600;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover td {
    background: #fbfcfe;
}

.table-compact th,
.table-compact td {
    padding: 9px 16px;
}

.chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
    vertical-align: middle;
}

.chip {
    background: #eef2ff;
    border-color: #dbe3fd;
    color: #3730a3;
    font-size: 12px;
    padding: 0 6px;
}

.row-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

/* ---------- 徽章 ---------- */

.badge {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-ok {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

.badge-warn {
    background: #fef3c7;
    color: #b45309;
    border-color: #fde68a;
}

.badge-bad {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
}

.badge-muted {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

/* ---------- 图标 ---------- */

.svg-sprite {
    display: none;
}

.icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: -2px;
    pointer-events: none;
}

/* ---------- 按钮 ---------- */

.btn {
    --btn-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 15px;
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 650;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    box-shadow: var(--btn-shadow);
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

.btn:hover {
    background: #ffffff;
    border-color: #b9c6d6;
    box-shadow: 0 6px 16px -6px rgba(15, 23, 42, .22);
    transform: translateY(-1px);
    text-decoration: none;
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--btn-shadow);
}

.btn:focus-visible {
    outline: 2px solid rgba(37, 99, 235, .55);
    outline-offset: 2px;
}

.btn .icon {
    width: 15px;
    height: 15px;
}

.btn-primary {
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    border-color: #2563eb;
    color: #fff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, .35), 0 8px 18px -8px rgba(37, 99, 235, .75);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #2f7bf6, #1d4ed8);
    border-color: #1d4ed8;
    color: #fff;
    box-shadow: 0 10px 24px -10px rgba(37, 99, 235, .85);
}

.btn-primary:active {
    background: #1d4ed8;
}

.btn-danger {
    background: linear-gradient(180deg, #ffffff, #fff7f7);
    border-color: #fecaca;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fff1f2;
    border-color: #fca5a5;
    color: #991b1b;
    box-shadow: 0 6px 16px -8px rgba(220, 38, 38, .45);
}

.btn-ghost {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .18);
    color: #e2e8f0;
    box-shadow: none;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .32);
    color: #fff;
    box-shadow: none;
}

.btn-sm {
    height: 31px;
    padding: 0 10px;
    font-size: 12.5px;
    border-radius: 8px;
    gap: 5px;
}

.btn-sm .icon {
    width: 14px;
    height: 14px;
}

.btn-block {
    width: 100%;
    height: 42px;
    font-size: 14px;
}

.btn:disabled,
.btn-disabled {
    color: #94a3b8;
    background: #f8fafc;
    border-color: #e2e8f0;
    cursor: default;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

.form-actions .btn {
    min-width: 106px;
}

.table .row-actions .btn {
    height: 30px;
    padding: 0 8px;
}

/* ---------- 表单 ---------- */

.form {
    padding: 0;
}

.form > .card-head {
    background: #fbfcfe;
}

.form > .form-grid,
.form > .field,
.form > .checkbox,
.form > .form-actions,
.form > p {
    margin-left: 20px;
    margin-right: 20px;
}

.form > .form-grid:first-of-type,
.form > .field:first-of-type {
    margin-top: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
}

.field > span:first-child {
    font-weight: 600;
    font-size: 13px;
}

.req {
    color: var(--bad);
    font-style: normal;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color .12s ease, box-shadow .12s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}

textarea {
    resize: vertical;
    min-height: 96px;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 13px;
}

.hint {
    color: var(--muted);
    font-size: 12.5px;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: 14px;
    font-size: 13.5px;
}

.checkbox input {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.checkbox-inline {
    align-self: end;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    margin-top: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 0 20px;
    margin-top: 8px;
}

.error-list {
    margin: 6px 0 0;
    padding-left: 20px;
}

/* ---------- 提示条 ---------- */

.flash {
    border-radius: 10px;
    padding: 11px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 13.5px;
}

.flash a {
    font-weight: 650;
}

.flash-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.flash-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.flash-warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.flash-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* ---------- 登录页 ---------- */

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.auth-head {
    text-align: center;
    margin-bottom: 20px;
}

.auth-head h1 {
    font-size: 20px;
    margin-top: 14px;
}

.auth-head .muted {
    margin: 6px 0 0;
    font-size: 13px;
}

.auth-card .field {
    margin-top: 14px;
}

.auth-card .btn-block {
    margin-top: 20px;
    padding: 10px;
}

.auth-card .hint {
    text-align: center;
    margin: 16px 0 0;
}

/* ---------- 详情页 ---------- */

.info {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0;
}

.info > div {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.info dt {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 3px;
}

.info dd {
    margin: 0;
    font-weight: 500;
}

.info .inline-form {
    margin-left: 8px;
}

.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 20px;
}

.code {
    margin: 0;
    padding: 16px 20px;
    background: #0f172a;
    color: #cbd5e1;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    max-height: 340px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-block {
    margin: 12px 20px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.code-line {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.code-label {
    flex: 0 0 42px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    padding-top: 2px;
}

.code-line code {
    flex: 1;
    padding: 4px 9px;
    background: #f8fafc;
}

.error-page {
    text-align: center;
    padding: 48px 24px;
}

.error-page h1 {
    font-size: 44px;
    color: var(--bad);
    margin-bottom: 8px;
}

.error-page p {
    color: var(--muted);
    margin: 0 0 16px;
}

@media (max-width: 980px) {
    .topbar-inner {
        height: auto;
        padding: 12px 16px;
        gap: 10px;
    }

    .nav {
        order: 3;
        flex: 1 1 100%;
        overflow-x: auto;
    }
}

@media (max-width: 720px) {
    .container {
        padding: 18px 14px 40px;
    }

    .table th,
    .table td {
        padding: 10px 12px;
    }

    .page-actions {
        width: 100%;
    }
}
