/* ==========================================================================
   PDS 管理后台样式
   设计语言：浅色底 + 白色圆角卡片 + 蓝色主色 + 图标块
   ========================================================================== */

/* ---------------------------------------------------------------- 设计令牌 */
:root {
    --bg: #f4f6f9;
    --bg-soft: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f8;

    --line: #e8ecf2;
    --line-2: #dde3ec;
    --line-3: #cfd7e3;

    --text: #18222f;
    --text-2: #3d4a5c;
    --muted: #7c8899;

    --primary: #2f6fed;
    --primary-hover: #1f5ed8;
    --primary-soft: #eef4ff;
    --primary-line: #c9dcff;

    --ok: #16a34a;
    --ok-soft: #e9f8ef;
    --ok-line: #c9ecda;

    --warn: #d97706;
    --warn-soft: #fdf5e6;
    --warn-line: #f6e3c2;

    --bad: #dc2626;
    --bad-soft: #fdeceb;
    --bad-line: #f7d5d2;

    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 9px;

    --shadow-1: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .045);
    --shadow-2: 0 2px 4px rgba(16, 24, 40, .05), 0 14px 32px rgba(16, 24, 40, .09);
    --ring: 0 0 0 4px rgba(47, 111, 237, .13);

    --sidebar-w: 246px;
    --ease: cubic-bezier(.22, .8, .32, 1);
}

html[data-theme="dark"] {
    --bg: #0f151d;
    --bg-soft: #131b25;
    --surface: #161f2b;
    --surface-2: #1b2533;
    --surface-3: #202b3b;

    --line: #22303f;
    --line-2: #2b3a4c;
    --line-3: #3a4b60;

    --text: #e8eef7;
    --text-2: #b9c6d6;
    --muted: #7d8ea3;

    --primary: #5b8dff;
    --primary-hover: #7aa2ff;
    --primary-soft: #1b2a45;
    --primary-line: #2f4470;

    --ok: #34d399;
    --ok-soft: #122b23;
    --ok-line: #1d4c3c;

    --warn: #fbbf24;
    --warn-soft: #2b2413;
    --warn-line: #4a3d1c;

    --bad: #f87171;
    --bad-soft: #2d1a1c;
    --bad-line: #55282b;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .22);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, .34), 0 18px 40px rgba(0, 0, 0, .3);
    --ring: 0 0 0 4px rgba(91, 141, 255, .18);
}

/* ---------------------------------------------------------------- 动画 */
@keyframes pds-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@keyframes pds-pop {
    from { opacity: 0; transform: translateY(18px) scale(.985); }
    to   { opacity: 1; transform: none; }
}

@keyframes pds-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pds-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .34); }
    60%      { box-shadow: 0 0 0 5px rgba(22, 163, 74, 0); }
}

@keyframes pds-drift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50%      { transform: translate3d(14px, -18px, 0) scale(1.06); }
}

/* ---------------------------------------------------------------- 基础 */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
    font-size: 13.5px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; transition: color .16s ease; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

h1 {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 680;
    letter-spacing: -.01em;
}

h2 {
    margin: 0 0 10px;
    font-size: 14.5px;
    font-weight: 660;
    letter-spacing: -.005em;
}

p { margin: 0 0 10px; }

.mono {
    font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 12.2px;
    letter-spacing: -.01em;
}

.small { font-size: 12px; }

.hint {
    font-size: 12.2px;
    color: var(--muted);
    line-height: 1.7;
    margin: 0;
    font-weight: 400;
}

.inline { display: inline; }

/* ---------------------------------------------------------------- 布局 */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100vh;
    padding: 18px 12px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    animation: pds-fade .3s both;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 8px 14px;
    border-bottom: 1px solid var(--line);
}

.logo-mark {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(140deg, #6a9bff, var(--primary));
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    box-shadow: 0 6px 16px rgba(47, 111, 237, .3);
}

.logo-title { font-size: 13.5px; font-weight: 660; line-height: 1.35; }
.logo-sub { font-size: 11.5px; color: var(--muted); line-height: 1.35; }

.menu {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    overflow: auto;
    padding: 2px 0;
}

.menu-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-label {
    padding: 0 10px 6px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.menu-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 13.5px;
    transition: background .18s ease, color .18s ease, transform .18s var(--ease);
}

.menu-item svg { width: 16px; height: 16px; flex: 0 0 auto; opacity: .78; }

.menu-item:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    transform: translateX(2px);
}

