/**
 * 亚马逊广告优化日志 - 全局设计系统 (Design System)
 * 遵循 3-Layer Token 规范: Primitives -> Semantics -> Components
 * 专注于高密度专业 SaaS 数据表格、现代表单与清晰的视觉层级
 */

/* ==========================================================================
   1. DESIGN TOKENS (设计令牌)
   ========================================================================== */
:root {
  /* --- 1.1 Primitive Tokens (基础原子令牌) --- */
  /* Slate / Zinc Neutrals */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Brand Blues / Indigos */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;

  /* Semantic Accents */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;

  --rose-50: #fff1f2;
  --rose-100: #ffe4e6;
  --rose-200: #fecdd3;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --rose-700: #be123c;

  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-200: #c7d2fe;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;

  /* --- 1.2 Semantic Tokens (语义化别名 - 兼容旧版变量) --- */
  --bg: var(--slate-50);
  --card: #ffffff;
  --line: var(--slate-200);
  --line-soft: var(--slate-100);
  --line-strong: var(--slate-300);
  --text: var(--slate-900);
  --text-2: var(--slate-600);
  --text-3: var(--slate-400);

  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --primary-soft: var(--blue-50);
  --primary-border: var(--blue-200);

  --green: var(--emerald-600);
  --green-soft: var(--emerald-50);
  --green-border: var(--emerald-200);

  --orange: var(--amber-600);
  --orange-soft: var(--amber-50);
  --orange-border: var(--amber-200);

  --red: var(--rose-600);
  --red-soft: var(--rose-50);
  --red-border: var(--rose-200);

  --gray: var(--slate-500);
  --gray-soft: var(--slate-100);

  /* Elevation & Shadows */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.22);

  /* Fonts */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ==========================================================================
   2. RESET & BASE TYPOGRAPHY
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  background-color: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.03) 0px, transparent 50%);
  color: var(--text);
  font: 13.5px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--slate-100);
  color: var(--slate-700);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
}

/* Custom Sleek Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

/* ==========================================================================
   3. TOPBAR & HEADER
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.brand-text {
  font-weight: 650;
  font-size: 15px;
  color: var(--slate-900);
  letter-spacing: -0.015em;
}

.topbar-mid {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.topbar-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--slate-100);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.field-inline:hover {
  background: #ffffff;
  border-color: var(--slate-300);
}
.field-inline span {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.field-inline select {
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 2px 4px;
  outline: none;
  cursor: pointer;
}

.searchbox {
  display: flex;
  flex: 1;
  max-width: 480px;
  gap: 6px;
  position: relative;
}

.searchbox input {
  flex: 1;
  background: var(--slate-100);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 12px 7px 32px;
  font-size: 13px;
  transition: all 0.15s ease;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>');
  background-repeat: no-repeat;
  background-position: 10px center;
}

.searchbox input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ==========================================================================
   4. NAVIGATION TABS
   ========================================================================== */
.tabs {
  position: sticky;
  top: 60px;
  z-index: 49;
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px 4px 0 0;
}

.tab:hover {
  color: var(--text);
  background: rgba(241, 245, 249, 0.6);
}

.tab.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
  background: transparent;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--slate-100);
  color: var(--slate-600);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: all 0.15s ease;
}

.tab.active .tab-badge {
  background: var(--primary-soft);
  color: var(--primary);
}

.tab-badge.badge-danger {
  background: var(--red);
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(225, 29, 72, 0.3);
}

.tab.active .tab-badge.badge-danger {
  background: var(--red);
  color: #ffffff;
}

/* ==========================================================================
   5. LAYOUT & CARDS
   ========================================================================== */
