/* =====================================================
   量化交易系统 - 公共样式 (深色主题)
   ===================================================== */

/* ---------- CSS 变量 ---------- */
:root {
    --bg-page: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2330;
    --bg-input: #0d1117;
    --bg-sidebar: #010409;
    --border: #30363d;
    --border-light: #21262d;

    --green: #00ff08;
    --green-dim: rgba(0, 255, 8, 0.12);
    --red: #ff0000;
    --red-dim: rgba(255, 0, 0, 0.12);
    --yellow: #f0b429;
    --yellow-dim: rgba(240, 180, 41, 0.12);
    --blue: #58a6ff;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --sidebar-width: 220px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

    /* ---------- 兼容 admin 端旧变量名 ---------- */
    --color-primary: var(--green);
    --color-success: var(--green);
    --color-danger: var(--red);
    --color-danger-soft: var(--red-dim);
    --color-warning: var(--yellow);
    --color-info: var(--blue);
    --bg-tertiary: #0d1117;
    --bg-hover: var(--bg-card-hover);
    --border-muted: var(--border-light);
}

/* ---------- Reset ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

ul {
    list-style: none;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* =====================================================
   登录页布局
   ===================================================== */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 20% 20%, rgba(0, 255, 8, 0.06), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(255, 0, 0, 0.05), transparent 40%),
        var(--bg-page);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.auth-header {
    text-align: center;
    padding: 32px 32px 16px;
}

.auth-header .logo {
    font-size: 30px;
    color: var(--green);
    margin-bottom: 8px;
}

.auth-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

/* ---------- 标签切换 ---------- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin: 0 32px;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    user-select: none;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--green);
    border-bottom-color: var(--green);
}

/* =====================================================
   通用布局（侧边栏 + 主内容）
   ===================================================== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green), #00b32d);
    color: #001a00;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    line-height: 1.2;
}

.sidebar-brand .brand-text strong {
    display: block;
    font-size: 15px;
    color: var(--text-primary);
}

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

.sidebar-user {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--green);
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user .user-meta {
    overflow: hidden;
}

.sidebar-user .user-meta .uname {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-meta .urole {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 2px;
    transition: all 0.18s;
    border: 1px solid transparent;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(0, 255, 8, 0.25);
}

.nav-item.logout {
    color: var(--red);
}

.nav-item.logout:hover {
    background: var(--red-dim);
}

.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- 主内容区 ---------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
}

.topbar h2 {
    font-size: 17px;
    font-weight: 700;
}

.topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 13px;
}

.topbar .live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.content {
    padding: 24px;
    flex: 1;
}

/* =====================================================
   卡片
   ===================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i {
    color: var(--green);
}

.card-header .header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.card-body {
    padding: 20px;
}

/* ---------- 统计卡片网格 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
}

.stat-card .stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
    font-family: var(--mono);
    line-height: 1.2;
}

.stat-card .stat-foot {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.icon-green { background: var(--green-dim); color: var(--green); }
.icon-red   { background: var(--red-dim); color: var(--red); }
.icon-yellow{ background: var(--yellow-dim); color: var(--yellow); }
.icon-blue  { background: rgba(88,166,255,0.12); color: var(--blue); }

.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* =====================================================
   按钮
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-card-hover);
    border-color: #484f58;
}

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

.btn-primary {
    background: var(--green);
    color: #001a00;
    border-color: var(--green);
}

.btn-primary:hover {
    background: #00cc06;
    border-color: #00cc06;
}

.btn-danger {
    background: var(--red);
    color: #1a0000;
    border-color: var(--red);
}

.btn-danger:hover {
    background: #cc0000;
    border-color: #cc0000;
}

.btn-ghost {
    background: transparent;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 12px 22px;
    font-size: 15px;
}

/* =====================================================
   开关按钮 (Toggle)
   ===================================================== */
.toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #30363d;
    border-radius: 28px;
    transition: 0.25s;
}

.toggle .slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background: #8b949e;
    border-radius: 50%;
    transition: 0.25s;
}

.toggle input:checked + .slider {
    background: var(--green);
}

.toggle input:checked + .slider:before {
    transform: translateX(24px);
    background: #001a00;
}