.menu-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 620;
}

.menu-item.active svg { opacity: 1; }

.menu-item.active::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -12px;
    width: 3px;
    height: 17px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
    transform: translateY(-50%);
}


.sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 10px 2px;
    border-top: 1px solid var(--line);
}

.who {
    font-size: 12.5px;
    font-weight: 620;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.foot-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.main {
    min-width: 0;
    padding: 28px 32px 48px;
    max-width: 1240px;
    width: 100%;
}

.main > * { animation: pds-rise .44s var(--ease) both; }
.main > *:nth-child(2) { animation-delay: .04s; }
.main > *:nth-child(3) { animation-delay: .08s; }
.main > *:nth-child(4) { animation-delay: .12s; }
.main > *:nth-child(5) { animation-delay: .16s; }
.main > *:nth-child(n+6) { animation-delay: .2s; }

/* ---------------------------------------------------------------- 页头 */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.page-head h1 { margin: 0; }

.page-head .sub {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
}

/* ---------------------------------------------------------------- 状态胶囊 */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border: 1px solid var(--ok-line);
    border-radius: 999px;
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 12.2px;
    font-weight: 620;
    transition: transform .2s var(--ease);
}

.status-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: pds-pulse 2.6s infinite;
}

.status-pill.is-off {
    border-color: var(--warn-line);
    background: var(--warn-soft);
    color: var(--warn);
}

.status-pill.is-off .dot { animation: none; }

.status-pill.is-bad {
    border-color: var(--bad-line);
    background: var(--bad-soft);
    color: var(--bad);
}

/* ---------------------------------------------------------------- 卡片 */
.panel {
    margin-bottom: 16px;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    transition: box-shadow .22s ease, border-color .22s ease;
}

.panel:hover {
    border-color: var(--line-2);
    box-shadow: var(--shadow-2);
}

.panel > h2:first-child { margin-top: 0; }

.card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.card-head h2 { margin: 0; }

.card-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12.2px;
    line-height: 1.6;
}

.icon-tile {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--surface-3);
    color: var(--text-2);
}

.icon-tile.is-primary { background: var(--primary-soft); color: var(--primary); }
.icon-tile.is-ok { background: var(--ok-soft); color: var(--ok); }
.icon-tile.is-warn { background: var(--warn-soft); color: var(--warn); }
.icon-tile.is-bad { background: var(--bad-soft); color: var(--bad); }
.icon-tile svg { width: 18px; height: 18px; }

/* 概览统计卡 */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(186px, 1fr));
    gap: 12px;
    margin: 16px 0 22px;
}

.card {
    position: relative;
    overflow: hidden;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    transition: transform .22s var(--ease), box-shadow .22s ease, border-color .22s ease;
}

.card::after {
    content: "";
    position: absolute;
    inset: auto -20% -60% auto;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary-soft);
    opacity: 0;
    transition: opacity .25s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-line);
    box-shadow: var(--shadow-2);
}

.card:hover::after { opacity: .7; }

.card .label {
    position: relative;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    z-index: 1;
}

.card .value {
    position: relative;
    font-size: 25px;
    font-weight: 680;
    letter-spacing: -.02em;
    line-height: 1.2;
    z-index: 1;
}

.card-top {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 10px;
    z-index: 1;
}

.card-top .icon-tile {
    width: 30px;
    height: 30px;
    border-radius: 9px;
}

.card-top .icon-tile svg { width: 15px; height: 15px; }

.card-top .label { margin: 0; }

/* ---------------------------------------------------------------- 按钮 */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 17px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 620;
    line-height: 1.5;
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s ease, transform .12s ease, box-shadow .18s ease, color .18s ease;
    box-shadow: 0 1px 2px rgba(47, 111, 237, .18);
}

