/*
 * 全平台 DNS 综合管理 —— 视觉与动效
 *
 * 设计语言参考 xuelemi.acg.xxx：奶白纸底、墨色文字、草绿主色，
 * 2px 描边 + 大圆角 + 「0 4px 0」硬投影构成的实体按键感，
 * 交互一律走「按下去再弹回来」的物理反馈。
 */

:root {
    color-scheme: light;

    /* 底色与结构 */
    --paper: #fffdf7;
    --card: #ffffff;
    --card-soft: #fbfbf6;
    --mist: #e5e5e5;
    --mist-soft: #f0efe9;

    /* 文字 */
    --ink: #3c3c3c;
    --ink-soft: #777777;
    --ink-faint: #afafaf;

    /* 主色与语义色 */
    --brand: #58cc02;
    --brand-dark: #46a302;
    --brand-light: #d7ffb8;
    --coral: #ff4b4b;
    --coral-dark: #e33d3d;
    --coral-light: #ffdfe0;
    --amber: #ffc800;
    --amber-light: #fff4cc;
    --sky: #1cb0f6;
    --sky-light: #ddf4ff;
    --grape: #ce82ff;

    /* 实体投影：所有可按压元素共用同一套下沉阴影 */
    --drop: 0 4px 0 rgba(60, 60, 60, .16);
    --drop-lift: 0 6px 0 rgba(60, 60, 60, .18);
    --drop-press: 0 1px 0 rgba(60, 60, 60, .16);
    --drop-soft: 0 2px 0 rgba(60, 60, 60, .08);
    --float: 0 18px 44px rgba(60, 60, 60, .18), 0 4px 0 rgba(60, 60, 60, .1);

    --radius: 16px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --speed: .18s;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: ui-rounded, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
    font-family: inherit;
}

h1, h2, h3 {
    font-weight: 900;
    letter-spacing: -.01em;
}

/* ---------- 按钮：实体按键 ---------- */

button {
    position: relative;
    min-height: 44px;
    border: 2px solid var(--brand);
    border-radius: var(--radius);
    padding: 0 18px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--drop);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-user-select: none;
    user-select: none;
    transition:
        transform var(--speed) var(--ease-out),
        box-shadow var(--speed) var(--ease-out),
        background-color var(--speed) ease,
        border-color var(--speed) ease,
        color var(--speed) ease,
        filter var(--speed) ease;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--drop-lift);
    filter: saturate(1.06);
}

button:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: var(--drop-press);
    transition-duration: .06s;
}

button:focus-visible {
    outline: none;
    box-shadow: var(--drop), 0 0 0 4px rgba(88, 204, 2, .32);
}

button.secondary {
    border-color: var(--mist);
    background: var(--card);
    color: var(--ink);
}

button.secondary:hover:not(:disabled) {
    border-color: #d3d3d3;
    background: var(--card-soft);
}

button.secondary:focus-visible {
    box-shadow: var(--drop), 0 0 0 4px rgba(60, 60, 60, .16);
}

button.danger {
    border-color: var(--coral);
    background: var(--coral);
    color: #fff;
}

button.danger:focus-visible {
    box-shadow: var(--drop), 0 0 0 4px rgba(255, 75, 75, .3);
}

button.ghost {
    border-color: var(--mist);
    background: var(--card);
    color: var(--coral);
}

button.ghost:hover:not(:disabled) {
    border-color: var(--coral);
    background: var(--coral-light);
}

button:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--drop-soft);
}

.btn-icon {
    display: inline-flex;
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    align-items: center;
    justify-content: center;
    transition: transform .3s var(--ease-spring);
}

.btn-icon svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

button:hover:not(:disabled) .btn-icon {
    transform: scale(1.14) rotate(-6deg);
}

button span:not(.btn-icon) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 同步/刷新按钮按下时图标转一圈，动作有了「正在发生」的暗示 */
button[data-icon="sync"]:active .btn-icon,
button[data-icon="refresh"]:active .btn-icon {
    animation: spin .6s var(--ease-out);
}

/* ---------- 表单控件 ---------- */

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    padding: 10px 14px;
    background: var(--card);
    color: var(--ink);
    font-weight: 600;
    outline: none;
    transition: border-color var(--speed) ease, box-shadow var(--speed) ease, background-color var(--speed) ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--ink-faint);
    font-weight: 500;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #d3d3d3;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(88, 204, 2, .18);
}