.toggle input:disabled + .slider {
    opacity: 0.45;
    cursor: not-allowed;
}

.toggle-lg {
    width: 64px;
    height: 32px;
}

.toggle-lg .slider:before {
    height: 24px;
    width: 24px;
}

.toggle-lg input:checked + .slider:before {
    transform: translateX(32px);
}

/* =====================================================
   表单
   ===================================================== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group label .req {
    color: var(--red);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-dim);
}

.input::placeholder {
    color: var(--text-muted);
}

.input-group {
    position: relative;
}

.input-group .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group .input {
    padding-left: 40px;
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-footer {
    margin-top: 4px;
}

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

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

table.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg-page);
}

table.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

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

table.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.td-mono {
    font-family: var(--mono);
}

/* =====================================================
   徽章
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.badge-green  { background: var(--green-dim); color: var(--green); }
.badge-red    { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-blue   { background: rgba(88,166,255,0.12); color: var(--blue); }
.badge-gray   { background: rgba(139,148,158,0.15); color: var(--text-secondary); }

.badge-vip {
    background: linear-gradient(135deg, #f0b429, #ff8c00);
    color: #1a1000;
}

/* =====================================================
   持仓 / 信号 卡片
   ===================================================== */
.position-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.position-item {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.position-item.long  { border-left-color: var(--green); }
.position-item.short { border-left-color: var(--red); }

.position-item .pos-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.position-item .pos-symbol {
    font-weight: 700;
    font-family: var(--mono);
    font-size: 14px;
}

.position-item .pos-rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    font-size: 12px;
}

.position-item .pos-rows .k {
    color: var(--text-muted);
}

.position-item .pos-rows .v {
    font-family: var(--mono);
    text-align: right;
}

/* ---------- 信号面板 ---------- */
.signal-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.signal-box {
    text-align: center;
    padding: 18px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-page);
    border: 1px solid var(--border);
}

.signal-box .sig-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.signal-box .sig-value {
    font-size: 18px;
    font-weight: 700;
}

.signal-box .sig-icon {
    font-size: 22px;
    margin-bottom: 6px;
    display: block;
}

.signal-box.bullish { border-color: rgba(0,255,8,0.4); background: var(--green-dim); }
.signal-box.bearish { border-color: rgba(255,0,0,0.4); background: var(--red-dim); }
.signal-box.choppy  { border-color: rgba(240,180,41,0.4); background: var(--yellow-dim); }

/* ---------- 日志列表 ---------- */
.log-list {
    max-height: 460px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    gap: 12px;
    padding: 11px 4px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.log-item:last-child {
    border-bottom: none;
}

.log-item .log-time {
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 12px;
    white-space: nowrap;
    width: 150px;
    flex-shrink: 0;
}

.log-item .log-tag {
    flex-shrink: 0;
    width: 86px;
}

.log-item .log-msg {
    flex: 1;
    color: var(--text-primary);
    word-break: break-word;
}

/* ---------- 策略卡片 ---------- */
.strategy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.strategy-card {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    transition: border-color 0.2s, transform 0.2s;
}

.strategy-card:hover {
    border-color: #484f58;
    transform: translateY(-2px);
}

.strategy-card .strat-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.strategy-card .strat-name {
    font-size: 15px;
    font-weight: 700;
}

.strategy-card .strat-desc {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 12px;
    min-height: 38px;
}

.strategy-card .strat-params {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.strategy-card .param-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-secondary);
}

/* =====================================================
   工具类
   ===================================================== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mono { font-family: var(--mono); }
.text-center { text-align: center; }
.fs-12 { font-size: 12px; }
.fs-16 { font-size: 16px; }
.fw-700 { font-weight: 700; }

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

.empty-state p {
    font-size: 13px;
}

/* ---------- 加载骨架 ---------- */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

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