.wrap {
  max-width: 1260px;
  margin: 0 auto;
  padding: 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.15s ease-out;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.grow {
  flex: 1;
}

.center {
  text-align: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  border-color: var(--slate-300);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(248, 250, 252, 0.5);
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-body {
  padding: 18px;
}

/* Negative Term Cards */
.neg-grid {
  margin-top: 16px;
  align-items: start;
}

.neg-grid .ta {
  min-height: 126px;
}

.neg-grid .card {
  border-top: 3px solid var(--line);
}
.neg-grid .card:nth-child(1) { border-top-color: var(--red); }
.neg-grid .card:nth-child(2) { border-top-color: var(--orange); }
.neg-grid .card:nth-child(3) { border-top-color: var(--indigo-500); }

.tag {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.tag-exact {
  background: var(--red-soft);
  color: var(--rose-700);
  border-color: var(--rose-200);
}
.tag-phrase {
  background: var(--orange-soft);
  color: var(--amber-700);
  border-color: var(--amber-200);
}
.tag-asin {
  background: var(--indigo-50);
  color: var(--indigo-700);
  border-color: var(--indigo-200);
  font-family: var(--font-mono);
}

/* ==========================================================================
   6. FORM CONTROLS & INPUTS
   ========================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 550;
}

.req {
  color: var(--red);
  font-style: normal;
  margin-left: 2px;
}

.inp, .ta, select, input[type=date], input[type=search], input[type=number] {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.inp:hover, .ta:hover, select:hover, input:hover {
  border-color: var(--slate-300);
}

.inp:focus, .ta:focus, select:focus, input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background: #ffffff;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 24px !important;
  cursor: pointer;
}

input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--slate-300);
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  transition: all 0.12s ease;
  position: relative;
  flex-shrink: 0;
}
input[type=checkbox]:hover {
  border-color: var(--primary);
}
input[type=checkbox]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
input[type=checkbox]:checked::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -1px);
}

.ta {
  resize: vertical;
  line-height: 1.6;
  font-family: inherit;
}

.ta-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.hint {
  font-size: 12px;
  color: var(--text-3);
}

.mini-select {
  width: auto;
  padding: 4px 8px;
  font-size: 12px;
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--slate-300);
  border-radius: var(--radius);
  background: var(--slate-50);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropzone:hover, .dropzone.over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dz-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-2);
  font-size: 13px;
}

.dz-inner strong {
  color: var(--text);
  font-weight: 600;
}

.dz-inner u {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.dz-inner u:hover {
  text-decoration: underline;
}

.shot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.shot {
  position: relative;
  width: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.shot:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.shot img {
  width: 100%;
  height: 76px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.shot .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  color: #ffffff;
  cursor: pointer;
  line-height: 22px;
  font-size: 13px;
  padding: 0;
  transition: background 0.12s ease;
}

.shot .del:hover {
  background: var(--red);
}

/* ==========================================================================
   7. KEYWORD FORM TABLE (.kw-table - 填写日志交互表)
   ========================================================================== */
.kw-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  background: #ffffff;
  box-shadow: var(--shadow-xs);
  --kw-first: 220px;
}

.kw-row {
  display: grid;
  grid-template-columns: var(--kw-first) 76px 90px 70px 66px 74px 64px 78px 64px 70px 70px 74px 74px minmax(110px, 1fr) 34px;
  gap: 8px;
  align-items: center;
  padding: 7px 12px;
  min-width: 1260px;
  transition: background 0.12s ease;
}

.kw-row:hover {
  background: rgba(248, 250, 252, 0.8);
}

.kw-head {
  background: var(--slate-50);
  font-size: 11.5px;
  color: var(--slate-600);
  font-weight: 600;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  user-select: none;
}

.kw-head > div {
  white-space: nowrap;
}

.kw-head > div:nth-child(6),
.kw-head > div:nth-child(7),
.kw-head > div:nth-child(8),
.kw-head > div:nth-child(9),
.kw-head > div:nth-child(10),
.kw-head > div:nth-child(11),
.kw-head > div:nth-child(12),
.kw-head > div:nth-child(13) {
  text-align: right;
  padding-right: 4px;
}

/* Resizer Handle */
.kw-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--kw-first) + 12px);
  width: 10px;
  transform: translateX(-50%);
  cursor: col-resize;
  z-index: 3;
  border-left: 2px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kw-resizer:hover, .kw-resizer.dragging {
  border-left-color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}

.kw-row + .kw-row {
  border-top: 1px solid var(--line-soft);
}

.kw-row input, .kw-row select {
  padding: 6px 8px;
  font-size: 12.5px;
  border: 1px solid var(--slate-200);
  border-radius: 5px;
  background: #ffffff;
  min-width: 0;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}

.kw-row input:focus, .kw-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.kw-row input[type=number] {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  padding: 6px;
}

