/* MoonAPI 控制台 —— 月相主题：深空蓝 × 月光金 */
:root {
  --ink: #0d1321;
  --ink-2: #141c30;
  --paper: #f5f3ee;
  --card: #ffffff;
  --line: #e3ded2;
  --text: #1f2635;
  --muted: #76705f;
  --gold: #c9a227;
  --gold-strong: #a8841a;
  --gold-soft: #f4e8c8;
  --danger: #b23a30;
  --ok: #2e7d51;
  --serif: Georgia, 'Times New Roman', 'Songti SC', 'SimSun', serif;
  --sans: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --mono: 'Cascadia Code', Consolas, 'Courier New', monospace;
  --shadow: 0 1px 2px rgba(13, 19, 33, .06), 0 8px 24px rgba(13, 19, 33, .07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body { font-family: var(--sans); color: var(--text); background: var(--paper); min-height: 100vh; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: .95rem; }
a { color: var(--gold-strong); }

/* ---------- 登录屏 ---------- */
.auth-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 700px at 70% -10%, #22315c 0%, var(--ink) 55%);
  overflow: hidden;
}
.starfield {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 24%, #fff8 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 78% 18%, #fff6 0, transparent 60%),
    radial-gradient(1px 1px at 32% 68%, #fff5 0, transparent 60%),
    radial-gradient(2px 2px at 88% 62%, #ffe9ad66 0, transparent 60%),
    radial-gradient(1px 1px at 56% 42%, #fff4 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 8% 82%, #fff5 0, transparent 60%),
    radial-gradient(1px 1px at 66% 88%, #fff4 0, transparent 60%);
}
.moon-orb {
  position: absolute; top: 12%; right: 14%; width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, #fff7dd, #e8cf8f 58%, #b99b4f);
  box-shadow: 0 0 60px 12px rgba(232, 207, 143, .25);
}
.moon-orb::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(14px 14px at 62% 30%, #d9bd7d55 0, transparent 70%),
    radial-gradient(10px 10px at 40% 62%, #d9bd7d4d 0, transparent 70%),
    radial-gradient(8px 8px at 70% 68%, #d9bd7d45 0, transparent 70%);
}
.auth-card {
  position: relative; width: min(400px, calc(100vw - 48px));
  background: rgba(16, 23, 42, .82); border: 1px solid #2c3a60;
  border-radius: 14px; padding: 40px 36px 32px; color: #e8e6df;
  backdrop-filter: blur(6px); box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%; font-size: 26px; color: var(--ink);
  background: radial-gradient(circle at 34% 32%, #fff7dd, #e0b64a);
  box-shadow: 0 0 24px rgba(224, 182, 74, .4); margin-bottom: 14px;
}
.auth-brand h1 { font-family: var(--serif); font-size: 1.55rem; letter-spacing: .06em; font-weight: 600; }
.auth-sub { margin-top: 6px; font-size: .85rem; color: #9aa3bd; letter-spacing: .12em; }
.auth-card label { display: block; font-size: .82rem; color: #9aa3bd; margin-bottom: 8px; letter-spacing: .08em; }
.auth-card input {
  width: 100%; padding: 11px 13px; border-radius: 8px; border: 1px solid #34436c;
  background: #0e1628; color: #f0eee6; outline: none; transition: border-color .15s;
}
.auth-card input:focus { border-color: var(--gold); }
.auth-hint { margin-top: 16px; font-size: .8rem; line-height: 1.6; color: #8f97b0; min-height: 1.2em; }

/* ---------- 布局 ---------- */
.app-screen { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink); color: #c8cad4; display: flex; flex-direction: column;
  padding: 22px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; border-bottom: 1px solid #232d49; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 34% 32%, #fff7dd, #e0b64a); color: var(--ink); font-size: 19px; flex: none;
}
.brand-text strong { font-family: var(--serif); font-size: 1.12rem; letter-spacing: .05em; color: #f2efe4; display: block; }
.brand-text small { font-size: .68rem; color: #8b90a5; letter-spacing: .18em; }
.nav { margin-top: 18px; display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: #a7abc0; text-decoration: none; font-size: .92rem; transition: background .15s, color .15s;
}
.nav a:hover { background: #1a2340; color: #e9e6da; }
.nav a.active { background: #23304f; color: #f4e8c8; box-shadow: inset 2px 0 0 var(--gold); }
.nav-ico { width: 20px; text-align: center; font-size: 1rem; color: var(--gold); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid #232d49; font-size: .8rem; }
.stat-line { color: #8b90a5; margin-bottom: 6px; }
.link-btn { background: none; border: none; color: #9aa3bd; font-size: .8rem; padding: 0; text-decoration: underline; }
.link-btn:hover { color: var(--gold); }

.main { padding: 26px 34px 60px; max-width: 1200px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
.topbar h2 { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; letter-spacing: .03em; }
.topbar p { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.topbar-date { font-family: var(--mono); font-size: .82rem; color: var(--muted); white-space: nowrap; }

/* ---------- 通用组件 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 16px; border-radius: 8px; font-size: .88rem; transition: all .15s;
}
.btn:hover { border-color: #c9c2ae; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #f2efe4; }
.btn-primary:hover { background: #1b2540; border-color: #1b2540; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 600; }
.btn-gold:hover { background: var(--gold-strong); border-color: var(--gold-strong); color: #fff; }
.btn-danger { color: var(--danger); border-color: #e5c2be; }
.btn-danger:hover { background: #faeeec; border-color: var(--danger); }
.btn-block { width: 100%; padding: 11px; margin-top: 18px; }
.btn-sm { padding: 4px 10px; font-size: .8rem; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.card-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fbfaf6;
}
.panel-head .spacer { flex: 1; }
.search-input {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; min-width: 200px; background: #fff;
}
.search-input:focus { outline: none; border-color: var(--gold); }

/* 表格 */
table.data { width: 100%; border-collapse: collapse; font-size: .89rem; }
table.data th {
  text-align: left; padding: 10px 14px; font-size: .74rem; letter-spacing: .1em;
  color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--line); background: #fbfaf6;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #efece3; vertical-align: middle; }
table.data tbody tr:hover { background: #fbf8f0; }
table.data tbody tr.selected { background: #f7f0dc; }
.td-title { font-weight: 600; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-muted { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.td-actions { white-space: nowrap; text-align: right; }
.td-actions .btn { margin-left: 6px; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem;
  background: var(--gold-soft); color: var(--gold-strong); border: 1px solid #e6d9a8;
}
.tag-pin { background: #e8f0ea; color: var(--ok); border-color: #c6dcd0; }

.empty-state { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty-state .empty-ico { font-size: 2rem; display: block; margin-bottom: 10px; color: #cfc8b2; }
.empty-state p { font-size: .9rem; margin-bottom: 14px; }

.mono { font-family: var(--mono); font-size: .83rem; }
.loading-row td { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(13, 19, 33, .55); display: flex;
  align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; z-index: 50; overflow-y: auto;
}
.modal {
  background: var(--card); border-radius: 12px; width: min(560px, 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3); animation: rise .18s ease-out;
}
.modal.wide { width: min(760px, 100%); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 22px 0; }
.modal-head h3 { font-family: var(--serif); font-size: 1.18rem; }
.modal-body { padding: 16px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.field .hint { font-size: .75rem; color: var(--muted); margin-top: 5px; }

.key-reveal {
  background: var(--ink); color: #f4e8c8; border-radius: 8px; padding: 14px;
  font-family: var(--mono); font-size: .88rem; word-break: break-all; line-height: 1.7;
}

/* ---------- Toast ---------- */
.toast-root { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #f0eee6; padding: 11px 20px; border-radius: 8px;
  font-size: .88rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: rise .2s ease-out;
  border-left: 3px solid var(--gold); max-width: min(480px, calc(100vw - 40px));
}
.toast.error { border-left-color: var(--danger); }

.notice {
  background: #fbf6e7; border: 1px solid #eadfae; color: #6d5b16; border-radius: 10px;
  padding: 12px 16px; font-size: .85rem; line-height: 1.7; margin-bottom: 16px;
}

/* ---------- 数据概览 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.stat-tile::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }
.stat-value { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; color: var(--ink); }
.stat-label { font-size: .78rem; color: var(--muted); letter-spacing: .08em; margin-top: 4px; }
.bar-track { background: #efece0; border-radius: 999px; height: 8px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--gold), var(--gold-strong)); height: 100%; border-radius: 999px; transition: width .3s; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .app-screen { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .brand { border: none; padding: 0; }
  .nav { flex-direction: row; margin: 0; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; gap: 12px; align-items: center; border: none; padding: 0; }
  .main { padding: 20px 16px 50px; }
  .td-actions { white-space: normal; }
}
