* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }

.layout { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar { width: 220px; background: #1e293b; color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; }
.logo { padding: 20px 16px; font-size: 17px; font-weight: bold; color: #fff; border-bottom: 1px solid #334155; }
.sidebar nav { flex: 1; padding: 12px 8px; }
.nav-item { display: block; padding: 11px 14px; color: #cbd5e1; text-decoration: none; border-radius: 8px; margin-bottom: 4px; transition: 0.15s; }
.nav-item:hover { background: #334155; color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; font-weight: bold; }
.nav-item .icon { margin-right: 8px; }
.sidebar-user { padding: 16px; border-top: 1px solid #334155; }
.user-name { font-size: 13px; margin-bottom: 10px; color: #94a3b8; }
.btn-logout { display: block; text-align: center; background: #475569; color: #fff; padding: 8px; border-radius: 6px; text-decoration: none; }
.btn-logout:hover { background: #dc2626; }

/* ===== 主内容区 ===== */
.content { flex: 1; margin-left: 220px; padding: 24px 32px; }
.page-title { margin-bottom: 20px; font-size: 20px; color: #1e293b; border-left: 4px solid #2563eb; padding-left: 12px; }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card .num { font-size: 28px; font-weight: bold; color: #2563eb; }
.stat-card.warn .num { color: #d97706; }
.stat-card.danger .num { color: #dc2626; }
.stat-card .label { color: #64748b; margin-top: 6px; }

/* 卡片与表格 */
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 20px; }
.card h3 { margin-bottom: 14px; font-size: 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e2e8f0; }
th { background: #f8fafc; color: #475569; font-weight: 600; font-size: 13px; }
tr:hover td { background: #f8fafc; }
.text-right { text-align: right; }

/* 标签 */
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.tag-in  { background: #dcfce7; color: #16a34a; }
.tag-out { background: #fee2e2; color: #dc2626; }
.tag-on  { background: #dcfce7; color: #16a34a; }
.tag-off { background: #f1f5f9; color: #64748b; }
.tag-low { background: #fef3c7; color: #d97706; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-item label { display: block; margin-bottom: 5px; color: #475569; font-size: 13px; }
.form-item input, .form-item select, .form-item textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px;
}
.form-item input:focus, .form-item select:focus { outline: none; border-color: #2563eb; }
.form-full { grid-column: 1 / -1; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; background: #f8fafc; padding: 14px; border-radius: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; }
.perm-item small { color: #64748b; }

/* 按钮 */
.btn { display: inline-block; padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; text-decoration: none; transition: 0.15s; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-secondary { background: #64748b; color: #fff; }
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; }

/* 提示 */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* 登录页 */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #1e293b, #2563eb); }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 22px; }
.login-box .sub { text-align: center; color: #64748b; margin-bottom: 24px; }
.login-box input { width: 100%; padding: 11px 14px; margin-bottom: 14px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; }
.login-box button { width: 100%; padding: 12px; background: #2563eb; color: #fff; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; }
.login-box button:hover { background: #1d4ed8; }
.login-tip { margin-top: 16px; text-align: center; color: #94a3b8; font-size: 12px; }

/* 分页 */
.pagination { margin-top: 16px; display: flex; gap: 6px; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid #cbd5e1; border-radius: 6px; text-decoration: none; color: #334155; }
.pagination span.cur { background: #2563eb; color: #fff; border-color: #2563eb; }