/* Calculated Metric Badges */
.kw-calc {
  font-size: 11.5px;
  color: var(--text-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  background: var(--slate-100);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.12s ease;
}

.kw-calc.empty {
  color: var(--text-3);
  background: transparent;
  border: 0;
}

.kw-calc.good {
  background: var(--emerald-50);
  border-color: var(--emerald-200);
  color: var(--emerald-700);
  font-weight: 600;
}

.kw-calc.bad {
  background: var(--rose-50);
  border-color: var(--rose-200);
  color: var(--rose-700);
  font-weight: 600;
}

.kw-del {
  border: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 17px;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.kw-del:hover {
  color: var(--red);
  background: var(--red-soft);
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

/* ==========================================================================
   8. BUTTONS (按钮系统)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--slate-700);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  user-select: none;
}

.btn:hover {
  border-color: var(--slate-300);
  background: var(--slate-50);
  color: var(--slate-900);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.btn-ghost {
  background: #ffffff;
  border-color: var(--line);
}

.btn-mini {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 5px;
}

.btn-lg {
  padding: 10px 22px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn.danger {
  color: var(--red);
  border-color: var(--rose-200);
  background: #ffffff;
}

.btn.danger:hover {
  background: var(--red-soft);
  border-color: var(--red);
}

.save-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 30px;
}

.edit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--orange-soft);
  border: 1px solid var(--amber-200);
  border-radius: var(--radius-sm);
  color: var(--amber-700);
  font-size: 13px;
  font-weight: 500;
}

/* ==========================================================================
   9. ANOMALY MONITORING TABLE (.anomaly-table - 异常监控数据表)
   ========================================================================== */
.anomaly-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.anomaly-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.anomaly-title-line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.anomaly-title-line h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
}

.anomaly-time-hint {
  font-size: 12px;
  color: var(--text-3);
}

/* KPI Summary Cards */
.anomaly-stats-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.anomaly-stats-summary > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--slate-50);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
}

.anomaly-stats-summary b {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.anomaly-stats-summary .text-danger {
  color: var(--red) !important;
}

.anomaly-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-icon {
  margin-right: 2px;
}

/* Filter Subtabs & Rule Chips */
.filter-bar-anomaly {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 18px;
}

.anomaly-subtabs {
  display: flex;
  gap: 4px;
  background: var(--slate-100);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
}

.subtab {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
  transition: all 0.15s ease;
}

.subtab:hover {
  color: var(--text);
}

.subtab.active {
  background: #ffffff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.rule-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  margin-right: 2px;
}

.rule-chips .chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.rule-chips .chip:hover {
  border-color: var(--slate-400);
  color: var(--text);
}

.rule-chips .chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

/* Master Anomaly Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  background: #ffffff;
}

.anomaly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.anomaly-table th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.anomaly-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  transition: background 0.1s ease;
}

.anomaly-table tr:hover td {
  background: rgba(241, 245, 249, 0.6);
}

.anomaly-table .num-r {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
}

.anomaly-table .kw-cell {
  font-weight: 600;
  max-width: 240px;
  word-break: break-all;
}

.anomaly-table .camp-cell {
  max-width: 180px;
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kw-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  border-bottom: 1px dashed var(--primary-border);
  transition: all 0.12s ease;
}

.kw-link:hover {
  color: var(--primary-hover);
  border-bottom-style: solid;
}

/* Metric Threshold Highlighting */
.anomaly-table td.cell-high-acos {
  color: var(--rose-700) !important;
  font-weight: 700;
  background: rgba(255, 228, 230, 0.5);
}

.anomaly-table td.cell-zero-ord {
  color: var(--amber-700) !important;
  font-weight: 700;
  background: rgba(254, 243, 199, 0.5);
}

.anomaly-table td.cell-warn {
  color: var(--rose-700) !important;
  font-weight: 600;
}

.anomaly-table tr:hover td.cell-high-acos {
  background: rgba(255, 228, 230, 0.75);
}

.anomaly-table tr:hover td.cell-zero-ord {
  background: rgba(254, 243, 199, 0.75);
}

/* Anomaly Badges */
.badge-reason {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--rose-50);
  color: var(--rose-700);
  border: 1px solid var(--rose-200);
  font-weight: 600;
  margin-right: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
}

