/* 1. Customer Report */
/**
 * customer_report.css
 * ─────────────────────────────────────────────
 * CSS เฉพาะของ Customer Report Module
 *
 * ไม่ duplicate สิ่งที่มีใน global.css แล้ว:
 *   reset, :root vars, body, .content, .btn, .panel, .panel-title,
 *   .tag, .tag-default, .tag-ink, .badge, .table.data-table,
 *   .td-muted, .td-mono, .alert, .modal, .spinner, .field-*
 * ─────────────────────────────────────────────
 */

/* ── Page Header ─────────────────────────────── */
.page-eyebrow {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--stone);
    margin-bottom: 4px;
}

.page-heading {
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -0.8px;
    color: var(--ink);
    line-height: 1.1;
    margin-bottom: 6px;
}

.page-sub {
    font-size: 13px;
    color: var(--slate);
    margin-bottom: 24px;
}

/* badge จำนวน alert ในปุ่ม */
.cr-nav-count {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 9999px;
    background: var(--surface-cool);
    color: var(--graphite);
    min-width: 18px;
    text-align: center;
}

.cr-nav-btn.active .cr-nav-count {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

.cr-nav-count-red { background: #fee2e2; color: #991b1b; }
.cr-nav-btn.active .cr-nav-count-red { background: rgba(185,28,28,0.7); color: #fff; }

/* ── Alert Strip ─────────────────────────────── */
.cr-alert-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.cr-alert-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 13px;
    flex: 1;
    min-width: 200px;
    border: 0.5px solid;
    transition: all 0.15s ease;
    text-decoration: none;
    color: inherit;
}

.cr-alert-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.cr-alert-item strong { font-weight: 600; }

.cr-a-red    { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.cr-a-yellow { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.cr-a-blue   { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ── Filter Bar ──────────────────────────────── */
.cr-filter {
    background: var(--canvas);
    border: 0.5px solid var(--hairline);
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.cr-fg {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cr-fg label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--stone);
}

/* input/select ใช้ .field-input ของ global แล้ว แต่ต้องปรับ min-width */
.cr-fg .field-input,
.cr-fg input[type="date"],
.cr-fg select {
    min-width: 140px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--hairline);
    padding: 8px 0;
    background: var(--canvas);
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s;
}

.cr-fg .field-input:focus,
.cr-fg input[type="date"]:focus,
.cr-fg select:focus {
    border-bottom-color: var(--ink);
    box-shadow: none;
}

.cr-date-range {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: var(--stone);
}

/* submit button ใน filter — ใช้ .btn .btn-primary ของ global */
.cr-filter .btn {
    align-self: flex-end;
    border-radius: 9999px;
    height: 40px;
}

/* ── Shell / Main ────────────────────────────── */
.cr-shell {
    padding: 0;
}

.cr-main {
    padding: 0;
}

/* ── Search Card (Unified Search UI) ─────────── */
.search-card {
    background: var(--canvas);
    border: 0.5px solid var(--hairline);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.search-card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.search-card-row:last-child {
    margin-bottom: 0;
}

.search-card-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-card-wrap i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--stone);
    font-size: 14px;
    pointer-events: none;
}

.search-card-input {
    width: 100%;
    background: var(--canvas-warm);
    border: 1px solid var(--hairline);
    padding: 10px 14px 10px 38px;
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--ink);
    outline: none;
    transition: all 0.15s ease;
    border-radius: 0;
}

.search-card-input:focus {
    background: var(--canvas);
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(15,15,15,0.05);
}

.search-card-input::placeholder { color: var(--stone); }

.search-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--on-primary);
    background: var(--ink);
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
    border-radius: 0;
}

.search-card-btn:hover {
    background: var(--ink-soft);
}

.search-card-clear {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 40px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--slate);
    text-decoration: none;
    transition: color 0.15s ease;
}

.search-card-clear:hover {
    color: var(--ink);
}

/* ── Search Box ──────────────────────────────── */
.cr-search-box {
    background: var(--canvas);
    border: 0.5px solid var(--hairline);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.cr-search-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.cr-search-wrap {
    position: relative;
    flex: 1;
}

.cr-search-wrap i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--stone);
    font-size: 14px;
    pointer-events: none;
}

.cr-search-input {
    width: 100%;
    background: var(--canvas-warm);
    border: 1px solid var(--hairline);
    padding: 10px 14px 10px 38px;
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--ink);
    outline: none;
    transition: all 0.15s ease;
    border-radius: 0;
}

.cr-search-input:focus {
    background: var(--canvas);
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(15,15,15,0.05);
}

.cr-search-input::placeholder { color: var(--stone); }

/* ── Panel (zero-padding variant) ────────────── */
/* global .panel มี padding:24px — CR ใช้ padding:0 แล้วแยก header/body */
.cr-panel {
    background: var(--canvas);
    border: 0.5px solid var(--hairline);
    padding: 0;
    margin-bottom: 20px;
}

.cr-panel-header {
    padding: 14px 20px;
    border-bottom: 0.5px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cr-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.2px;
}

.cr-panel-desc { font-size: 12px; color: var(--stone); }

/* ── Table (CR specific class เพื่อไม่ชน global) */
table.cr-dt {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.cr-dt th {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--stone);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 0.5px solid var(--hairline);
    white-space: nowrap;
    background: var(--canvas);
}

