:root {
  --bg: #f5f6fa;
  --paper: #ffffff;
  --ink: #202333;
  --muted: #73788d;
  --line: #e8e9f0;
  --purple: #7158c9;
  --purple-dark: #5d45b4;
  --purple-soft: #f0ecff;
  --green: #27856d;
  --green-soft: #e9f6f1;
  --orange: #c1782e;
  --orange-soft: #fff4e6;
  --danger: #b42318;
  --shadow: 0 12px 36px rgba(39, 35, 61, .07);
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px 18px; display: flex; flex-direction: column; background: linear-gradient(180deg, #34285f 0%, #281e4d 100%); color: white; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg, #9b86e8, #7257c9); box-shadow: 0 10px 24px rgba(0, 0, 0, .2); font-size: 13px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { margin-top: 3px; color: rgba(255,255,255,.62); font-size: 12px; }
.side-nav { display: grid; gap: 7px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 13px; background: transparent; color: rgba(255,255,255,.7); text-align: left; transition: .18s ease; }
.nav-item span { width: 22px; font-size: 20px; line-height: 1; text-align: center; }
.nav-item b { font-size: 14px; font-weight: 650; }
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: rgba(255,255,255,.15); color: white; box-shadow: inset 3px 0 0 #b6a6f4; }
.sidebar-foot { margin-top: auto; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 13px 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: rgba(255,255,255,.05); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { margin-top: 3px; color: rgba(255,255,255,.55); font-size: 10.5px; }
.sidebar-foot button { padding: 5px 7px; border-radius: 8px; background: rgba(255,255,255,.1); color: white; font-size: 11px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #d4a44d; box-shadow: 0 0 0 4px rgba(212,164,77,.13); }
.status-dot.online { background: #57cca5; box-shadow: 0 0 0 4px rgba(87,204,165,.13); }
.status-dot.error { background: #f07373; box-shadow: 0 0 0 4px rgba(240,115,115,.13); }

.main-column { min-width: 0; }
.topbar { min-height: 132px; padding: 28px clamp(24px, 4vw, 56px) 24px; display: flex; justify-content: space-between; align-items: center; gap: 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86); }
.breadcrumb, .eyebrow { margin: 0 0 6px; color: var(--purple); font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 0; font-size: 28px; letter-spacing: -.025em; }
.topbar p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.top-actions, .toolbar-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.secure-pill { padding: 7px 10px; border-radius: 999px; background: #fff1ef; color: var(--danger); font-size: 11.5px; font-weight: 700; }
.secure-pill.ok { background: var(--green-soft); color: var(--green); }
.primary, .secondary, .wide-secondary { padding: 10px 15px; border-radius: 11px; font-size: 13px; font-weight: 700; }
.primary { background: var(--purple); color: white; box-shadow: 0 7px 16px rgba(113,88,201,.2); }
.primary:hover { background: var(--purple-dark); }
.secondary, .wide-secondary { border: 1px solid var(--line); background: white; color: var(--ink); }
.secondary.small { padding: 7px 10px; font-size: 12px; }
.wide-secondary { width: 100%; }
.page-content { padding: 26px clamp(24px, 4vw, 56px) 48px; }
.page-view { display: grid; gap: 18px; }
.page-view[hidden], .drawer-backdrop[hidden] { display: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-height: 136px; padding: 17px 18px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, #fff, #fbfaff); box-shadow: var(--shadow); }
.metric-card.online { background: linear-gradient(145deg, #fff, #eff9f5); }
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card strong { margin: 8px 0; color: var(--purple); font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-card.online strong { color: var(--green); }
.metric-card small { color: #999dae; font-size: 11px; line-height: 1.35; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); }
.panel-head { min-height: 42px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head h2 small { margin-left: 6px; color: var(--muted); font-size: 12px; }
.panel-head > small { color: var(--muted); font-size: 11.5px; }
.dashboard-grid, .two-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 18px; }
.two-column { grid-template-columns: 1fr 1fr; }
.text-button { padding: 4px; background: none; color: var(--purple); font-size: 12px; font-weight: 700; }
.compact-list { display: grid; }
.compact-list button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.compact-list button:last-child { border-bottom: 0; }
.compact-list strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.compact-list time { color: var(--muted); font-size: 11px; }
.tag { display: inline-flex; padding: 3px 8px; border-radius: 999px; background: var(--purple-soft); color: var(--purple); font-size: 10.5px; font-weight: 750; }
.campaign-visual { min-height: 95px; padding: 18px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 15px; overflow: hidden; }
.campaign-visual.sakura { color: #7f4055; background: radial-gradient(circle at 85% 20%, rgba(255,255,255,.75), transparent 32%), linear-gradient(135deg, #fde9ef, #f7c6d4); }
.campaign-visual span { font-size: 18px; font-weight: 800; }
.campaign-visual small { margin-top: 4px; opacity: .78; }
.summary-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin: 15px 0; }
.summary-grid div { min-width: 0; }
.summary-grid dt { color: var(--muted); font-size: 11px; }
.summary-grid dd { margin: 5px 0 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 12px; font-weight: 700; white-space: nowrap; }

.news-list { display: grid; gap: 9px; }
.news-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 13px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: #fcfcfe; }
.news-thumb { width: 62px; height: 62px; overflow: hidden; border-radius: 11px; background: var(--purple-soft); }
.news-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.news-thumb.fallback { display: grid; place-items: center; color: var(--purple); font-size: 11px; font-weight: 800; }
.news-copy { min-width: 0; }
.news-copy > strong { display: block; margin-bottom: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.news-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; color: var(--muted); font-size: 11.5px; }
.news-meta a { color: var(--purple); text-decoration: none; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); font-size: 11.5px; font-weight: 650; }
.row-actions .danger { color: var(--danger); }

.version-list { display: grid; gap: 15px; }
.version-row > div { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 12px; }
.version-row span { color: var(--muted); font-variant-numeric: tabular-nums; }
progress { width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 99px; background: #efedf5; }
progress::-webkit-progress-bar { border-radius: 99px; background: #efedf5; }
progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, var(--purple), #a18ce6); }
.privacy-note { margin: 0; padding: 12px 15px; border: 1px solid #d8ebe4; border-radius: 13px; background: var(--green-soft); color: var(--green); font-size: 11.5px; line-height: 1.5; }

.resources-view { grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); align-items: start; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { padding: 10px 12px; background: #f8f7fb; color: var(--muted); text-align: left; font-size: 11px; }
th:first-child { border-radius: 10px 0 0 10px; }
th:last-child { border-radius: 0 10px 10px 0; }
td { padding: 14px 12px; border-bottom: 1px solid var(--line); }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.status-badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 800; }
.status-badge.active { background: var(--green-soft); color: var(--green); }
.status-badge.waiting { background: var(--orange-soft); color: var(--orange); }
.status-badge.neutral { background: #f0f1f5; color: var(--muted); }
.panel-copy { margin: -4px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.toggle-row { margin-bottom: 16px; padding: 14px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-radius: 13px; background: #faf9fd; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.toggle-row input { width: 42px; height: 22px; accent-color: var(--purple); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: 12px; }
.field em { color: #a2a5b4; font-style: normal; font-size: 10.5px; }
input[type="text"], input[type="url"], input[type="password"], input[type="datetime-local"], select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #fbfbfd; color: var(--ink); }
input:focus, select:focus { border-color: #a998e4; box-shadow: 0 0 0 3px rgba(113,88,201,.1); }
.campaign-actions { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 3px; }
.campaign-actions span { color: var(--muted); font-size: 11px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; background: rgba(25,20,40,.35); backdrop-filter: blur(2px); }
.editor-drawer { width: min(520px, 100vw); height: 100%; padding: 26px; overflow-y: auto; background: white; box-shadow: -20px 0 60px rgba(26,18,49,.18); animation: slide-in .18s ease-out; }
@keyframes slide-in { from { transform: translateX(25px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h2 { margin: 0; font-size: 21px; }
.close-button { width: 34px; height: 34px; border-radius: 10px; background: #f3f2f6; color: var(--muted); font-size: 22px; }
.image-row { display: flex; align-items: center; gap: 8px; }
.file-btn { padding: 8px 11px; border-radius: 10px; background: var(--purple-soft); color: var(--purple); font-size: 12px; font-weight: 750; cursor: pointer; }
.image-preview { min-height: 130px; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--line); border-radius: 12px; background: #faf9fd; color: var(--muted); font-size: 11.5px; }
.image-preview img { width: 100%; height: 170px; object-fit: cover; }
.drawer-actions, .dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 6px; }
.form-hint { color: var(--muted); font-size: 10.5px; }
.drawer-open { overflow: hidden; }

.auth-dialog { width: min(440px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 18px; box-shadow: 0 24px 80px rgba(32,22,54,.22); }
.auth-dialog::backdrop { background: rgba(31,22,45,.42); backdrop-filter: blur(3px); }
.auth-dialog h2 { margin: 0 0 8px; }
.auth-dialog p { margin: 0 0 18px; color: var(--muted); font-size: 12px; }
.empty { margin: 26px 0 8px; color: var(--muted); text-align: center; font-size: 12px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: 360px; padding: 12px 15px; border-radius: 12px; background: #252232; color: white; box-shadow: var(--shadow); font-size: 12.5px; }
.toast.error { background: #7f1d1d; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .resources-view { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { padding-inline: 7px; }
  .brand > div, .nav-item b, .sidebar-foot div, .sidebar-foot button { display: none; }
  .nav-item { justify-content: center; padding-inline: 8px; }
  .sidebar-foot { grid-template-columns: 1fr; justify-items: center; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .two-column, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .page-content, .topbar { padding-inline: 16px; }
  .news-row { grid-template-columns: 52px minmax(0, 1fr); }
  .news-thumb { width: 52px; height: 52px; }
  .row-actions { grid-column: 2; }
  .secure-pill { display: none; }
}
