/* ============================================================
   9月 vs 10月 运营数据环比分析 · 在线看板样式
   浅色主题 · 无外部依赖 · 适配打印
   ============================================================ */

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e5e9f0;
  --bg: #f2f5fa;
  --card: #ffffff;
  --up: #dc2626;   /* 上涨 = 红 */
  --down: #16a34a; /* 下跌 = 绿 */
  --flat: #64748b;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 页头 ---------- */
.topbar {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  padding: 22px 0;
  box-shadow: 0 2px 10px rgba(30, 58, 138, 0.18);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
}

.actions { display: flex; gap: 10px; }

.btn {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

.btn:hover { background: rgba(255, 255, 255, 0.28); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; }

/* ---------- 页签导航 ---------- */
.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(242, 245, 250, 0.94);
  backdrop-filter: blur(6px);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover { border-color: #93c5fd; color: var(--blue); }

.tab-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* ---------- 主体 ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.22s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel {
  background: var(--card);
  border: 1px solid #edf1f7;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.panel-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  padding-left: 10px;
  border-left: 4px solid var(--blue);
  line-height: 1.3;
}

/* ---------- KPI 卡片 ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid #edf1f7;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.kpi-label { font-size: 13px; color: var(--muted); }

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  margin: 4px 0 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.kpi-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  flex-wrap: wrap;
}

.kpi-sep { color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-note { margin-top: 8px; font-size: 12px; color: #94a3b8; }

/* ---------- 涨跌与徽标 ---------- */
.trend { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trend.up { color: var(--up); }
.trend.down { color: var(--down); }
.trend.flat { color: var(--flat); font-weight: 500; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

/* ---------- 数据表 ---------- */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child { text-align: left; }

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table tbody tr:hover { background: #f8fbff; }

.data-table .total-row { background: #eff6ff; font-weight: 700; }
.data-table .total-row td { border-top: 2px solid #bfdbfe; border-bottom: none; }
.data-table .total-row:last-child td { border-bottom: none; }

/* ---------- 备注 ---------- */
.note {
  margin-top: 12px;
  font-size: 13px;
  color: #7c2d12;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.7;
}

/* ---------- 图表 ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 11px; fill: #64748b; }
.chart .val { font-size: 10px; fill: #475569; }
.chart rect { transition: opacity 0.15s ease; }
.chart rect:hover { opacity: 0.82; }

/* ---------- 环形图 ---------- */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.donut-box { flex: none; }

.donut { width: 220px; height: 220px; display: block; }
.donut-num { font-size: 26px; font-weight: 700; fill: #1e293b; }

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 260px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 2px;
  font-size: 13px;
  border-bottom: 1px dashed #eef2f7;
}

.legend li:last-child { border-bottom: none; }
.legend li b { margin-left: auto; font-variant-numeric: tabular-nums; color: #334155; }

.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ---------- 页脚 ---------- */
.footer {
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  padding: 8px 24px 32px;
}

.footer p { margin: 4px 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .kpi-value { font-size: 22px; }
  .container { padding: 16px 14px 40px; }
  .tabs { padding: 10px 14px; }
  .panel { padding: 14px 14px; }
}

/* ---------- 打印 ---------- */
@media print {
  .topbar { box-shadow: none; }
  .tabs, .actions, .footer { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .tab-panel { display: block !important; page-break-after: always; }
  .tab-panel:last-child { page-break-after: auto; }
  .panel, .kpi-card { box-shadow: none; border: 1px solid #e2e8f0; break-inside: avoid; }
  .kpi-card:hover { transform: none; }
}

/* ============================================================
   数据管理后台（admin.php）
   ============================================================ */

.muted { color: #94a3b8; font-weight: 400; }

.admin-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-bar .links { display: flex; gap: 10px; }
.admin-bar .links a, .admin-bar .links button {
  font-size: 13px; color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.14); padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-family: inherit;
}
.admin-bar .links a:hover, .admin-bar .links button:hover { background: rgba(255,255,255,.26); }

.sheet-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.sheet-nav a {
  text-decoration: none; font-size: 14px; color: #334155; background: #fff;
  border: 1px solid #e5e9f0; padding: 7px 16px; border-radius: 999px;
}
.sheet-nav a.active { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 600; }

.flash { border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.flash.error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.flash.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

/* ---------- 期间管理 ---------- */
.period-form { display: none; }
.period-list { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.period-table { border-collapse: collapse; font-size: 13px; }
.period-table th {
  text-align: left; font-weight: 600; color: #334155; padding: 6px 8px;
  border-bottom: 2px solid #e5e9f0; white-space: nowrap;
}
.period-table td { padding: 6px 8px; border-bottom: 1px solid #eef2f7; }
.period-table .col-act { white-space: nowrap; }
.period-input {
  padding: 6px 8px; border: 1px solid #dde5ee; border-radius: 6px;
  font-size: 13px; font-family: inherit; background: #fff;
}
.period-input[type=number] { width: 92px; }
.period-label-cell { color: #64748b; font-variant-numeric: tabular-nums; white-space: nowrap; }

.period-add {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: #f8fafc; border: 1px dashed #d8e0ea; border-radius: 10px;
}
.period-add-label { font-size: 13px; color: #334155; font-weight: 600; }

.btn-mini {
  border: 1px solid #d8e0ea; background: #fff; color: #334155; padding: 6px 12px;
  border-radius: 6px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.btn-mini:hover { border-color: #93c5fd; color: #2563eb; }
.btn-mini.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-mini.primary:hover { background: #1d4ed8; color: #fff; }
.btn-mini.danger { color: #b91c1c; border-color: #fecaca; }
.btn-mini.danger:hover { background: #fef2f2; border-color: #f87171; }

/* ---------- 编辑表格 ---------- */
.edit-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.edit-table th {
  background: #f8fafc; color: #334155; font-weight: 600; padding: 8px 6px;
  border-bottom: 2px solid #e5e9f0; text-align: left; white-space: nowrap;
}
.edit-table td { padding: 5px 6px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.edit-table input[type=text] {
  width: 100%; min-width: 72px; padding: 6px 8px; border: 1px solid #dde5ee;
  border-radius: 6px; font-size: 13px; font-family: inherit;
}
.edit-table input[type=text]:focus {
  outline: none; border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.edit-table tr.total-row-edit { background: #f6faff; font-weight: 700; }
.edit-table tr.total-row-edit td { border-top: 2px solid #bfdbfe; border-bottom: none; }
.edit-table .col-flag { white-space: nowrap; text-align: center; color: #64748b; }
.edit-table .col-flag label { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; cursor: pointer; }
.edit-table .th-derived { color: #64748b; background: #f1f5f9; }
.edit-table td.derived { color: #334155; font-variant-numeric: tabular-nums; white-space: nowrap; background: #fbfdff; }

.auto-tag {
  display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 4px;
  background: #e0edff; color: #2563eb; font-size: 10px; font-weight: 600;
  vertical-align: middle; line-height: 16px;
}

/* ---------- 表单操作区 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn-primary {
  border: 0; background: #2563eb; color: #fff; padding: 9px 22px;
  border-radius: 8px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-plain {
  border: 1px solid #d8e0ea; background: #fff; color: #334155; padding: 9px 16px;
  border-radius: 8px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.btn-plain:hover { border-color: #93c5fd; color: #2563eb; }
.hint { font-size: 12px; color: #64748b; margin-top: 10px; line-height: 1.9; }
.hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.note-box { margin-top: 16px; }
.note-box label { display: block; font-size: 13px; color: #334155; margin-bottom: 6px; }
.note-box textarea {
  width: 100%; min-height: 62px; padding: 9px 11px; border: 1px solid #dde5ee;
  border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical;
}

/* ---------- 自动行 / 自动列（转化率、公式行） ---------- */
.edit-table tr.auto-row td { background: #f7fbff; }
.edit-table tr.auto-row td.derived { background: #f2f8ff; }
.auto-name { font-weight: 600; color: #334155; }