table.cr-dt td {
    padding: 11px 16px;
    border-bottom: 0.5px solid var(--hairline-soft, #f0f1f3);
    color: var(--ink);
    vertical-align: middle;
    line-height: 1.4;
}

table.cr-dt tr:hover td { background: var(--canvas-warm); }
table.cr-dt tr:last-child td { border-bottom: none; }

.cr-td-co   { font-weight: 600; letter-spacing: -0.1px; }
.cr-td-mono { font-family: var(--font-mono); font-size: 12px; color: var(--graphite); }

/* ── Tags (เพิ่มสีที่ global ไม่มี) ─────────── */
.tag-blue    { background: #dbeafe; color: #1e40af; }
.tag-warn    { background: #fef9c3; color: #92400e; }
.tag-success { background: #dcfce7; color: #166534; }
.tag-danger  { background: #fee2e2; color: #991b1b; }

.tag-action {
    background: var(--ink);
    color: var(--on-primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.tag-action:hover { background: var(--ink-soft); }

/* ── Trend / Overdue ─────────────────────────── */
.cr-trend-up   { font-size: 12px; font-weight: 500; color: #16a34a; }
.cr-trend-down { font-size: 12px; font-weight: 500; color: #b91c1c; }
.cr-trend-same { font-size: 12px; font-weight: 500; color: var(--slate); }

.cr-ov-high { color: #b91c1c; font-weight: 600; font-family: var(--font-mono); font-size: 12px; }
.cr-ov-mid  { color: #d97706; font-weight: 500; font-family: var(--font-mono); font-size: 12px; }
.cr-ov-low  { color: var(--slate); font-family: var(--font-mono); font-size: 12px; }

/* ───────────────── Summary Head ───────────────── */
.cr-summary-head{
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.2px;
    border-bottom: 0.5px solid var(--hairline);
    padding: 14px 20px;
}
/* ── Group Label (silent page) ───────────────── */
.cr-group-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--stone);
    padding: 12px 20px 10px;
    border-bottom: 0.5px solid var(--hairline-soft, #f0f1f3);
}

.cr-group-label span {
    font-weight: 400;
    color: var(--ash);
    margin-left: 6px;
    text-transform: none;
    letter-spacing: 0;
}

/* ── KPI Grid (customer 360) ─────────────────── */
.cr-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--hairline);
    border-bottom: 0.5px solid var(--hairline);
}

.cr-kpi-card { background: var(--canvas); padding: 16px 20px; }

.cr-kpi-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--stone);
    margin-bottom: 5px;
}

.cr-kpi-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.1;
}

.cr-kpi-sub { font-size: 11px; color: var(--slate); margin-top: 3px; }

/* ── Profile Grid ────────────────────────────── */
.cr-profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (min-width: 992px) {
    .cr-profile-grid { grid-template-columns: 280px 1fr; }
}

/* ── Info List ───────────────────────────────── */
.cr-info-list {
    list-style: none;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cr-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 0.5px solid var(--hairline-soft, #f0f1f3);
    padding-bottom: 8px;
}

.cr-info-item:last-child { border-bottom: none; padding-bottom: 0; }

.cr-info-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--stone);
}

.cr-info-value {
    font-size: 13.5px;
    color: var(--ink);
    font-weight: 500;
    word-break: break-all;
}

.cr-info-value.empty { color: var(--stone); font-weight: 400; font-style: italic; }

/* ── Inner Tabs (orders/products ใน customer 360) */
.cr-inner-tabs {
    display: flex;
    border-bottom: 0.5px solid var(--hairline);
    background: var(--canvas-warm);
}

.cr-inner-tab-btn {
    background: none;
    border: none;
    border-right: 0.5px solid var(--hairline);
    border-bottom: 2px solid transparent;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--slate);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cr-inner-tab-btn:hover { color: var(--ink); background: var(--canvas); }

.cr-inner-tab-btn.active {
    color: var(--ink);
    background: var(--canvas);
    border-bottom-color: var(--ink);
    font-weight: 600;
}

.cr-tab-panel { display: none; }
.cr-tab-panel.active { display: block; }

/* ── Misc ─────────────────────────────────────── */
hr.cr-div { border: none; border-top: 0.5px solid var(--hairline); }

.cr-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--stone);
    font-size: 13.5px;
}

.table-wrap { overflow-x: auto; }

/* ── Trend Chart (customer 360) ──────────────── */
.cr-trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 140px;
    padding: 20px 20px 10px;
    border-bottom: 0.5px solid var(--hairline);
}

.cr-trend-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 6px;
}

.cr-trend-bar {
    width: 100%;
    max-width: 28px;
    background: var(--ink);
    border-radius: 2px 2px 0 0;
    transition: opacity 0.15s ease;
}

.cr-trend-bar-empty {
    background: var(--hairline);
}

.cr-trend-bar-wrap:hover .cr-trend-bar {
    opacity: 0.75;
}

.cr-trend-bar-label {
    font-size: 10px;
    color: var(--stone);
    white-space: nowrap;
}

/* 2. Search Card */
/**
 * search.css — Standard Search Card (2-row layout)
 * Runwai Design System · salecnc admin
 * ─────────────────────────────────────
 * Structure:
 *   .scard
 *     .scard-row          ← row 1: text input + submit
 *       .scard-field      ← input wrapper (icon + input)
 *       .scard-btn        ← submit button
 *       .scard-clear      ← clear link
 *     .scard-filters      ← row 2: filter groups
 *       .sf               ← single filter group (label + control)
 *         label
 *         input / select / .sf-daterange
 */

/* ── Card Container ── */
.scard {
  background: var(--canvas);
  border: 0.5px solid var(--hairline);
  padding: 20px 24px;
  margin-bottom: 20px;
}

/* ── Row 1: Main Search ── */
.scard-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 16px;
}

/* Input wrapper (icon inside) */
.scard-field {
  position: relative;
  flex: 1;
}

.scard-field i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--stone);
  font-size: 13px;
  pointer-events: none;
}

.scard-input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 36px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas-warm);
  border: 1px solid var(--hairline);
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.scard-input:focus {
  background: var(--canvas);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 15, 15, 0.05);
}

.scard-input::placeholder {
  color: var(--stone);
}

/* Submit button */
.scard-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--on-primary);
  background: var(--ink);
  border: none;
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  text-decoration: none;
}

.scard-btn:hover {
  background: var(--ink-soft, #333);
}

/* Clear link */
.scard-clear {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--slate);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.scard-clear:hover {
  color: var(--ink);
}

/* ── Row 2: Filters ── */
.scard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  padding-top: 14px;
  border-top: 0.5px solid var(--hairline);
}

/* Single filter group */
.sf {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sf > label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--stone);
  white-space: nowrap;
}

.sf input[type="date"],
.sf input[type="text"],
.sf input[type="number"],
.sf select {
  height: 34px;
  min-width: 130px;
  padding: 0 8px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas);
  border: none;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s;
}

.sf input:focus,
.sf select:focus {
  border-bottom-color: var(--ink);
}

/* Date range pair */
.sf-daterange {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--stone);
  font-size: 12px;
}

.sf-daterange input[type="date"] {
  min-width: 120px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .scard {
    padding: 16px;
  }

  .scard-filters {
    gap: 14px;
  }

  .sf input[type="date"],
  .sf input[type="text"],
  .sf select {
    min-width: 100px;
  }
}

/* 3. Header */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --light: #f8fafc;
  --ink: #1f2937;
  --ink-soft: #374151;
  --slate: #6b7280;
  --graphite: #374151;
  --stone: #9ca3af;
  --ash: #d1d5db;
  --canvas: #ffffff;
  --canvas-warm: #fafafa;
  --surface-cool: #f8fafc;
  --border: #e5e7eb;
  --hairline: #e5e7eb;
  --hairline-soft: #f0f1f3;
  --font-sans: "Noto Serif Thai", serif;
  --font-mono: "IBM Plex Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 72px;
  background: var(--canvas-warm);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
}