.badge-action-recent {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--amber-50);
  color: var(--amber-700);
  border: 1px solid var(--amber-200);
  font-weight: 600;
  white-space: nowrap;
}

.badge-in-neg {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--rose-50);
  color: var(--rose-700);
  font-weight: 600;
  border: 1px solid var(--rose-200);
  white-space: nowrap;
}

.empty-hint {
  padding: 40px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
}

/* Card Table Body with full width / integrated look */
.card-body-table {
  padding: 0 !important;
  overflow: hidden;
}
.card-body-table > .table-responsive {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Sticky Right Actions Column */
.anomaly-table .col-sticky-right {
  position: sticky;
  right: 0;
  z-index: 15;
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: -5px 0 10px -2px rgba(15, 23, 42, 0.08);
  white-space: nowrap;
  text-align: center;
}

.anomaly-table th.col-sticky-right {
  background: var(--slate-50);
  z-index: 25;
}

.anomaly-table tr:hover td.col-sticky-right {
  background: #f8fafc;
}

/* Table Pagination Bar */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: #ffffff;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
  flex-wrap: wrap;
}

.pagination-info {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-info b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-weight: 600;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.pagination-size-select {
  padding: 3px 24px 3px 8px !important;
  font-size: 12px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background-color: #ffffff;
  color: var(--text-2);
  cursor: pointer;
}

.pagination-size-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.pagination-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text-2);
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  user-select: none;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--slate-300);
  background: var(--slate-50);
  color: var(--text);
}

.page-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--line-soft);
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  color: var(--text-3);
  font-size: 12px;
  user-select: none;
}

/* ==========================================================================
   10. NEGATIVE LIBRARY TABLE (.lib-table & .lib-block)
   ========================================================================== */
.lib-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.lib-toolbar .inp {
  width: auto;
  min-width: 210px;
}

.chk {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.sel-info {
  font-size: 13px;
  color: var(--text-2);
}

.sel-info b {
  color: var(--primary);
  font-weight: 600;
}

.lib-table {
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  background: #ffffff;
}

.lib-row {
  display: grid;
  grid-template-columns: 32px 1.9fr 90px 70px 90px 90px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  transition: background 0.1s ease;
}

.lib-row + .lib-row {
  border-top: 1px solid var(--line-soft);
}

.lib-head {
  background: var(--slate-50);
  font-size: 11.5px;
  color: var(--slate-600);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
}

.lib-head > div:nth-child(4) {
  text-align: center;
}

.lib-row > div:nth-child(4) {
  display: flex;
  justify-content: center;
}

.lib-row:hover {
  background: rgba(248, 250, 252, 0.9);
}

.lib-term {
  font-weight: 600;
  color: var(--slate-900);
  word-break: break-all;
}

.lib-asin {
  font-family: var(--font-mono);
  color: var(--indigo-700);
}

.lib-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
  word-break: break-all;
}

.freq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  padding: 0 7px;
  font-weight: 700;
  font-size: 11.5px;
  font-family: var(--font-mono);
}

/* Grouped Library Blocks */
.lib-block {
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
  border-radius: var(--radius);
}

.lib-block:last-child {
  margin-bottom: 0;
}

.lib-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--slate-50);
}

.lib-accent {
  width: 4px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.lib-block-title {
  font-weight: 650;
  font-size: 13.5px;
  color: var(--text);
}

.lib-block-count {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.lib-block-sub {
  font-size: 12px;
  color: var(--text-3);
}

/* ==========================================================================
   11. REVIEW & FOLLOW-UP MATRIX (.follow-cmp)
   ========================================================================== */
.follow-section {
  margin-bottom: 20px;
}

.follow-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 2px 12px;
}

.follow-section-title {
  font-weight: 650;
  font-size: 14.5px;
  color: var(--text);
}

.follow-section-sub {
  font-size: 12px;
  color: var(--text-3);
}

.follow-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 14px;
  border-left: 4px solid var(--primary);
  transition: all 0.15s ease;
}

.follow-card.overdue {
  border-left-color: var(--red);
  background: linear-gradient(to right, rgba(255, 241, 242, 0.4), #ffffff);
}

.follow-card.done {
  border-left-color: var(--green);
}

.follow-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.follow-kw {
  font-weight: 700;
  font-size: 15px;
  color: var(--slate-900);
}

.follow-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
}

