* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #14735f;        /* 主色：墨绿 */
  --blue-dark: #0e5c4b;
  --bg: #f6f5f2;          /* 暖白纸感背景 */
  --panel: #ffffff;
  --border: #e8e6e1;
  --text: #232825;
  --muted: #79756d;
  --green: #14735f;
  --red: #bf4540;
  --sidebar: #fbfaf8;
}
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* 登录 */
.login-wrap { position: relative; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.doc-link {
  position: absolute; top: 22px; right: 26px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border: 1px solid var(--border); border-radius: 20px;
  background: #fff; color: var(--muted); text-decoration: none; font-size: 13px;
  transition: color .15s, border-color .15s, box-shadow .15s;
}
.doc-link:hover { color: var(--blue); border-color: var(--blue); box-shadow: 0 4px 14px rgba(20, 115, 95, 0.12); }
.login-card { background: var(--panel); padding: 40px 36px; border-radius: 14px; width: 340px; text-align: center; border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(35, 40, 37, 0.06); }
.login-logo { display: block; margin: 0 auto 16px; border-radius: 14px; box-shadow: 0 8px 22px rgba(14, 92, 75, 0.25); }
.login-card h1 { font-size: 20px; margin-bottom: 8px; }
.login-card p { margin-bottom: 20px; }
.login-card input { width: 100%; margin-bottom: 14px; }
.error { color: var(--red); margin-top: 12px; }

/* 布局 */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 220px; height: 100%; overflow-y: auto; background: var(--sidebar); color: var(--text); display: flex; flex-direction: column; flex-shrink: 0; border-right: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; font-weight: 700; padding: 20px 18px 16px; letter-spacing: .02em; }
.logo img { display: block; border-radius: 7px; box-shadow: 0 3px 8px rgba(14, 92, 75, 0.22); }
.project-switch { padding: 0 16px 16px; border-bottom: 1px solid var(--border); }
.project-switch label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sidebar nav { flex: 1; padding: 10px; }
.sidebar nav a { display: block; color: #55524b; text-decoration: none; padding: 10px 12px; border-radius: 9px; margin-bottom: 2px; }
.sidebar nav a:hover { background: #f0eeea; color: var(--text); }
.sidebar nav a.active { background: #e5efeb; color: var(--blue); font-weight: 600; }
.logout { margin: 16px; }

.main { flex: 1; height: 100%; overflow-y: auto; padding: 0 28px 24px; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); padding: 20px 0 14px; margin-bottom: 6px;
}
.topbar h2 { font-size: 18px; }
.spacer { flex: 1; }

/* 组件 */
input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
.btn { padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { background: #f0eeea; color: var(--text); }
.btn.block { width: 100%; }
.btn.mini { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--red); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.stat-card .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-card .num { font-size: 24px; font-weight: 700; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 6px 16px 14px; overflow-x: auto; }
.panel h3 { padding: 12px 0 4px; font-size: 15px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.table th, .table td {
  text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.table th { color: var(--muted); font-weight: 500; font-size: 13px; background: #faf9f6; }
.table th:first-child { border-top-left-radius: 8px; }
.table th:last-child { border-top-right-radius: 8px; }
.table tbody tr:hover td { background: #f7f6f2; }
.table code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* 操作列固定在右侧，横向滚动时不动 */
.table th.sticky-col, .table td.sticky-col {
  position: sticky; right: 0; z-index: 2;
  background: #fff; overflow: visible;
  box-shadow: -12px 0 12px -12px rgba(17, 24, 39, 0.15);
}
.table th.sticky-col { background: #faf9f6; }
.table tbody tr:hover td.sticky-col { background: #f7f6f2; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; }
.badge.unused { background: #f0efeb; color: var(--muted); }
.badge.active { background: #e0eee8; color: var(--green); }
.badge.banned { background: #f7e4e2; color: var(--red); }
.badge.expired { background: #f7ecd8; color: #a4691c; }
.badge.used { background: #eae6f5; color: #6a55a8; }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 12px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(35, 40, 37, 0.42); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 100; animation: mask-in .15s ease-out; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 420px; max-width: 92vw; border: 1px solid var(--border); box-shadow: 0 24px 60px rgba(35, 40, 37, 0.18); animation: modal-in .18s cubic-bezier(.2, .8, .3, 1); }
.modal h3 { margin-bottom: 16px; }
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.form-sub { display: flex; flex-direction: column; gap: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal textarea { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 13px; resize: vertical; }
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

/* 确认弹窗 */
.confirm-box { width: 380px; }
.confirm-box h3 { margin-bottom: 0; }
.confirm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.confirm-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; background: #e0eee8; color: var(--green);
}
.confirm-box.danger .confirm-icon { background: #f7e4e2; color: var(--red); }
.confirm-message { color: #55524b; line-height: 1.6; margin: 0; }
.confirm-box.danger .btn.primary { background: var(--red); border-color: var(--red); }
.confirm-box.danger .btn.primary:hover { background: #a83a35; border-color: #a83a35; }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #2c332f; color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 200; }

/* 自定义下拉框 */
.cselect { position: relative; display: inline-block; min-width: 130px; }
.cselect select { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.cselect-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; color: var(--text); text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.cselect-btn:hover { border-color: #cfccc4; }
.cselect-btn svg { color: var(--muted); flex-shrink: 0; transition: transform .15s; }
.cselect:has(.cselect-list:not(.hidden)) .cselect-btn { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 115, 95, 0.13); }
.cselect:has(.cselect-list:not(.hidden)) .cselect-btn svg { transform: rotate(180deg); }
.cselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-list {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 100%; max-height: 280px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 5px;
  box-shadow: 0 10px 30px rgba(35, 40, 37, 0.12); z-index: 150;
  animation: cselect-in .12s ease-out;
}
@keyframes cselect-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cselect-item { padding: 8px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.cselect-item:hover { background: #eef3f0; color: var(--blue); }
.cselect-item.selected { background: var(--blue); color: #fff; }

.form .cselect { display: block; }

/* 侧边栏的项目切换器（浅色侧栏配套样式） */
.cselect.dark { display: block; }
.cselect.dark .cselect-btn { background: #fff; border-color: var(--border); color: var(--text); }
.cselect.dark .cselect-btn:hover { border-color: #cfccc4; }
