:root {
  --green: #16a34a;
  --green-d: #15803d;
  --green-l: #dcfce7;
  --green-xl: #f0fdf4;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #9ca3af;
  --line: #e5e7eb;
  --bg: #f5f7f6;
  --card: #ffffff;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --radius: 12px;
  --sidebar-w: 86px;
  --flyout-w: 640px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
.link { color: var(--green); cursor: pointer; font-size: 13px; background: none; border: none; }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; min-height: 100vh; }
.login-card { width: 440px; max-width: 100%; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; background: #fff; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, var(--green), #4ade80); color: #fff; font-weight: 800; font-size: 26px; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(22,163,74,.35); }
.logo.sm { width: 34px; height: 34px; font-size: 18px; border-radius: 9px; }
.login-brand h1 { margin: 0; font-size: 22px; }
.login-brand p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.login-form input[type=text], .login-form input[type=password] { height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; outline: none; transition: .2s; background: #fafafa; }
.login-form input:focus { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px var(--green-l); }
.login-row { display: flex; justify-content: space-between; align-items: center; }
.remember { flex-direction: row !important; align-items: center; gap: 7px !important; font-weight: 500 !important; color: var(--ink-2) !important; }
.btn-primary { background: var(--green); color: #fff; border: none; height: 46px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; transition: .2s; letter-spacing: 4px; }
.btn-primary:hover { background: var(--green-d); }
.btn-primary.block { width: 100%; }
.login-tip { text-align: center; color: var(--ink-3); font-size: 12px; margin: 4px 0 0; }
.login-aside { flex: 1; background: linear-gradient(135deg, #0f7a37, var(--green) 55%, #4ade80); color: #fff; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.login-aside::after { content: ""; position: absolute; right: -120px; top: -120px; width: 380px; height: 380px; background: rgba(255,255,255,.08); border-radius: 50%; }
.aside-inner { max-width: 420px; padding: 40px; position: relative; z-index: 1; }
.aside-inner h2 { font-size: 34px; line-height: 1.3; margin: 0 0 24px; font-weight: 800; }
.aside-inner ul { list-style: none; padding: 0; margin: 0 0 60px; }
.aside-inner li { padding: 12px 0 12px 30px; position: relative; font-size: 15px; opacity: .95; border-bottom: 1px solid rgba(255,255,255,.15); }
.aside-inner li::before { content: "✓"; position: absolute; left: 0; top: 12px; font-weight: 800; }
.aside-foot { font-size: 12px; opacity: .8; }

/* ---------- 后台布局 ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.announce-bar { background: #fff8e6; border-bottom: 1px solid #f0e6c8; color: #8a6d3b; font-size: 13px; padding: 8px 18px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.announce-icon { font-size: 14px; }
.announce-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace { display: flex; flex: 1; min-height: 0; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: #1f2329; color: #a7adb6; display: flex; flex-direction: column; z-index: 20; }
.side-brand { display: flex; align-items: center; justify-content: center; padding: 16px 0; }
.side-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 4px; border-radius: 10px; cursor: pointer; transition: .15s; color: #a7adb6; user-select: none; font-size: 12px; }
.nav-item .ico { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(22,163,74,.18); color: var(--green); }
.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); display: flex; justify-content: center; }

.flyout { position: fixed; left: var(--sidebar-w); top: 38px; bottom: 0; width: var(--flyout-w); background: #fff; box-shadow: 4px 0 24px rgba(0,0,0,.12); z-index: 15; padding: 22px 26px; overflow-y: auto; display: none; }
.flyout.open { display: block; }
.flyout-title { font-size: 18px; font-weight: 800; margin-bottom: 18px; color: var(--ink); }
.flyout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 28px; }
.flyout-col h4 { font-size: 13px; color: var(--ink); font-weight: 700; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.flyout-col a { display: block; padding: 6px 0; font-size: 13px; color: var(--ink-2); cursor: pointer; border-radius: 6px; }
.flyout-col a:hover { color: var(--green); background: var(--green-xl); padding-left: 8px; margin-left: -8px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0; }
.crumb { font-size: 16px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn { position: relative; background: none; border: none; font-size: 18px; cursor: pointer; padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); }
.icon-btn .badge { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.user-chip { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.logout { margin-left: 6px; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------- 通用卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.section-title { font-size: 16px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title small { font-weight: 400; color: var(--ink-3); font-size: 12px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .k-label { color: var(--ink-2); font-size: 13px; }
.kpi .k-val { font-size: 28px; font-weight: 800; margin: 8px 0 4px; letter-spacing: .5px; }
.kpi .k-sub { font-size: 12px; color: var(--ink-3); }
.kpi .k-trend { font-size: 12px; font-weight: 700; }
.up { color: var(--green); } .down { color: var(--red); }
.kpi-ico { position: absolute; right: 16px; top: 16px; width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.bg-green { background: var(--green-xl); } .bg-orange { background: #fff7ed; } .bg-blue { background: #eff6ff; } .bg-red { background: #fef2f2; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* 表格 */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; color: var(--ink-2); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafbfa; white-space: nowrap; }
table.tbl td { padding: 11px 14px; border-bottom: 1px solid #f1f3f2; white-space: nowrap; }
table.tbl tbody tr:hover { background: var(--green-xl); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag-green { background: var(--green-l); color: var(--green-d); }
.tag-orange { background: #fef3c7; color: #b45309; }
.tag-red { background: #fee2e2; color: #b91c1c; }
.tag-gray { background: #f1f3f2; color: var(--ink-2); }
.tag-blue { background: #dbeafe; color: #1d4ed8; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.input, select.input { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; outline: none; background: #fff; }
.input:focus { border-color: var(--green); }
.btn { height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn:hover { border-color: var(--green); color: var(--green); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12px; }
.btn-primary.sm { background: var(--green); color: #fff; border: none; }

/* 图表 */
.chart-box { width: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.bar-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-size: 13px; }
.bar-row .bl { width: 70px; color: var(--ink-2); flex-shrink: 0; }
.bar-track { flex: 1; background: #f1f3f2; border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), #4ade80); border-radius: 6px; }
.bar-val { width: 54px; text-align: right; color: var(--ink-2); flex-shrink: 0; }

/* 占位页 */
.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 70px 20px; text-align: center; color: var(--ink-3); }
.placeholder .ph-ico { width: 80px; height: 80px; border-radius: 24px; background: var(--green-xl); color: var(--green); font-size: 36px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.placeholder h2 { margin: 0 0 8px; color: var(--ink); font-size: 18px; }
.placeholder p { margin: 0; font-size: 14px; }

/* 弹窗 */
.modal-root { position: fixed; inset: 0; background: rgba(15,23,20,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ink-3); }
.modal-body { padding: 20px 22px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; color: var(--ink); }

.muted { color: var(--ink-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.pill-stat { display: flex; gap: 22px; flex-wrap: wrap; }
.pill-stat .ps { text-align: center; }
.pill-stat .ps b { display: block; font-size: 22px; }
.pill-stat .ps span { font-size: 12px; color: var(--ink-3); }
.empty { text-align: center; color: var(--ink-3); padding: 40px; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d3d9d5; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 通用 CRUD 表单 ---------- */
.crud-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.wide { grid-column: 1 / -1; }
.form-item label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.form-item .input { width: 100%; }
.row-actions { white-space: nowrap; }
.row-actions .link { margin-right: 10px; }
.row-actions .link.danger { color: var(--red); }
.link:hover { text-decoration: underline; }

/* ---------- 轻提示 toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(20px);
  background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #b91c1c; }

@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2b { grid-template-columns: 1fr; }
  .flyout { width: 420px; }
  .login-aside { display: none; }
}