button:hover,
.btn:hover { background: var(--primary-hover); box-shadow: 0 4px 14px rgba(47, 111, 237, .26); }

button:active,
.btn:active { transform: scale(.982); }

button:focus-visible,
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

button:disabled,
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn.ghost,
button.ghost {
    border-color: var(--line-2);
    background: var(--surface);
    color: var(--text-2);
    box-shadow: var(--shadow-1);
}

.btn.ghost:hover,
button.ghost:hover {
    border-color: var(--line-3);
    background: var(--surface-2);
    color: var(--text);
    box-shadow: var(--shadow-1);
}

button.danger,
.btn.danger {
    background: var(--bad);
    box-shadow: 0 1px 2px rgba(220, 38, 38, .2);
}

button.danger:hover { background: #b91c1c; }

button[type="submit"] { margin-top: 4px; }

.icon-btn {
    padding: 5px 10px;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    box-shadow: none;
}

.icon-btn:hover {
    border-color: var(--line-3);
    background: var(--surface-2);
    color: var(--text-2);
    box-shadow: none;
}

.link-btn {
    padding: 5px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    box-shadow: none;
}

.link-btn:hover {
    background: var(--bad-soft);
    color: var(--bad);
    box-shadow: none;
}

/* ---------------------------------------------------------------- 表单 */
label {
    display: block;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 620;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.5;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

textarea { resize: vertical; min-height: 96px; }

input::placeholder,
textarea::placeholder { color: var(--muted); opacity: .75; }

input[type="text"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover { border-color: var(--line-3); }

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

input[type="checkbox"],
input[type="radio"] {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

input[type="file"] {
    width: 100%;
    padding: 9px 12px;
    border: 1px dashed var(--line-3);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease;
}

input[type="file"]:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* 拖拽上传区：input 铺满整块并透明化，点击与拖拽都落在它身上 */
.file-drop {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 16px;
    border: 1.5px dashed var(--line-3);
    border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s var(--ease);
}

.file-drop:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.file-drop:focus-within {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.file-drop > input[type="file"] {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    border-radius: inherit;
    background: none;
    opacity: 0;
    cursor: pointer;
}

.file-drop__icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--primary);
}

.file-drop__icon svg { width: 17px; height: 17px; }

.file-drop__main {
    font-size: 13px;
    font-weight: 620;
    color: var(--text-2);
}

.file-drop__name {
    flex: 1 1 100%;
    color: var(--muted);
    font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 11.6px;
    word-break: break-all;
}

.file-drop.is-drag {
    border-color: var(--primary);
    border-style: solid;
    background: var(--primary-soft);
    box-shadow: var(--ring);
    transform: scale(1.006);
}

.file-drop.has-file {
    border-style: solid;
    border-color: var(--ok-line);
    background: var(--ok-soft);
}

.file-drop.has-file .file-drop__icon {
    border-color: var(--ok-line);
    color: var(--ok);
}

.file-drop.has-file .file-drop__name {
    color: var(--ok);
    font-weight: 600;
}

.file-drop.is-invalid {
    border-color: var(--bad);
    background: var(--bad-soft);
    animation: pds-shake .38s ease;
}

@keyframes pds-shake {
    0%, 100% { transform: translateX(0); }
    22%      { transform: translateX(-4px); }
    55%      { transform: translateX(4px); }
    80%      { transform: translateX(-2px); }
}

/* 设置项：左标签 / 右控件 */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 4px;
}

.form-grid > div {
    display: grid;
    grid-template-columns: 178px minmax(0, 1fr);
    column-gap: 22px;
    align-items: start;
    padding: 15px 0;
    border-top: 1px dashed var(--line-2);
}

.form-grid > div:first-child { padding-top: 6px; border-top: none; }

.form-grid > div > * {
    grid-column: 2;
    min-width: 0;
}

.form-grid > div > label:first-child {
    grid-column: 1;
    grid-row: 1;
    padding-top: 9px;
    line-height: 1.5;
}

.form-grid > div > label:first-child .hint { font-weight: 400; }

.form-grid > div > .hint,
.form-grid > div > label.hint { margin-top: 7px; }

/* 整行只有一个可勾选项时，不要占左栏 */
.form-grid > div.check-row > label:first-child {
    grid-column: 2;
    grid-row: auto;
    padding-top: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

/* 提示条 */
details summary { color: var(--muted); font-size: 12.5px; }
details summary:hover { color: var(--text-2); }

/* ---------------------------------------------------------------- 设置页标签 */
.settings-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
    gap: 11px;
    margin: 16px 0 18px;
}

/* 日志中心有 5 个标签，宽屏排成一行，避免最后一张孤零零换行 */
@media (min-width: 1100px) {
    .settings-tabs.tabs-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.settings-tabs .tab {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    text-align: left;
    box-shadow: var(--shadow-1);
    transition: transform .2s var(--ease), box-shadow .2s ease, border-color .2s ease, background .2s ease;
}

.settings-tabs .tab:hover {
    transform: translateY(-2px);
    border-color: var(--primary-line);
    box-shadow: var(--shadow-2);
}

.settings-tabs .tab.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, .1), var(--shadow-1);
}

/* 日志中心的标签是普通链接（?tab=xxx），不需要 JS 也不会有下划线 */
.settings-tabs a.tab,
.settings-tabs a.tab:hover {
    text-decoration: none;
}

/* PHP 错误日志尾部：固定高度内滚动，避免一条长堆栈把页面撑开 */
.log-tail {
    margin: 0;
    padding: 12px 14px;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 11.5px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-all;
}

.settings-tabs .tab-ico {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text-2);
    transition: background .2s ease, color .2s ease;
}