/* 只在用户动过之后才提示错误，空表单一进页面不该满屏飘红 */
input:user-invalid,
textarea:user-invalid {
    border-color: var(--coral);
    box-shadow: 0 0 0 4px rgba(255, 75, 75, .14);
}

/* app.js 接管之前，原生 select 会短暂可见。
   保留上面的输入框基础样式并抹掉系统箭头，让这一瞬间不至于露出浏览器默认外观。 */
select {
    appearance: none;
}

/* ---------- 自绘下拉 ----------
 *
 * 原生 select 的弹出列表由操作系统绘制，和这套圆角实体风格完全割裂。
 * 真正的 select 仍留在表单里（.select-native 视觉隐藏），
 * 视觉与交互由 .select-trigger + .select-menu 接管。
 */

.select-native {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    opacity: 0;
    pointer-events: none;
}

.select-shell {
    position: relative;
    width: 100%;
    min-width: 0;
}

.select-trigger {
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    padding: 10px 12px 10px 14px;
    background: var(--card);
    color: var(--ink);
    font-weight: 600;
    text-align: left;
    box-shadow: none;
}

.select-trigger:hover:not(:disabled) {
    transform: none;
    border-color: #d3d3d3;
    background: var(--card);
    box-shadow: none;
    filter: none;
}

.select-trigger:active:not(:disabled) {
    transform: none;
    box-shadow: none;
}

.select-trigger:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(88, 204, 2, .18);
}

.select-shell.is-open .select-trigger {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(88, 204, 2, .18);
}

.select-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-shell.is-placeholder .select-label {
    color: var(--ink-faint);
    font-weight: 500;
}

.select-arrow {
    display: inline-flex;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--ink-soft);
    transition: transform .22s var(--ease-spring);
}

.select-arrow svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.select-shell.is-open .select-arrow {
    transform: rotate(180deg);
    color: var(--brand-dark);
}

/* 菜单挂在 body 上、固定定位，避开面板的裁剪和层叠上下文 */
.select-menu {
    position: fixed;
    z-index: 120;
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 20px);
    overflow: hidden;
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--float);
    outline: none;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
}

/* 先量高度定好位置，再让它出现，避免开屏瞬间的位移 */
.select-menu.is-ready {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity .16s var(--ease-out), transform .2s var(--ease-spring);
}

.select-search {
    flex: 0 0 auto;
    border-bottom: 2px solid var(--mist-soft);
    padding: 10px;
    background: var(--card-soft);
}

.select-search input {
    min-height: 38px;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
}

.select-options {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 6px;
}

.select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: 12px;
    padding: 10px 12px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}

.select-option > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-option.is-active {
    background: var(--mist-soft);
}

.select-option.is-selected {
    background: var(--brand-light);
    color: var(--brand-dark);
    font-weight: 800;
}

.select-option.is-selected.is-active {
    background: #c9f8a4;
}

.select-check {
    display: none;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

.select-option.is-selected .select-check {
    display: inline-flex;
}

.select-check svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.select-empty {
    padding: 18px 12px;
    color: var(--ink-faint);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

textarea {
    min-height: 116px;
    resize: vertical;
    line-height: 1.6;
}

label {
    display: grid;
    gap: 8px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}

/* ---------- 表格 ---------- */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 820px;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 2px solid var(--mist-soft);
    text-align: left;
    vertical-align: top;
    font-size: 13px;
    font-weight: 600;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card-soft);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}

th:first-child { border-top-left-radius: var(--radius); }
th:last-child { border-top-right-radius: var(--radius); }

tbody tr {
    transition: background-color var(--speed) ease;
}

tbody tr:hover {
    background: var(--card-soft);
}

tbody tr:last-child td {
    border-bottom: 0;
}

td small,
.brand small,
.metric small,
.section-head p,
.mini-row small {
    display: block;
    margin-top: 5px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
}

code {
    display: inline-block;
    max-width: 100%;
    border: 2px solid var(--mist-soft);
    border-radius: 10px;
    padding: 2px 8px;
    background: var(--card-soft);
    color: var(--ink-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    word-break: break-word;
}

/* ---------- 登录 / 初始化 ---------- */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(470px, 100%);
    display: grid;
    gap: 22px;
    padding: 34px;
    border: 2px solid var(--mist);
    border-radius: 28px;
    background: var(--card);
    box-shadow: var(--float);
    animation: panelDrop .5s var(--ease-spring) both;
}

.auth-brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.auth-brand strong {
    font-size: 15px;
    font-weight: 900;
}

.auth-panel h1 {
    margin: 0 0 10px;
    font-size: 30px;
    line-height: 1.2;
}

.stack {
    display: grid;
    gap: 16px;
}

.stack button[type="submit"] {
    margin-top: 4px;
    min-height: 50px;
    font-size: 15px;
}

.eyebrow {
    margin: 0 0 10px;
    display: inline-block;
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.muted {
    color: var(--ink-soft);
    font-weight: 600;
    line-height: 1.7;
}

/* ---------- 提示条 ---------- */

.form-message,
.toast {
    min-height: 22px;
    color: var(--ink-soft);
    font-weight: 700;
}

.toast {
    min-width: min(320px, 100%);
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    padding: 11px 16px;
    background: var(--card);
    box-shadow: var(--drop);
    display: flex;
    gap: 10px;
    align-items: center;
    animation: toastIn .4s var(--ease-spring) both;
}

.toast[hidden] {
    display: none;
}

.toast.is-ok {
    border-color: var(--brand);
    background: var(--brand-light);
    color: var(--brand-dark);
}

.toast.is-warn {
    border-color: var(--coral);
    background: var(--coral-light);
    color: var(--coral-dark);
}

.toast-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-pill);
    background: currentColor;
    animation: pulseDot 1.6s ease-in-out infinite;
}

/* ---------- 加载态 ---------- */

.busy-layer {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: start center;
    padding-top: 24px;
    pointer-events: none;
}

.busy-layer[hidden] {
    display: none;
}

.busy-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    border: 2px solid var(--mist);
    border-radius: var(--radius-pill);
    padding: 0 20px;
    background: var(--card);
    box-shadow: var(--float);
    color: var(--ink);
    font-weight: 800;
    animation: toastIn .34s var(--ease-spring) both;
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: var(--radius-pill);
    border: 3px solid var(--brand-light);
    border-top-color: var(--brand);
    animation: spin .7s linear infinite;
}

/* 骨架屏：首屏数据未到位时先占好版面，避免布局跳动。
   用整块明暗呼吸，不用扫光渐变。 */
.skeleton {
    border-radius: 12px;
    background: var(--mist-soft);
    animation: skeletonPulse 1.3s ease-in-out infinite;
}

.skeleton-row {
    height: 18px;
    margin: 12px 0;
}

.skeleton-card {
    height: 116px;
}

/* ---------- 模态框 ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(60, 60, 60, .42);
    backdrop-filter: blur(6px);
    animation: fadeIn .2s ease both;
}

.confirm-dialog {
    width: min(430px, 100%);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    border: 2px solid var(--mist);
    border-radius: 24px;
    padding: 24px;
    background: var(--card);
    box-shadow: var(--float);
    animation: modalIn .38s var(--ease-spring) both;
}

.confirm-dialog h2 {
    margin: 0 0 8px;
    font-size: 19px;
}

.confirm-dialog p {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 600;
    line-height: 1.7;
}

.confirm-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 2px solid var(--coral);
    border-radius: var(--radius);
    background: var(--coral-light);
    color: var(--coral);
    animation: wobble .6s var(--ease-spring) both;
}

.confirm-mark .btn-icon,
.confirm-mark svg {
    width: 22px;
    height: 22px;
}

.dialog-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.certificate-backdrop {
    place-items: start center;
    overflow-y: auto;
}

.certificate-dialog {
    width: min(1040px, 100%);
    max-height: calc(100vh - 40px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 18px;
    border: 2px solid var(--mist);
    border-radius: 24px;
    padding: 22px;
    background: var(--card);
    box-shadow: var(--float);
    animation: modalIn .38s var(--ease-spring) both;
}

.certificate-dialog-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 2px solid var(--mist-soft);
    padding-bottom: 16px;
}

.certificate-dialog-head h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.certificate-dialog-head p,
.certificate-dialog-head small,
.certificate-file-head p {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 600;
    line-height: 1.6;
}

.certificate-file-list {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    overflow-y: auto;
    padding-right: 4px;
}

.certificate-file {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(190px, 1fr);
    gap: 12px;
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    padding: 14px;
    background: var(--card-soft);
}

.certificate-file-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.certificate-file-head h3 {
    margin: 0 0 5px;
    font-size: 15px;
}

.certificate-file-head code {
    margin-top: 8px;
}

.certificate-file textarea {
    min-height: 190px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 500;
    white-space: pre;
    word-break: normal;
    overflow: auto;
    resize: vertical;
}

/* ---------- 主框架 ---------- */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 262px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
}

