/* ============================================================
   气象观测手记 · 后台样式  (Meridian 后台 shell)
   ============================================================ */
:root {
  --bg: #FAF7F2; --fg: #1C1A17; --primary: #C0512F; --primary-soft:#E9A98F;
  --accent: #2F5B4F; --accent-soft:#7FA79B; --surface: #FFFFFF; --surface-2: #F3EDE3;
  --muted: #8A817A; --border: rgba(28,26,23,.09); --border-strong: rgba(28,26,23,.16);
  --danger: #C0392B;
  --shadow-sm: 0 1px 3px rgba(28,26,23,.05); --shadow-md: 0 6px 24px rgba(28,26,23,.08); --shadow-lg: 0 16px 48px rgba(28,26,23,.13);
  --radius: 12px; --radius-lg: 18px;
  --font-display: 'Noto Serif SC', 'Source Serif 4', Georgia, serif;
  --font-body: 'Instrument Sans', -apple-system, 'Segoe UI', 'PingFang SC', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --sidebar-w: 244px; --topbar-h: 62px;
}
[data-theme="dark"] {
  --bg: #1A1714; --fg: #EDE8E0; --primary: #D4714F; --accent: #5E9B8A;
  --surface: #242019; --surface-2: #2B2620; --muted: #9B938A;
  --border: rgba(237,232,224,.10); --border-strong: rgba(237,232,224,.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3); --shadow-md: 0 6px 24px rgba(0,0,0,.35); --shadow-lg: 0 16px 48px rgba(0,0,0,.45);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--bg); color: var(--fg); line-height: 1.5;
  -webkit-font-smoothing: antialiased; transition: background-color .35s ease, color .35s ease; }
h1,h2,h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ===== 登录屏 ===== */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-shell::before { content: ""; position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(900px 520px at 80% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 60%),
              radial-gradient(800px 520px at 0% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%); }
.login-card { position: relative; z-index: 1; width: 100%; max-width: 392px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 36px;
  animation: fadeUp .5s cubic-bezier(.2,.8,.3,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.login-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 8px; }
.login-brand .crest { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 22px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent); }
.login-brand h1 { font-size: 1.18rem; } .login-brand em { font-style: normal; color: var(--primary); }
.login-sub { text-align: center; font-family: var(--font-mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 28px; }
.login-card h2 { font-size: 1.15rem; margin-bottom: 6px; }
.login-card .hint { font-size: .84rem; color: var(--muted); margin-bottom: 22px; }
.login-foot { margin-top: 20px; text-align: center; font-size: .78rem; }
.login-foot a { color: var(--muted); }

/* ===== 应用 Shell ===== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; min-height: 100vh; }
.admin-sidebar { grid-row: 1 / -1; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 0; transition: background-color .35s ease; overflow-y: auto; }
.sidebar-logo { display: flex; align-items: center; gap: 11px; padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.sidebar-logo .crest { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 18px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 26%, transparent); }
.sidebar-logo .t { font-family: var(--font-display); font-weight: 900; font-size: .98rem; line-height: 1.1; }
.sidebar-logo .t em { font-style: normal; color: var(--primary); }
.sidebar-logo .t small { display: block; font-family: var(--font-mono); font-weight: 500; font-size: .55rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.sidebar-label { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; font-size: .86rem; color: var(--muted);
  border: none; background: none; width: 100%; text-align: left; transition: background-color .15s ease, color .15s ease; }
.nav-item:hover { background: color-mix(in srgb, var(--fg) 4%, transparent); color: var(--fg); }
.nav-item.active { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); font-weight: 600; }
.nav-item svg, .nav-item .ni { width: 18px; height: 18px; flex-shrink: 0; font-size: 16px; text-align: center; }
.nav-item .badge-count { margin-left: auto; font-family: var(--font-mono); font-size: .66rem; background: var(--surface-2); color: var(--muted); padding: 1px 8px; border-radius: 100px; }
.nav-item.active .badge-count { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.sidebar-footer { padding: 14px 12px 0; border-top: 1px solid var(--border); margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.sidebar-footer .nav-item.danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }

/* ===== 顶栏 ===== */
.admin-topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); }
.topbar-title { font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
.topbar-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { display: flex; align-items: center; gap: 9px; font-size: .82rem; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.theme-btn { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--fg); transition: transform .2s ease, border-color .2s ease; }
.theme-btn:hover { transform: rotate(18deg); border-color: var(--primary); color: var(--primary); }
.theme-btn svg { width: 16px; height: 16px; }
.icon-moon { display: block; } .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; } [data-theme="dark"] .icon-sun { display: block; }

/* ===== 主内容 ===== */
.admin-main { overflow-y: auto; padding: 28px; }
.panel { animation: fadeUp .35s ease both; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.4rem; } .panel-head .ph-sub { color: var(--muted); font-size: .86rem; margin-top: 2px; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 9px; font-size: .84rem; font-weight: 600; border: 1px solid transparent; transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease, border-color .2s ease, background .2s ease; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--primary); color: #FFF7F0; box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 28%, transparent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 36%, transparent); }
.btn-secondary { background: transparent; color: var(--fg); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--fg); border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 9%, transparent); }
.btn-sm { padding: 6px 12px; font-size: .78rem; }

