:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2733;
  --muted: #6b7686;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.12), 0 4px 8px rgba(15,23,42,.06);
  --radius: 12px;
  --transition: .2s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}

/* 背景模式：白天（默认）/ 黑夜（浅黑）/ 护眼（淡紫） */
body.theme-night {
  --bg: #20242b;
  --card: #2a2f37;
  --border: #3b424d;
  --text: #e6e9ee;
  --muted: #9aa3b0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,.25);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.35);
}
body.theme-eye {
  --bg: #fdf6e3;
  --card: #ece7f6;
  --border: #e5d9b8;
  --shadow-sm: 0 1px 3px rgba(120,100,60,.08);
  --shadow-md: 0 4px 12px rgba(120,100,60,.10);
  --shadow-lg: 0 12px 32px rgba(120,100,60,.14);
}
body.theme-eye .data-table th { background: #e8e1f5; color: #5b626e; }
body.theme-eye .modal { background: #ece7f6; }
body.theme-eye .empty { background: #ece7f6; }
body.theme-eye input[type="text"],
body.theme-eye input[type="number"],
body.theme-eye input[type="date"],
body.theme-eye select {
  background: #f5f2fc;
}
body.theme-eye .btn { background: #f5f2fc; }
body.theme-eye .btn:hover { background: #ede8f8; }
body.theme-eye .btn.primary { background: var(--primary); }
body.theme-eye .tab { background: #f5f2fc; }
body.theme-night .data-table th { background: #262b33; color: #9aa3b0; }
body.theme-night .data-table tbody tr:hover { background: #30363f; }
body.theme-night .data-table th.col-manual,
body.theme-night .data-table th.col-computed { color: #9aa3b0; }
body.theme-night input[type="text"],
body.theme-night input[type="number"],
body.theme-night input[type="date"],
body.theme-night select {
  background: #1f242b;
  color: var(--text);
}
body.theme-night .btn { background: #2a2f37; }
body.theme-night .btn:hover { background: #333a44; }
body.theme-night .btn.primary { background: var(--primary); }
body.theme-night .tab { background: #2a2f37; }
body.theme-night .tab.active { background: #1f3a5f; color: #9cc4ff; }
body.theme-night .modal { background: #2a2f37; }
body.theme-night #nav button:hover { background: #333a44; }
body.theme-night .empty { background: #2a2f37; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px 10px 146px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.tz-clock {
  margin-left: auto;
  margin-right: 130px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--muted);
}
.tz-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .16);
}
.tz-label {
  font-weight: 600;
}
.tz-sep {
  opacity: .5;
}
.tz-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .2px;
}

.brand {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#nav { display: flex; gap: 6px; flex-wrap: wrap; }
#nav button {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  font-family: inherit;
  transition: all var(--transition);
}
#nav button:hover { background: #eef2f7; color: var(--primary); }
body.theme-night #nav button:hover { background: #333a44; color: #9cc4ff; }
#nav button.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }

#content { max-width: 1700px; margin: 20px auto; padding: 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.row h2 { margin: 0; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input[type="text"], input[type="number"], input[type="date"], select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.btn:hover { background: #f0f3f8; box-shadow: var(--shadow-sm); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.btn.primary:hover { box-shadow: 0 4px 14px rgba(37,99,235,.35); transform: translateY(-1px); }
.btn.danger { color: var(--danger); border-color: #f3c6c6; }
.btn.danger:hover { background: #fdf0f0; border-color: var(--danger); box-shadow: 0 2px 8px rgba(220,38,38,.15); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.loading { opacity: .7; cursor: wait; pointer-events: none; }
.btn.loading::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  margin-right: 6px;
  vertical-align: text-bottom;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.import-status { margin: 8px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.import-status.ok { color: #15803d; }
.import-status.err { color: var(--danger); }

.hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.budget-ro { display: inline-block; min-width: 140px; padding: 7px 10px; background: #f0f2f6; border-radius: var(--radius); color: var(--text); font-variant-numeric: tabular-nums; }
.empty {
  color: var(--muted);
  padding: 40px 30px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 15px;
}
.empty-icon { font-size: 32px; display: block; margin-bottom: 8px; opacity: .5; }
.account-region { margin-bottom: 20px; }
.account-region .section-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
  background: linear-gradient(90deg, #eef2f7, #f8fafc);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 8px 12px;
  transition: box-shadow var(--transition), background var(--transition);
}
.account-region .section-title:hover {
  background: linear-gradient(90deg, #e5edf7, #f2f7fc);
  box-shadow: 0 2px 10px rgba(37,99,235,.12);
}
body.theme-night .account-region .section-title {
  color: #e5e7eb;
  background: linear-gradient(90deg, #262b33, #2a303a);
}
body.theme-night .account-region .section-title:hover {
  background: linear-gradient(90deg, #2b323c, #303843);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.acct-range { font-weight: 400; font-size: 12.5px; color: #6b7280; margin-left: 10px; }
body.theme-night .acct-range { color: #9aa3b0; }
.region-sub { color: var(--muted); font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
.region-scroll { max-height: 460px; overflow: auto; }
/* 账户区内表格：让滚动发生在 .region-scroll，避免 .table-wrap 成为独立滚动容器而让 sticky 表头失效 */
.region-scroll .table-wrap { overflow: visible; margin: 0; box-shadow: none; }
/* 看板账户区：表头固定，纵向滚动数据时表头吸顶不随滚动条移动 */
.data-table.overview-table { border-collapse: separate; border-spacing: 0; }
.data-table.overview-table thead th { position: sticky; top: 0; z-index: 3; }
.account-card { position: relative; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 44px 14px 14px; margin-bottom: 12px; background: var(--card); transition: box-shadow .2s ease, transform .2s ease, opacity .2s ease; }
.account-card.dragging { opacity: .65; border-style: dashed; box-shadow: 0 10px 26px rgba(37,99,235,.18); transform: scale(1.015); cursor: grabbing; z-index: 5; }
.acct-handle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: grab; color: var(--muted); font-size: 20px; user-select: none; }
.acct-handle:active { cursor: grabbing; }
.account-card .acct-grid { display: grid; grid-template-columns: 1.3fr 2.3fr 1.3fr auto auto 1.5fr; gap: 10px 12px; }
.account-card .acct-grid label { min-width: 0; }
.account-card .switch-label { margin-top: 20px; }
.account-card input:not([type="checkbox"]) {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.account-card input:not([type="checkbox"]):focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.account-card input.acct-lookback,
.account-card input.acct-interval { width: 90px; }
.account-card .acct-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.account-card [data-acct-status] { margin-top: 8px; }
.loading {
  color: var(--muted);
  padding: 30px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.err { color: var(--danger); padding: 12px; }

.table-wrap { overflow-x: auto; margin: 10px 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
/* 广告管理：把最右「操作」列固定在右侧，横向滚动时按钮始终完整可见，不被容器裁切 */
.table-wrap th.col-action,
.table-wrap td.action-cell {
  position: sticky;
  right: 0;
  background: #fff;
  z-index: 2;
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, .12);
}
.table-wrap th.col-action { background: linear-gradient(180deg, #f8fafc, #eef2f7); }
body.theme-night .table-wrap th.col-action,
body.theme-night .table-wrap td.action-cell { background: #1f2426; }
body.theme-eye .table-wrap th.col-action,
body.theme-eye .table-wrap td.action-cell { background: #f5f2fc; }
/* 广告管理：table-layout fixed + 明确列宽，彻底消除横向滚动 */
.ads-manage-table { table-layout: fixed; width: 100%; }
.ads-manage-table th,
.ads-manage-table td { white-space: normal; overflow: hidden; text-overflow: ellipsis; }
.ads-manage-table th:nth-child(1) { width: 12%; }
.ads-manage-table th:nth-child(2) { width: 15%; }
.ads-manage-table th:nth-child(3) { width: 25%; }
.ads-manage-table th:nth-child(4) { width: 10%; }
.ads-manage-table th:nth-child(5) { width: 8%; }
.ads-manage-table th:nth-child(6) { width: 7%; }
.ads-manage-table th:nth-child(7) { width: 8%; }
.ads-manage-table th:nth-child(8) { width: 4%; }
.ads-manage-table th:nth-child(9) { width: 11%; }
.ads-manage-table th:nth-child(10), .ads-manage-table td.action-cell { width: 130px; }
.ads-manage-table .ad-name { white-space: normal; word-break: break-word; }
.ads-manage-table td:nth-child(1),
.ads-manage-table td:nth-child(2),
.ads-manage-table td:nth-child(3) { text-overflow: clip; word-break: break-word; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}
.data-table th {
  color: #64748b;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: .02em;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border-bottom: 2px solid var(--border);
}
.data-table th.col-manual,
.data-table th.col-computed { color: #64748b; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: #f0f5ff; }
body.theme-night .data-table tbody tr:hover { background: #30363f; }
.data-table td.metric-val {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 11px 8px;
  white-space: nowrap;
  text-align: center;
}
.data-table th.col-ad { min-width: 60px; }
.data-table th.col-data { width: 92px; text-align: center; }
/* 综合看板表格：列更多，收紧列宽避免横向滚动（不影响数据录入表格） */
.data-table.overview-table th.col-ad { width: 160px; }
.data-table.overview-table th.col-data { width: 78px; text-align: center; }
.data-table.overview-table .ad-name {
  white-space: nowrap;
}
.data-table.overview-table .ad-sub {
  white-space: normal;
}
.data-table.overview-table .decision-detail,
.data-table.overview-table .decision-detail .reasons,
.data-table.overview-table .decision-detail .sug { white-space: normal; }
.data-table.overview-table .decision-detail .reasons > div { white-space: pre-line; }

.ad-name { font-weight: 600; cursor: pointer; transition: color var(--transition); }
.ad-name:hover { color: var(--primary); text-decoration: underline; }
.ad-cell { display: flex; align-items: center; gap: 6px; }
.ad-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.camp-eye { cursor: pointer; font-size: 12px; color: var(--muted); opacity: .7; transition: all var(--transition); }
.camp-eye:hover { color: var(--primary); opacity: 1; }
.camp-eye.open { color: var(--primary); opacity: 1; }

/* ---------- 登录界面 ---------- */
.login-screen { display: flex; position: fixed; inset: 0; z-index: 9999; }
.login-left {
  flex: 0 0 55%;
  background: linear-gradient(140deg, #0b1f3a, #13294b 55%, #0d2138);
  color: #fff;
  padding: 48px 56px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.login-left::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 400px at 20% 15%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(500px 300px at 80% 85%, rgba(56,189,248,.12), transparent 60%);
  pointer-events: none;
}
.login-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 26px;
}
.login-title { font-size: 34px; font-weight: 700; letter-spacing: .01em; margin: 0 0 10px; position: relative; }
.login-sub { color: #aebbd0; font-size: 15px; margin: 0 0 42px; position: relative; }
.login-points { list-style: none; margin: 0; padding: 0; position: relative; }
.login-points li {
  display: flex; align-items: flex-start; gap: 10px;
  color: #cfd8e5; font-size: 14px; line-height: 1.6; margin-bottom: 14px;
}
.login-points li svg { flex: 0 0 auto; margin-top: 3px; color: #7fb3f5; }
.login-copyright { position: absolute; left: 56px; bottom: 26px; color: #7e8aa0; font-size: 13px; }
.login-right { flex: 1; background: #f2f4f8; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 12px 36px rgba(0,0,0,.10); padding: 34px 32px; width: 380px; max-width: 100%; position: relative; }
.login-card h2 { font-size: 22px; font-weight: 700; color: #1f2937; margin: 0 0 4px; }
.login-card-sub { color: #6b7280; font-size: 14px; margin: 0 0 22px; }
.login-field { display: flex; align-items: center; gap: 8px; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0 12px; height: 44px; margin-bottom: 14px; background: #fff; }
.login-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.login-ico { color: #9ca3af; display: flex; align-items: center; }
.login-field input { border: none; outline: none; flex: 1; min-width: 0; padding: 0 0 0 4px; box-shadow: none; font-size: 15px; line-height: 1.2; caret-color: var(--primary); color: #1f2937; background: transparent; }
.login-field input::placeholder { color: #8a95a6; opacity: 1; }
.login-remember { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: #3f4753; margin: 2px 0 20px; cursor: pointer; user-select: none; }
.login-remember input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.login-remember .rm-m { font-weight: 400; color: #8a95a6; }
.login-remember .rm-d { color: #9aa3b0; font-size: 12px; margin-left: 2px; }
.login-btn { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background var(--transition), transform var(--transition); }
.login-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.login-card-foot { text-align: center; color: #9ca3af; font-size: 12.5px; margin: 16px 0 0; }
/* 右上角「切换微信扫码」角标（紫色斜切角旗 + 白色二维码图标） */
.login-switch-corner {
  position: absolute; top: 0; right: 0;
  width: 144px; height: 112px;
  border: none; cursor: pointer;
  background: transparent;
  padding: 0;
  overflow: hidden;
  border-top-right-radius: 14px;
  z-index: 3;
}
.login-switch-corner .corner-bg {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--primary);
  clip-path: polygon(0 0, 100% 0, 100% 74%, 44% 0);
  transition: background var(--transition);
}
.login-switch-corner:hover .corner-bg { background: var(--primary-dark); }
.login-switch-corner svg {
  position: absolute; top: 20px; right: 20px;
  width: 34px; height: 34px;
}
.login-switch-corner.corner-user svg { top: 10px; right: 10px; width: 44px; height: 44px; }
/* 登录面板容器：账号 / 微信两套内容切换 */
.login-card { min-height: 300px; }
.login-panel { transition: opacity var(--transition); }
.login-wechat-panel { display: flex; flex-direction: column; align-items: center; padding-top: 12px; }
.wechat-title { font-size: 22px; font-weight: 700; color: #1f2937; margin: 0 0 22px; }
.wechat-qr { border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.wechat-qr svg { display: block; }
.wechat-tip { color: #6b7280; font-size: 14px; margin: 20px 0 0; }
.wechat-back { margin-top: 26px; background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.wechat-back:hover { background: #f5f8ff; transform: translateY(-1px); }

.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; transition: all var(--transition); }
.s-active { background: #e7f6ec; color: var(--ok); }
.s-paused { background: #fdf1e3; color: var(--warn); }
.s-closed { background: #f0f2f5; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition);
  animation: badgeIn .25s ease;
}
@keyframes badgeIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
.badge.ok { background: #e7f6ec; color: var(--ok); border-color: #b4e4c4; }
.badge.warn { background: #fdf1e3; color: var(--warn); border-color: #f5d9a0; }
.badge.danger { background: #fdeaea; color: var(--danger); border-color: #f3b8b8; }
.badge.off { background: #f0f2f5; color: var(--muted); font-weight: 400; border-color: var(--border); }
.badge.na { background: transparent; color: #c0c7d1; }

.decision { margin-bottom: 8px; }
.decision:last-child { margin-bottom: 0; }
.decision-top { display: flex; align-items: center; justify-content: center; gap: 4px; }
.badge-wrap { position: relative; display: inline-flex; align-items: center; }
.decision-eye {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  padding: 1px 4px;
  color: var(--muted);
  line-height: 1;
  border-radius: 4px;
  transition: all var(--transition);
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
}
.decision-eye:hover { color: var(--primary); background: #eef2f7; }
.decision-eye.open { color: var(--primary); }
.decision-detail { display: none; }
.decision-detail.open { display: block; text-align: center; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.sug { color: var(--primary); font-size: 12.5px; margin-top: 3px; }
.reasons { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.5; }
.dim { color: var(--muted); }
.data-table td.metric-val.val-trigger { color: var(--danger); font-weight: 700; }
.tag { display: inline-block; background: #eaf1fe; color: var(--primary); border-radius: 4px; padding: 1px 6px; font-size: 11px; }

.window-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: flex-end; gap: 16px; position: sticky; top: var(--topbar-h, 58px); z-index: 9; box-shadow: var(--shadow-md); }
#overview.ov-refreshing::before {
  content: '正在同步数据…';
  position: sticky;
  top: var(--topbar-h, 58px);
  display: block;
  width: fit-content;
  margin: 0 auto 10px;
  padding: 5px 14px;
  background: #eaf1fe;
  color: var(--primary);
  border: 1px solid #cdddfa;
  border-radius: 999px;
  font-size: 12.5px;
  z-index: 8;
}
.window-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.window-dates { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; justify-content: center; }
.date-sep { color: var(--muted); padding-bottom: 8px; }
.range-note { color: var(--muted); margin: 4px 0 10px; }
.col-legend { color: var(--muted); font-size: 12.5px; margin: -2px 0 10px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.dot-manual { background: #1d4ed8; }
.dot-computed { background: #b45309; }
.dot-attr { background: #c0c7d1; }
.section-title { margin: 18px 0 10px; font-size: 16px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--muted);
  transition: all var(--transition);
}
.tab.active { border-color: var(--primary); color: var(--primary); background: #eef4ff; font-weight: 600; }

.batch-table input:not(.in-notes), .batch-table select { width: 80px; padding: 6px 8px; }
.batch-table .in-notes { width: 200px; }
.batch-table td:first-child { min-width: 120px; }
.batch-table input[type="number"]::-webkit-outer-spin-button,
.batch-table input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.batch-table input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.single-row { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.single-row #single-ad { width: 367px; }
.single-row #single-date { width: 200px; }
.single-row .single-half { width: 110px; }
.single-table td input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.single-table td input:hover { border-color: var(--primary-dark); }
.single-table td input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.single-table td .d-notes { width: 200px; }
.single-table input[type="number"]::-webkit-outer-spin-button,
.single-table input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.single-table input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.single-table th:first-child { border-top-left-radius: 8px; }
.single-table th:last-child { border-top-right-radius: 8px; }
.single-table tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
.single-table tbody tr:last-child td:last-child { border-bottom-right-radius: 8px; }
.clear-row-btn {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.clear-row-btn:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}
.single-wrap { min-height: 300px; }
#batch-table-wrap { min-height: 300px; }

.ref-table td { white-space: normal; }
.ref-table .ref-name { font-weight: 600; white-space: nowrap; }
.ref-table .ref-input { width: 260px; }

.currency-fields { display: flex; gap: 18px; flex-wrap: wrap; }
.currency-fields label { min-width: 0; }
#set-name { width: 190px; }
#set-code { width: 90px; }
#set-symbol { width: 70px; }
#set-code, #set-symbol { background: #f4f6f9; color: var(--muted); }
#set-code:focus, #set-symbol:focus { outline: none; border-color: var(--border); }
.currency-picker { position: relative; display: inline-block; }
.currency-picker input { padding-right: 30px; }
.currency-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: all var(--transition);
}
.currency-toggle:hover { color: var(--primary); background: #eef2f7; }
.currency-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  min-width: 190px;
}
.currency-option { padding: 7px 12px; cursor: pointer; font-size: 14px; transition: all var(--transition); }
.currency-option:hover { background: #eef4ff; color: var(--primary); }
.currency-option.disabled { color: var(--muted); cursor: default; }
body.theme-night .currency-option:hover { background: #333a44; color: #9cc4ff; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 50;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 0;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-inner { padding: 22px; }
.modal h3 {
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
  line-height: 1;
  border-radius: 6px;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--danger); background: #fdeaea; }
.form-card { display: flex; flex-direction: column; gap: 14px; }

.rule-card .rule-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.rule-card h3 { margin: 0 0 4px; }
.rule-block { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.rule-block h4 { margin: 0 0 10px; font-size: 14px; }
.rule-fixed { margin: 6px 0; padding-left: 20px; line-height: 1.9; }
.rule-fixed ul { margin: 2px 0; }
.switch-label { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.switch-label input { width: 16px; height: 16px; }
.cond-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.cond-row select { min-width: 150px; }
.cond-row input { width: 110px; }
.cond-unit { color: var(--muted); min-width: 14px; }
.cond-drag {
  cursor: grab;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  user-select: none;
  line-height: 1;
  transition: color var(--transition);
}
.cond-drag:active { cursor: grabbing; }
.cond-row.dragging {
  opacity: .55;
  border: 1px dashed var(--primary);
  background: #f0f5ff;
  border-radius: 8px;
}
body.theme-night .cond-row.dragging { background: #333a44; }
.rule-card input[data-rule-verdict],
.rule-card input[data-rule-fail] {
  width: 12.5%;
  min-width: 150px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2733;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 100;
  max-width: 80vw;
  box-shadow: var(--shadow-md);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }
