:root {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #64748b;
    --border: #e2e8f0;
    --brand: #2563eb;
    --danger: #dc2626;
    --ok: #16a34a;
    --warn: #d97706;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; flex: none;
    background: #0f172a; color: #cbd5e1;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.side-brand {
    padding: 20px; font-size: 18px; font-weight: 700; color: #fff; letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.side-brand span { color: var(--brand); font-size: 13px; margin-left: 4px; }
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 20px; color: #cbd5e1; font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.sidebar nav a.active { background: rgba(37, 99, 235, .18); color: #fff; border-left-color: var(--brand); }
.side-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; flex-direction: column; gap: 6px; }
.side-foot a { color: #94a3b8; font-size: 13px; }

.main { flex: 1; min-width: 0; padding: 0 24px 40px; }
.main > .topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 64px; margin-bottom: 18px;
}
.main > .topbar h2 { font-size: 18px; }
.user { color: var(--muted); font-size: 13px; }

/* 面板 */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { font-size: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 24px; }

/* 表单 */
label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
label input[type="text"], label input[type="password"], label select, label textarea,
table input[type="text"], .inline-add input[type="text"] {
    display: block; width: 100%; margin-top: 6px;
    padding: 9px 11px;
    border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text); font-size: 14px; outline: none;
}
label input:focus, label select:focus, label textarea:focus, table input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.req { color: var(--danger); }
.muted { color: var(--muted); font-size: 12px; font-weight: 400; }
.center { text-align: center; }
.switch-line { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.switch-line input { width: 16px; height: 16px; }

.btn {
    display: inline-block; padding: 8px 14px; border-radius: 8px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    cursor: pointer; font-size: 13px; text-align: center;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; color: var(--danger); }
.btn.mini { padding: 4px 8px; font-size: 12px; }
.btn.block { width: 100%; display: block; }
.ops { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* 提示条 */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.table th, .table td {
    padding: 10px 10px; border-bottom: 1px solid var(--border);
    text-align: left; vertical-align: middle; font-size: 13px;
}
.table th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.table tbody tr:hover { background: #f8fafc; }
.group-title {
    display: flex; align-items: baseline; gap: 10px;
    margin: 16px 0 6px; font-size: 14px; font-weight: 700;
}
.group-title em { color: var(--muted); font-weight: 400; font-size: 12px; font-style: normal; }
.row-off { background: #fafafa; color: var(--muted); }
.row-off strong { color: var(--muted); }
.handle { cursor: grab; color: #cbd5e1; user-select: none; text-align: center; }
.handle:active { cursor: grabbing; }
.sort-row.dragging { opacity: .45; }
.drop-target { box-shadow: inset 0 2px 0 var(--brand); }
.drop-after { box-shadow: inset 0 -2px 0 var(--brand); }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge-on { background: #ecfdf5; color: #047857; }
.badge-off { background: #f3f4f6; color: #6b7280; }
.ell { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-preview { margin-top: 8px; }
.icon-preview img { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); }
.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter input[type="text"], .filter select {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13px;
}
.filter input[type="text"] { min-width: 220px; }
.inline-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-add input[type="text"] { max-width: 260px; }
.table select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }

/* 保存状态提示 */
.toast {
    position: fixed; right: 22px; bottom: 22px; z-index: 99;
    background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px;
    font-size: 13px; opacity: 0; transform: translateY(10px);
    transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* 登录页 */
.login-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #38bdf8);
    padding: 20px;
}
.login-card {
    width: 100%; max-width: 380px;
    background: #fff; border-radius: 14px; padding: 30px 28px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
}
.login-head { text-align: center; margin-bottom: 20px; }
.login-head .logo {
    width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 12px;
    background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700;
}
.login-head h1 { font-size: 18px; }
.login-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.login-card label { margin-bottom: 16px; }
.login-tip { color: var(--muted); font-size: 12px; text-align: center; margin: 14px 0 6px; }
.back-home { display: block; text-align: center; font-size: 13px; }

@media (max-width: 860px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; }
    .sidebar nav { display: flex; flex-wrap: wrap; padding: 8px; }
    .sidebar nav a { padding: 8px 12px; border-left: none; border-bottom: 2px solid transparent; }
    .sidebar nav a.active { border-left: none; border-bottom-color: var(--brand); }
    .side-foot { flex-direction: row; padding: 8px 14px; }
    .side-brand { border-bottom: none; padding: 14px; }
    .main { padding: 0 14px 30px; }
    .ell { max-width: 160px; }
}
