:root {
  --bg: #f5f6fa;
  --side: #1e2233;
  --side-hi: #2b3150;
  --card: #fff;
  --text: #232733;
  --muted: #8a90a2;
  --border: #e8eaf0;
  --primary: #4f7cff;
  --primary-d: #3a63d8;
  --danger: #ef5350;
  --ok: #43a047;
  --shadow: 0 4px 16px rgba(20, 24, 40, .06);
  --shadow-hi: 0 10px 30px rgba(20, 24, 40, .12);
}
[data-theme="dark"] {
  --bg: #15171f;
  --side: #0f1117;
  --side-hi: #232838;
  --card: #1f2330;
  --text: #e6e8f0;
  --muted: #9aa0b4;
  --border: #2a2f3e;
  --primary: #5b8bff;
  --primary-d: #4f7cff;
  --shadow: 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-hi: 0 10px 30px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); transition: background .25s, color .25s; }
.hidden { display: none !important; }
button { font-family: inherit; }

/* 动效 */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view > * { animation: fadeIn .3s ease both; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* 登录 */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 70% -10%, #2b3150, #1e2233); }
.login-card { width: 340px; background: var(--card); padding: 38px 30px; border-radius: 16px; box-shadow: var(--shadow-hi); text-align: center; animation: pop .35s ease both; }
.login-card h1 { font-size: 22px; }
.brand-mark { font-size: 34px; margin-bottom: 6px; }
.login-sub { color: var(--muted); margin: 6px 0 24px; font-size: 13px; }
.login-card input { width: 100%; padding: 11px 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; outline: none; background: var(--bg); color: var(--text); transition: border .2s; }
.login-card input:focus { border-color: var(--primary); }
.login-card button { width: 100%; padding: 11px; background: var(--primary); color: #fff; border: none; border-radius: 9px; font-size: 15px; cursor: pointer; transition: transform .1s, background .2s; }
.login-card button:hover { background: var(--primary-d); }
.login-card button:active { transform: scale(.98); }
.login-msg { margin-top: 12px; font-size: 13px; color: var(--danger); min-height: 18px; }

/* 框架 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--side); color: #cfd3e0; display: flex; flex-direction: column; padding: 18px 12px; transition: width .25s ease, padding .25s ease, opacity .2s ease, background .25s; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: #fff; padding: 8px 10px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), #8a5bff); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a { color: #cfd3e0; text-decoration: none; padding: 11px 14px; border-radius: 9px; font-size: 14px; transition: background .15s, transform .1s; }
.sidebar nav a:hover { background: var(--side-hi); }
.sidebar nav a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(79, 124, 255, .35); }
.side-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px; gap: 8px; }
.theme-btn { background: transparent; border: 1px solid var(--side-hi); color: #cfd3e0; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px; transition: background .15s; }
.theme-btn:hover { background: var(--side-hi); }
.side-foot .who { font-size: 13px; color: #cfd3e0; flex: 1; }

/* 左侧菜单收起 */
body.sidebar-collapsed .sidebar { width: 0; min-width: 0; padding-left: 0; padding-right: 0; opacity: 0; overflow: hidden; border: none; }
body.sidebar-collapsed .app { --side-w: 0; }

/* 内容区顶栏（含菜单开关，常驻可见） */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; transition: background .15s, transform .1s; }
.icon-btn:hover { background: var(--side-hi); }
.icon-btn:active { transform: scale(.94); }
.side-foot .logout { background: transparent; border: 1px solid var(--side-hi); color: #cfd3e0; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.side-foot .logout:hover { background: var(--side-hi); }

.content { flex: 1; padding: 26px 30px; overflow: auto; }
.view h2 { font-size: 18px; margin-bottom: 18px; }

/* 卡片 */
.cards { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.card { background: var(--card); border-radius: 14px; padding: 20px 24px; min-width: 180px; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hi); }
.card .num { font-size: 30px; font-weight: 700; color: var(--primary); }
.card .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

.chart-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.chart-card { background: var(--card); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); flex: 1; min-width: 320px; }
.chart-card h3 { font-size: 14px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.chart { width: 100%; height: 240px; }

.notice-box { background: var(--card); border-radius: 14px; padding: 18px 22px; box-shadow: var(--shadow); max-width: 560px; }
.notice-box h3 { margin-bottom: 12px; font-size: 15px; }
.notice-item { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.notice-item:last-child { border-bottom: none; }
.notice-title { font-weight: 600; }
.notice-time { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; outline: none; font-size: 14px; background: var(--bg); color: var(--text); }
.toolbar input:focus { border-color: var(--primary); }
.btn { padding: 9px 16px; border: none; border-radius: 9px; cursor: pointer; font-size: 14px; background: var(--primary); color: #fff; transition: transform .1s, background .2s; }
.btn:hover { background: var(--primary-d); }
.btn:active { transform: scale(.97); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }

/* 表格 */
.table-wrap { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: color-mix(in srgb, var(--bg) 70%, var(--card)); color: var(--muted); font-weight: 600; }
td.cover img { height: 40px; border-radius: 5px; object-fit: cover; cursor: zoom-in; transition: transform .15s; }
td.cover img:hover { transform: scale(1.08); }
td.url a { color: var(--primary); text-decoration: none; max-width: 220px; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
td.name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.expired { color: var(--danger); }

/* 灯箱 */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .82); display: flex; align-items: center; justify-content: center; z-index: 60; animation: fadeIn .2s ease; cursor: zoom-out; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }

/* 弹窗 & toast */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: flex; align-items: center; justify-content: center; z-index: 50; animation: fadeIn .2s ease; }
.modal-box { background: var(--card); padding: 24px; border-radius: 14px; width: 360px; box-shadow: var(--shadow-hi); animation: pop .25s ease both; }
.modal-box h3 { margin-bottom: 14px; }
.modal-box input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 16px; outline: none; background: var(--bg); color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: #32384a; color: #fff; padding: 10px 18px; border-radius: 9px; font-size: 14px; z-index: 99; box-shadow: var(--shadow-hi); animation: pop .2s ease; }
[data-theme="dark"] .toast { background: #2b3150; }