/* 统计卡 */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; transition: box-shadow .2s ease, transform .2s ease; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.stat-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--bar, var(--accent)); }
.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.stat-delta { font-size: .74rem; margin-top: 5px; color: var(--accent); display: flex; align-items: center; gap: 6px; }
.stat-delta.warn { color: var(--primary); }
.stat-delta .live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; position: relative; }
.stat-delta .live-dot::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid currentColor; opacity: .5; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.5); opacity: .7; } 80% { transform: scale(1.4); opacity: 0; } 100% { opacity: 0; } }

/* 双栏状态 */
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card h3 { font-size: 1rem; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px dashed var(--border); font-size: .85rem; }
.status-row:last-child { border-bottom: none; }
.status-row .k { color: var(--muted); }
.status-row .v { font-family: var(--font-mono); font-weight: 600; font-size: .82rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 600; padding: 3px 11px; border-radius: 100px; }
.pill.ok { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.pill.bad { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.pill.idle { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* 活动流 */
.activity-list { display: flex; flex-direction: column; gap: 6px; }
.activity-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; font-size: .83rem; transition: transform .15s ease; }
.activity-item:hover { transform: translateX(4px); }
.activity-item .a-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.activity-item .a-time { margin-left: auto; color: var(--muted); font-size: .72rem; font-family: var(--font-mono); white-space: nowrap; }

/* 内容列表卡（公报） */
.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.content-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .2s ease, transform .2s ease; }
.content-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.content-cover { height: 120px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.content-cover img { width: 100%; height: 100%; object-fit: cover; }
.content-cover .no-cover { color: var(--muted); font-size: 1.6rem; }
.content-cover .pdf-badge { position: absolute; top: 8px; right: 8px; background: var(--primary); color: #fff; font-size: .6rem; font-weight: 700; padding: 3px 9px; border-radius: 100px; }
.content-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.content-body h4 { font-size: .92rem; font-weight: 700; line-height: 1.4; }
.content-body .meta { font-family: var(--font-mono); font-size: .68rem; color: var(--muted); }
.content-actions { display: flex; gap: 7px; margin-top: auto; padding-top: 10px; }

/* 研究行 */
.row-list { display: flex; flex-direction: column; gap: 10px; }
.row-item { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 20px; transition: border-color .2s ease, box-shadow .2s ease; }
.row-item:hover { border-color: color-mix(in srgb, var(--accent) 35%, transparent); box-shadow: var(--shadow-sm); }
.row-item .r-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); flex-shrink: 0; }
.row-item h4 { font-size: .94rem; font-weight: 700; }
.row-item .meta { font-family: var(--font-mono); font-size: .68rem; color: var(--muted); margin-top: 2px; }
.row-item .row-actions { margin-left: auto; display: flex; gap: 7px; }

/* 表单 */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px 32px; max-width: 820px; box-shadow: var(--shadow-sm); }
.form-card h3 { font-size: 1.1rem; margin-bottom: 22px; }
.field { margin-bottom: 20px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 8px; color: var(--fg); }
.field .hint { font-weight: 400; color: var(--muted); font-size: .74rem; }
.input, .textarea, .select, .file {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--bg); color: var(--fg); font-family: inherit; font-size: .9rem; transition: border-color .2s ease, box-shadow .2s ease; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.textarea { resize: vertical; min-height: 140px; line-height: 1.7; }
.file { padding: 9px; }
.file::file-selector-button { margin-right: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg); border-radius: 7px; padding: 6px 12px; font-size: .78rem; cursor: pointer; }
.check { display: flex; align-items: center; gap: 9px; font-size: .86rem; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 12px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }
.form-back { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 18px; }
.form-back:hover { color: var(--primary); }

/* 提示横幅（toast） */
.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 400; background: var(--accent); color: #fff;
  padding: 12px 22px; border-radius: 100px; font-size: .86rem; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toastIn .4s cubic-bezier(.2,.9,.3,1.2) both; display: flex; align-items: center; gap: 9px; }
.toast.err { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translateX(-50%); } }

/* 空状态 */
.empty { text-align: center; padding: 52px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); }
.empty .icon { font-size: 2.2rem; margin-bottom: 12px; }

/* 标签知识库 */
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.label-chip { background: var(--surface-2); border-radius: 9px; padding: 10px 14px; font-size: .82rem; text-align: center; font-weight: 600; }
.label-chip span { display: block; font-family: var(--font-mono); font-size: .64rem; color: var(--muted); font-weight: 500; margin-top: 2px; }

/* ===== 响应式 ===== */
@media (max-width: 1023px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto var(--topbar-h) 1fr; }
  .admin-sidebar { grid-row: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-logo, .sidebar-footer, .sidebar-label { display: none; }
  .sidebar-nav { flex-direction: row; padding: 0; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 12px; } .nav-item .badge-count { display: none; }
  .admin-main { padding: 18px; }
  .stats-row { grid-template-columns: 1fr; }
  .form-card { padding: 22px 18px; }
}