.sidebar {
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 20px;
    padding: 18px;
    border: 2px solid var(--mist);
    border-radius: 24px;
    background: var(--card);
    box-shadow: var(--drop);
    animation: slideInLeft .45s var(--ease-out) both;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.brand strong {
    display: block;
    overflow: hidden;
    font-size: 14px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border: 2px solid var(--brand-dark);
    border-radius: var(--radius);
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    box-shadow: var(--drop);
    transition: transform .35s var(--ease-spring);
}

.brand-mark:hover {
    transform: rotate(-8deg) scale(1.06);
}

.nav {
    display: grid;
    align-content: start;
    gap: 6px;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 0 4px;
}

.nav button {
    justify-content: flex-start;
    min-height: 44px;
    border-color: transparent;
    padding: 0 14px;
    background: transparent;
    color: var(--ink-soft);
    box-shadow: none;
    font-weight: 800;
}

.nav button:hover:not(.active) {
    transform: none;
    background: var(--mist-soft);
    color: var(--ink);
    box-shadow: none;
}

.nav button:active:not(:disabled) {
    transform: scale(.97);
}

.nav button.active {
    border-color: var(--brand);
    background: var(--brand-light);
    color: var(--brand-dark);
    box-shadow: var(--drop-soft);
    animation: navPop .34s var(--ease-spring);
}

.nav button.active .btn-icon {
    animation: iconHop .4s var(--ease-spring);
}

.main {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 18px;
    padding-bottom: 20px;
}

.topbar {
    position: sticky;
    top: 20px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 2px solid var(--mist);
    border-radius: 24px;
    padding: 16px 22px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    box-shadow: var(--drop);
    animation: slideDown .45s var(--ease-out) both;
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
}

/* ---------- 视图切换 ---------- */

.view {
    display: none;
}

.view.active {
    display: grid;
    gap: 18px;
}

/* 面板依次落位，切换视图时有明确的先后顺序感 */
.view.active > * {
    animation: panelDrop .42s var(--ease-out) both;
}

.view.active > *:nth-child(1) { animation-delay: .02s; }
.view.active > *:nth-child(2) { animation-delay: .08s; }
.view.active > *:nth-child(3) { animation-delay: .14s; }
.view.active > *:nth-child(4) { animation-delay: .2s; }

.panel {
    display: grid;
    gap: 16px;
    border: 2px solid var(--mist);
    border-radius: 24px;
    padding: 22px;
    background: var(--card);
    box-shadow: var(--drop);
    transition: box-shadow var(--speed) var(--ease-out), transform var(--speed) var(--ease-out);
}

.panel:hover {
    transform: translateY(-2px);
    box-shadow: var(--drop-lift);
}

.panel h2 {
    margin: 0;
    font-size: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.section-head > div:first-child {
    min-width: 0;
}

.section-head p {
    margin: 0;
}

/* 「当前所在」的标记靠整圈实心描边。
   之前试过加粗左边框，24px 圆角会把它收成楔形，不如通栏描边干净。 */
.context-panel {
    border-color: var(--brand);
    background: var(--card);
}

.context-panel h2 {
    color: var(--brand-dark);
}

/* ---------- 总览指标 ---------- */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.metric {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 4px;
    border: 2px solid var(--mist);
    border-radius: 24px;
    padding: 20px;
    background: var(--card);
    box-shadow: var(--drop);
    transition: transform .28s var(--ease-spring), box-shadow var(--speed) var(--ease-out);
}

.metric:hover {
    transform: translateY(-4px);
    box-shadow: var(--drop-lift);
}

/* 顶部彩条，四张卡片按顺序换色 */
.metric::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 6px;
    background: var(--brand);
}

.metric:nth-child(2)::before { background: var(--sky); }
.metric:nth-child(3)::before { background: var(--amber); }
.metric:nth-child(4)::before { background: var(--grape); }
.metric:nth-child(5)::before { background: var(--coral); }

.metric span {
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 800;
}

.metric strong {
    font-size: 34px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

/* ---------- 表单与工具栏 ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    align-items: end;
}

.form-grid .wide {
    grid-column: span 2;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.toolbar.compact {
    justify-content: flex-end;
}

/* 让工具栏作为一个整体占满标题行的剩余宽度，
   控件按需收缩，避免最后一个按钮被单独挤到下一行 */
.section-head .toolbar {
    flex: 1 1 340px;
}

.toolbar .select-shell,
.toolbar input {
    width: auto;
    flex: 1 1 150px;
    min-width: 120px;
    max-width: 260px;
}

.toolbar button {
    flex: 0 0 auto;
}

.toolbar #recordKeyword {
    flex: 1 1 180px;
}

.table-wrap {
    overflow: auto;
    max-width: 100%;
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    background: var(--card);
}

.actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
}