.follow-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.follow-period {
  padding: 4px 8px;
  font-size: 12px;
  width: auto;
}

.follow-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.follow-status.wait {
  background: var(--slate-100);
  color: var(--slate-600);
}

.follow-status.over {
  background: var(--red);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(225, 29, 72, 0.3);
}

.follow-status.ok {
  background: var(--emerald-50);
  color: var(--emerald-700);
  border: 1px solid var(--emerald-200);
}

.follow-dates {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  flex-wrap: wrap;
}

.follow-dates b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.follow-dates .over {
  color: var(--red);
  font-weight: 600;
}

/* Comparison Table */
.follow-cmp {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.follow-cmp-row {
  display: grid;
  grid-template-columns: 130px repeat(4, 1fr) 60px;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  align-items: center;
}

.follow-cmp-row > div:nth-child(2),
.follow-cmp-row > div:nth-child(3),
.follow-cmp-row > div:nth-child(4),
.follow-cmp-row > div:nth-child(5) {
  text-align: right;
  padding-right: 4px;
}

.follow-cmp-row + .follow-cmp-row {
  border-top: 1px solid var(--line-soft);
}

.follow-cmp-head {
  background: var(--slate-50);
  color: var(--slate-600);
  font-weight: 600;
  font-family: var(--font-sans);
  font-size: 11.5px;
}

.follow-cmp-row .up {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: var(--emerald-700);
  background: var(--emerald-50);
  border: 1px solid var(--emerald-200);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 700;
  font-size: 11px;
  margin-left: 4px;
}

.follow-cmp-row .down {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: var(--rose-700);
  background: var(--rose-50);
  border: 1px solid var(--rose-200);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 700;
  font-size: 11px;
  margin-left: 4px;
}

.follow-cmp-act {
  display: flex;
  justify-content: center;
}

.snap-edit {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.12s ease;
}

.snap-edit:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.follow-modal-head {
  padding: 10px 14px;
  background: var(--slate-100);
  border-radius: 8px;
  font-size: 13px;
}

/* ==========================================================================
   12. LOG LIST & TIMELINE
   ========================================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar .inp {
  width: auto;
  min-width: 150px;
  flex: 0 1 auto;
}

.sep {
  color: var(--text-3);
  font-size: 12px;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  transition: all 0.15s ease;
}

.log:hover {
  border-color: var(--slate-300);
  box-shadow: var(--shadow-md);
}

.log-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.log-date {
  font-weight: 650;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.log-sub {
  color: var(--text-3);
  font-size: 12px;
}

.badge-store {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--primary-border);
}

.log-group {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.log-group b {
  color: var(--text);
  font-weight: 600;
}

.log-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12.5px;
}

.chip b {
  font-weight: 600;
}

.chip .act {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.act-pause { background: var(--slate-200); color: var(--slate-600); }
.act-decrease { background: var(--emerald-50); color: var(--emerald-700); border: 1px solid var(--emerald-200); }
.act-increase { background: var(--amber-50); color: var(--amber-700); border: 1px solid var(--amber-200); }
.act-enable { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-200); }
.act-other { background: var(--slate-200); color: var(--slate-700); }

.chip-neg, .chip-neg-exact {
  background: var(--rose-50);
  color: var(--rose-700);
  border-color: var(--rose-200);
}

.chip-neg-phrase {
  background: var(--amber-50);
  color: var(--amber-700);
  border-color: var(--amber-200);
}

.chip em {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
}

.chip-asin {
  background: var(--amber-50);
  color: var(--amber-700);
  border-color: var(--amber-200);
  font-family: var(--font-mono);
}

.chip-kw {
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 5px 9px;
}

.chip-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-metrics {
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  border-top: 1px dashed var(--slate-200);
  padding-top: 3px;
  margin-top: 2px;
}

.log-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  white-space: pre-wrap;
}

.log-shots {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.log-shots img {
  width: 78px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  transition: transform 0.15s ease;
}

.log-shots img:hover {
  transform: scale(1.04);
}

.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
}

/* History Timeline */
.hist-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.hist-summary .m {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hist-summary .m span {
  font-size: 11.5px;
  color: var(--text-3);
}

.hist-summary .m b {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline:before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--line);
}

.tl-item {
  position: relative;
  padding: 14px 0 14px 8px;
}

.tl-item:before {
  content: "";
  position: absolute;
  left: -21px;
  top: 20px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--primary);
  box-shadow: 0 0 0 2px #ffffff;
}

