/* 内容后台 · 与前台完全同一套色板（石墨绿 / 运输橙 / 浅纸白） */

:root {
  --ink: #162A27;
  --ink-2: #203A35;
  --accent: #E05A32;
  --accent-dark: #C84724;
  --accent-soft: #FBECE5;
  --paper: #F5F7F3;
  --surface: #FFFFFF;
  --line: #DDE5DF;
  --line-strong: #C8D4CD;
  --muted: #64716B;
  --muted-light: #8B9992;
  --ok: #2F7D57;
  --warn: #B4761C;
  --danger: #B4341F;
  --radius: 12px;
  --sans: system-ui, -apple-system, "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 14.5px; line-height: 1.6;
  color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
img { max-width: 100%; }
.hide { display: none !important; }

/* ── 登录 ─────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 34px 30px 28px; }
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.login-brand b { display: block; font-size: 15px; }
.login-brand i { font-style: normal; font-size: 9px; letter-spacing: 0.16em; color: var(--muted-light); }
.login-h { font-size: 22px; margin-top: 26px; }
.login-sub { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-form { margin-top: 22px; display: grid; gap: 12px; }
.login-err { font-size: 13px; color: var(--danger); background: #FBEDE9; border-radius: 8px; padding: 9px 12px; }

/* ── 布局 ─────────────────────────── */
.app { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.side {
  background: var(--ink); color: #A8A498; padding: 22px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.side-mark {
  width: 34px; height: 34px; border-radius: 9px; background: #2A2D22; color: #FAF8F2;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none;
}
.side-brand b { display: block; font-size: 14px; color: #FAF8F2; }
.side-brand i { font-style: normal; font-size: 9px; letter-spacing: 0.14em; color: #6E6B60; }
.side-group { font-size: 10.5px; letter-spacing: 0.14em; color: #5E5B52; padding: 16px 10px 8px; text-transform: uppercase; }
.side-a {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 8px;
  font-size: 14px; color: #A8A498; transition: background 0.14s, color 0.14s;
}
.side-a:hover { background: rgba(255, 255, 255, 0.06); color: #FAF8F2; }
.side-a.on { background: rgba(226, 84, 43, 0.16); color: #FAF8F2; font-weight: 600; }
.side-a .dot {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.side-foot a { font-size: 12.5px; color: #6E6B60; display: block; padding: 5px 0; cursor: pointer; }
.side-foot a:hover { color: #FAF8F2; }

.main { min-width: 0; padding: 26px 32px 60px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.top h1 { font-size: 25px; }
.top .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.top-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ── 按钮 ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: var(--ink-2); }
.btn-line { border: 1px solid var(--line-strong); color: var(--ink); background: var(--surface); }
.btn-line:hover:not(:disabled) { border-color: var(--muted-light); }
.btn-quiet { color: var(--muted); }
.btn-quiet:hover { color: var(--ink); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 7px; }
.btn-danger { color: var(--danger); border: 1px solid #E7C9C1; background: #fff; }
.btn-danger:hover { background: #FBEDE9; }

/* ── 卡片 ─────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; text-align: left; transition: border-color 0.15s, transform 0.15s;
}
.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat-k { font-size: 12px; color: var(--muted); display: block; }
.stat-v { font-size: 27px; font-weight: 700; margin-top: 6px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-v em { font-style: normal; font-size: 12px; color: var(--muted-light); margin-left: 3px; font-weight: 500; }
.stat.alert .stat-v { color: var(--accent); }

.panels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-hd h3 { font-size: 14px; }
.panel-hd a { font-size: 12.5px; color: var(--accent); font-weight: 600; cursor: pointer; }
.panel-row {
  display: block; width: 100%; text-align: left; padding: 11px 16px;
  border-bottom: 1px solid #F1EEE5; font-size: 13.5px;
}
.panel-row:last-child { border-bottom: 0; }
.panel-row:hover { background: #FDFCF8; }
.panel-row .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-row .m { display: block; font-size: 11.5px; color: var(--muted-light); margin-top: 3px; }
.panel-empty { padding: 22px 16px; font-size: 13px; color: var(--muted-light); text-align: center; }

/* ── 工具条 ───────────────────────── */
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11.5px; color: var(--muted); letter-spacing: 0.03em; }
.input, .select, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 9px 12px; font-size: 14px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236F6B60' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.spacer { flex: 1; }

/* ── 表格 ─────────────────────────── */
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl-head { display: grid; gap: 12px; padding: 11px 16px; background: #F4F1E9; font-size: 12px; color: var(--muted); align-items: center; }
.tbl-row {
  display: grid; gap: 12px; padding: 13px 16px; border-top: 1px solid #F1EEE5;
  align-items: center; transition: background 0.14s;
}
.tbl-row:hover { background: #FDFCF8; }
.tbl-row.flash { background: var(--accent-soft); animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: #F7D9CD; } 100% { background: transparent; } }
.cell-t { min-width: 0; }
.cell-t b { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-t span { display: block; font-size: 12px; color: var(--muted-light); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px; font-size: 11.5px; font-weight: 600; }
.badge.published { background: #E8F3ED; color: var(--ok); }
.badge.draft { background: #F4F1E9; color: var(--muted); }
.badge.new { background: var(--accent-soft); color: var(--accent-dark); }
.badge.replied { background: #E8F3ED; color: var(--ok); }
.badge.archived { background: #F1EEE5; color: var(--muted-light); }
.badge.read { background: #EEF1F4; color: #4A5A6A; }
.badge.route { background: var(--accent-soft); color: var(--accent-dark); }
.badge.article { background: #EEF1F4; color: #4A5568; }

.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 4px 0; font-size: 13px; color: var(--muted); }
.pager button { height: 30px; min-width: 30px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); font-size: 13px; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted-light); font-size: 13.5px; }

/* ── 编辑器 ───────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(18, 20, 15, 0.55); backdrop-filter: blur(3px); }
.sheet {
  position: relative; width: 100%; max-width: 1020px; max-height: calc(100vh - 48px);
  background: var(--paper); border-radius: 16px; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 40px 80px -40px rgba(18, 20, 15, 0.6);
}
.sheet-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet-hd h2 { font-size: 17px; }
.sheet-x { width: 34px; height: 34px; border-radius: 8px; font-size: 20px; color: var(--muted); line-height: 1; }
.sheet-x:hover { background: #F4F1E9; color: var(--ink); }
.sheet-body { overflow-y: auto; padding: 20px 22px; }
.sheet-ft {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; background: var(--surface); border-top: 1px solid var(--line);
}
.sheet-ft .msg { margin-right: auto; font-size: 13px; color: var(--danger); }

.form-grid { display: grid; gap: 14px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.textarea { min-height: 260px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.75; }
.tabs { display: flex; gap: 3px; background: #F4F1E9; padding: 3px; border-radius: 9px; width: fit-content; }
.tab { padding: 7px 14px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.tab.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

.prompt-box { display: grid; gap: 10px; }
.prompt-pre {
  background: #1A1D16; color: #D9D6CC; border-radius: 10px; padding: 14px 16px;
  font-family: var(--mono); font-size: 12px; line-height: 1.75;
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.prompt-pre .k { color: var(--accent); }
.hint { font-size: 12px; color: var(--muted-light); line-height: 1.6; }

.preview-frame { width: 100%; height: 62vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.preview-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.preview-stage { display: flex; justify-content: center; background: #EDEAE0; padding: 10px; border-radius: 10px; }
.preview-stage .frame-holder { width: 100%; max-width: 100%; }
.preview-stage.mobile .frame-holder { max-width: 420px; }

/* ── 提示 ─────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; z-index: 300; opacity: 0; transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 12px 30px -12px rgba(18, 20, 15, 0.5); max-width: 80vw;
}
.toast[hidden] { display: none; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.boot { padding: 60px; text-align: center; color: var(--muted); }

/* ── 响应式 ───────────────────────── */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panels { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 12px; align-items: center; gap: 8px; }
  .side-brand, .side-group, .side-foot { display: none; }
  .side-a { white-space: nowrap; }
  .main { padding: 18px 16px 48px; }
  .form-2, .form-3 { grid-template-columns: 1fr; }
  .tbl-head { display: none; }
  .tbl-row { grid-template-columns: 1fr !important; }
}
