/* 数据BI看板 —— 浅色专业主题 */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e6e9f0;
  --border-strong: #d4d9e3;
  --text: #1a2233;
  --text-2: #5b6579;
  --text-3: #8f98aa;
  --primary: #2f6bff;
  --primary-soft: #eaf0ff;
  --green: #12b886;
  --green-soft: #e6f8f2;
  --red: #f0483e;
  --red-soft: #ffecea;
  --orange: #f59f00;
  --orange-soft: #fff6e5;
  --purple: #7c5cff;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 4px 16px rgba(20, 30, 60, .06);
  --shadow-lg: 0 8px 32px rgba(20, 30, 60, .12);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; letter-spacing: -.2px; }
.brand-dot {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}

.tabs { display: flex; gap: 3px; background: #eef1f6; padding: 3px; border-radius: 9px; }
.tab {
  padding: 6px 18px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 550; color: var(--text-2);
  border: none; background: transparent; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(20,30,60,.1); }
.tab-badge {
  font-size: 10px; font-weight: 600; line-height: 1;
  padding: 2px 6px; border-radius: 999px;
  background: var(--orange-soft); color: #b57900;
  border: 1px solid #ffe0a3;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.refresh-info { font-size: 12px; color: var(--text-3); text-align: right; line-height: 1.5; }
.refresh-info .ri-row { display: flex; justify-content: flex-end; gap: 6px; align-items: baseline; }
.refresh-info .ri-label { color: var(--text-3); font-weight: 500; }
.refresh-info b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 开发中占位 ---------- */
.dev-placeholder { padding: 10px 0 40px; }
.dev-card {
  background: var(--card); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 60px 24px; text-align: center;
}
.dev-icon { font-size: 52px; opacity: .75; margin-bottom: 14px; }
.dev-title { font-size: 18px; font-weight: 650; color: var(--text); margin-bottom: 10px; }
.dev-desc { font-size: 13px; color: var(--text-3); line-height: 1.7; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 7px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--card); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 550; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: inherit;
}
.btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2559d8; border-color: #2559d8; color: #fff; }
.btn-danger { color: var(--red); border-color: #f3c3bf; }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eef1f6; color: var(--text); }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 布局 ---------- */
.wrap { max-width: 1600px; margin: 0 auto; padding: 20px 24px 60px; }

.filters {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: #f1f4f9; border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 7px; white-space: nowrap;
}
.filter-arrow { color: var(--text-3); font-size: 13px; }
.record-count {
  font-size: 12px; color: var(--text-3); font-weight: 500;
  background: #f1f4f9; border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 7px; white-space: nowrap;
}

input[type="date"], input[type="text"], input[type="password"], input[type="number"], select {
  padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--card);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.quick-ranges { display: flex; gap: 4px; }
.chip {
  padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--card); font-size: 12px; cursor: pointer; color: var(--text-2);
  transition: all .15s; user-select: none; font-family: inherit;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.store.active { background: var(--primary-soft); color: var(--primary); border-color: #b9cdff; font-weight: 550; }

/* 时间范围选中标签（日/月/年筛选后展示） */
.range-label {
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); border: 1px solid #b9cdff;
  padding: 4px 10px; border-radius: 7px; white-space: nowrap;
}

/* 日历弹层 */
.calendar-pop {
  position: fixed; z-index: 500;
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 12px; width: 268px;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 13px; font-weight: 600; color: var(--text); }
.cal-nav {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); cursor: pointer; color: var(--text-2); font-size: 14px;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.cal-nav:hover { border-color: var(--primary); color: var(--primary); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--text-3); padding: 2px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-grid-3 { grid-template-columns: repeat(3, 1fr); gap: 5px; }
.cal-cell {
  text-align: center; font-size: 12px; padding: 6px 0; border-radius: 6px;
  cursor: pointer; color: var(--text-2); transition: all .12s; user-select: none;
}
.cal-cell.empty { cursor: default; }
.cal-cell.day:hover, .cal-cell.month:hover, .cal-cell.year:hover {
  background: var(--primary-soft); color: var(--primary);
}
.cal-cell.active { background: var(--primary); color: #fff; font-weight: 600; }
.cal-cell.month, .cal-cell.year { padding: 9px 0; font-size: 13px; }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary);
}
.kpi.c-green::before { background: var(--green); }
.kpi.c-orange::before { background: var(--orange); }
.kpi.c-purple::before { background: var(--purple); }
.kpi-label { font-size: 12px; color: var(--text-3); margin-bottom: 7px; font-weight: 500; }
.kpi-value { font-size: 25px; font-weight: 680; letter-spacing: -.7px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-sub { margin-top: 7px; font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--text-3); }
.kpi-sub .muted { color: var(--text-3); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 14px; font-weight: 620; }
.card-desc { font-size: 12px; color: var(--text-3); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 18px; }

.chart { width: 100%; height: 320px; }
.chart-tall { height: 380px; }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th {
  background: #fafbfd; font-weight: 600; color: var(--text-2); font-size: 12px;
  position: sticky; top: 0; z-index: 2;
}
th:first-child, td:first-child, th.txt, td.txt { text-align: left; }
tbody tr:hover { background: #fafbfd; }
td { font-variant-numeric: tabular-nums; }
.td-strong { font-weight: 600; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600;
}
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-orange { background: var(--orange-soft); color: #b57900; }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #eef1f6; color: var(--text-2); }

/* ---------- 状态 ---------- */
.empty { padding: 50px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .5; }

.banner {
  padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px;
  display: flex; align-items: center; gap: 9px;
}
.banner-warn { background: var(--orange-soft); color: #a06800; border: 1px solid #ffe0a3; }
.banner-err { background: var(--red-soft); color: #c0271d; border: 1px solid #ffcdc8; }
.banner-info { background: var(--primary-soft); color: #1a4fd0; border: 1px solid #c5d7ff; }

/* ---------- Toast ---------- */
#toasts { position: fixed; top: 74px; right: 22px; z-index: 9999; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 11px 16px; box-shadow: var(--shadow-lg);
  font-size: 13px; min-width: 240px; max-width: 400px;
  animation: slidein .22s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--orange); }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #eef2fb 0%, #f6f7fa 45%, #eaf0ff 100%);
  padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 38px 34px; width: 100%; max-width: 372px; border: 1px solid var(--border);
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; letter-spacing: -.3px; }
.login-card .sub { color: var(--text-3); font-size: 13px; margin-bottom: 26px; }
.login-card input { width: 100%; padding: 11px 13px; font-size: 14px; margin-bottom: 13px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.login-err { color: var(--red); font-size: 13px; margin-bottom: 13px; min-height: 18px; }
.login-logo {
  width: 46px; height: 46px; border-radius: 13px; margin-bottom: 18px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 21px; font-weight: 700;
}

/* ---------- 设置页 ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.form-row { display: flex; gap: 14px; margin-bottom: 14px; align-items: flex-start; flex-wrap: wrap; }
.form-field { flex: 1; min-width: 190px; }
.form-field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; font-weight: 550; }
.form-field input, .form-field select { width: 100%; }
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; line-height: 1.45; }

.switch { position: relative; display: inline-block; width: 42px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #ccd2de; border-radius: 23px;
  cursor: pointer; transition: .2s;
}
.slider:before {
  content: ''; position: absolute; height: 17px; width: 17px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(19px); }

.rule-row td { vertical-align: middle; }
.store-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 28, 48, .42);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
}
.modal-head { padding: 17px 22px; border-bottom: 1px solid var(--border); font-weight: 620; font-size: 15px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 9px; }

.checkbox-list { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 11px;
  border: 1px solid var(--border-strong); border-radius: 7px; cursor: pointer; font-size: 13px;
  user-select: none; transition: all .15s;
}
.checkbox-item:hover { border-color: var(--primary); }
.checkbox-item.checked { background: var(--primary-soft); border-color: #b9cdff; color: var(--primary); font-weight: 550; }
.checkbox-item input { display: none; }

.section-title {
  font-size: 13px; font-weight: 620; color: var(--text-2);
  margin: 22px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 12px; }
  .wrap { padding: 16px 14px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .chart { height: 280px; }
}
