:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #17232d;
  --muted: #5b6d78;
  --line: #d9e3e8;
  --brand: #1267a6;
  --brand-dark: #0c4d7c;
  --green: #147a52;
  --green-soft: #e8f7f0;
  --red: #b52f35;
  --red-soft: #fff0ef;
  --shadow: 0 12px 32px rgba(27, 49, 63, 0.07);
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --surface-dark: #0e2636;
  --surface-soft: #eef2f4;
  --brand-tint: #e9f3fa;
  --brand-tint-strong: #dcebf6;
  --brand-tint-active: #cfe2f0;
  --neutral-strong: #e3e8eb;
  --neutral-active: #d9e0e4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; line-height: 1.6; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button, input, select { transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease, transform .08s ease; }
button:active { transform: translateY(1px); }

.loading { display: grid; min-height: 100vh; place-items: center; color: var(--muted); animation: breathe 1.6s ease-in-out infinite; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #e3f1fa, transparent 30%), var(--bg); }
.login-card { width: min(100%, 420px); padding: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-card h1 { margin: 4px 0 10px; }
.eyebrow { margin: 0; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.muted, .hint { color: var(--muted); line-height: 1.65; }
.form-error { padding: 10px 12px; border-radius: 9px; color: var(--red); background: var(--red-soft); }
.hint { font-size: 13px; }
.field { display: grid; gap: 7px; margin: var(--space-sm) 0; font-size: 14px; font-weight: 600; }
.field input, .field select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.field.inline { min-width: 180px; margin: 0; }
.field:has(input:required) > span::after { content: " *"; color: var(--red); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.button { border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 650; }
.button-primary { color: #fff; background: var(--brand); }
.button-primary:hover { background: var(--brand-dark); }
.button-primary:active { background: #0a3e63; }
.button-secondary { color: var(--brand-dark); background: var(--brand-tint); }
.button-secondary:hover { background: var(--brand-tint-strong); }
.button-secondary:active { background: var(--brand-tint-active); }
.button-quiet { color: var(--ink); background: var(--surface-soft); }
.button-quiet:hover { background: var(--neutral-strong); }
.button-quiet:active { background: var(--neutral-active); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18, 103, 166, 0.14); }
.sidebar :focus-visible { outline-color: #7fc3e8; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; display: flex; flex-direction: column; background: var(--surface-dark); color: #fff; }
.brand { display: grid; gap: 2px; padding: 0 10px 24px; }
.brand span { color: #88b8d5; font-size: 12px; letter-spacing: .12em; }
.brand strong { font-size: 22px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item, .logout { border: 0; padding: 11px 13px; border-radius: 9px; text-align: left; color: #dceaf2; background: transparent; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item:active { background: rgba(255,255,255,.14); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.14); }
.logout { margin-top: auto; color: #a8bfcb; }
.logout:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-main { width: min(100%, 1400px); padding: 30px clamp(18px, 4vw, 46px) 60px; }
.page-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-header h1 { margin: 4px 0 7px; font-size: clamp(28px, 4vw, 40px); }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.panel { padding: var(--space-lg); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.panel h2, .panel h3 { margin: 0 0 var(--space-sm); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-sm); margin-bottom: var(--space-lg); }
.metric { padding: var(--space-md); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.metric-grid.flat .metric { padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.metric-grid.flat { margin-bottom: var(--space-sm); }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 7px; font-size: 25px; }
.quick-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); }
.split-layout { display: grid; grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); gap: var(--space-lg); align-items: start; }
.split-layout.wide-form { grid-template-columns: minmax(340px, 470px) minmax(0, 1fr); }
.form-panel { position: sticky; top: 22px; }
.stack { display: grid; gap: var(--space-sm); }
.list-row, .channel-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.list-row h3, .channel-card h3 { margin: 0 0 6px; }
.row-actions { display: flex; align-items: center; gap: var(--space-xs); }
.badge { padding: 5px 9px; border-radius: 999px; font-size: 12px; background: var(--surface-soft); color: var(--muted); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.off { background: var(--red-soft); color: var(--red); }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.channel-heading { justify-content: flex-start; }
.channel-heading > div:nth-child(2) { flex: 1; }
.small-logo, .logo-placeholder { width: 48px; height: 48px; border-radius: 11px; object-fit: contain; background: var(--surface-soft); }
.logo-placeholder { display: grid; place-items: center; color: var(--brand); font-weight: 800; }
.logo-preview { width: 86px; height: 86px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.details { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; margin: 16px 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; }
.report-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: end; margin-bottom: var(--space-md); }
.report-summary { margin-bottom: 12px; background: linear-gradient(135deg, #edf8ff, #fff); }
.ledger-row { padding: 10px 0; margin: 0; border-top: 1px solid var(--line); color: var(--muted); }
.mono { padding: 10px 12px; border-radius: 9px; background: var(--surface-soft); word-break: break-all; font-family: Consolas, monospace; }
.plain-list { padding-left: 20px; color: var(--muted); line-height: 1.9; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); animation: toast-in .28s cubic-bezier(0.16, 1, 0.3, 1); }
.toast.success { background: var(--green-soft); color: var(--green); }
.toast.error { background: var(--red-soft); color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.page-enter-active { transition: opacity .16s ease, transform .16s ease; }
.page-leave-active { transition: opacity .12s ease, transform .12s ease; }
.page-enter-from { opacity: 0; transform: translateY(8px); }
.page-leave-to { opacity: 0; transform: translateY(-6px); }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; }
  .brand { padding-bottom: 12px; }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .logout { margin-top: 12px; }
  .split-layout, .split-layout.wide-form { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .metric-grid, .quick-grid, .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .admin-main { padding: 20px 13px 42px; }
  .page-header { display: grid; }
  .field-pair, .metric-grid, .quick-grid, .settings-grid { grid-template-columns: 1fr; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
