:root {
  --primary: #1f6fd6;
  --primary-dark: #1758ad;
  --accent: #7c5cff;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1a2333;
  --text-sub: #5b6b85;
  --radius: 12px;
  --shadow: 0 6px 18px rgba(31, 111, 214, 0.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
[hidden] { display: none !important; }

/* 登录页 */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f6fd6 0%, #4a3fd6 55%, #7c5cff 100%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 16px;
  padding: 28px 28px; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.auth-card h1 { font-size: 21px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-sub); font-size: 13px; margin-bottom: 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 8px 12px; border: 1px solid #dbe2ee; border-radius: 8px;
  font-size: 13px; outline: none; transition: border .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.btn {
  display: inline-block; border: none; background: linear-gradient(135deg, #1f6fd6, #7c5cff);
  color: #fff; font-weight: 600; padding: 8px 18px; border-radius: 8px;
  font-size: 14px; transition: opacity .15s, transform .15s;
}
.btn:hover { opacity: .92; transform: translateY(-1px); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid #dbe2ee; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-sub); }
.auth-switch a { color: var(--primary); font-weight: 600; }
.error { color: #d93025; font-size: 13px; margin-bottom: 12px; display: none; }

/* 主界面 */
.topbar {
  position: sticky; top: 0; z-index: 100; background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px); border-bottom: 1px solid rgba(31,111,214,0.08);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 800; font-size: 16px; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topbar-right .user { color: var(--text-sub); }

.container { max-width: 1280px; margin: 0 auto; padding: 16px 20px; }
.layout { display: flex; gap: 24px; align-items: flex-start; }
.main { flex: 1; min-width: 0; }
.sidebar { width: 400px; flex-shrink: 0; position: sticky; top: 64px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--text-sub);
  background: #fff; border: 1px solid #e2e8f2; cursor: pointer; transition: all .15s;
}
.tab.active { background: linear-gradient(135deg, #1f6fd6, #7c5cff); color: #fff; border-color: transparent; }
.page-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.page-tab {
  padding: 8px 24px; border-radius: 10px; font-size: 14px; font-weight: 600;
  color: #333; background: #fff; border: 1px solid #e2e8f2; cursor: pointer; transition: all .15s;
}
.page-tab.active { background: linear-gradient(135deg, #1f6fd6, #7c5cff); color: #fff; border-color: transparent; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-box { background: #f7f9fe; border: 1px solid #eef2f8; border-radius: 12px; padding: 14px; }
.stat-box .k { font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.stat-box .v { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-range.active { background: #eaf1fd; border-color: #1f6fd6; color: #1f6fd6; }
@media (max-width: 700px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h2 { font-size: 15px; margin-bottom: 10px; }
.panel { display: none; }
.panel.active { display: block; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid #eef2f8; }
th { color: var(--text-sub); font-weight: 600; font-size: 12px; }
tr:hover td { background: #f8faff; }
.empty { color: var(--text-sub); text-align: center; padding: 18px; font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.group-form { display: flex; gap: 12px; align-items: flex-end; }
.table-scroll { max-height: 380px; overflow-y: auto; overflow-x: auto; }
.table-scroll thead th { position: sticky; top: 0; background: #fff; z-index: 1; }
.center-table th, .center-table td { text-align: center; }
textarea {
  width: 100%; min-height: 70px; padding: 8px 12px; border: 1px solid #dbe2ee;
  border-radius: 8px; font-size: 13px; outline: none; font-family: inherit; resize: vertical;
}
textarea:focus { border-color: var(--primary); }
.hint { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.progress-track { height: 6px; background: #eef2f8; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #1f6fd6, #7c5cff); transition: width .2s; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: #eef4ff; color: var(--primary-dark);
}
.badge.green { background: #e7f8ef; color: #1b8a4b; }
.badge.red { background: #fdeeee; color: #d93025; }
.badge.gray { background: #f1f3f7; color: var(--text-sub); }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1a2333; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 999;
  max-width: 80vw; white-space: pre-wrap; word-break: break-all; text-align: center;
  animation: toast-in .2s;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: #fff; border-radius: 12px; padding: 24px; min-width: 300px; max-width: 90%;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-msg { font-size: 15px; margin-bottom: 20px; color: var(--text); }
.modal-btns { display: flex; justify-content: flex-end; gap: 12px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
}
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ===== 管理后台现代化布局 ===== */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 230px; flex-shrink: 0; background: #fff; border-right: 1px solid #eef2f8;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.admin-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; color: var(--text); padding: 2px 10px 18px; }
.admin-brand-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #1f6fd6, #7c5cff); box-shadow: 0 0 0 4px rgba(31,111,214,.12); }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav .nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: none;
  border-radius: 10px; background: transparent; color: var(--text-sub); font-size: 14px; font-weight: 500;
  text-align: left; cursor: pointer; transition: background .15s, color .15s;
}
.admin-nav .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.admin-nav .nav-item:hover { background: #f5f7fb; color: var(--text); }
.admin-nav .nav-item.active { background: linear-gradient(135deg, #1f6fd6, #7c5cff); color: #fff; box-shadow: 0 6px 16px rgba(31,111,214,.28); }
.admin-sidebar-foot { margin-top: auto; padding-top: 14px; }
.admin-main { flex: 1; min-width: 0; padding: 24px 28px; }
.admin-panel h2 { font-size: 19px; font-weight: 800; margin-bottom: 18px; }
.admin-section { margin-top: 24px; }
.admin-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }

.sys-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.stat-card {
  background: #fff; border: 1px solid #eef2f8; border-radius: 14px; padding: 18px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(31,111,214,.13); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-body { min-width: 0; }
.stat-label { font-size: 13px; color: var(--text-sub); margin-bottom: 2px; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }

.feature { background: #fff; border: 1px solid #eef2f8; border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.feature h3 { font-size: 12px; color: var(--text-sub); font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .3px; }
.feature p { font-size: 14px; color: var(--text); font-weight: 600; }

.admin-main .table-scroll { border: 1px solid #eef2f8; border-radius: 12px; background: #fff; }
.admin-main .table-scroll thead th { background: #f8fafd; color: #5b6b85; }
.admin-main table th { padding: 10px 12px; white-space: nowrap; }
.admin-main table td { padding: 10px 12px; }
.admin-main #usersPager, .admin-main #tasksPager, .admin-main #codesPager,
.admin-main #loginsPager, .admin-main #visitorsPager { margin-top: 14px; }

.code-gen-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; padding: 14px; background: #fff; border: 1px solid #eef2f8; border-radius: 12px; }
.code-gen-bar .input { padding: 8px 12px; border: 1px solid #dbe2ee; border-radius: 8px; font-size: 13px; outline: none; }
.code-gen-bar .input-sm { width: 90px; }
.code-result { font-family: monospace; font-size: 15px; font-weight: 700; color: #1b8a4b; white-space: pre-wrap; word-break: break-all; }

.advert-cols { display: grid; grid-template-columns: 1fr 1.5fr; gap: 20px; align-items: start; }
.advert-col-main { min-width: 0; }
.advert-col-side { min-width: 0; }
.advert-col-side .admin-section { margin-top: 0; }
.bot-media-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 14px; background: #fff; border: 1px solid #eef2f8; border-radius: 12px; margin-bottom: 8px; }
.bot-schedule-bar { grid-template-columns: 140px minmax(0, 1fr) auto; }
.bot-media-bar input[type="file"] { max-width: 100%; font-size: 12px; }
.bot-media-bar .input, .bot-btn-fields .input { width: 100%; box-sizing: border-box; padding: 8px 12px; border: 1px solid #dbe2ee; border-radius: 8px; font-size: 13px; outline: none; }
.bot-btn-bar { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: #fff; border: 1px solid #eef2f8; border-radius: 12px; margin-bottom: 16px; }
#channelBtnTable td { word-break: break-all; }
#channelBtnTable .row-no { padding: 6px 8px; border: 1px solid #dbe2ee; border-radius: 6px; font-size: 13px; }
.bot-btn-fields { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 10px; align-items: center; }
@media (max-width: 1200px) { .advert-cols { grid-template-columns: 1fr; } }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h3 { margin-bottom: 0; }
.mode-group { display: flex; gap: 14px; }
.mode-group label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.advert-params { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.param-row { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #eef2f8; border-radius: 8px; padding: 8px 10px; }
.param-row label { font-size: 13px; color: var(--text-sub); white-space: nowrap; }
.param-row input { width: 56px; }
.param-row span { font-size: 13px; color: var(--text-sub); }
@media (max-width: 1200px) { .advert-params { grid-template-columns: 1fr; } }

.admin-panel.readonly button, .admin-panel.readonly input, .admin-panel.readonly select, .admin-panel.readonly textarea { pointer-events: none; opacity: .55; }
.admin-panel.readonly [id$="Pager"] button { pointer-events: auto; opacity: 1; }

@media (max-width: 1100px) { .sys-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-sidebar-foot { margin-top: 10px; }
  .admin-main { padding: 16px; }
}
@media (max-width: 640px) { .sys-grid { grid-template-columns: 1fr; } }

/* ===== 用户界面美化 ===== */
.plan-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eef4ff; color: var(--primary-dark);
  margin-right: 8px; white-space: nowrap;
}
.plan-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.plan-badge.green { background: #e7f8ef; color: #1b8a4b; }
.plan-badge.warn { background: #fdf3e3; color: #e6a23c; }
.plan-badge.red { background: #fdeeee; color: #d93025; }
.activate-group { display: flex; align-items: center; gap: 6px; }
.activate-group input {
  width: 120px; padding: 6px 10px; border-radius: 8px; border: 1px solid #dbe2ee;
  font-size: 13px; outline: none; transition: border .15s;
}
.activate-group input:focus { border-color: var(--primary); }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: var(--text);
}
.user-chip::before {
  content: ''; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #1f6fd6, #7c5cff); box-shadow: 0 2px 6px rgba(31,111,214,.3);
}

.card h2 { display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ''; width: 4px; height: 16px; border-radius: 2px; background: linear-gradient(135deg, #1f6fd6, #7c5cff); flex-shrink: 0; }

.main .table-scroll { border: 1px solid #eef2f8; border-radius: 12px; background: #fff; }
.main .table-scroll thead th { background: #f8fafd; color: #5b6b85; }

.badge::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: middle; }

.progress-fill { background: linear-gradient(90deg, #1f6fd6, #7c5cff); background-size: 200% 100%; animation: progress-shine 1.6s linear infinite; }
@keyframes progress-shine { from { background-position: 200% 0; } to { background-position: 0 0; } }

.btn-green { background: linear-gradient(135deg, #1b8a4b, #2ecc71); }
.btn-warn { background: linear-gradient(135deg, #e6a23c, #f0b65a); }
.btn-red { background: linear-gradient(135deg, #d93025, #ef5a4e); }

@media (max-width: 720px) {
  .topbar-right { flex-wrap: wrap; }
  .activate-group { width: 100%; }
  .activate-group input { flex: 1; }
}