.tl-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tl-date {
  font-weight: 650;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.tl-body {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-2);
}

.tl-note {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-3);
}

.tl-metrics {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  background: var(--slate-100);
  border-radius: 4px;
  padding: 4px 8px;
  display: inline-block;
}

.tl-shots {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.tl-shots img {
  width: 60px;
  height: 44px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

/* Campaign History Reference Table */
#campHistoryHead {
  cursor: pointer;
  user-select: none;
}

#campHistoryHead:hover {
  background: var(--slate-100);
}

.ch-arrow {
  display: inline-block;
  width: 15px;
  color: var(--text-3);
  font-size: 11px;
}

.ch-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}

.ch-item:last-child {
  margin-bottom: 0;
}

.ch-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  cursor: pointer;
  background: #ffffff;
  transition: background 0.1s ease;
}

.ch-head:hover {
  background: var(--slate-50);
}

.ch-date {
  font-weight: 600;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.ch-where {
  font-size: 12px;
  color: var(--text-3);
  flex: none;
}

.ch-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

.ch-chips .chip {
  font-size: 11.5px;
  padding: 2px 7px;
}

.ch-detail {
  border-top: 1px solid var(--line-soft);
  background: var(--slate-50);
  padding: 8px 12px;
}

.ch-d-row {
  display: grid;
  grid-template-columns: 1.6fr .9fr .7fr .7fr .7fr .7fr 1.3fr;
  gap: 6px;
  padding: 5px 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.ch-d-head {
  color: var(--slate-600);
  font-weight: 600;
  font-family: var(--font-sans);
  border-bottom: 1px solid var(--line);
}

.ch-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-2);
}

/* ==========================================================================
   13. STORE MANAGEMENT MODAL & CARDS
   ========================================================================== */
.store-mgmt-table {
  max-height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.store-mgmt-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: all 0.15s ease;
}

.store-mgmt-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow);
}

.store-mgmt-card.disabled {
  opacity: 0.55;
  background: var(--slate-50);
}

.store-info-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.store-title-text {
  font-weight: 650;
  color: var(--text);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.badge-country {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-200);
  font-weight: 600;
}

.badge-ads-ok {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--emerald-50);
  color: var(--emerald-700);
  border: 1px solid var(--emerald-200);
  font-weight: 500;
}

.badge-ads-no {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--slate-100);
  color: var(--slate-500);
  border: 1px solid var(--slate-200);
}

.store-seller-info {
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.store-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* iOS-Style Toggle Switch */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--slate-300);
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 20px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch-toggle input:checked + .slider-round {
  background-color: var(--primary);
}

.switch-toggle input:checked + .slider-round:before {
  transform: translateX(18px);
}

.store-empty-hint {
  text-align: center;
  padding: 36px;
  color: var(--text-3);
  font-size: 13px;
}

/* ==========================================================================
   14. MODALS, PROGRESS BAR, LIGHTBOX, TOAST
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.15s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--slate-200);
  animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from { transform: scale(0.97) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  font-size: 15px;
  color: var(--slate-900);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--slate-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.x {
  position: relative;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.x:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

/* Sync Progress Modal */
.sync-progress-box {
  text-align: center;
}

.sync-status-icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: inline-block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

.sync-status-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}

.progress-track {
  height: 8px;
  background: var(--slate-100);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--slate-200);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sync-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.sync-progress-msg {
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  animation: modalFadeIn 0.15s ease-out;
}

.lightbox img {
  max-width: 95%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: var(--shadow-modal);
}

.lb-close {
  position: absolute;
  top: 20px;
  right: 28px;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.lb-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 400;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: toastPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastPop {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.toast.err {
  background: rgba(225, 29, 72, 0.95);
}

/* ==========================================================================
   15. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 960px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  .tabs {
    top: auto;
    position: static;
    overflow-x: auto;
  }
  .kw-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .kw-head {
    display: none;
  }
  .lib-row {
    grid-template-columns: 32px 1fr 70px;
    gap: 6px;
  }
  .lib-row > *:nth-child(n+5) {
    display: none;
  }
}