/* 操作列不折行，列表过宽时由 .table-wrap 横向滚动 */
td:last-child {
    white-space: nowrap;
}

.actions button {
    min-height: 36px;
    padding: 0 12px;
    font-size: 12px;
}

/* ---------- 标记 ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 2px solid var(--mist);
    border-radius: var(--radius-pill);
    padding: 3px 12px;
    background: var(--card-soft);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge.ok {
    border-color: var(--brand);
    background: var(--brand-light);
    color: var(--brand-dark);
}

.badge.warn {
    border-color: var(--amber);
    background: var(--amber-light);
    color: #8a6d00;
}

.badge.off {
    border-color: var(--mist);
    background: var(--mist-soft);
    color: var(--ink-faint);
}

.record-type {
    display: inline-block;
    min-width: 54px;
    border: 2px solid var(--sky);
    border-radius: 10px;
    padding: 2px 8px;
    background: var(--sky-light);
    color: #0b78ad;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.json-lines {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.6;
}

/* ---------- 快捷入口 ---------- */

.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.quick-action {
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    min-height: 78px;
    border-color: var(--mist);
    padding: 14px 16px;
    background: var(--card);
    color: var(--ink);
    text-align: left;
}

.quick-action:hover:not(:disabled) {
    border-color: var(--brand);
    background: var(--brand-light);
    color: var(--brand-dark);
}

.quick-action .btn-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--brand-light);
    color: var(--brand-dark);
    transition: transform .32s var(--ease-spring), background-color var(--speed) ease;
}

.quick-action:hover .btn-icon {
    transform: rotate(-8deg) scale(1.08);
    background: var(--card);
}

.quick-action .btn-icon svg {
    width: 21px;
    height: 21px;
}

.quick-action span:not(.btn-icon) {
    display: grid;
    gap: 3px;
    overflow: visible;
    white-space: normal;
}

.quick-action strong {
    font-size: 14px;
    font-weight: 900;
}

.quick-action small {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
}

.quick-action:hover small {
    color: var(--brand-dark);
}

.mini-list {
    display: grid;
    gap: 10px;
}

.mini-row {
    justify-content: space-between;
    min-height: 60px;
    border-color: var(--mist);
    padding: 12px 16px;
    background: var(--card);
    color: var(--ink);
    text-align: left;
}

.mini-row:hover:not(:disabled) {
    border-color: var(--brand);
    background: var(--brand-light);
}

.mini-row span:not(.btn-icon) {
    display: grid;
    gap: 2px;
    overflow: visible;
    white-space: normal;
}

.mini-row strong {
    font-size: 14px;
    font-weight: 900;
}

.empty-state,
.empty-row td {
    padding: 34px 16px;
    color: var(--ink-faint);
    font-weight: 700;
    text-align: center;
}

/* ---------- API 密钥 ---------- */

.scope-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}

/* 复选框做成可点的卡片，勾选状态一眼可见 */
.scope-chip {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--card);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: border-color var(--speed) ease, background-color var(--speed) ease, transform var(--speed) var(--ease-out);
}

.scope-chip:hover {
    border-color: #d3d3d3;
    transform: translateY(-2px);
}

.scope-chip:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-light);
}

.scope-chip input {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    min-height: 0;
    margin: 1px 0 0;
    accent-color: var(--brand);
    cursor: pointer;
}

