/* AI Footwear Trend Intelligence V0.7 — static interactive demo */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #17202b; --muted: #5b6878; --line: #e2e6eb; --soft: #eef2f7;
  --accent: #1d5fd6; --accent-soft: #e8f0fd; --good: #19734a; --good-soft: #e5f4ec; --bad: #b42318; --bad-soft: #fdecea;
  --warn: #8f3a0c; --warn-soft: #fff3e2; --info: #5a3fb8; --info-soft: #f1edfd; --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Leelawadee UI", "Segoe UI", -apple-system, BlinkMacSystemFont, "Noto Sans Thai", "Sarabun",
               Thonburi, Tahoma, "Loma", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.6; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
h1 { font-size: 1.4rem; margin: .2rem 0 .3rem; line-height: 1.35; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: .4rem 0 .3rem; }
p { margin: .3rem 0 .6rem; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%;
  min-width: 0; }
@media (max-width: 760px) { input, select, textarea { font-size: 16px; } }   /* iOS Safari: no zoom on focus */

/* ---------- layout ---------- */
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 50; background: #fff; padding: 6px; }
.banner { padding: 8px 16px; text-align: center; font-size: .9rem; border-bottom: 2px solid; }
.banner.demo { background: var(--warn-soft); color: var(--warn); border-color: #f2b27a; font-weight: 600; }
.banner.real { background: var(--good-soft); color: #0f5132; border-color: #a7d9bd; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 1400px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; min-width: 0; }
.logo img { width: 28px; height: 28px; }
.logo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo small { color: var(--muted); font-weight: 500; }
.mode { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--soft); flex-shrink: 0; }
.mode button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .85rem; color: var(--muted); }
.mode button[aria-pressed="true"].real { background: var(--good); color: #fff; }
.mode button[aria-pressed="true"].demo { background: var(--warn); color: #fff; }
.menubtn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
nav.main { max-width: 1400px; margin: 0 auto; padding: 0 12px 8px; display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .9rem; white-space: nowrap; }
nav.main a[aria-current="page"], nav.main a:hover { background: var(--accent-soft); color: var(--accent); }
main { max-width: 1400px; margin: 0 auto; padding: 16px 16px 48px; }
footer { max-width: 1400px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .menubtn { display: inline-block; }
  nav.main { display: none; flex-direction: column; padding: 0 12px 10px; }
  nav.main.open { display: flex; }
  .logo small { display: none; }
}

/* ---------- components ---------- */
.lead { color: var(--muted); margin: 0 0 1rem; max-width: 80ch; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g5 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .v { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi .s { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: .74rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; vertical-align: middle; }
.b-obs { background: var(--good-soft); color: var(--good); border-color: #b6dfc8; }
.b-demo { background: var(--warn-soft); color: var(--warn); border-color: #f2c79a; }
.b-imp { background: var(--info-soft); color: var(--info); border-color: #d2c8f5; }
.b-na { background: var(--soft); color: var(--muted); border-color: var(--line); }
.b-est { background: #fff8db; color: #7a5a00; border-color: #efd98a; }
.b-l5 { background: #eef1f5; color: #3d4a5a; border-color: #d5dbe3; }
.st { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .72rem; letter-spacing: .02em; }
.st-CONNECTED { background: var(--good-soft); color: var(--good); }
.st-PARTIAL { background: #fff8db; color: #7a5a00; }
.st-MANUAL { background: var(--accent-soft); color: var(--accent); }
.st-NEED { background: var(--info-soft); color: var(--info); }
.st-BLOCKED { background: var(--bad-soft); color: var(--bad); }
.st-UNAVAILABLE, .st-DEMO { background: var(--soft); color: var(--muted); }
.na { color: var(--muted); font-size: .8rem; font-family: ui-monospace, Menlo, Consolas, monospace; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .76rem; }
.note { background: var(--soft); border-radius: 10px; padding: 10px 12px; font-size: .88rem; color: #334155; }
.warnbox { background: var(--warn-soft); border: 1px solid #f2c79a; color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.empty { border: 1px dashed #c8d0da; background: var(--panel); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); gap: 3px; min-width: 0; }
.filters select, .filters input { width: 100%; }
.scope { font-size: .82rem; color: var(--muted); margin: 6px 0 10px; }

/* product cards */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.card .img { aspect-ratio: 244 / 170; background: var(--soft); }
.card .img img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .name { font-weight: 600; font-size: .92rem; line-height: 1.35; overflow-wrap: anywhere; }
.card .metric { font-size: 1.15rem; font-weight: 700; }
.card .foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.rankno { position: relative; }
.rankno::before { content: attr(data-rank); position: absolute; top: 8px; left: 8px; background: var(--ink); color: #fff; font-weight: 700; border-radius: 8px; padding: 0 8px; font-size: .85rem; z-index: 1; }

/* tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-weight: 600; color: #334155; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .wrap { overflow-wrap: anywhere; }

/* bars, swatches, sparkline */
.bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: .86rem; margin: 5px 0; }
.bar .track { display: block; background: var(--soft); border-radius: 6px; height: 12px; overflow: hidden; }
.bar .fill { display: block; background: var(--accent); height: 100%; border-radius: 6px; }
.bar .fill.demo { background: #e08a4a; }
.bar .fill.obs { background: var(--good); }
.stack { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--soft); }
.stack span { display: block; height: 100%; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; align-items: center; font-size: .75rem; gap: 2px; }
.swatch i { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); display: block; }
.spark { width: 100%; height: 56px; }
.mood { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.mood img { border-radius: 10px; border: 1px solid var(--line); }
.cluster { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.cluster .thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.cluster .thumbs img { width: 64px; border-radius: 6px; border: 1px solid var(--line); }
dl.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 4px 10px; margin: 0; font-size: .87rem; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.tag { display: inline-block; background: var(--soft); border-radius: 6px; padding: 0 6px; font-size: .75rem; margin: 1px 2px 1px 0; }
.q { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.q:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; }
.dot.ok { background: var(--good); } .dot.part { background: #d4a106; } .dot.no { background: var(--bad); }
.chk { display: flex; gap: 6px; align-items: center; font-size: .82rem; cursor: pointer; }
.drop { border: 2px dashed #c8d0da; border-radius: var(--radius); padding: 20px; text-align: center; background: var(--panel); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.errors li { color: var(--bad); } .warns li { color: #7a5a00; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dhead { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
dialog .dbody { padding: 16px; }
.compare-bar { position: sticky; bottom: 0; background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; z-index: 10; }
.compare-bar .btn.ghost { background: transparent; color: #fff; border-color: #475569; }

/* print / PDF report */
.print-only { display: none; }
@media print {
  .topbar, nav.main, footer, .no-print, .compare-bar, .banner.real { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .panel, .kpi, .card, .tablewrap { box-shadow: none; break-inside: avoid; }
  .banner.demo { display: block !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; }
}

.noscript{padding:16px}

/* V0.10 */
.nowrap { white-space: nowrap; }
.model-cell { min-width: 120px; max-width: 260px; }
.pname { overflow-wrap: anywhere; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.gcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.gcard .body { padding: 8px 10px; display: grid; gap: 4px; }
.gpic { aspect-ratio: 1 / 1; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.gimg { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.noimg { padding: 12px; text-align: center; color: var(--muted); }
.bigimg { width: 100%; max-height: 60vh; object-fit: contain; background: #f8fafc; border-radius: 8px; }
.thumb { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: #fff; }
.badge.b-warn { background: #fef3c7; color: #92400e; }