.loading-overlay {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading-overlay .spinner {
    margin-bottom: 12px;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =====================================================
   Toast 提示
   ===================================================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    min-width: 260px;
    animation: toastIn 0.25s ease;
}

@keyframes toastIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.out {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastOut {
    to { transform: translateX(120%); opacity: 0; }
}

.toast i {
    font-size: 16px;
    margin-top: 1px;
}

.toast .toast-body {
    flex: 1;
    font-size: 13px;
}

.toast .toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}

.toast-success { border-left-color: var(--green); }
.toast-success i { color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-error i { color: var(--red); }
.toast-warning { border-left-color: var(--yellow); }
.toast-warning i { color: var(--yellow); }
.toast-info    { border-left-color: var(--blue); }
.toast-info i { color: var(--blue); }

/* =====================================================
   提示横幅
   ===================================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.alert-warning {
    background: var(--yellow-dim);
    border-color: rgba(240,180,41,0.4);
    color: var(--yellow);
}

.alert-info {
    background: rgba(88,166,255,0.10);
    border-color: rgba(88,166,255,0.35);
    color: var(--blue);
}

.alert-danger {
    background: var(--red-dim);
    border-color: rgba(255,0,0,0.35);
    color: var(--red);
}

/* =====================================================
   信息行 (用户中心)
   ===================================================== */
.info-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-light);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .info-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.info-row .info-value {
    font-weight: 600;
    font-family: var(--mono);
}

/* ---------- 遮罩 (移动端侧边栏) ---------- */
.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

.backdrop.show {
    display: block;
}

/* =====================================================
   响应式
   ===================================================== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .topbar .menu-toggle {
        display: block;
    }

    .content {
        padding: 16px;
    }

    .signal-row {
        grid-template-columns: 1fr;
    }

    .field-row {
        grid-template-columns: 1fr;
    }
}

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

    .auth-card {
        max-width: 100%;
    }

    .topbar h2 {
        font-size: 15px;
    }

    table.data-table thead th,
    table.data-table tbody td {
        padding: 10px 12px;
    }
}

/* =====================================================
   Admin 端兼容层（BEM 命名 + 布局组件）
   供 /admin 页面与 admin.js 使用，不影响用户端样式
   ===================================================== */

/* ---------- 布局 ---------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.page-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ---------- 侧边栏 (admin) ---------- */
.sidebar__logo {
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
}

.sidebar__logo i {
    color: var(--green);
    font-size: 18px;
}

.sidebar__logo .brand-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--green-dim);
    color: var(--green);
}

.sidebar__nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar__nav-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 10px 6px;
}

.sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 2px;
    border: 1px solid transparent;
    transition: all 0.18s;
}

.sidebar__nav a i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar__nav a:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar__nav a.active {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(0, 255, 8, 0.25);
}

.sidebar__footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

.sidebar__footer a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 14px;
}

.sidebar__footer a:hover {
    background: var(--red-dim);
    text-decoration: none;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

.sidebar-backdrop.is-open {
    display: block;
}

/* ---------- 顶栏 (admin) ---------- */
.topbar__title {
    font-size: 17px;
    font-weight: 700;
}

.topbar__subtitle {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 1px;
}

.topbar__right {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 13px;
}

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

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--green);
    font-weight: 700;
    flex-shrink: 0;
}

/* ---------- 卡片 (BEM) ---------- */
.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.card__header h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card__header h3 i {
    color: var(--green);
}

.card__body {
    padding: 20px;
}

.card__body--flush {
    padding: 0;
}

/* ---------- 统计卡片 (BEM) ---------- */
.stat-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--green-dim);
    color: var(--green);
    margin-bottom: 12px;
}

.stat-card__label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 6px;
}

.stat-card__value {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--mono);
    line-height: 1.2;
}

.stat-card__sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.stat-card--success .stat-card__icon { background: var(--green-dim); color: var(--green); }
.stat-card--warning .stat-card__icon { background: var(--yellow-dim); color: var(--yellow); }
.stat-card--danger  .stat-card__icon { background: var(--red-dim); color: var(--red); }

/* ---------- 描述列表 ---------- */
.desc-list__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.desc-list__item:last-child {
    border-bottom: none;
}

.desc-list__item label {
    color: var(--text-secondary);
}

.desc-list__item span {
    font-weight: 600;
    font-family: var(--mono);
    text-align: right;
}

/* ---------- 按钮 (BEM) ---------- */
.btn--primary {
    background: var(--green);
    color: #001a00;
    border-color: var(--green);
}