.scope-chip small {
    display: block;
    margin-top: 3px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
}

.scope-chip code {
    border: 0;
    padding: 0;
    background: none;
    color: inherit;
    font-size: 12px;
    font-weight: 800;
}

.scope-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.scope-tags .badge {
    font-size: 11px;
    padding: 2px 9px;
}

/* 一次性明文令牌 */
.token-reveal {
    display: grid;
    gap: 14px;
    border: 2px dashed var(--brand);
    border-radius: var(--radius);
    padding: 18px;
    background: var(--brand-light);
    animation: modalIn .42s var(--ease-spring) both;
}

.token-reveal h3 {
    margin: 0;
    font-size: 15px;
    color: var(--brand-dark);
}

.token-value {
    display: block;
    width: 100%;
    border: 2px solid var(--brand);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--card);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    font-weight: 700;
    word-break: break-all;
}

.hint-list {
    margin: 0;
    padding-left: 20px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.9;
}

.code-block {
    margin: 0;
    overflow-x: auto;
    border: 2px solid var(--mist);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--card-soft);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.75;
    white-space: pre;
}

/* ---------- 关键帧 ---------- */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes panelDrop {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-14px) scale(.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-18px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes rowIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes navPop {
    0% { transform: scale(.94); }
    60% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@keyframes iconHop {
    0% { transform: translateY(0); }
    45% { transform: translateY(-5px) rotate(-8deg); }
    100% { transform: translateY(0); }
}

@keyframes wobble {
    0% { transform: rotate(0); }
    25% { transform: rotate(-9deg); }
    55% { transform: rotate(7deg); }
    100% { transform: rotate(0); }
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: .6; }
}

@keyframes skeletonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}

/* 新增的表格行逐条浮现，只对前若干行生效，长列表不拖慢渲染 */
tbody tr.row-in {
    animation: rowIn .34s var(--ease-out) both;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .sidebar {
        position: static;
        height: auto;
        grid-template-rows: auto auto auto;
    }

    .nav {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        overflow: visible;
    }

    .topbar {
        position: static;
    }

    .form-grid .wide {
        grid-column: span 1;
    }
}

@media (max-width: 760px) {
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    table {
        min-width: 0;
    }

    thead {
        display: none;
    }

    tbody tr {
        border-bottom: 2px solid var(--mist);
        padding: 12px 4px;
    }

    tbody tr:last-child {
        border-bottom: 0;
    }

    /* 标签独占一行放在值上方。
       单元格里常有「主值 + 若干 small」多个子节点，用两列网格会把它们
       轮流甩进标签列，只有单列才排得稳。 */
    td {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
        border-bottom: 0;
        padding: 7px 10px;
        white-space: normal;
    }

    td::before {
        content: attr(data-label);
        color: var(--ink-soft);
        font-size: 11px;
        font-weight: 900;
        letter-spacing: .02em;
        text-transform: uppercase;
    }

    td small {
        margin-top: 0;
    }

    td[colspan] {
        display: block;
    }

    td[colspan]::before {
        display: none;
    }

    .actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .actions button {
        width: 100%;
    }

    .toolbar.compact {
        justify-content: stretch;
    }

    .toolbar .select-shell,
    .toolbar input,
    .toolbar button {
        flex: 1 1 150px;
        min-width: 0;
        max-width: none;
    }

    .certificate-backdrop {
        padding: 10px;
    }

    .certificate-dialog {
        max-height: calc(100vh - 20px);
        padding: 16px;
    }

    .certificate-dialog-head,
    .certificate-file-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .certificate-dialog-head button,
    .certificate-file-head button {
        width: 100%;
    }

    .certificate-file-list {
        grid-template-columns: 1fr;
    }

    .confirm-dialog {
        grid-template-columns: 1fr;
    }

    .auth-panel {
        padding: 24px;
    }
}

@media (max-width: 460px) {
    .app-shell {
        padding: 10px;
    }

    .auth-shell {
        padding: 14px;
    }

    .auth-panel h1 {
        font-size: 25px;
    }

    .metric strong {
        font-size: 29px;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .actions {
        grid-template-columns: 1fr;
    }
}

/* 尊重系统的「减少动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }

    button:hover:not(:disabled),
    .panel:hover,
    .metric:hover {
        transform: none;
    }
}
