:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #e8efff;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #15803d;
    --success-soft: #dcfce7;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --bg: #f4f6fb;
    --card: #ffffff;
    --sidebar: #111c33;
    --sidebar-hover: #1b2a4a;
    --radius: 10px;
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

button {
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

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

.btn-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
}

.btn-ghost {
    border-color: rgba(255, 255, 255, 0.28);
    background: transparent;
    color: #e5ecff;
}

.btn-ghost:hover {
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
    border-color: #fecaca;
    background: #fff;
    color: var(--danger);
}

.btn-danger:hover {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 13px;
    border-radius: 6px;
}

.link-btn {
    padding: 4px 6px;
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.link-btn.danger {
    color: var(--danger);
}

.icon-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-light);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.icon-btn:hover {
    background: #f1f5f9;
    color: var(--text);
}

/* ==================== 登录页 ==================== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 18% 22%, #1e3a8a 0%, #111c33 45%, #0b1220 100%);
    position: relative;
    overflow: hidden;
}

.login-body::before,
.login-body::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.18);
    filter: blur(2px);
}

.login-body::before {
    width: 420px;
    height: 420px;
    top: -140px;
    right: -120px;
}

.login-body::after {
    width: 320px;
    height: 320px;
    bottom: -120px;
    left: -90px;
    background: rgba(37, 99, 235, 0.14);
}

.login-card {
    position: relative;
    z-index: 1;
    width: 400px;
    max-width: calc(100vw - 40px);
    padding: 40px 36px 32px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(2, 8, 23, 0.45);
}

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

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.login-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.login-subtitle {
    margin: 4px 0 26px;
    color: var(--text-light);
    font-size: 13px;
}

.login-form .field {
    margin-bottom: 16px;
}

.login-error {
    min-height: 20px;
    margin: 0 0 10px;
    color: var(--danger);
    font-size: 13px;
}

.login-submit {
    width: 100%;
    padding: 11px 16px;
    font-size: 15px;
}

.login-foot {
    margin-top: 22px;
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
}

/* ==================== 后台框架 ==================== */
.admin-body {
    min-height: 100vh;
    background: var(--bg);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 24px;
    background: var(--sidebar);
    color: #e5ecff;
    box-shadow: 0 2px 10px rgba(2, 8, 23, 0.25);
}

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

.brand-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: #cbd7f5;
}

.topbar-user .user-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.35);
    color: #fff;
    font-size: 13px;
}

.layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 208px;
    flex: 0 0 208px;
    padding: 18px 12px;
    background: #16213a;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #b7c4e2;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.18s ease;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.95), rgba(37, 99, 235, 0.65));
    color: #fff;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

.sidebar-foot {
    padding: 12px 14px 0;
    color: #5b6c8f;
    font-size: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.content {
    flex: 1;
    min-width: 0;
    padding: 22px 24px 32px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.panel-card {
    background: var(--card);
    border: 1px solid #eef2f7;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.panel-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.panel-desc {
    margin: 6px 0 0;
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.6;
}

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

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box input {
    width: 280px;
    max-width: 60vw;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ==================== 表格 ==================== */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #eef2f7;
    border-radius: 8px;
}

.data-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    padding: 11px 12px;
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    word-break: break-all;
}

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

.data-table tbody tr:hover {
    background: #f9fbff;
}

.cell-actions {
    white-space: nowrap;
}

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

.cell-mono {
    font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
    font-size: 12.5px;
}

.empty-cell {
    padding: 40px 12px !important;
    text-align: center;
    color: #94a3b8;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
}

.badge-ok {
    background: var(--success-soft);
    color: var(--success);
}

.badge-off {
    background: #f1f5f9;
    color: #64748b;
}

.badge-admin {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-operator {
    background: #f1f5f9;
    color: #64748b;
}

/* ==================== 分页 ==================== */
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    min-height: 32px;
}

.pager-info {
    color: var(--text-light);
    font-size: 13px;
    margin-right: 4px;
}

/* ==================== 模态框 ==================== */
.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.5);
}

.modal-mask[hidden] {
    display: none;
}

.modal {
    width: 480px;
    max-width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(2, 8, 23, 0.35);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 18px 20px 4px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px 18px;
}

/* ==================== 表单 ==================== */
.field {
    display: block;
    margin-bottom: 16px;
}

.field > span {
    display: block;
    margin-bottom: 6px;
    color: #374151;
    font-size: 13px;
}

.field > span em {
    color: var(--danger);
    font-style: normal;
    margin-left: 2px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.field textarea {
    resize: vertical;
    min-height: 72px;
}

/* ==================== 提示 ==================== */
.toast-container {
    position: fixed;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    min-width: 200px;
    max-width: 420px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.toast-info {
    background: #1e293b;
    color: #f8fafc;
}

.toast-success {
    background: #14532d;
    color: #f0fdf4;
}

.toast-error {
    background: #7f1d1d;
    color: #fef2f2;
}

.toast-out {
    opacity: 0;
}

/* ==================== 响应式 ==================== */
@media (max-width: 900px) {
    .sidebar {
        width: 68px;
        flex: 0 0 68px;
        padding: 14px 8px;
    }

    .nav-item {
        justify-content: center;
        padding: 12px 0;
        font-size: 0;
    }

    .nav-item svg {
        width: 18px;
        height: 18px;
        flex: 0 0 18px;
    }

    .sidebar-foot {
        display: none;
    }

    .content {
        padding: 16px 14px 26px;
    }

    .search-box input {
        width: 200px;
    }
}