.btn--primary:hover {
    background: #00cc06;
    border-color: #00cc06;
}

.btn--success {
    background: var(--green);
    color: #001a00;
    border-color: var(--green);
}

.btn--success:hover {
    background: #00cc06;
    border-color: #00cc06;
}

.btn--warning {
    background: var(--yellow);
    color: #1a1000;
    border-color: var(--yellow);
}

.btn--warning:hover {
    background: #d99f1a;
    border-color: #d99f1a;
}

.btn--danger {
    background: var(--red);
    color: #1a0000;
    border-color: var(--red);
}

.btn--danger:hover {
    background: #cc0000;
    border-color: #cc0000;
}

.btn--ghost {
    background: transparent;
}

.btn--sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn--block {
    width: 100%;
}

.btn--lg {
    padding: 12px 22px;
    font-size: 15px;
}

/* ---------- 表单 (BEM) ---------- */
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.form-control:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-dim);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.input-group .form-control {
    padding-left: 40px;
}

.form-control.with-toggle {
    padding-right: 38px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--green);
    cursor: pointer;
}

.field-error {
    font-size: 12px;
    color: var(--red);
    margin-top: 5px;
    display: none;
}

.field-error.is-show {
    display: block;
}

.pwd-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    background: none;
    border: none;
}

.pwd-toggle:hover {
    color: var(--text-primary);
}

/* ---------- 过滤栏 ---------- */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 160px;
    flex: 1;
}

/* ---------- 徽章 (BEM) ---------- */
.badge--success { background: var(--green-dim); color: var(--green); }
.badge--warning { background: var(--yellow-dim); color: var(--yellow); }
.badge--danger  { background: var(--red-dim); color: var(--red); }
.badge--info    { background: rgba(88, 166, 255, 0.12); color: var(--blue); }
.badge--neutral { background: rgba(139, 148, 158, 0.15); color: var(--text-secondary); }

.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* ---------- 表格辅助 ---------- */
.cell-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ---------- 文本/间距工具 ---------- */
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.font-mono { font-family: var(--mono); }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }

/* ---------- 登录页 (admin) ---------- */
.auth-card__logo {
    text-align: center;
    padding: 32px 32px 16px;
}

.auth-card__logo h1 {
    font-size: 22px;
    font-weight: 700;
    margin-top: 8px;
}

.auth-card__logo p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 4px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--green), #00b32d);
    color: #001a00;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.auth-card > form {
    padding: 0 32px 24px;
}

.auth-card .login-alert {
    margin: 0 32px 18px;
}

.auth-card__footer {
    padding: 16px 32px 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ---------- Toast (BEM) ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast > span {
    flex: 1;
    font-size: 13px;
}

.toast--success { border-left-color: var(--green); }
.toast--success i { color: var(--green); }
.toast--error   { border-left-color: var(--red); }
.toast--error i { color: var(--red); }
.toast--warning { border-left-color: var(--yellow); }
.toast--warning i { color: var(--yellow); }
.toast--info    { border-left-color: var(--blue); }
.toast--info i { color: var(--blue); }

/* ---------- 加载/状态 ---------- */
.spinner--lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

.state-box {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.state-box i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

.state-box p {
    font-size: 13px;
}

.state-box .state-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---------- 分页 ---------- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 4px 4px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination__info {
    font-size: 12px;
    color: var(--text-muted);
}

.pagination__controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination__controls button {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}

.pagination__controls button:hover:not(:disabled) {
    background: var(--bg-card-hover);
}

.pagination__controls button.active {
    background: var(--green);
    color: #001a00;
    border-color: var(--green);
}

.pagination__controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---------- 模态框 ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 9998;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal-overlay.is-open {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: auto;
}

.modal--lg { max-width: 760px; }
.modal--sm { max-width: 420px; }

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

.modal__header h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
}

.modal__close:hover {
    color: var(--text-primary);
}

.modal__body {
    padding: 20px;
}

.modal__footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- 图表容器 ---------- */
.chart-container {
    width: 100%;
    height: 280px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.chart-container canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------- Admin 响应式补充 ---------- */
@media (max-width: 900px) {
    .sidebar.is-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }
}
