/* 旋芯小游戏诊断台：深色运维风，纯 CSS 实现布局与图表，不依赖任何外部资源 */
:root {
    --bg: #080d16;
    --bg-glow: #0d1c2e;
    --panel: #0f1826;
    --panel-2: #131f31;
    --border: rgba(148, 178, 214, 0.14);
    --border-strong: rgba(148, 178, 214, 0.26);
    --text: #e8effa;
    --muted: #8ba0bd;
    --accent: #2ee6a8;
    --accent-dim: rgba(46, 230, 168, 0.14);
    --danger: #ff6b7d;
    --danger-dim: rgba(255, 107, 125, 0.14);
    --warn: #ffc05a;
    --warn-dim: rgba(255, 192, 90, 0.14);
    --info: #63b3ff;
    --info-dim: rgba(99, 179, 255, 0.14);
    --radius: 14px;
    --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Segoe UI Variable", system-ui, -apple-system, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
}

* {
    box-sizing: border-box;
}

/* 组件自身设置了 display，需要显式覆盖浏览器的 hidden 默认样式 */
[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: 0;
    background: none;
}

h1,
h2,
h3,
p {
    margin: 0;
}

.muted {
    color: var(--muted);
}

/* ===== 通用控件 ===== */
button.primary,
button.ghost {
    border-radius: 10px;
    padding: 8px 16px;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
    white-space: nowrap;
}

