:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --wait: #475569;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #111827;
  color: #cbd5e1;
  flex: 0 0 220px;
  padding: 18px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  padding: 8px 14px 14px;
  border-bottom: 1px solid #1f2937;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .brand .brand-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
  background: transparent;
  padding: 0;
  flex: 0 0 auto;
}
.sidebar .brand .brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  padding: 11px 20px;
  font-size: 14px;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.sidebar nav a.on { background: var(--primary); color: #fff; }
/* 菜单图标：统一单色线风（财税/办公场景），颜色随文字状态变化 */
.sidebar nav a .ui-icon {
  flex: 0 0 auto;
  opacity: .8;
  transition: opacity .15s;
}
.sidebar nav a:hover .ui-icon,
.sidebar nav a.on .ui-icon { opacity: 1; }
/* 正文/标题/按钮中的同风格线稿图标 */
.ui-icon { flex: 0 0 auto; vertical-align: -3px; }
h2 .ui-icon, .toolbar h2 .ui-icon { margin-right: 7px; opacity: .85; color: var(--primary); }
.btn .ui-icon { margin-right: 6px; opacity: .9; }
summary .ui-icon { margin-right: 6px; }

.content { flex: 1; min-width: 0; padding: 22px 28px; }
.topbar {
  position: relative;
  min-height: 44px;
  margin-bottom: 18px;
  padding-right: 170px; /* 给右上角用户菜单留位 */
}
.topbar h1 { font-size: 22px; margin: 0; }

/* 右上角用户菜单（头像 + 用户名 + 下拉）：绝对定位锁定右上角 */
.user-menu {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  flex: 0 0 auto;
}
.user-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}
.user-trigger:hover, .user-menu.open .user-trigger { background: #eef2f7; }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
  display: block;
}
.user-avatar-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.user-name { font-weight: 600; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-caret { color: var(--muted); font-size: 12px; transition: transform .15s; }
.user-menu.open .user-caret { transform: rotate(180deg); }

.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 140px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 6px;
  z-index: 50;
}
.user-menu.open .user-dropdown { display: block; }
/* 小三角 */
.user-dropdown::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 26px;
  width: 9px;
  height: 9px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.user-dropdown a {
  display: block;
  padding: 10px 14px;
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
}
.user-dropdown a:hover { background: #f1f5f9; color: var(--primary); text-decoration: none; }

/* 汉堡按钮（仅移动端显示，绝对定位，不依赖 flex） */
.menu-btn {
  display: none;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.menu-btn span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
.menu-btn:active { background: #f1f5f9; }

/* 侧栏遮罩（移动端展开菜单时） */
.sidebar-mask {
  display: none;
  position: fixed;
  left: 0; right: 0; top: 0; bottom: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 900;
}
.sidebar-mask.show { display: block; }

/* 个人设置页（标签右对齐 + 控件区） */
.profile-panel { max-width: 760px; }
.prow { display: flex; align-items: flex-start; margin-bottom: 18px; }
.plabel {
  flex: 0 0 110px;
  text-align: right;
  padding: 9px 14px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.plabel .req { color: var(--danger); margin-right: 2px; }
.pctrl { flex: 1; min-width: 0; }
.pctrl input[type="text"],
.pctrl input[type="password"] {
  width: 100%;
  max-width: 560px;
  display: block;
}
.pctrl input.readonly { background: #f8fafc; color: var(--muted); cursor: not-allowed; }
.avatar-box { display: inline-block; }
.avatar-box img {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
  display: block;
}
.avatar-ph {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 600;
}
.avatar-ops { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pctrl .btn.sm { margin-right: 4px; }

@media (max-width: 640px) {
  .prow { flex-direction: column; }
  .plabel { flex: none; text-align: left; padding: 0 0 6px; }
}

/* 卡片 / 面板 */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { color: var(--muted); margin-top: 4px; }
.stat.danger .num { color: var(--danger); }
.stat.warn .num { color: var(--warn); }
.stat.ok .num { color: var(--ok); }

/* 表格 */
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 13px; }
tr:hover td { background: #f9fbff; }

/* 表单 */
.form-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: var(--muted); }
input, select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* 按钮 */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--primary-d); text-decoration: none; }
.btn.gray { background: #fff; color: var(--text); border-color: var(--border); }
.btn.gray:hover { background: #f1f5f9; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--danger); border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; }

/* 状态标签 */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag.ok { background: #dcfce7; color: var(--ok); }
.tag.warn { background: #fef3c7; color: var(--warn); }
.tag.danger { background: #fee2e2; color: var(--danger); }
.tag.wait { background: #e2e8f0; color: var(--wait); }

/* 提示 */
.alert { padding: 11px 14px; border-radius: 7px; margin-bottom: 16px; }
.alert.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert.success { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.alert.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs a { padding: 7px 14px; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); }
.tabs a.on { background: var(--primary); color: #fff; border-color: var(--primary); }

.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* 配置说明（可折叠） */
details.muted summary { display: inline-block; margin: 2px 0; }
details.muted > p { line-height: 1.8; }
code { background: #f3f4f6; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; }

@media (max-width: 880px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }

  /* 移动端：侧栏改为抽屉（默认收起，点汉堡展开），保留与 PC 一致的全部菜单 */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px;
    height: 100vh;
    z-index: 950;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 18px rgba(0,0,0,.18);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar nav a { padding: 14px 20px; }

  .menu-btn { display: flex; }
  .topbar { padding-left: 50px; padding-right: 132px; min-height: 44px; }
  .content { padding: 16px 18px; }
  .topbar h1 { font-size: 19px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 480px) {
  .user-name { display: none; }      /* 极窄屏只留头像，给标题让位 */
  .topbar { padding-right: 70px; }
  .stats { grid-template-columns: 1fr; }
}
