:root {
    --sidebar: #2f4358;
    --sidebar-dark: #26384a;
    --surface: #ffffff;
    --surface-alt: #f5f7fa;
    --border: #d9dde3;
    --text: #1f2933;
    --muted: #667085;
    --primary: #2f9e44;
    --primary-dark: #258638;
    --danger: #e74c3c;
    --danger-dark: #cf3f31;
    --warning-bg: #fff4ce;
    --warning-border: #f0b429;
    --focus: #4c9ffe;
    --radius: 6px;
    font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--surface-alt);
}

[hidden] {
    display: none !important;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #26384a, #3a556d);
}

.login-panel {
    width: min(400px, 100%);
    display: grid;
    gap: 18px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(17, 24, 39, 0.18);
}

.login-panel h1 {
    margin: 0 0 4px;
    font-size: 24px;
    text-align: center;
}

.field {
    display: grid;
    gap: 7px;
}

.field.grow {
    flex: 1 1 260px;
}

.field span {
    color: var(--muted);
    font-size: 14px;
}

.field input,
.field select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.field input:focus,
.field select:focus {
    outline: 2px solid rgba(76, 159, 254, 0.22);
    border-color: var(--focus);
}

.button {
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: #eef2f6;
    color: var(--text);
    white-space: nowrap;
}

.button.primary {
    background: var(--primary);
    color: #fff;
}

.button.primary:hover {
    background: var(--primary-dark);
}

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

.button.danger:hover {
    background: var(--danger-dark);
}

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

.button.ghost:hover {
    background: #f3f6f9;
}

.form-error {
    min-height: 18px;
    margin: 0;
    color: var(--danger);
    font-size: 14px;
    text-align: center;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: #fff;
}

.brand {
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--sidebar-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: #f7fafc;
    color: var(--sidebar-dark);
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.nav-list {
    padding: 10px 0;
}

.nav-item {
    min-height: 54px;
    display: flex;
    align-items: center;
    padding: 0 18px;
    color: #fff;
    text-decoration: none;
    border-left: 4px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--primary);
    color: #d8f5df;
}

.logout-button {
    margin: auto 12px 14px;
    min-height: 42px;
    border: 0;
    border-radius: var(--radius);
    background: var(--danger);
    color: #fff;
}

.main-area {
    min-width: 0;
}

.topbar {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 30px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

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

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 14px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #98a2b3;
}

.status-dot.online {
    background: var(--primary);
}

.status-dot.offline {
    background: #98a2b3;
}

.content {
    padding: 30px;
}

.page-section {
    display: grid;
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 20px;
}

.stat-card {
    min-height: 120px;
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat-card span {
    color: #475467;
    font-weight: 700;
}

.stat-card strong {
    color: var(--primary);
    font-size: 36px;
    line-height: 1;
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 20px;
}

.panel {
    padding: 24px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

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

.panel-header {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-header h2 {
    margin: 0;
}

.below-panel-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: -12px;
}

.toolbar,
.inline-form {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.stack-form {
    display: grid;
    gap: 14px;
    max-width: 420px;
}

.status-line {
    max-width: 520px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0 18px;
}

.status-line strong {
    color: var(--primary);
}

.hint {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 14px;
}

.muted-count {
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

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

.list-empty {
    padding: 24px;
    color: var(--muted);
    text-align: center;
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.compact-list {
    max-height: 520px;
    overflow: auto;
}

.alert-item {
    align-items: flex-start;
    background: var(--warning-bg);
    border-color: #f4d98f;
    border-left: 4px solid var(--warning-border);
}

.alert-lines {
    display: grid;
    gap: 8px;
    width: 100%;
    min-width: 0;
    color: #1f2937;
    line-height: 1.55;
}

.alert-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    word-break: break-word;
}

.alert-label {
    flex: 0 0 auto;
    font-weight: 800;
    color: #111827;
    white-space: nowrap;
}

.alert-keyword-line {
    color: #b42318;
    font-weight: 700;
}

.alert-keyword-line .alert-label {
    color: #b42318;
}

.alert-text-line {
    white-space: pre-wrap;
}

.inline-remark {
    color: #d92d20;
    font-weight: 500;
}

.item-title {
    margin: 0 0 6px;
    font-weight: 800;
}

.item-meta {
    color: var(--muted);
    font-size: 13px;
}

.item-text {
    margin: 8px 0 0;
    color: #344054;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: #475467;
    font-size: 12px;
}

.badge.online {
    background: #dcfce7;
    color: #166534;
}

.badge.offline {
    background: #f2f4f7;
    color: #667085;
}

.pager {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
    color: var(--muted);
}

.toast {
    position: fixed;
    z-index: 30;
    right: 24px;
    top: 20px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 14px;
    display: none;
    border-radius: var(--radius);
    background: #1f2933;
    color: #fff;
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.2);
}

.toast.show {
    display: block;
}

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

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

    .sidebar {
        position: static;
        height: auto;
    }

    .nav-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .logout-button {
        margin-top: 8px;
    }

    .stats-grid,
    .two-column {
        grid-template-columns: 1fr;
    }

    .topbar,
    .content {
        padding-left: 18px;
        padding-right: 18px;
    }
}

@media (max-width: 640px) {
    .nav-list {
        grid-template-columns: 1fr;
    }

    .topbar {
        height: auto;
        min-height: 68px;
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .panel,
    .login-panel {
        padding: 18px;
    }

    .list-item,
    .status-line {
        align-items: stretch;
        flex-direction: column;
    }

    .button {
        width: 100%;
    }
}