.settings-tabs .tab.active .tab-ico { background: var(--primary); color: #fff; }
.settings-tabs .tab-ico svg { width: 17px; height: 17px; }

.settings-tabs .tab-txt { min-width: 0; }
.settings-tabs .tab-txt b { display: block; font-size: 13px; font-weight: 640; line-height: 1.45; }
.settings-tabs .tab-txt small { display: block; color: var(--muted); font-size: 11.2px; line-height: 1.5; }
.settings-tabs .tab.active .tab-txt small { color: var(--primary); opacity: .82; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: pds-rise .32s var(--ease) both; }

/* ---------------------------------------------------------------- 表格 */
table {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    font-size: 13px;
}

thead th {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11.2px;
    font-weight: 640;
    letter-spacing: .05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--text-2);
    vertical-align: middle;
}

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

tbody tr { transition: background .16s ease; }
tbody tr:hover { background: var(--surface-2); }

td.empty {
    padding: 30px 14px;
    color: var(--muted);
    text-align: center;
}

/* 表格里的操作按钮用紧凑尺寸 */
tbody td button,
tbody td .btn {
    padding: 5px 12px;
    font-size: 12px;
}

tbody td form { margin: 0; display: inline-block; }

/* 卡片「详情」按钮：只在手机端出现，桌面表格不需要 */
.card-toggle { display: none; }

/* 面板内的表格去掉外框，避免双层圆角 */
.panel table {
    border: none;
    border-radius: var(--radius);
    box-shadow: none;
}

/* ---------------------------------------------------------------- 标签 */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 620;
    line-height: 1.7;
    white-space: nowrap;
}

.tag-ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.tag-bad { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }
.tag-warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.tag-muted { border-color: var(--line-2); background: var(--surface-2); color: var(--muted); }

/* ---------------------------------------------------------------- 提示 */
.alert,
.notice-ok,
.notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0 0 14px;
    padding: 11px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
    animation: pds-rise .3s var(--ease) both;
}

.alert { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }
.notice-ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.notice { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }

/* ---------------------------------------------------------------- 筛选与分页 */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-1);
}

.filters label { font-size: 11.8px; }

/* 筛选条里的控件按内容宽度排列，不要撑满整行 */
.filters input,
.filters select {
    width: auto;
    min-width: 150px;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 14px;
    margin-top: 14px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    color: var(--muted);
    font-size: 12.5px;
}

.pager-info b { color: var(--text); font-weight: 640; }

