:root {
  --bg: #eef6ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #dbe3ef;
  --line-2: #edf1f7;
  --text: #182033;
  --muted: #667085;
  --soft: #98a2b3;
  --blue: #2563eb;
  --blue-2: #3b82f6;
  --purple: #7c3aed;
  --teal: #0f766e;
  --green: #15803d;
  --amber: #b45309;
  --rose: #be123c;
  --red: #b42318;
  --shadow: 0 12px 30px rgba(24, 32, 51, .09);
  --action-shadow: 0 8px 18px rgba(37, 99, 235, .28);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Sarabun', system-ui, -apple-system, Segoe UI, sans-serif;
  background:
    linear-gradient(135deg, #eef6ff 0%, #f8fbff 34%, #f0fdf8 68%, #fff7ed 100%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

#app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    linear-gradient(180deg, #0f172a 0%, #132449 48%, #0f3d3b 100%);
  color: #e4e7ec;
  border-right: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(135deg, rgba(37,99,235,.18), rgba(15,118,110,.16));
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  box-shadow: 0 10px 24px rgba(37,99,235,.26);
}
.brand-title { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 11.5px; color: #98a2b3; }

.nav { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-section {
  padding: 12px 10px 5px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.nav-section:first-child { padding-top: 4px; }
.nav-section.hidden { display: none; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: #cbd5e1;
  font-weight: 500;
  transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}
.nav a.nav-key { border: 1px solid rgba(147,197,253,.15); background: rgba(37,99,235,.09); }
.nav a.nav-key:nth-of-type(3n+1) { background: rgba(37,99,235,.12); }
.nav a.nav-key:nth-of-type(3n+2) { background: rgba(15,118,110,.12); }
.nav a.nav-key:nth-of-type(3n+3) { background: rgba(124,58,237,.12); }
.nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.nav a.active {
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #fff;
  box-shadow: 0 7px 16px rgba(2, 6, 23, .30);
}
.nav a.hidden { display: none; }
.nav-icon { width: 18px; text-align: center; color: #93c5fd; }
.nav a.active .nav-icon { color: #fff; }
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 14px 16px;
  color: #cbd5e1;
  font-size: 11.5px;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  background: rgba(255,255,255,.90);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(24, 32, 51, .06);
}
.topbar-title { flex: 1; font-weight: 800; font-size: 17px; color: #1e3a8a; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.lang-field {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.lang-select {
  width: auto;
  min-height: 32px;
  padding: 5px 28px 5px 10px;
  border-radius: 999px;
  background: #fff;
}
.top-warning {
  color: #0f3d3b;
  background: linear-gradient(135deg, #ecfeff, #eff6ff);
  border: 1px solid #a5f3fc;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface);
  font-size: 12.5px;
}
.content { padding: 22px; width: 100%; max-width: 1480px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 30px 10px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid #c7d7fe;
  border-left: 6px solid var(--blue);
  border-radius: var(--radius);
  background: linear-gradient(120deg, #eff6ff 0%, #ffffff 45%, #ecfdf5 100%);
}
.page-head h1 { margin: 0; font-size: 20px; line-height: 1.25; color: #1e3a8a; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.notice {
  background: linear-gradient(135deg, #f8fbff, #eef4ff);
  border: 1px solid #c7d7fe;
  border-left: 4px solid var(--blue);
  color: #243b68;
  border-radius: var(--radius);
  padding: 11px 13px;
  margin-bottom: 14px;
  font-size: 12.5px;
}
.notice.warn { background: #fffbeb; border-color: #fedf89; color: #7a4b0b; }
.quick-start {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(120deg, #eff6ff, #ffffff 48%, #ecfdf5);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.quick-start-title { font-size: 16px; font-weight: 700; color: #1d4ed8; }
.quick-start p { color: var(--muted); margin: 3px 0 0; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-guide {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #1e3a8a;
  background: linear-gradient(135deg, #eff6ff, #ecfdf5);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.step-tag {
  display: inline-flex;
  flex-shrink: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #dbeafe, #ccfbf1);
  color: #1e3a8a;
  padding: 3px 9px;
  font-weight: 700;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card {
  --card-accent: var(--blue);
  position: relative;
  overflow: hidden;
  padding: 15px;
  border-top: 4px solid var(--card-accent);
  background: linear-gradient(180deg, rgba(255,255,255,.98), #fff);
}
.cards .card:nth-child(4n+1) { --card-accent: var(--blue); background: linear-gradient(180deg, #eff6ff, #fff 72%); }
.cards .card:nth-child(4n+2) { --card-accent: var(--teal); background: linear-gradient(180deg, #ecfdf5, #fff 72%); }
.cards .card:nth-child(4n+3) { --card-accent: var(--amber); background: linear-gradient(180deg, #fffbeb, #fff 72%); }
.cards .card:nth-child(4n+4) { --card-accent: var(--purple); background: linear-gradient(180deg, #f5f3ff, #fff 72%); }
.card .label { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.card .value { font-weight: 800; font-size: 26px; letter-spacing: 0; color: var(--card-accent); }
.card .sub { color: var(--soft); font-size: 12px; margin-top: 3px; }
.panel {
  --panel-accent: var(--blue);
  padding: 16px;
  margin-bottom: 14px;
  border-color: #d6e3f5;
}
.grid-2 .panel:nth-child(4n+1),
.grid-3 .panel:nth-child(4n+1) { --panel-accent: var(--blue); }
.grid-2 .panel:nth-child(4n+2),
.grid-3 .panel:nth-child(4n+2) { --panel-accent: var(--teal); }
.grid-2 .panel:nth-child(4n+3),
.grid-3 .panel:nth-child(4n+3) { --panel-accent: var(--amber); }
.grid-2 .panel:nth-child(4n+4),
.grid-3 .panel:nth-child(4n+4) { --panel-accent: var(--purple); }
.panel.primary-task {
  --panel-accent: var(--blue);
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #f8fbff, #fff 92px);
  box-shadow: 0 12px 30px rgba(37, 99, 235, .12);
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-left: 12px;
  position: relative;
  font-weight: 800;
  color: #243b68;
}
.panel-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 4px;
  border-radius: 999px;
  background: var(--panel-accent);
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }

.filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.history-help { line-height: 1.8; }
.history-filters label { min-width: 148px; flex: 1 1 148px; }
.history-filters label:first-child { min-width: 210px; flex-grow: 1.45; }
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.history-filters .filter-field { min-width: 148px; flex: 1 1 148px; }
.history-filters .filter-field-type { min-width: 210px; flex-grow: 1.45; }
.type-picker {
  position: relative;
  width: 100%;
  color: var(--text);
  font-weight: 500;
}
.type-picker-trigger {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
}
.type-picker-trigger[aria-expanded="true"] {
  border-color: var(--blue-2);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.type-picker-chevron { color: var(--muted); flex: 0 0 auto; }
.type-picker-menu {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(340px, 56vh);
  padding: 8px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
}
.type-picker-search {
  min-height: 34px;
  margin-bottom: 8px;
  background: var(--surface-2);
}
.type-picker-options {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}
.type-picker-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 8px 9px;
  cursor: pointer;
  text-align: left;
}
.type-picker-option:hover,
.type-picker-option.is-selected {
  background: #eff6ff;
  color: var(--blue);
}
.type-picker-option[hidden] { display: none; }
.type-picker-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.type-picker-code {
  color: var(--muted);
  font-size: 11px;
  flex: 0 0 auto;
}
.history-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.history-summary { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; color: var(--muted); font-size: 12.5px; }
.fixed-prediction-types {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.form-row { margin-bottom: 11px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  outline: none;
}
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }

.btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  min-height: 36px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.btn:hover, .icon-btn:hover { border-color: #b7c4d8; background: var(--surface-2); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid rgba(59,130,246,.30); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  border-color: var(--blue);
  color: #fff;
  box-shadow: var(--action-shadow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  border-color: #1d4ed8;
  color: #fff;
  box-shadow: 0 12px 22px rgba(37, 99, 235, .34);
  transform: translateY(-1px);
}
.btn-route {
  border-color: #bfdbfe;
  color: #1d4ed8;
  background: linear-gradient(135deg, #fff, #eff6ff);
  font-weight: 700;
}
.btn-route:hover { border-color: #93c5fd; background: linear-gradient(135deg, #eff6ff, #ecfdf5); color: #1d4ed8; }
.btn-cta { min-height: 46px; border-radius: 10px; padding: 10px 18px; font-size: 15px; font-weight: 700; }
.action-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  font-size: 14px;
  vertical-align: middle;
}
.btn-purple { background: var(--purple); border-color: var(--purple); color: #fff; box-shadow: 0 7px 16px rgba(124,58,237,.20); }
.btn-purple:hover { background: #6d28d9; border-color: #6d28d9; color: #fff; }
.btn-danger { color: var(--red); border-color: #fecdca; background: #fff5f4; }
.btn-sm { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.icon-btn { width: 36px; padding: 0; display: none; place-items: center; }
.hamburger-label { display: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.table-wrap { overflow-x: auto; border: 1px solid #d6e3f5; border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
th {
  background: linear-gradient(135deg, #eff6ff, #ecfdf5);
  color: #243b68;
  font-weight: 800;
  white-space: nowrap;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f8fbff; }

.badge, .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: #475467;
  min-height: 22px;
  padding: 2px 8px;
  font-size: 11.5px;
  white-space: nowrap;
}
.badge-good { background: #ecfdf3; border-color: #abefc6; color: var(--green); }
.badge-warn { background: #fffaeb; border-color: #fedf89; color: var(--amber); }
.badge-danger { background: #fff5f4; border-color: #fecdca; color: var(--red); }
.badge-info { background: #eff6ff; border-color: #bfdbfe; color: var(--blue); }
.badge-direct { background: #fffbeb; border-color: #fbbf24; color: #92400e; }
.badge-box { background: #f5f3ff; border-color: #c4b5fd; color: var(--purple); }
.chip { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700; }
.chip-good { background: #ecfdf3; border-color: #abefc6; color: var(--green); }
.chip-near { background: #eff6ff; border-color: #bfdbfe; color: var(--blue); }
.chip-box { background: #f5f3ff; border-color: #c4b5fd; color: var(--purple); }
.number-chip.is-direct-hit {
  transform: scale(1.08);
  color: #111827;
  background: linear-gradient(135deg, #fde047, #f59e0b);
  border-color: #92400e;
  box-shadow: 0 12px 24px rgba(245, 158, 11, 0.32);
}
.number-chip.is-direct-hit small {
  color: rgba(17, 24, 39, 0.7);
}
.number-chip.is-box-hit {
  transform: scale(1.05);
  color: #4c1d95;
  background: linear-gradient(135deg, #ede9fe, #c4b5fd);
  border-color: #7c3aed;
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.22);
}
.number-chip.is-box-hit small {
  color: rgba(76, 29, 149, 0.7);
}
.muted-text { color: var(--muted); font-size: 11.5px; margin-top: 3px; line-height: 1.35; }
.prize-stack { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.prize-list { display: grid; gap: 6px; min-width: 230px; }
.prize-line { display: grid; grid-template-columns: 92px minmax(120px, 1fr); gap: 8px; align-items: center; color: var(--muted); }
.prize-line b { display: flex; flex-wrap: wrap; gap: 5px; color: #1d2939; font-weight: 700; }
.notice.soft {
  margin: 0 0 14px;
  background: linear-gradient(135deg, #f8fbff, #f0fdf8);
  border-color: #d6e3f5;
  border-left-color: var(--teal);
  color: #475467;
}
.context-grid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 12px; }
.context-card {
  --context-accent: var(--blue);
  border: 1px solid #d6e3f5;
  border-top: 3px solid var(--context-accent);
  border-radius: var(--radius);
  padding: 12px;
  background: linear-gradient(180deg, #f8fbff, #fff 56px);
}
.context-card:nth-child(4n+1) { --context-accent: var(--blue); }
.context-card:nth-child(4n+2) { --context-accent: var(--teal); }
.context-card:nth-child(4n+3) { --context-accent: var(--amber); }
.context-card:nth-child(4n+4) { --context-accent: var(--purple); }
.context-title { font-weight: 800; color: #1d2939; }
.mode-card .context-title { color: var(--context-accent); margin-bottom: 7px; }
.mode-subtitle { margin-top: 12px; font-weight: 700; }
.context-total { color: var(--blue); font-weight: 800; margin-top: 8px; }
.context-numbers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.context-numbers small { margin-left: 4px; color: var(--muted); font-size: 10px; }
.combined-note { margin-top: 12px; }
.context-table { margin-top: 14px; }
.forecast-board {
  --panel-accent: var(--purple);
  border-color: #c4b5fd;
  background: linear-gradient(180deg, #f5f3ff, #fff 92px);
}
.forecast-note {
  margin: -3px 0 12px;
  color: #475467;
  background: linear-gradient(135deg, #f8fbff, #f5f3ff);
  border: 1px solid #ddd6fe;
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 12.5px;
}
.forecast-filter-panel {
  margin-bottom: 14px;
}
.forecast-filter-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.forecast-status-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.forecast-status-tabs .btn.active {
  box-shadow: var(--action-shadow);
}
.forecast-search-field {
  min-width: min(320px, 100%);
  flex: 1;
  max-width: 420px;
}
.forecast-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.forecast-card {
  width: 100%;
  display: grid;
  gap: 12px;
  text-align: left;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f8fbff 0%, #fff 42%);
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 7px 18px rgba(24, 32, 51, .06);
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.forecast-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 12px 26px rgba(37, 99, 235, .13);
  transform: translateY(-1px);
}
.forecast-card:focus-visible {
  outline: 3px solid rgba(59,130,246,.30);
  outline-offset: 2px;
}
.forecast-card-head,
.forecast-prize-head,
.forecast-card-foot,
.forecast-detail-meta,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.forecast-card-head {
  background: #eef4ff;
  border: 1px solid #dbeafe;
  border-radius: var(--radius);
  padding: 10px;
  margin: -4px -4px 0;
}
.forecast-card-prizes {
  display: grid;
  gap: 10px;
}
.forecast-prize {
  --prize: #2563eb;
  --prize-bg: #eff6ff;
  border: 1px solid var(--line-2);
  border-left: 4px solid var(--prize);
  border-radius: var(--radius);
  padding: 10px;
  background: linear-gradient(90deg, var(--prize-bg), #fff 44%);
}
.forecast-prize-top3,
.forecast-detail-top3 {
  --prize: #2563eb;
  --prize-bg: #eff6ff;
  --prize-soft: #bfdbfe;
}
.forecast-prize-bottom2,
.forecast-detail-bottom2 {
  --prize: #0f766e;
  --prize-bg: #ecfdf5;
  --prize-soft: #99f6e4;
}
.forecast-prize-head {
  font-size: 12.5px;
  font-weight: 800;
  color: #344054;
  margin-bottom: 8px;
}
.forecast-prize-head > span:first-child {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--prize);
  background: var(--prize-bg);
  border: 1px solid var(--prize-soft, #bfdbfe);
}
.forecast-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.number-chip {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 14px;
  gap: 5px;
  background: #fff;
  border-color: #dbe3ef;
  box-shadow: 0 1px 0 rgba(16, 24, 40, .03);
}
.number-chip small {
  color: var(--muted);
  font-size: 10px;
}
.number-chip.number-top3 { color: #1d4ed8; }
.number-chip.number-bottom2 { color: #0f766e; }
.number-chip.rank-one {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #1d4ed8, #4f46e5);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
}
.number-chip.number-bottom2.rank-one {
  background: linear-gradient(135deg, #0f766e, #15803d);
  box-shadow: 0 8px 18px rgba(15, 118, 110, .20);
}
.number-chip.rank-one small { color: rgba(255,255,255,.74); }
.number-chip.rank-top {
  color: #1d4ed8;
  background: #eef4ff;
  border-color: #bfdbfe;
}
.number-chip.number-bottom2.rank-top {
  color: #0f766e;
  background: #ecfdf5;
  border-color: #99f6e4;
}
.forecast-card-foot {
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 800;
  border-top: 1px solid var(--line-2);
  padding-top: 10px;
}
.mini-hit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.mini-hit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  width: 100%;
}
button.mini-hit-card {
  cursor: pointer;
}
button.mini-hit-card:hover {
  border-color: var(--blue);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.12);
}
button.mini-hit-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}
button.mini-hit-card:disabled {
  cursor: default;
  opacity: 0.7;
}
.mini-hit-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.mini-hit-main b,
.mini-hit-main .muted-text {
  overflow-wrap: anywhere;
}
.mini-hit-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mini-hit-action-text {
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 800;
}
.detail-fold {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.detail-fold summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 800;
  color: #344054;
}
.detail-fold-body {
  border-top: 1px solid var(--line-2);
  padding: 16px;
}
.forecast-modal .modal-head {
  align-items: flex-start;
  margin: -18px -18px 16px;
  padding: 16px 18px;
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  border-radius: var(--radius) var(--radius) 0 0;
}
.forecast-modal h2 {
  margin-bottom: 3px;
}
.forecast-modal .modal-head .muted-text { color: rgba(255,255,255,.78); }
.forecast-modal .modal-head .btn {
  color: #fff;
  border-color: rgba(255,255,255,.34);
  background: rgba(255,255,255,.12);
}
.modal.forecast-modal {
  max-width: 1320px;
  background: #f7faff;
}
.forecast-modal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.forecast-mode-detail {
  --mode: #2563eb;
  --mode-bg: #eff6ff;
  --mode-soft: #bfdbfe;
  display: grid;
  gap: 11px;
  border: 1px solid var(--mode-soft);
  border-radius: var(--radius);
  padding: 12px;
  background: linear-gradient(180deg, var(--mode-bg), #fff 90px);
  overflow: hidden;
}
.forecast-mode-detail.mode-safe {
  --mode: #047857;
  --mode-bg: #ecfdf5;
  --mode-soft: #99f6e4;
}
.forecast-mode-detail.mode-balanced {
  --mode: #1d4ed8;
  --mode-bg: #eff6ff;
  --mode-soft: #bfdbfe;
}
.forecast-mode-detail.mode-aggressive {
  --mode: #b45309;
  --mode-bg: #fffbeb;
  --mode-soft: #fedf89;
}
.forecast-mode-detail.mode-custom {
  --mode: #7c3aed;
  --mode-bg: #f5f3ff;
  --mode-soft: #ddd6fe;
}
.forecast-mode-detail > .context-title {
  margin: -12px -12px 0;
  padding: 11px 12px;
  color: var(--mode);
  background: var(--mode-bg);
  border-bottom: 1px solid var(--mode-soft);
}
.forecast-detail-run {
  border: 1px solid var(--prize-soft, var(--line-2));
  border-left: 4px solid var(--prize, var(--blue));
  border-radius: var(--radius);
  padding: 11px;
  background: #fff;
}
.forecast-detail-run.is-hit {
  border-color: #f59e0b;
  border-left-color: #111827;
  background: linear-gradient(180deg, #fffbeb, #fff 96px);
  box-shadow: 0 14px 30px rgba(245, 158, 11, 0.16);
}
.forecast-detail-run.is-box-hit {
  border-color: #a78bfa;
  border-left-color: #7c3aed;
  background: linear-gradient(180deg, #f5f3ff, #fff 96px);
  box-shadow: 0 14px 30px rgba(124, 58, 237, 0.14);
}
.detail-numbers .number-chip {
  min-width: 58px;
}
.direct-hit-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin: 9px 0 11px;
  padding: 10px 12px;
  border: 1px solid #111827;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #111827, #374151);
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.18);
}
.direct-hit-label {
  color: #fde047;
  font-size: 12px;
  font-weight: 900;
}
.direct-hit-sub {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11.5px;
  line-height: 1.3;
}
.direct-hit-number {
  min-width: 70px;
  padding: 7px 13px;
  border-radius: 999px;
  text-align: center;
  color: #111827;
  background: linear-gradient(135deg, #fef08a, #f59e0b);
  box-shadow: 0 10px 22px rgba(245, 158, 11, 0.34);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 24px;
  font-weight: 900;
}
.direct-hit-rank {
  min-width: 42px;
  padding: 5px 9px;
  border: 1px solid rgba(254, 240, 138, 0.78);
  border-radius: 999px;
  color: #111827;
  background: #fef08a;
  font-weight: 900;
  text-align: center;
}
.box-hit-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin: 9px 0 11px;
  padding: 10px 12px;
  border: 1px solid #7c3aed;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #4c1d95, #7c3aed);
  box-shadow: 0 12px 24px rgba(124, 58, 237, 0.18);
}
.box-hit-label {
  color: #ddd6fe;
  font-size: 12px;
  font-weight: 900;
}
.box-hit-sub {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11.5px;
  line-height: 1.3;
}
.box-hit-number {
  min-width: 70px;
  padding: 7px 13px;
  border-radius: 999px;
  text-align: center;
  color: #4c1d95;
  background: linear-gradient(135deg, #ede9fe, #c4b5fd);
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.28);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 24px;
  font-weight: 900;
}
.box-hit-rank {
  min-width: 42px;
  padding: 5px 9px;
  border: 1px solid rgba(221, 214, 254, 0.78);
  border-radius: 999px;
  color: #4c1d95;
  background: #ede9fe;
  font-weight: 900;
  text-align: center;
}
.forecast-detail-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.ai-result-cell {
  display: grid;
  gap: 6px;
  align-items: start;
  min-width: 96px;
}
.ai-result-cell small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.btn-ai-result {
  gap: 5px;
  justify-content: center;
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
  white-space: nowrap;
}
.btn-ai-result:hover {
  border-color: #93c5fd;
  background: #dbeafe;
}
.btn-ai-result.has-direct-hit {
  color: #92400e;
  border-color: #fbbf24;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  box-shadow: 0 8px 18px rgba(245, 158, 11, 0.18);
}
.btn-ai-result.has-direct-hit:hover {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
}
.btn-ai-result.has-box-hit {
  color: #6d28d9;
  border-color: #c4b5fd;
  background: #f5f3ff;
}
.btn-ai-result.has-box-hit:hover {
  border-color: #a78bfa;
  background: #ede9fe;
}
.ai-result-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.ai-direct-badge {
  gap: 4px;
  font-weight: 800;
}
.ai-direct-stars {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 26px;
  height: 15px;
  vertical-align: -2px;
}
.ai-direct-stars span {
  position: absolute;
  display: block;
  color: #f59e0b;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65), 0 2px 6px rgba(245, 158, 11, 0.3);
}
.ai-direct-stars .star-left {
  left: 0;
  top: 4px;
  font-size: 9px;
  opacity: 0.88;
}
.ai-direct-stars .star-center {
  left: 8px;
  top: 0;
  z-index: 2;
  color: #eab308;
  font-size: 15px;
}
.ai-direct-stars .star-right {
  right: 0;
  top: 4px;
  font-size: 9px;
  opacity: 0.88;
}
.badge-stars {
  width: 22px;
  height: 12px;
  margin-right: 1px;
  transform: translateY(-1px);
}
.badge-stars .star-left {
  top: 3px;
  font-size: 8px;
}
.badge-stars .star-center {
  left: 7px;
  font-size: 12px;
}
.badge-stars .star-right {
  top: 3px;
  font-size: 8px;
}
.button-stars {
  margin-right: 1px;
}
.ai-box-badge {
  gap: 3px;
  font-weight: 800;
}
.ai-box-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--purple);
  font-size: 11px;
  line-height: 1;
}
.button-star {
  margin-left: 1px;
  transform: translateY(-1px);
}
.ai-result-modal .modal-head {
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
}
.ai-actual-strip {
  display: grid;
  grid-template-columns: minmax(180px, .9fr) minmax(260px, 1.6fr) minmax(160px, .7fr);
  gap: 12px;
  margin-bottom: 14px;
}
.ai-actual-strip > div {
  border: 1px solid #dbe3ef;
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}
.ai-summary-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.ai-result-grid {
  margin-top: 4px;
}
.ai-empty {
  background: #fff;
  border: 1px dashed #bfdbfe;
  border-radius: var(--radius);
}
.insight-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.insight-list span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; color: #475467; background: #fff; font-size: 12px; }
.empty.sm { padding: 12px 0 0; font-size: 12px; }

.score-row {
  display: grid;
  grid-template-columns: 72px minmax(180px, 1fr) 120px auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-2);
}
.score-row:last-child { border-bottom: 0; }
.score-num {
  min-height: 50px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
}
.score-meta b { display: block; margin-bottom: 4px; }
.score-meta .reasons { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 5px; }
.scorebar { width: 100%; height: 8px; border-radius: 999px; background: #e5e7eb; overflow: hidden; margin-top: 5px; }
.scorebar span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--purple)); }
.score-total { font-weight: 700; color: var(--blue); }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(16, 24, 40, .56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 24px 72px rgba(16,24,40,.24);
}
.modal-lg { max-width: 920px; }
.modal-head { margin-bottom: 12px; }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.toast.success { border-color: #abefc6; color: var(--green); }
.toast.error { border-color: #fecdca; color: var(--red); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #eef2ff;
}
.login-box {
  width: 100%;
  max-width: 390px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-language {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.login-box h1 { margin: 0 0 4px; }
.login-box .sub, .footer-note { color: var(--muted); font-size: 12.5px; }
.login-box .btn { width: 100%; margin-top: 4px; }
.footer-note { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin .8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) and (min-width: 921px) {
  .forecast-modal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 248px; z-index: 60; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .icon-btn { display: grid; }
  .hamburger {
    width: auto;
    display: inline-flex;
    gap: 7px;
    padding: 0 11px;
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
  }
  .hamburger-label { display: inline; }
  .topbar { padding: 10px 14px; }
  .top-warning { display: none; }
  .lang-field span { display: none; }
  .content { padding: 14px; }
  .grid-2, .grid-3, .context-grid { grid-template-columns: 1fr; }
  .forecast-card-grid, .forecast-modal-grid, .mini-hit-grid, .ai-actual-strip { grid-template-columns: 1fr; }
  .score-row { grid-template-columns: 64px 1fr; }
  .score-row .actions, .score-row .btn { grid-column: 1 / -1; }
  .quick-start { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .page-head { flex-direction: column; }
  .actions { justify-content: flex-start; }
  .filters { display: grid; grid-template-columns: 1fr; }
  .user-box span:first-child { display: none; }
  .cards { grid-template-columns: 1fr; }
  .direct-hit-banner,
  .box-hit-banner {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .direct-hit-number,
  .box-hit-number {
    min-width: 96px;
  }
}

/* ===== Hybrid Scoring page ===== */
.hybrid-summary {
  display: flex; flex-wrap: wrap; gap: 14px 22px;
  padding: 10px 12px; margin-bottom: 10px;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
  font-size: 13px; color: #334155;
}
.hybrid-summary b { color: #0f172a; }
.hybrid-num {
  display: inline-block; min-width: 56px; text-align: center;
  padding: 4px 10px; border-radius: 8px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1d4ed8; font-weight: 700; font-size: 15px;
  border: 1px solid #bfdbfe; letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.hybrid-bar {
  height: 6px; width: 100%; max-width: 140px; margin-top: 4px;
  background: #e2e8f0; border-radius: 3px; overflow: hidden;
}
.hybrid-bar-fill {
  height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: 3px; transition: width 0.3s ease;
}
.hybrid-feat { display: flex; flex-wrap: wrap; gap: 4px; }
.hybrid-chip {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  background: #f1f5f9; border: 1px solid #cbd5e1; color: #475569;
  font-size: 11px; font-variant-numeric: tabular-nums;
}
.hybrid-chip.warn { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.hybrid-chip.hit { background: #ecfdf5; border-color: #6ee7b7; color: #047857; font-weight: 700; }
.hybrid-reasons {
  margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: #475569;
  line-height: 1.55;
}
.hybrid-reasons li { margin-bottom: 2px; }
.hybrid-inspect {
  padding: 10px 4px;
}
.hybrid-inspect-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.hybrid-inspect-head .hybrid-num { font-size: 22px; padding: 8px 14px; }
.hybrid-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px; margin: 10px 0;
}
.hybrid-metric-card {
  padding: 12px 14px; background: #fff;
  border: 1px solid #d6e3f5; border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.hybrid-metric-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .5px; }
.hybrid-metric-value { font-size: 22px; font-weight: 700; color: #1e3a8a; margin: 4px 0; font-variant-numeric: tabular-nums; }
.hybrid-metric-foot { font-size: 11.5px; color: #64748b; line-height: 1.4; }
.hybrid-reasons details > summary { cursor: pointer; }

/* Hybrid Forecasts page */
.hybrid-forecast-list { display: grid; gap: 12px; }
.hybrid-forecast-card { padding: 14px 16px; }
.hybrid-forecast-head {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 8px; margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid #e2e8f0;
}
.hf-best { background: linear-gradient(90deg, #ecfdf5, #ffffff); }
.hf-best td:first-child { border-left: 3px solid #10b981; }

/* Hybrid Forecasts grid (เหมือนคำทำนาย AI) */
.hf-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.hf-card {
  background: #fff;
  border: 1px solid #d6e3f5;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  display: flex; flex-direction: column; gap: 8px;
}
.hf-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 6px; border-bottom: 1px dashed #e2e8f0;
}
.hf-card-date { font-weight: 700; color: #0f172a; font-size: 15px; }
.hf-card-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.hf-section {
  border-radius: 10px;
  padding: 10px 12px;
  border-left: 4px solid;
}
.hf-section-top {
  background: linear-gradient(180deg, #eff6ff, #ffffff);
  border-left-color: #3b82f6;
}
.hf-section-bottom {
  background: linear-gradient(180deg, #ecfdf5, #ffffff);
  border-left-color: #10b981;
}
.hf-section-six {
  background: linear-gradient(180deg, #faf5ff, #ffffff);
  border-left-color: #a855f7;
}
.hf-section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.hf-section-label {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  background: #fff; border: 1px solid #cbd5e1;
  font-size: 12px; font-weight: 600; color: #334155;
}
.hf-section-top .hf-section-label { color: #1d4ed8; border-color: #bfdbfe; }
.hf-section-bottom .hf-section-label { color: #047857; border-color: #6ee7b7; }
.hf-section-six .hf-section-label { color: #7e22ce; border-color: #d8b4fe; }
.hf-section-status {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: #f1f5f9; color: #64748b;
}
.hf-status-hit { background: #ecfdf5; color: #047857; font-weight: 600; }
.hf-status-miss { background: #fef2f2; color: #b91c1c; }
.hf-status-skip { background: #fffbeb; color: #92400e; }
.hf-status-pending { background: #eff6ff; color: #1d4ed8; }
.hf-section-numbers {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px;
}
.hf-section-foot { font-size: 11px; color: #64748b; }
.hf-num {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 14px;
  background: #fff; border: 1px solid #cbd5e1;
  font-weight: 700; font-size: 14px; color: #334155;
  font-variant-numeric: tabular-nums;
}
.hf-num small { font-size: 9px; color: #94a3b8; font-weight: 500; }
.hf-section-top .hf-num { background: #ffffff; border-color: #bfdbfe; color: #1d4ed8; }
.hf-section-top .hf-num.hf-num-top { background: #2563eb; color: #fff; border-color: #2563eb; }
.hf-section-top .hf-num.hf-num-top small { color: rgba(255,255,255,.7); }
.hf-section-bottom .hf-num { background: #ffffff; border-color: #6ee7b7; color: #047857; }
.hf-section-bottom .hf-num.hf-num-top { background: #059669; color: #fff; border-color: #059669; }
.hf-section-bottom .hf-num.hf-num-top small { color: rgba(255,255,255,.7); }
.hf-section-six .hf-num { background: #ffffff; border-color: #d8b4fe; color: #7e22ce; }
.hf-section-six .hf-num.hf-num-top { background: #9333ea; color: #fff; border-color: #9333ea; }
.hf-section-six .hf-num.hf-num-top small { color: rgba(255,255,255,.7); }
.hf-num.hf-num-hit { outline: 2px solid #22c55e; outline-offset: 1px; }
.hf-card-link {
  margin-top: 4px; padding: 8px 0;
  text-align: left; font-size: 13px; font-weight: 600;
  color: #2563eb; text-decoration: none;
  border-top: 1px dashed #e2e8f0;
}
.hf-card-link:hover { color: #1d4ed8; text-decoration: underline; }

.hf-tab-panel { padding: 12px 14px; }
.hf-tab-bar {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 4px; background: #f1f5f9; border-radius: 12px;
  width: fit-content;
}
.hf-tab {
  padding: 8px 18px; border: 0; background: transparent;
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: #475569; cursor: pointer; border-radius: 8px;
  transition: all 0.15s;
}
.hf-tab:hover { background: rgba(255,255,255,0.6); color: #0f172a; }
.hf-tab.active { background: #ffffff; color: #1d4ed8; box-shadow: 0 2px 4px rgba(15,23,42,.08); }
.hf-tab[data-number-type="2_digit"].active { color: #047857; }
.hf-tab[data-number-type="6_digit"].active { color: #7e22ce; }

/* ===== Hybrid Modal (เหมือนระบบ AI เดิม) ===== */
.hf-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 28px 16px;
  overflow-y: auto;
  animation: hfFadeIn .15s ease;
}
@keyframes hfFadeIn { from { opacity: 0 } to { opacity: 1 } }
.hf-modal-box {
  width: 100%; max-width: 1320px;
  background: #ffffff; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15,23,42,.32);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.hf-modal-head {
  background: linear-gradient(120deg, #2563eb 0%, #1d4ed8 45%, #059669 100%);
  color: #ffffff;
  padding: 16px 22px;
  display: flex; justify-content: space-between; align-items: center;
}
.hf-modal-title { font-size: 18px; font-weight: 700; }
.hf-modal-sub { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.hf-modal-head .btn { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.3); }
.hf-modal-head .btn:hover { background: rgba(255,255,255,.28); }
.hf-modal-body { padding: 18px 18px 8px; }
.hf-modal-cols {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.hf-modal-col {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.hf-modal-col-head {
  font-weight: 700; font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  text-align: left;
}
.hf-mode-safe .hf-modal-col-head    { background: #ecfdf5; color: #047857; border-left: 4px solid #10b981; }
.hf-mode-balanced .hf-modal-col-head { background: #eff6ff; color: #1d4ed8; border-left: 4px solid #3b82f6; }
.hf-mode-aggressive .hf-modal-col-head { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }
.hf-mode-chaos .hf-modal-col-head   { background: #f5f3ff; color: #6d28d9; border-left: 4px solid #8b5cf6; }
.hf-modal-foot {
  padding: 12px 22px;
  border-top: 1px solid #e2e8f0;
  display: flex; justify-content: flex-end;
}

@media (max-width: 1100px) {
  .hf-modal-cols { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .hf-modal-cols { grid-template-columns: 1fr; }
  .hf-modal-head { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* Cell "ผลจาก AI" หลายบอท */
.ai-result-cell-multi { display: flex; flex-direction: column; gap: 6px; }
.ai-bot-row {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 6px;
}
.ai-bot-row + .ai-bot-row { border-top: 1px dashed #e2e8f0; padding-top: 6px; }
.ai-bot-tag {
  display: inline-block; padding: 1px 6px; margin-right: 6px;
  border-radius: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
  color: #fff; background: #64748b;
  vertical-align: middle;
}
.tag-ai     { background: #2563eb; }
.tag-hybrid { background: #9333ea; }
.btn-hybrid-result {
  background: linear-gradient(135deg, #faf5ff, #f3e8ff);
  border-color: #d8b4fe;
  color: #6d28d9;
}
.btn-hybrid-result:hover {
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
  border-color: #c084fc;
  color: #581c87;
}
.btn-hybrid-result.has-direct-hit {
  background: linear-gradient(135deg, #9333ea, #7e22ce);
  color: #fff; border-color: #7e22ce;
}
.btn-hybrid-result.has-box-hit {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border-color: #a78bfa; color: #5b21b6;
}

/* Banner ในแต่ละ section (ทางตรง / เลขกลับ) */
.hf-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  margin: 8px 0;
}
.hf-banner-direct {
  background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
  color: #fef3c7;
  border: 1px solid #fbbf24;
}
.hf-banner-box {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
  color: #ffffff;
  border: 1px solid #a78bfa;
}
.hf-banner-text { flex: 1; }
.hf-banner-title { font-size: 13px; font-weight: 700; letter-spacing: .3px; }
.hf-banner-sub { font-size: 11px; opacity: .85; margin-top: 2px; }
.hf-banner-num {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1f2937;
  padding: 6px 14px; border-radius: 10px;
  font-weight: 800; font-size: 18px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.hf-banner-box .hf-banner-num {
  background: linear-gradient(135deg, #c4b5fd, #a78bfa);
  color: #4c1d95;
}
.hf-banner-rank {
  padding: 4px 10px; border-radius: 16px;
  background: rgba(255,255,255,.18); color: #fff;
  font-weight: 700; font-size: 13px;
}
.hf-banner-direct .hf-banner-rank { background: rgba(251,191,36,.25); color: #fde68a; }

/* Section ที่เข้า/box เปลี่ยน outline สีให้เด่น */
.hf-section.hf-section-hit { box-shadow: 0 0 0 2px rgba(251,191,36,.5) inset; }
.hf-section.hf-section-box { box-shadow: 0 0 0 2px rgba(167,139,250,.5) inset; }

/* highlight เลขใน list */
.hf-num.hf-num-hit {
  outline: 2px solid #fbbf24; outline-offset: 1px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
  color: #1f2937 !important;
}
.hf-num.hf-num-box {
  outline: 2px solid #a78bfa; outline-offset: 1px;
  background: linear-gradient(135deg, #ede9fe, #ddd6fe) !important;
  color: #5b21b6 !important;
}

.hf-chip-near {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: #fef3c7; color: #92400e; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hf-chip-far {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: #f1f5f9; color: #475569;
  font-variant-numeric: tabular-nums;
}