.nav {
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  margin: 0 auto;
  padding: 0 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas-warm);
}

.nav-wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.4px;
  text-decoration: none;
  text-transform: lowercase;
}

.nav-wordmark img {
  display: block;
  height: 28px;
  border-radius: 4px;
}

.nav-chip {
  padding: 3px 10px;
  border: 1px solid var(--hairline);
  border-radius: 9999px;
  color: var(--stone);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-username {
  color: var(--graphite);
  font-size: 13px;
  font-weight: 500;
}

.nav-avatar {
  display: block;
  width: 30px;
  height: 30px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  object-fit: cover;
}

.content {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px 20px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--hairline);
  border-radius: 9999px;
  background: var(--surface-cool);
  color: var(--graphite);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.tag-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.tag-default {
  border-color: var(--hairline);
  background: var(--surface-cool);
  color: var(--graphite);
}

/* Google Ads Competition: shared badge colors for every planner table. */
.seo-competition-low {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.seo-competition-medium {
  border-color: #fde68a;
  background: #fefce8;
  color: #a16207;
}

.seo-competition-high {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.seo-competition-none {
  border-color: var(--hairline);
  background: var(--surface-cool);
  color: var(--graphite);
}

.modal-backdrop {
  display: none;
}

@media (max-width: 640px) {
  body {
    padding-bottom: 84px;
  }

  .nav {
    padding: 0 14px;
  }

  .nav-username,
  .nav-wordmark-text {
    display: none;
  }

  .content {
    padding: 18px 14px;
  }
}

/* 4. Function Analysis and Category Comparison */
/* Function Analysis */

.cap-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin-bottom: 24px }
        .cap-kpi-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0, 0, 0, .05) }
        .cap-kpi-card.cap-kpi-forecast { border-color: #6366f1; background: #eef2ff }
        .cap-kpi-card.cap-kpi-30d-ly { border-color: #0891b2; background: #ecfeff }
        .cap-kpi-label { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px }
        .cap-kpi-value { font-size: 19px; font-weight: 700; color: #111827; line-height: 1.2 }
        .cap-kpi-sub { font-size: 12px; margin-top: 4px }
        .cap-kpi-up { color: #16a34a } .cap-kpi-down { color: #dc2626 } .cap-kpi-neutral { color: #6b7280 }
        .cap-week-row td:first-child { font-weight: 700; color: #92400e }
        .cap-today-cell { background: #fbbf24 !important; font-weight: 700; color: #78350f }
        .cap-date-sub { font-size: 10px; color: #9ca3af; display: block; line-height: 1.2; margin-bottom: 1px }
        .cap-today-cell .cap-date-sub { color: #92400e }
        .cap-empty-day { color: #e5e7eb }
        tr.row-current-month td { background: #fefce8 !important; font-weight: 600 }
        .cap-width-tab { font-size: 12px; padding: 4px 12px; border-radius: 999px; text-decoration: none; background: #e5e7eb; color: #374151; }
        .cap-width-tab.cap-width-tab-active { background: #6366f1; color: #fff; font-weight: 600; }
        .cap-orders-link { color: #4338ca; text-decoration: underline; font-weight: 600; }

/* Category Comparison */
.cr-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 32px;
        padding: 6px 14px;
        border: 0;
        border-radius: 999px;
        background: var(--primary);
        color: #fff;
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
    }

    .cr-btn:hover {
        opacity: 0.86;
    }

    .cr-btn-secondary {
        background: var(--light);
        color: var(--ink);
        border: 1px solid var(--border);
    }

    .cmp-page {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .cmp-filter {
        display: grid;
        grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(130px, 1fr));
        gap: 10px;
        align-items: end;
        padding: 16px 20px;
    }

    .cmp-field label {
        display: block;
        margin-bottom: 5px;
        color: var(--slate);
        font-size: 12px;
        font-weight: 700;
    }

    .cmp-field select,
    .cmp-field input {
        width: 100%;
        min-height: 36px;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 6px 10px;
        background: #fff;
        font: inherit;
    }

    .cmp-actions,
    .cmp-status-filter {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 0 20px 16px;
    }

    .cmp-status-filter {
        padding-top: 14px;
        border-bottom: 1px solid var(--border);
    }

    .cmp-filter-btn {
        border: 1px solid var(--border);
        background: #fff;
        color: var(--ink);
        border-radius: 999px;
        padding: 6px 12px;
        font: inherit;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
    }

    .cmp-actions .cr-btn {
        border-color: var(--primary);
        background: var(--primary);
        color: #fff;
    }

    .cmp-actions .cr-btn-secondary {
        border-color: var(--border);
        background: #fff;
        color: var(--ink);
    }

    .cmp-filter-btn[data-status-filter="มาใหม่"],
    .cmp-filter-btn[data-status-filter="โตขึ้น"] {
        border-color: #bbf7d0;
        background: #f0fdf4;
        color: #166534;
    }

    .cmp-filter-btn[data-status-filter="ลดลง"] {
        border-color: #fecaca;
        background: #fef2f2;
        color: #991b1b;
    }

    .cmp-filter-btn[data-status-filter="หายไป"] {
        border-color: #b91c1c;
        background: #fee2e2;
        color: #7f1d1d;
    }

    .cmp-filter-btn[data-status-filter="ทรงตัว"] {
        border-color: #cbd5e1;
        background: #f8fafc;
        color: #475569;
    }

    .cmp-filter-btn.is-active {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
    }

    .cmp-section-head {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        align-items: center;
        padding: 14px 18px;
        border-bottom: 1px solid var(--border);
    }

    .cmp-section-title {
        margin: 0;
        font-size: 15px;
        font-weight: 800;
        color: var(--ink);
    }

    .cmp-table-wrap {
        overflow: auto;
    }

    .cmp-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 13px;
    }

    .cmp-table th,
    .cmp-table td {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
        text-align: left;
    }

    .cmp-table th {
        color: var(--slate);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .02em;
        background: #f8fafc;
        white-space: nowrap;
    }

    .cmp-num {
        text-align: right !important;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .cmp-main-num {
        display: block;
        font-size: 14px;
        font-weight: 800;
        color: var(--ink);
    }

    .cmp-sub-num {
        display: block;
        margin-top: 3px;
        color: var(--slate);
        font-size: 12px;
        font-weight: 600;
    }

    .cmp-sub-qty {
        color: var(--slate);
    }

    .cmp-sub-percent {
        font-weight: 800;
    }

    .cmp-sub-percent.cmp-up {
        color: #15803d;
    }

    .cmp-sub-percent.cmp-down {
        color: #b91c1c;
    }

    .cmp-sub-percent.cmp-flat {
        color: var(--slate);
    }

    .cmp-muted {
        color: var(--slate);
    }

    .cmp-up {
        color: #15803d !important;
        font-weight: 800;
    }

    .cmp-down {
        color: #b91c1c !important;
        font-weight: 800;
    }

    .cmp-flat {
        color: var(--slate) !important;
        font-weight: 800;
    }

    .cmp-product {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 260px;
    }

    .cmp-product-img {
        width: 42px;
        height: 42px;
        object-fit: cover;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: #f8fafc;
        flex: none;
    }

    .cmp-product-img-empty {
        display: block;
        width: 42px;
        height: 42px;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: #f1f5f9;
        flex: none;
    }

    .cmp-product-name {
        font-weight: 800;
        color: var(--ink);
        line-height: 1.35;
    }

    .cmp-empty {
        padding: 22px;
        text-align: center;
        color: var(--slate);
    }

    .cmp-empty-row {
        display: none;
    }

    .tag.tag-danger {
        background: #fee2e2;
        color: #991b1b;
    }

    .tag.tag-critical {
        background: #7f1d1d;
        color: #fff;
    }

    @media (max-width:1100px) {
        .cmp-filter {
            grid-template-columns: 1fr 1fr;
        }
    }

    @media (max-width:640px) {
        .cmp-filter {
            grid-template-columns: 1fr;
        }

        .cmp-table th,
        .cmp-table td {
            padding: 10px;
        }
    }
.seo-page {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

.seo-page > * + * { margin-top: 16px; }
.seo-navigation {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
}
.seo-flash { margin-bottom: 12px; }
.seo-filter-panel { padding: 20px; }
.seo-page-heading { margin: 0 0 6px; }
.seo-page-sub { margin: 0; }
.seo-filter-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    padding: 16px;
}
.seo-filter-form label { display: grid; gap: 5px; min-width: 135px; color: var(--slate); font-size: 12px; font-weight: 700; }
.seo-filter-form input,
.seo-filter-form select {
    display: block;
    min-height: 36px;
    margin-top: 5px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--canvas);
    color: var(--ink);
    font: inherit;
}
.seo-filter-form label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
}
.seo-filter-form input[type="checkbox"] { min-height: auto; margin: 0; }
.seo-selected-category { margin-bottom: 16px; }
.seo-tabs-panel { overflow: hidden; }
.seo-kpi-grid { margin-bottom: 16px; }
.seo-filter-panel .seo-kpi-grid {
    margin: 18px -20px 0;
    border-top: 0.5px solid var(--hairline);
}
.seo-filter-form textarea {
    display: block;
    width: min(420px, 100%);
    min-height: 90px;
    margin-top: 5px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--canvas);
    color: var(--ink);
    font: inherit;
}
.seo-keyword-toolbar {
    padding: 14px 20px;
    border-bottom: 0.5px solid var(--hairline-soft, #f0f1f3);
}
.seo-keyword-toolbar label { font-size: 12px; font-weight: 700; color: var(--slate); }
.seo-keyword-toolbar select { display: block; min-height: 36px; margin-top: 5px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--canvas); color: var(--ink); font: inherit; }

/* SEO dashboard: compact workflow with larger reading targets. */
.seo-dashboard { max-width: 1440px; }
.seo-hero-panel { overflow: hidden; }
.seo-page-header { flex-direction: row; justify-content: space-between; align-items: center; gap: 20px; }
.seo-page-heading { font-size: 25px; line-height: 1.3; }
.seo-page-sub { max-width: 760px; color: var(--slate); font-size: 14px; line-height: 1.55; }
.seo-header-actions, .seo-table-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seo-kpi-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seo-kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seo-kpi-grid .cr-kpi-card { padding: 22px 20px; }
.seo-kpi-grid .cr-kpi-value { font-size: 26px; }
.seo-filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.seo-filter-row + .seo-filter-row { margin-top: 12px; }
.seo-filter-row label { min-width: 150px; }
.seo-filter-actions { display: flex; gap: 8px; align-items: end; min-height: 36px; }
.seo-simple-table th { text-transform: none !important; font-size: 12px !important; font-weight: 600 !important; letter-spacing: 0 !important; }
.seo-simple-table td { padding-top: 14px !important; padding-bottom: 14px !important; }
.global-sparkline-cell { display: grid; gap: 3px; min-width: 120px; }
.global-sparkline { position: relative; width: 120px; height: 38px; color: #64748b; }
.global-sparkline svg { display: block; width: 120px; height: 38px; overflow: visible; }
.global-sparkline-line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.global-sparkline-marker { fill: transparent; stroke: transparent; cursor: crosshair; }
.global-sparkline-marker:hover, .global-sparkline-marker:focus { fill: currentColor; stroke: #fff; stroke-width: 1.5; outline: none; }
.global-sparkline.is-up { color: #15803d; }
.global-sparkline.is-down { color: #dc2626; }
.global-sparkline.is-flat, .global-sparkline.is-insufficient, .global-sparkline.is-started { color: #64748b; }
.global-sparkline-trend { font-size: 11px; font-weight: 600; white-space: nowrap; }
.global-sparkline-trend.is-up { color: #15803d; }
.global-sparkline-trend.is-down { color: #dc2626; }
.global-sparkline-trend.is-flat, .global-sparkline-trend.is-insufficient, .global-sparkline-trend.is-started, .global-sparkline-empty { color: #64748b; }
.global-sparkline-empty { display: block; height: 38px; line-height: 38px; font-size: 20px; text-align: center; }
.global-sparkline-tooltip { position: absolute; z-index: 4; bottom: calc(100% + 5px); left: 0; width: max-content; max-width: 190px; padding: 5px 7px; border-radius: 5px; background: #1f2937; color: #fff; font-size: 10px; line-height: 1.35; white-space: pre-line; pointer-events: none; box-shadow: 0 2px 8px rgb(15 23 42 / 20%); }
.seo-category-planner-summary, .seo-planner-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 14px 0 0; color: var(--slate); font-size: 12px; }
.seo-product-planner .seo-filter-form { margin-bottom: 14px; }
.seo-cell-sub { display: block; margin-top: 4px; color: var(--slate); font-size: 11px; font-weight: 400; }
.seo-manual-form { padding: 20px; border-top: 0.5px solid var(--hairline); }
.seo-manual-primary { display: grid; grid-template-columns: minmax(220px, 35fr) minmax(320px, 65fr); gap: 16px; }
.seo-manual-form label { display: block; color: var(--slate); font-size: 12px; font-weight: 700; }
.seo-manual-form label span { color: var(--stone); font-weight: 400; }
.seo-manual-form input, .seo-manual-form select, .seo-manual-form textarea { box-sizing: border-box; width: 100%; margin-top: 6px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--canvas); color: var(--ink); font: inherit; }
.seo-manual-form textarea { min-height: 94px; resize: vertical; }

.seo-planner-manual-add { position: relative; }
.seo-planner-manual-add > summary { list-style: none; cursor: pointer; }
.seo-planner-manual-add > summary::-webkit-details-marker { display: none; }
.seo-planner-manual-add[open] > .seo-manual-form {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    right: 0;
    width: min(360px, calc(100vw - 32px));
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--canvas);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}
.seo-planner-manual-add .seo-manual-form small { display: block; margin-top: 5px; color: var(--stone); font-weight: 400; }
.seo-planner-manual-add .seo-manual-form .cr-btn { margin-top: 10px; }
.seo-manual-secondary { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; margin-top: 14px; }
.seo-manual-secondary label { width: min(330px, 100%); }
.seo-manual-secondary small { display: block; margin-top: 5px; color: var(--stone); font-size: 11px; font-weight: 400; line-height: 1.45; }
.seo-text-action { display: block; padding: 2px 0; border: 0; background: transparent; color: var(--slate); cursor: pointer; font: inherit; font-size: 12px; text-align: left; }
.seo-text-action:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 980px) {
    .seo-kpi-grid-5, .seo-kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .seo-page-header { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 760px) {
    .seo-kpi-grid .cr-kpi-card { padding: 18px 14px; }
    .seo-kpi-grid .cr-kpi-value { font-size: 23px; }
    .seo-filter-row, .seo-filter-actions, .seo-header-actions, .seo-table-actions { width: 100%; }
    .seo-filter-row label, .seo-filter-actions .cr-btn, .seo-header-actions .cr-btn, .seo-table-actions .cr-btn { width: 100%; }
    .seo-manual-primary { grid-template-columns: 1fr; }
    .seo-manual-secondary .cr-btn { width: 100%; }
}

.seo-breadcrumb { display: flex; gap: 8px; align-items: center; color: var(--slate); font-size: 13px; }
.seo-breadcrumb a { color: var(--ink); text-decoration: none; }
.seo-detail-header { flex-direction: row; justify-content: space-between; align-items: center; gap: 18px; }
.seo-detail-date-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 16px 20px; border-top: .5px solid var(--hairline); }
.seo-detail-date-filter label { display: grid; gap: 5px; color: var(--slate); font-size: 12px; font-weight: 700; }
.seo-detail-date-filter input { min-height: 36px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--canvas); color: var(--ink); font: inherit; }
.seo-kpi-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.seo-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.seo-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.seo-chart-grid .cr-panel { margin-bottom: 0; }
.seo-planner-detail-header { flex-direction: row; justify-content: space-between; align-items: center; gap: 18px; }
.seo-detail-grid .cr-panel { margin-bottom: 0; }
.seo-chart-card { overflow: hidden; }
.seo-chart-container { position: relative; min-height: 340px; padding: 18px 20px; }
.seo-chart-container .cr-empty { margin: 0; }
.cr-note-success { border-color: #16a34a; color: #166534; background: #f0fdf4; }
.cr-note-warning { border-color: #d97706; color: #92400e; background: #fffbeb; }
.cr-note-error { border-color: #dc2626; color: #991b1b; background: #fef2f2; }

.planner-toast:not([hidden]) {
    position: fixed;
    z-index: 9999;
    top: 20px;
    right: 20px;
    width: min(420px, calc(100vw - 40px));
    box-shadow: 0 12px 28px rgba(15, 23, 42, .22);
}
.planner-toast-progress:not([hidden]) { top: 88px; }
#planner-fetch-progress progress { width: 100%; margin: 8px 0 4px; }
.seo-dashboard .seo-chart-card:has(#planner-category-count-chart),
.seo-dashboard .seo-chart-card:has(#planner-status-chart),
.seo-dashboard .seo-chart-card:has(#planner-search-volume-chart) { display: none; }
.seo-dashboard .seo-chart-grid:has(#planner-status-chart) { display: none; }
#planner-top-keywords-chart { max-height: 280px; }
#planner-competition-chart { max-height: 260px; }
#planner-monthly-trend-chart { max-height: 320px; }
.seo-opportunity-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--hairline); }
.seo-opportunity-card { display: block; min-height: 126px; padding: 20px; background: var(--canvas); color: var(--ink); text-decoration: none; }
.seo-opportunity-card:hover { background: var(--canvas-warm); }
.seo-opportunity-card strong { display: block; font-size: 26px; line-height: 1.1; }
.seo-opportunity-card span { display: block; margin-top: 9px; font-weight: 600; }
.seo-opportunity-card small { display: block; margin-top: 5px; color: var(--slate); font-size: 11px; line-height: 1.4; }

@media (max-width: 980px) {
    .seo-kpi-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .seo-opportunity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .seo-detail-header { align-items: flex-start; flex-direction: column; }
    .seo-detail-date-filter { align-items: stretch; flex-direction: column; }
    .seo-detail-date-filter .cr-btn, .seo-detail-date-filter .seo-text-action { width: 100%; }
    .seo-kpi-grid-6, .seo-detail-grid, .seo-chart-grid, .seo-opportunity-grid { grid-template-columns: 1fr; }
    .seo-planner-detail-header { align-items: flex-start; flex-direction: column; }
    .seo-chart-container { min-height: 300px; }
}
.seo-section-panel { margin-bottom: 0; }
.seo-tab-panel { display: none; }
.seo-tab-panel.is-active { display: block; }
.seo-keyword-header {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.seo-keyword-header form { margin-left: auto; }
.seo-keyword-actions { padding: 0 20px 12px; }
.seo-url-cell {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.seo-pagination {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    padding: 16px;
}
.seo-preline { white-space: pre-line; }
.seo-unmapped-note { margin-top: 12px; }
.seo-product-card-heading { display: flex; gap: 13px; align-items: center; min-width: 0; }
.seo-product-card-heading h1, .seo-product-card-heading h2 { margin: 0; color: var(--ink); font-size: 17px; line-height: 1.35; }
.seo-product-card-heading p { margin: 4px 0 0; color: var(--slate); font-size: 12px; }
.seo-product-thumbnail { width: 56px; height: 56px; flex: 0 0 56px; border: 1px solid var(--hairline); border-radius: 9px; object-fit: cover; background: var(--canvas-warm); }
.seo-product-thumbnail-empty { display: grid; place-items: center; color: var(--stone); font-size: 10px; }

/* Compact product cards: category listing */
.seo-product-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
}
.seo-product-card--compact {
    display: flex;
    min-width: 0;
    margin-bottom: 0;
    flex-direction: column;
    font-size: 13px;
    line-height: 1.3;
}
.seo-product-card--compact .seo-product-card-header { padding: 9px 11px; }
.seo-product-card--compact .seo-product-card-heading { gap: 9px; align-items: center; }
.seo-product-card--compact .seo-product-card-image,
.seo-product-card--compact .seo-product-thumbnail { width: 56px; height: 56px; flex-basis: 56px; border-radius: 6px; }
.seo-product-card--compact .seo-product-card-title {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 14px;
    line-height: 1.25;
    text-overflow: ellipsis;
    word-break: break-word;
}
.seo-product-card--compact .seo-product-card-heading p {
    overflow: hidden;
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.seo-product-card--compact .cr-group-label {
    padding: 6px 10px 4px;
    font-size: 9px;
    line-height: 1.2;
}
.seo-product-card--compact .seo-product-card-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
}
.seo-product-card--compact .seo-product-card-metric { min-width: 0; padding: 7px 6px; }
.seo-product-card--compact .seo-product-card-metric .cr-kpi-label {
    overflow: hidden;
    margin-bottom: 3px;
    font-size: 8px;
    letter-spacing: .2px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.seo-product-card--compact .seo-product-card-metric .cr-kpi-value { font-size: 16px; line-height: 1; }
.seo-product-card--compact .seo-product-card-metric .cr-kpi-sub { margin-top: 2px; font-size: 9px; }
.seo-product-card--compact .cr-info-list { display: grid; gap: 2px; padding: 6px 10px; font-size: 11px; line-height: 1.3; }
.seo-product-card--compact .cr-info-list > div { min-width: 0; }
.seo-product-card--compact .cr-info-list > div:first-child {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    word-break: break-word;
}
.seo-product-card--compact .seo-product-card-sparkline { min-height: 0; padding: 3px 10px 5px; }
.seo-product-card--compact .global-sparkline,
.seo-product-card--compact .global-sparkline svg { width: 100%; height: 40px; }
.seo-product-card--compact .global-sparkline-empty { height: 40px; font-size: 11px; line-height: 40px; }
.seo-product-card--compact .seo-product-card-assignment,
.seo-product-card--compact .seo-product-card-editor { padding-top: 5px; padding-bottom: 5px; }
.seo-product-card--compact .seo-product-card-assignment > div,
.seo-product-card--compact .seo-product-card-editor > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seo-product-card--compact .seo-product-card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin-top: auto;
    padding: 7px 10px;
    border-top: .5px solid var(--hairline);
    border-bottom: 0;
}
.seo-product-card--compact .seo-product-card-actions .cr-btn {
    min-height: 28px;
    padding: 4px 7px;
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
}
.seo-product-card--compact .seo-product-card-actions form,
.seo-product-card--compact .seo-product-card-actions form .cr-btn { width: 100%; }

@media (max-width: 1180px) {
    .seo-product-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .seo-product-card-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* Shared compact assignment card */
.badge { display: inline-flex; align-items: center; width: max-content; max-width: 100%; padding: 2px 7px; border: 1px solid transparent; border-radius: 999px; font-size: 11px; font-weight: 650; line-height: 1.25; white-space: nowrap; }
.badge-positive { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.badge-negative { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.badge-neutral { border-color: var(--hairline); background: var(--canvas-warm); color: var(--slate); }
.badge-info { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.badge-warning { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.seo-product-card { overflow: hidden; padding: 0; }
.seo-product-card .seo-product-card-header { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 10px 11px; border-bottom: 1px solid var(--hairline); }
.seo-product-card .seo-product-card-heading { gap: 9px; align-items: center; overflow: hidden; }
.seo-product-card .seo-product-card-heading-text { min-width: 0; }
.seo-product-card .seo-product-card-image { display: grid; width: 52px; height: 52px; flex: 0 0 52px; place-items: center; border: 1px solid var(--hairline); border-radius: 7px; object-fit: cover; background: var(--canvas-warm); }
.seo-product-card .seo-product-card-title { display: -webkit-box; overflow: hidden; margin: 0; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--ink); font-size: 15px; line-height: 1.25; text-overflow: ellipsis; }
.seo-product-card .seo-product-card-heading p { overflow: hidden; margin: 3px 0 0; font-size: 11px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.seo-product-card .seo-product-card-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; padding: 1px 0; background: var(--hairline); }
.seo-product-card .seo-product-card-metric { min-width: 0; padding: 7px 5px; background: var(--canvas); text-align: center; }
.seo-product-card .seo-product-card-metric .cr-kpi-label { overflow: hidden; margin-bottom: 2px; font-size: 10px; letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }
.seo-product-card .seo-product-card-metric .cr-kpi-value { font-size: 16px; line-height: 1.1; }
.seo-product-card .seo-product-card-metric .cr-kpi-sub { overflow: hidden; margin-top: 2px; color: var(--slate); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.metric-change { display: inline-flex; align-items: center; width: max-content; max-width: 100%; margin-top: 3px; padding: 1px 5px; overflow: hidden; border: 1px solid transparent; border-radius: 999px; font-size: 9px; font-weight: 650; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.metric-change--positive { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.metric-change--negative { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.metric-change--neutral { border-color: #d1d5db; background: #f9fafb; color: #374151; }
.metric-change--insufficient { border-color: #e5e7eb; background: #f9fafb; color: #6b7280; }
.seo-product-card-meta { display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--hairline); color: var(--slate); font-size: 11px; }
.seo-product-card-main { display: -webkit-box; overflow: hidden; min-width: 0; flex: 1; -webkit-box-orient: vertical; -webkit-line-clamp: 1; color: var(--ink); }
.seo-product-card .seo-product-card-sparkline { min-height: 0; padding: 5px 10px 4px; border-bottom: 1px solid var(--hairline); }
.seo-product-card .global-sparkline-cell { width: 100%; min-width: 0; }
.seo-product-card .global-sparkline-trend { margin-top: 1px; font-size: 10px; line-height: 1.2; }
.seo-product-card-sparkline-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seo-product-card-sparkline-grid .global-sparkline,
.seo-product-card-sparkline-grid .global-sparkline svg { height: 36px; }
.seo-product-card-section-label { margin-bottom: 1px; color: var(--slate); font-size: 10px; }
.seo-product-card .global-sparkline, .seo-product-card .global-sparkline svg { width: 100%; height: 40px; }
.seo-product-card .global-sparkline-empty { display: block; height: 40px; color: var(--stone); font-size: 10px; line-height: 40px; text-align: center; }
.seo-product-card .seo-product-card-assignment { display: grid; gap: 3px; padding: 7px 10px; font-size: 11px; line-height: 1.35; }
.seo-product-card-assignment-line { display: flex; gap: 5px; align-items: center; min-width: 0; }
.seo-product-card-secondary { color: var(--stone); font-size: 10px; }
.seo-product-card .seo-product-card-editor { overflow: hidden; padding-top: 3px; border-top: 1px dashed var(--hairline); text-overflow: ellipsis; white-space: nowrap; }
.seo-product-card.seo-product-card--compact .seo-product-card-actions { display: flex; grid-template-columns: none; gap: 5px; flex-wrap: wrap; margin-top: auto; padding: 7px 10px; border-top: 1px solid var(--hairline); border-bottom: 0; }
.seo-product-card .seo-product-card-actions .cr-btn { min-height: 28px; padding: 4px 8px; font-size: 10px; line-height: 1.15; }
.seo-product-card.seo-product-card--compact .seo-product-card-actions form { width: auto; margin: 0; }
.assignment-release { position: relative; }
.assignment-release > summary { list-style: none; cursor: pointer; }
.assignment-release > summary::-webkit-details-marker { display: none; }
.assignment-release[open] { width: 100%; }
.assignment-release[open] > summary { margin-bottom: 6px; }
.assignment-release .seo-manual-form { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--hairline); border-radius: 7px; background: var(--canvas-warm); }
.assignment-release textarea { box-sizing: border-box; width: 100%; min-height: 54px; }

/* Product assignment performance detail */
.seo-assignment-performance { padding-bottom: 14px; }
.seo-assignment-performance-header { gap: 12px; align-items: end; }
.seo-assignment-history-select label { display: grid; gap: 4px; color: var(--slate); font-size: 11px; }
.seo-assignment-history-select select, .seo-assignment-chart-toolbar select { min-height: 32px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--canvas); color: var(--ink); }
.seo-product-assignment-history .cr-table-wrap { margin-top: 0; }
.seo-product-assignment-history td { vertical-align: middle; }
.seo-product-assignment-history td:nth-child(7) { min-width: 180px; max-width: 320px; white-space: normal; }
.seo-product-assignment-history .cr-btn { min-height: 30px; padding: 5px 9px; white-space: nowrap; }
.seo-assignment-summary-badges, .seo-assignment-dates, .seo-assignment-score-row { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; margin: 0 16px 10px; font-size: 12px; }
.seo-assignment-dates { padding: 8px 10px; border-radius: 7px; background: var(--canvas-warm); }
.seo-assignment-score-row { justify-content: space-between; }
.seo-assignment-baseline-note { color: var(--slate); }
.seo-assignment-chart-toolbar { display: flex; gap: 8px; align-items: center; margin: 0 16px 6px; font-size: 12px; }
.seo-assignment-chart-toolbar #assignment-position-note { color: #92400e; }
.seo-assignment-chart-wrap { position: relative; height: 300px; margin: 0 16px 12px; }
.seo-assignment-chart-wrap canvas { width: 100%; }
.seo-assignment-chart-wrap.is-chart-unavailable::after { display: grid; position: absolute; inset: 0; place-items: center; content: 'ไม่สามารถโหลดไลบรารีกราฟได้'; color: var(--slate); font-size: 12px; }
.seo-assignment-comparison-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 16px; }
.seo-assignment-comparison-card { display: grid; gap: 5px; min-width: 0; padding: 10px; border: 1px solid var(--hairline); border-radius: 8px; background: var(--canvas); font-size: 11px; }
.seo-assignment-comparison-card > strong { font-size: 12px; }

@media (max-width: 900px) {
    .seo-assignment-comparison-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .seo-product-card .seo-product-card-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .seo-assignment-performance-header { align-items: stretch; flex-direction: column; }
    .seo-assignment-history-select select { width: 100%; }
    .seo-assignment-chart-wrap { height: 240px; margin-right: 10px; margin-left: 10px; }
    .seo-assignment-comparison-grid { grid-template-columns: 1fr; margin-right: 10px; margin-left: 10px; }
}
.seo-rank-math-readonly { display: grid; gap: 4px; margin: 0 20px 18px; padding: 12px 14px; border: 1px solid #f4c978; border-radius: 9px; background: #fffbeb; color: #78350f; font-size: 12px; }
.seo-inline-form { display: flex; gap: 6px; align-items: center; }
.seo-inline-form select, .seo-inline-form input { box-sizing: border-box; min-height: 30px; max-width: 105px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--canvas); color: var(--ink); font: inherit; font-size: 12px; }
.seo-analysis-page .seo-product-table-wrap { overflow: hidden; }
.seo-analysis-page .seo-table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.seo-analysis-page .seo-product-table { width: 100%; min-width: 1180px; border-collapse: collapse; table-layout: fixed; }
.seo-analysis-page .seo-product-table .col-product { width: 250px; }
.seo-analysis-page .seo-product-table .col-id { width: 90px; }
.seo-analysis-page .seo-product-table .col-main { width: 220px; }
.seo-analysis-page .seo-product-table .col-score { width: 96px; }
.seo-analysis-page .seo-product-table .col-gsc { width: 85px; }
.seo-analysis-page .seo-product-table .col-clicks { width: 70px; }
.seo-analysis-page .seo-product-table .col-impressions { width: 95px; }
.seo-analysis-page .seo-product-table .col-ctr { width: 75px; }
.seo-analysis-page .seo-product-table .col-position { width: 90px; }
.seo-analysis-page .seo-product-table .col-sub { width: 65px; }
.seo-analysis-page .seo-product-table .col-candidate { width: 85px; }
.seo-analysis-page .seo-product-table .col-review { width: 100px; }
.seo-analysis-page .seo-product-table .col-status { width: 110px; }
.seo-analysis-page .seo-product-table .col-actions { width: 140px; }
.seo-analysis-page .seo-product-table th { position: sticky; top: 0; z-index: 1; background: var(--canvas-warm); }
.seo-analysis-page .seo-product-table th,
.seo-analysis-page .seo-product-table td { overflow: hidden; }
.seo-analysis-page .seo-product-table tbody tr { min-height: 88px; background: #fff; }
.seo-analysis-page .seo-product-table tbody tr:hover { background: #f7f9fc; }
.seo-analysis-page .seo-product-table td {
    height: 88px;
    padding: 10px 12px !important;
    box-sizing: border-box;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    vertical-align: middle;
}
.seo-analysis-page .seo-product-table tbody tr:last-child td { border-bottom: 1px solid #e5e7eb; }
.seo-analysis-page table.cr-dt .seo-product-row:hover td { background: #f7f9fc; }
.seo-analysis-page .seo-product-name-cell { display: flex; gap: 9px; align-items: center; min-width: 0; }
.seo-analysis-page .seo-product-table td > .cell-inner { min-height: 100%; }
.seo-analysis-page .seo-product-name-text { min-width: 0; }
.seo-analysis-page .seo-product-name-cell strong, .seo-analysis-page .seo-product-name-cell small { display: block; }
.seo-analysis-page .seo-product-name-cell strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.35; word-break: break-word; }
.seo-analysis-page .seo-product-name-cell small { margin-top: 3px; overflow: hidden; color: var(--slate); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.seo-analysis-page .seo-product-thumb-frame { display: block; width: 42px; height: 42px; flex: 0 0 42px; }
.seo-analysis-page .seo-product-thumb { display: block; width: 42px; height: 42px; border: 1px solid var(--hairline); border-radius: 6px; object-fit: cover; background: var(--canvas-warm); }
.seo-analysis-page .seo-main-keyword-cell { min-width: 180px; max-width: 240px; }
.seo-analysis-page .seo-main-keyword-text { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.4; text-overflow: ellipsis; word-break: break-word; }
.seo-analysis-page .seo-main-keyword-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    margin-top: 6px;
    padding: 2px 8px;
    border: 1px solid;
    border-radius: 999px;
    box-sizing: border-box;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.seo-analysis-page .seo-main-duplicate { color: #b42318; border-color: #f04438; background: #fff1f0; }
.seo-analysis-page .seo-main-unique { color: #067647; border-color: #12b76a; background: #ecfdf3; }
.seo-analysis-page .seo-main-missing { color: #667085; border-color: #d0d5dd; background: #f9fafb; }
.seo-analysis-page .seo-main-near-duplicate { color: #b54708; border-color: #f79009; background: #fffaeb; }
.seo-analysis-page .seo-main-keyword-duplicates-link { display: block; margin-top: 5px; color: var(--slate); font-size: 11px; text-decoration: underline; }

.seo-analysis-page .seo-main-keyword-kpis .cr-kpi-card { min-height: 0; padding: 14px; }
.seo-analysis-page .seo-main-keyword-detail-status {
    display: inline-block;
    margin: 0 20px 16px;
    padding: 5px 9px;
    border: 1px solid;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.seo-analysis-page .seo-main-keyword-overview { margin: 0 20px 16px; padding: 10px 12px; border: 1px solid; border-radius: 9px; font-size: 12px; }
.seo-analysis-page .seo-main-keyword-overview > div { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.seo-analysis-page .seo-main-keyword-overview > div strong { font-size: 13px; }
.seo-analysis-page .seo-main-keyword-overview > div span { font-size: 14px; font-weight: 700; }
.seo-analysis-page .seo-main-keyword-overview p { margin: 5px 0 0; }
.seo-analysis-page .seo-main-keyword-overview ul { display: flex; flex-wrap: wrap; gap: 5px 12px; margin: 6px 0 0; padding-left: 18px; }
.seo-analysis-page .seo-main-keyword-overview a { color: inherit; font-weight: 600; text-decoration: underline; }
.seo-analysis-page .seo-main-keyword-overview small { font-weight: 400; }
.seo-analysis-page .seo-number-cell { text-align: right; white-space: nowrap; }
.seo-analysis-page .seo-center-cell { text-align: center; }
.seo-analysis-page .seo-sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.seo-analysis-page .seo-sort-link:hover { color: var(--ink); text-decoration: underline; }
.seo-analysis-page .seo-status-badge { display: inline-block; max-width: 140px; padding: 4px 7px; border-radius: 999px; background: var(--canvas-warm); color: var(--slate); font-size: 11px; line-height: 1.25; white-space: normal; }
.seo-analysis-page .seo-status-ready { background: #ecfdf5; color: #166534; }
.seo-analysis-page .seo-status-warning { background: #fff7ed; color: #9a3412; }
.seo-analysis-page .seo-status-waiting { background: #eff6ff; color: #1d4ed8; }
.seo-analysis-page .seo-rankmath-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid;
    border-radius: 4px;
    box-sizing: border-box;
    font-weight: 600;
}
.seo-analysis-page .seo-score-good { color: #008f68; border-color: #00a878; background: #effcf7; }
.seo-analysis-page .seo-score-medium { color: #c45a00; border-color: #ff7a00; background: #fff8f0; }
.seo-analysis-page .seo-score-low { color: #c62828; border-color: #e53935; background: #fff4f4; }
.seo-analysis-page .seo-score-empty { color: #6b7280; border-color: #d1d5db; background: #f9fafb; }
.seo-analysis-page .seo-product-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}
.seo-analysis-page .seo-product-actions .cr-btn {
    max-width: 100%;
    white-space: normal;
    text-align: center;
}
.seo-analysis-page .seo-product-actions .seo-text-action {
    max-width: 100%;
    text-align: center;
    white-space: normal;
}
.seo-category-name-wrap { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.seo-category-thumb { display: block; width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid var(--hairline); border-radius: 6px; object-fit: cover; background: var(--canvas-warm); }
.seo-category-thumb-placeholder { display: flex; align-items: center; justify-content: center; color: var(--stone); font-size: 10px; text-align: center; }
.seo-category-info { min-width: 0; }
.seo-category-title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--ink); font-weight: 600; line-height: 1.35; text-decoration: none; }
.seo-category-title:hover { text-decoration: underline; }
.seo-category-meta { margin-top: 3px; color: var(--slate); font-size: 11px; }
.seo-empty-state { padding: 28px 20px; text-align: center; }
.seo-empty-state h2 { margin: 0; font-size: 18px; }
.seo-empty-state p { color: var(--slate); }
.seo-empty-state .cr-btn { margin: 4px; }

@media (max-width: 760px) {
    .seo-page { padding: 12px; }
    .seo-filter-form { display: grid; grid-template-columns: 1fr; }
    .seo-filter-form input,
    .seo-filter-form select { width: 100%; }
    .seo-keyword-header { align-items: stretch; }
    .seo-keyword-header form,
    .seo-keyword-header .cr-btn { width: 100%; margin-left: 0; }
    .cr-inner-tabs { overflow-x: auto; }
    .cr-inner-tab-btn { white-space: nowrap; }
}