.pager-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 33px;
    height: 33px;
    padding: 0 11px;
    border: 1px solid var(--line-2);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 620;
    text-decoration: none;
    transition: border-color .16s ease, background .16s ease, color .16s ease, transform .12s ease;
}

.pager-btn:hover {
    border-color: var(--primary-line);
    background: var(--primary-soft);
    color: var(--primary);
    text-decoration: none;
}

.pager-btn:active { transform: scale(.96); }

.pager-btn.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(47, 111, 237, .28);
}

.pager-btn.is-nav { padding: 0 13px; }

.pager-btn.is-disabled {
    opacity: .42;
    pointer-events: none;
    cursor: default;
}

.pager-gap {
    padding: 0 3px;
    color: var(--muted);
}

.pager-size {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12.5px;
}

.pager-size label { font-size: 12.5px; }

.pager-size select {
    width: auto;
    min-width: 72px;
    height: 33px;
    padding: 0 9px;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 620;
    color: var(--text-2);
}

.pager-size button {
    height: 33px;
    margin: 0;
    padding: 0 11px;
    font-size: 12.5px;
}

/* 访问日志「档案」列：显示标题，太长就截断，完整 uid 留给鼠标悬停 */
.archive-title {
    display: inline-block;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* ---------------------------------------------------------------- 代码块 */
.code-block {
    margin: 0;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: #0f172a;
    color: #cbd5e1;
    font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.75;
    overflow: auto;
    white-space: pre;
}

.code-block .k { color: #7dd3a0; }
.code-block .s { color: #e7c07b; }
.code-block .n { color: #93c5fd; }

/* ---------------------------------------------------------------- 登录页 */
.login-wrap {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    overflow: hidden;
    background: var(--bg);
}

.login-wrap::before,
.login-wrap::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
}

.login-wrap::before {
    top: -12%;
    left: -8%;
    width: 420px;
    height: 420px;
    background: rgba(47, 111, 237, .16);
    animation: pds-drift 18s ease-in-out infinite;
}

.login-wrap::after {
    right: -10%;
    bottom: -14%;
    width: 460px;
    height: 460px;
    background: rgba(106, 155, 255, .14);
    animation: pds-drift 22s ease-in-out infinite reverse;
}

.login-box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 392px;
    padding: 32px 30px 26px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 24px 60px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .05);
    animation: pds-pop .5s var(--ease) both;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 20px;
}

.login-brand .logo-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 13px; }

.login-brand h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 680;
}

.login-brand p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.login-box label { margin-bottom: 6px; }

.login-box input[type="text"],
.login-box input[type="password"] {
    margin-bottom: 15px;
    padding: 11px 13px;
    animation: pds-rise .42s var(--ease) both;
}

.login-box input[type="text"] { animation-delay: .06s; }
.login-box input[type="password"] { animation-delay: .12s; }

.login-box .hint { animation: pds-rise .42s var(--ease) .16s both; }

.login-box button[type="submit"] {
    width: 100%;
    margin-top: 6px;
    padding: 11px 16px;
    font-size: 13.5px;
    animation: pds-rise .42s var(--ease) .2s both;
}

.login-box .alert { animation: pds-rise .3s var(--ease) both, pds-fade .3s both; }

.login-foot {
    margin: 18px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11.5px;
    text-align: center;
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 980px) {
    .app { grid-template-columns: 1fr; }

    .sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        overflow: visible;
    }

    .menu-label { display: none; }

    .menu-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .menu-item.active::before { display: none; }

    .logo { border-bottom: none; padding-bottom: 4px; }

    .main { padding: 20px 16px 40px; }
}

@media (max-width: 720px) {
    .form-grid > div {
        grid-template-columns: 1fr;
        row-gap: 7px;
        padding: 14px 0;
    }

    .form-grid > div > label:first-child {
        grid-column: 1;
        padding-top: 0;
    }

    .form-grid > div > * { grid-column: 1; }

    .page-head { align-items: flex-start; }
}

/* ---------------------------------------------------------------- 手机适配 */
/* 顶部条是手机专用的；桌面上完全不存在，不影响原布局 */
.mobile-bar { display: none; }