button.primary {
    background: linear-gradient(180deg, #35f0b4, #1fc98f);
    color: #062819;
    font-weight: 600;
}

button.primary:hover {
    filter: brightness(1.06);
}

button.primary:active {
    transform: translateY(1px);
}

button.ghost {
    border: 1px solid var(--border-strong);
    color: var(--text);
    background: rgba(255, 255, 255, 0.02);
}

button.ghost:hover {
    background: rgba(255, 255, 255, 0.06);
}

button.small {
    padding: 5px 12px;
    font-size: 12px;
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

input,
select {
    background: #0b1522;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    outline: none;
    min-width: 0;
}

input:focus,
select:focus {
    border-color: rgba(46, 230, 168, 0.5);
    box-shadow: 0 0 0 3px rgba(46, 230, 168, 0.1);
}

input::placeholder {
    color: #5b708c;
}

select option {
    background: #0f1826;
}

/* ===== 登录 ===== */
.login-screen {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(700px 420px at 50% -10%, rgba(46, 230, 168, 0.16), transparent 70%),
        radial-gradient(600px 400px at 90% 110%, rgba(99, 179, 255, 0.12), transparent 70%),
        var(--bg);
}

.login-card {
    width: min(380px, 100%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 32px 28px;
    background: linear-gradient(180deg, rgba(23, 36, 54, 0.92), rgba(12, 20, 32, 0.94));
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}

.login-card h1 {
    font-size: 20px;
    letter-spacing: 0.5px;
}

.login-card p {
    font-size: 13px;
}

.login-error {
    min-height: 18px;
    color: var(--danger);
    font-size: 12px;
}

.logo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #2ee6a8, #0f8f6a);
    color: #04231a;
    font-weight: 700;
    font-size: 22px;
    box-shadow: 0 8px 24px rgba(46, 230, 168, 0.25);
}

.logo.small {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 17px;
    box-shadow: none;
}

/* ===== 控制台骨架 ===== */
.console {
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 22px 16px;
    background: linear-gradient(180deg, #0c1624, #080d16);
    border-right: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.brand-text strong {
    font-size: 14px;
}

.brand-text small {
    color: var(--muted);
    font-size: 11px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--muted);
    text-align: left;
    transition: background 0.16s ease, color 0.16s ease;
}

.nav-item svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
    opacity: 0.85;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 12px;
    color: var(--muted);
}

.sidebar-foot .ghost {
    margin-left: auto;
    padding: 3px 8px;
    font-size: 11px;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(46, 230, 168, 0.16);
}

.dot.bad {
    background: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-dim);
}

.main {
    padding: 24px 28px 48px;
    max-width: 1440px;
    width: 100%;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.topbar h2 {
    font-size: 22px;
    letter-spacing: 0.4px;
}

.topbar p {
    margin-top: 2px;
    font-size: 12px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ===== 面板与卡片 ===== */
.view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    background: linear-gradient(180deg, rgba(20, 32, 49, 0.72), rgba(13, 21, 33, 0.72));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-head h3 {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.swatch {
    width: 9px;
    height: 9px;
    border-radius: 3px;
    display: inline-block;
}

.swatch.total {
    background: rgba(46, 230, 168, 0.7);
}

.swatch.error {
    background: var(--danger);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 16px 18px;
    background: linear-gradient(180deg, rgba(23, 36, 54, 0.75), rgba(12, 20, 32, 0.75));
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -30px;
    top: -40px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--accent-dim);
    filter: blur(12px);
}

.stat-card .label {
    color: var(--muted);
    font-size: 12px;
}

.stat-card .value {
    margin-top: 6px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
}

.stat-card .hint {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}

.stat-card.danger .value {
    color: var(--danger);
}

.stat-card.warn .value {
    color: var(--warn);
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

/* ===== 趋势柱状图 ===== */
.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 176px;
    padding-top: 8px;
}

.trend-col {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.trend-track {
    position: relative;
    flex: 1;
    width: 100%;
    max-width: 34px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(148, 178, 214, 0.05), transparent);
}

.trend-bar {
    width: 100%;
    border-radius: 7px 7px 4px 4px;
    background: linear-gradient(180deg, rgba(46, 230, 168, 0.85), rgba(46, 230, 168, 0.35));
    min-height: 0;
    transition: height 0.3s ease;
}

.trend-bar.error {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 0;
    background: linear-gradient(180deg, rgba(255, 107, 125, 0.9), rgba(255, 107, 125, 0.45));
    border-radius: 0 0 4px 4px;
}

.trend-label {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.trend-empty {
    width: 100%;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 48px 0;
}

/* ===== 排行与列表 ===== */
.rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.rank-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    font-size: 13px;
}

.rank-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.rank-bar {
    grid-column: 1 / -1;
    height: 4px;
    border-radius: 2px;
    background: rgba(148, 178, 214, 0.1);
    overflow: hidden;
}

.rank-bar i {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(46, 230, 168, 0.8), rgba(99, 179, 255, 0.7));
}

.empty {
    padding: 26px 0;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

/* ===== 表格 ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 940px;
}

th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--muted);
    padding: 0 12px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(148, 178, 214, 0.07);
    font-size: 13px;
    vertical-align: middle;
    white-space: nowrap;
}

tbody tr {
    cursor: pointer;
    transition: background 0.14s ease;
}

tbody tr:hover {
    background: rgba(46, 230, 168, 0.05);
}

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

.cell-strong {
    font-weight: 600;
}

.cell-muted {
    color: var(--muted);
}

.cell-time {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.6;
    background: rgba(148, 178, 214, 0.1);
    color: var(--muted);
    white-space: nowrap;
}

.tag.accent {
    background: var(--accent-dim);
    color: var(--accent);
}

.tag.danger {
    background: var(--danger-dim);
    color: var(--danger);
}

.tag.warn {
    background: var(--warn-dim);
    color: var(--warn);
}

.tag.info {
    background: var(--info-dim);
    color: var(--info);
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    font-size: 12px;
}

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

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 14px 16px;
}

.filters input#filter-keyword {
    flex: 1 1 200px;
    min-width: 160px;
}

.filters select {
    min-width: 104px;
}

.check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    padding: 0 2px;
}

.check input {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
}

/* ===== 详情抽屉 ===== */
.drawer-mask {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 13, 0.62);
    backdrop-filter: blur(2px);
    z-index: 40;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(620px, 94vw);
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: #0c1523;
    border-left: 1px solid var(--border-strong);
    box-shadow: -30px 0 60px rgba(0, 0, 0, 0.4);
    animation: slide-in 0.2s ease;
}

@keyframes slide-in {
    from {
        transform: translateX(24px);
        opacity: 0;
    }
}

.drawer-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.drawer-head h3 {
    font-size: 16px;
}

.drawer-head p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
    word-break: break-all;
}

.drawer-close {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
}

.drawer-close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.drawer-section h4 {
    margin: 0 0 10px;
    font-size: 12px;
    letter-spacing: 0.6px;
    color: var(--muted);
    text-transform: uppercase;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
}

.kv {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 10px;
    border-radius: 9px;
    background: rgba(148, 178, 214, 0.05);
    border: 1px solid rgba(148, 178, 214, 0.07);
    min-width: 0;
}

.kv span {
    font-size: 11px;
    color: var(--muted);
}

.kv strong {
    font-size: 12.5px;
    font-weight: 500;
    word-break: break-word;
}

.log-tools {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.log-tools input {
    flex: 1 1 150px;
    padding: 6px 10px;
    font-size: 12px;
}

.chip {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
}

.chip.active {
    border-color: rgba(46, 230, 168, 0.45);
    background: var(--accent-dim);
    color: var(--accent);
}

.log-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 46vh;
    overflow-y: auto;
    padding-right: 4px;
}

.log-row {
    display: grid;
    grid-template-columns: 74px 52px 1fr;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 8px;
    background: rgba(148, 178, 214, 0.04);
    border-left: 2px solid rgba(148, 178, 214, 0.2);
    font-size: 12px;
}

.log-row.level-warn {
    border-left-color: var(--warn);
}

.log-row.level-error,
.log-row.level-fatal {
    border-left-color: var(--danger);
    background: rgba(255, 107, 125, 0.06);
}

.log-time {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    padding-top: 1px;
}

.log-level {
    font-size: 10px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: 2px;
}

.log-row.level-warn .log-level {
    color: var(--warn);
}

.log-row.level-error .log-level,
.log-row.level-fatal .log-level {
    color: var(--danger);
}

.log-msg {
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cfdcef;
}

.log-msg mark {
    background: rgba(46, 230, 168, 0.28);
    color: var(--accent);
    border-radius: 3px;
    padding: 0 1px;
}

.log-tag {
    color: var(--info);
    margin-right: 4px;
    font-size: 11px;
}

.drawer-actions {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.drawer-actions .danger {
    margin-left: auto;
    border-color: rgba(255, 107, 125, 0.4);
    color: var(--danger);
}

.drawer-actions .danger:hover {
    background: var(--danger-dim);
}

/* ===== 轻提示 ===== */
.toast-wrap {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(23, 38, 57, 0.96);
    border: 1px solid rgba(46, 230, 168, 0.35);
    color: var(--text);
    font-size: 12.5px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    animation: toast-in 0.18s ease;
}

.toast.error {
    border-color: rgba(255, 107, 125, 0.45);
    color: #ffd9de;
}

@keyframes toast-in {
    from {
        transform: translateY(-6px);
        opacity: 0;
    }
}

/* ===== 小屏适配 ===== */
@media (max-width: 1080px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .console {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 14px;
        padding: 12px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .nav {
        flex-direction: row;
    }

    .sidebar-foot {
        margin-top: 0;
        margin-left: auto;
        border: 0;
        padding: 0;
    }

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

    .two-col {
        grid-template-columns: 1fr;
    }

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

    .brand-text small {
        display: none;
    }
}