@media (max-width: 720px) {
    html { -webkit-text-size-adjust: 100%; }

    /* ---------- 顶栏 + 抽屉式侧栏 ---------- */
    .mobile-bar {
        position: sticky;
        top: 0;
        z-index: 70;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 9px 12px;
        border-bottom: 1px solid var(--line);
        background: var(--surface);
    }

    .mobile-bar .nav-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        padding: 0;
        border: 1px solid var(--line-2);
        border-radius: 10px;
        background: var(--surface-2);
        color: var(--text);
    }

    .mobile-bar .nav-toggle svg { width: 18px; height: 18px; }

    .mobile-bar .mobile-title {
        min-width: 0;
        overflow: hidden;
        color: var(--text);
        font-size: 14.5px;
        font-weight: 640;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* 手机上改成块布局，侧栏脱离文档流做抽屉 */
    .app { display: block; }

    /* 层级：抽屉(80) > 遮罩(75) > 顶栏(70)。
       抽屉打开时必须盖住顶栏，否则标题会压在菜单上 */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 80;
        width: min(82vw, 304px);
        height: 100vh;
        height: 100dvh;
        padding-bottom: 20px;
        overflow-y: auto;
        border-right: 1px solid var(--line);
        border-bottom: none;
        transform: translateX(-102%);
        transition: transform .26s var(--ease);
    }

    body.nav-open { overflow: hidden; }

    body.nav-open .sidebar {
        transform: none;
        box-shadow: var(--shadow-2);
    }

    .nav-scrim {
        position: fixed;
        inset: 0;
        z-index: 75;
        background: rgba(15, 23, 42, .48);
    }

    .nav-scrim[hidden] { display: none; }

    /* 980 那一档把菜单摊成了横向 chip，手机上必须恢复竖排，否则一行一个挤成一片 */
    .menu,
    .menu-group {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 2px;
    }

    .menu-label { display: block; }

    .menu-item { padding: 11px 12px; }

    /* ---------- 内容区 ---------- */
    .main { padding: 14px 12px 40px; }

    .page-head { margin-bottom: 14px; gap: 10px; }
    .page-head h1 { font-size: 19px; }
    .page-head .sub { font-size: 12px; }

    .panel { padding: 14px; }
    .card-head { flex-wrap: wrap; gap: 10px; }

    /* ---------- 概览统计卡：一排横向滑动，不再占三行 ---------- */
    .cards {
        display: flex;
        gap: 10px;
        margin: 12px 0 16px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .cards::-webkit-scrollbar { display: none; }

    .cards .card {
        flex: 0 0 auto;
        width: 152px;
        padding: 11px 13px;
        border-radius: var(--radius);
        scroll-snap-align: start;
    }

    .cards .card:hover { transform: none; }

    .cards .card .card-top {
        align-items: flex-start;
        gap: 7px;
        margin-bottom: 6px;
    }

    .cards .card .card-top .icon-tile {
        width: 24px;
        height: 24px;
        border-radius: 8px;
    }

    .cards .card .card-top .icon-tile svg { width: 13px; height: 13px; }

    .cards .card .label { margin: 0; font-size: 11px; line-height: 1.35; }

    .cards .card .value { font-size: 20px; }

    /* ---------- 表格：改成卡片，一行一张 ---------- */
    /* 兜底：万一 JS 没跑到，至少是横滑，不会像以前那样一个字一行 */
    .main table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 有表头的数据表：thead 隐藏，每行变成一张卡片，列名写在左侧 */
    .main table.is-stacked {
        display: block;
        overflow: visible;
        border: none;
        background: transparent;
        box-shadow: none;
    }

    .main table.is-stacked thead { display: none; }

    .main table.is-stacked tbody { display: block; }

    .main table.is-stacked tbody tr {
        display: block;
        margin-bottom: 8px;
        padding: 2px 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-1);
    }

    .main table.is-stacked tbody tr:last-child { margin-bottom: 0; }
    .main table.is-stacked tbody tr:hover { background: var(--surface); }

    /* 标签绝对定位在左侧，值放在左内边距里正常流式排列：
       这样一格里有多个元素（文件名 + <br> + 哈希、多个按钮）也不会串到别的行 */
    .main table.is-stacked tbody td {
        display: block;
        position: relative;
        padding: 6px 0 6px 84px;
        border-bottom: 1px dashed var(--line-2);
        font-size: 12.5px;
        line-height: 1.55;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .main table.is-stacked tbody td:last-child { border-bottom: none; }

    .main table.is-stacked tbody td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 6px;
        width: 74px;
        color: var(--muted);
        font-size: 11px;
        font-weight: 620;
        line-height: 1.76;
        white-space: normal;
    }

    /* 表头为空的列（复选框、纯操作列）不占标签位，直接铺满一行 */
    .main table.is-stacked tbody td[data-label=""] { padding-left: 0; }
    .main table.is-stacked tbody td[data-label=""]::before { content: none; }

    .main table.is-stacked tbody td.empty {
        padding: 20px 0;
        border-bottom: none;
        text-align: center;
    }

    .main table.is-stacked tbody td.empty::before { content: none; }

    .main table.is-stacked tbody td .btn,
    .main table.is-stacked tbody td button { margin: 0 6px 0 0; }

    /* 卡片要能定位右上角的状态标签 */
    .main table.is-stacked tbody tr { position: relative; }

    /* 折叠态：标题独占一行（去掉列名），其余字段收起来，卡片是一条长方形 */
    .main table.is-stacked tbody td.cell-primary {
        padding: 8px 0 2px;
        border-bottom: none;
        color: var(--text);
        font-size: 13.5px;
        font-weight: 640;
    }

    /* 有状态标签时给标题右侧留出位置，免得长标题压到标签 */
    .main table.is-stacked tbody tr.has-status td.cell-primary { padding-right: 78px; }

    /* 状态列：收起时浮在卡片右上角，标签和「详情」按钮并排 */
    .main table.is-stacked tbody td.cell-status {
        position: absolute;
        top: 7px;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
        width: auto;
        max-width: 66%;
        padding: 0;
        border: none;
    }

    .main table.is-stacked tbody td.cell-status::before { content: none; }

    .main table.is-stacked tbody td.cell-status .tag {
        margin: 0;
        white-space: normal;
    }

    /* 标题行右侧要同时放下标签和按钮 */
    .main table.is-stacked tbody tr.has-status-toggle td.cell-primary { padding-right: 132px; }

    /* 展开后标题也回到「列名 + 值」的常规行 */
    .main table.is-stacked tbody tr.is-open td.cell-primary {
        padding: 8px 0 6px 84px;
        font-size: 12.5px;
        font-weight: 500;
    }

    .main table.is-stacked tbody tr.is-open td.cell-primary::before {
        content: attr(data-label);
    }

    /* 展开后状态回到正常的一行，带列名 */
    .main table.is-stacked tbody tr.is-open td.cell-status {
        position: relative;
        justify-content: flex-start;
        max-width: none;
        padding: 6px 0 6px 84px;
        border-bottom: 1px dashed var(--line-2);
    }

    .main table.is-stacked tbody tr.is-open td.cell-status::before {
        content: attr(data-label);
    }

    /* 操作按钮跟标题左对齐，不再占一个列名位 */
    .main table.is-stacked tbody td.cell-actions { padding-left: 0; }
    .main table.is-stacked tbody td.cell-actions::before { content: none; }

    .main table.is-stacked tbody td.cell-primary::before { content: none; }

    /* 既没有状态列也没有操作列时，「详情」靠标题行右侧 */
    .main table.is-stacked tbody td.cell-toggle-host .card-toggle {
        float: right;
        margin-top: -1px;
    }

    .main table.is-stacked tbody td.cell-extra { display: none; }

    .main table.is-stacked tbody tr.is-open td.cell-extra { display: block; }

    .main table.is-stacked tbody tr.is-open td.cell-primary {
        padding-bottom: 6px;
        border-bottom: 1px dashed var(--line-2);
    }

    .main .card-toggle {
        display: inline-flex;
        padding: 5px 12px;
        border: 1px solid var(--line-2);
        border-radius: var(--radius-sm);
        background: var(--surface-2);
        color: var(--text-2);
        font-size: 12px;
        font-weight: 620;
        box-shadow: none;
    }

    /* 键值型表单表格（th + td，没有 thead）：标签在上、控件在下 */
    .main table:not(.is-stacked) tbody,
    .main table:not(.is-stacked) tr,
    .main table:not(.is-stacked) th,
    .main table:not(.is-stacked) td {
        display: block;
        width: auto;
    }

    .main table:not(.is-stacked) th {
        padding: 12px 14px 4px;
        border-bottom: none;
        background: transparent;
        color: var(--muted);
        font-size: 11.5px;
        font-weight: 620;
        letter-spacing: 0;
        text-align: left;
        text-transform: none;
        white-space: normal;
    }

    .main table:not(.is-stacked) td {
        padding: 0 14px 12px;
        border-bottom: 1px dashed var(--line-2);
    }

    .main table:not(.is-stacked) tr:last-child td { border-bottom: none; }

    /* 页面里写死了 360px 之类的宽度，手机上要让位 */
    .main table:not(.is-stacked) input,
    .main table:not(.is-stacked) select,
    .main table:not(.is-stacked) textarea {
        width: 100% !important;
        max-width: 100%;
    }

    /* ---------- 筛选 / 分页 / 表单 ---------- */
    .filters {
        padding: 12px;
        gap: 8px;
    }

    /* 行内 style 里写了 min-width，这里必须 !important 才压得住 */
    .filters input,
    .filters select {
        width: 100%;
        min-width: 0 !important;
    }

    .filters button,
    .filters .btn { width: 100%; }

    .pager {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .pager-links { flex-wrap: wrap; }

    .pager-size { justify-content: space-between; }

    /* 设置页标签：手机上不再竖排一堆大卡片，改成一行横向滑动的胶囊条 */
    .settings-tabs {
        display: flex;
        grid-template-columns: none;
        gap: 8px;
        margin: 12px 0 14px;
        padding-bottom: 4px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .settings-tabs::-webkit-scrollbar { display: none; }

    .settings-tabs .tab {
        flex: 0 0 auto;
        align-items: center;
        gap: 7px;
        padding: 8px 13px 8px 9px;
        border-radius: 999px;
        scroll-snap-align: start;
        box-shadow: none;
    }

    .settings-tabs .tab:hover {
        transform: none;
        box-shadow: none;
    }

    .settings-tabs .tab.active { box-shadow: 0 0 0 2px rgba(47, 111, 237, .12); }

    .settings-tabs .tab-ico {
        width: 24px;
        height: 24px;
        border-radius: 8px;
    }

    .settings-tabs .tab-ico svg { width: 14px; height: 14px; }

    .settings-tabs .tab-txt b {
        font-size: 12.5px;
        line-height: 1.3;
        white-space: nowrap;
    }

    /* 胶囊里放不下副标题，先收起来；文字说明在面板里都有 */
    .settings-tabs .tab-txt small { display: none; }

    .form-actions { justify-content: stretch; }
    .form-actions button { width: 100%; }

    .notice-ok,
    .alert,
    .notice { padding: 10px 12px; font-size: 12.5px; }

    /* 长哈希、日志片段不撑破屏幕 */
    .main pre,
    .main code,
    .main .mono {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    /* ---------- 登录页 ---------- */
    .login-wrap { padding: 18px 14px; }
    .login-box { width: 100%; max-width: 380px; }
}

/* 极小屏：按钮和标签再收一档 */
@media (max-width: 400px) {
    .main { padding: 12px 10px 36px; }

    .page-head h1 { font-size: 18px; }

    .settings-tabs .tab { padding: 7px 11px 7px 8px; }
    .settings-tabs .tab-txt b { font-size: 12px; }

    .tag { font-size: 11px; padding: 2px 7px; }
}

/* ---------------------------------------------------------------- 日志 IP 位置 */
.geo-label {
    display: block;
    margin-top: 2px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    line-height: 1.25;
    color: var(--muted, #8b93a1);
    white-space: nowrap;
}

.geo-label:empty {
    display: none;
}

/* ---------------------------------------------------------------- 无障碍 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
