:root {
  --rose: #e11d48;
  --rose-dark: #9f1239;
  --rose-pale: #fff1f2;
  --text: #18181b;
  --muted: #71717a;
  --card: #fff;
  --shadow: 0 8px 24px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", "Noto Sans Thai", system-ui, sans-serif; background: #fafafa; color: var(--text); }
.ticker { background: var(--text); color: #fff; text-align: center; padding: 0.4rem; font-size: 0.85rem; display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.ticker .sep { opacity: 0.4; }
.topnav { position: sticky; top: 0; z-index: 50; display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.5rem; background: #fff; border-bottom: 1px solid #f4f4f5; flex-wrap: wrap; gap: 0.5rem; }
.logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text); font-weight: 700; }
.logo-icon { width: 36px; height: 36px; background: var(--rose); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.nav-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.nav-links a { text-decoration: none; color: var(--text); font-size: 0.9rem; }
.nav-links a:hover { color: var(--rose); }
.nav-admin { color: var(--muted) !important; font-size: 0.8rem !important; }
.hero { background: linear-gradient(135deg, var(--rose-pale), #fff); padding: 3rem 1.5rem; }
.hero h1 { font-size: 2.2rem; margin: 0.5rem 0; }
.badge { display: inline-block; background: var(--rose); color: #fff; padding: 0.25rem 0.6rem; border-radius: 999px; font-size: 0.8rem; }
.tagline { color: var(--muted); max-width: 480px; }
.hero-actions { display: flex; gap: 0.75rem; margin: 1.25rem 0; flex-wrap: wrap; }
.hero-ai { font-size: 0.9rem; color: var(--muted); }
.btn { padding: 0.6rem 1.2rem; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; font-size: 0.95rem; }
.btn-primary { background: var(--rose); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--rose); color: var(--rose-dark); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.section { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.section.alt { background: var(--rose-pale); max-width: none; }
.section.alt > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.section h2 { margin: 0 0 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.products { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: var(--card); border-radius: 12px; padding: 1.25rem; box-shadow: var(--shadow); }
.product-card { position: relative; }
.product-card .sale-badge { position: absolute; top: 0.75rem; right: 0.75rem; background: var(--rose); color: #fff; font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 6px; }
.product-card .price { font-size: 1.15rem; font-weight: 700; color: var(--rose-dark); }
.product-card .was { text-decoration: line-through; color: var(--muted); font-size: 0.9rem; margin-left: 0.35rem; }
.product-card .meta { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.out-of-stock { opacity: 0.55; }
.filter-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.filter-row select { padding: 0.5rem; border-radius: 8px; border: 1px solid #e4e4e7; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 768px) { .contact-grid { grid-template-columns: 1fr; } }
.form-card input, .form-card textarea { width: 100%; margin-bottom: 0.75rem; padding: 0.6rem; border: 1px solid #e4e4e7; border-radius: 8px; font-family: inherit; }
.result { margin-top: 0.75rem; padding: 0.75rem; background: var(--rose-pale); border-radius: 8px; font-size: 0.9rem; }
.result.hidden { display: none; }
.footer { text-align: center; padding: 2rem; color: var(--muted); font-size: 0.85rem; }
.admin-body { background: #f4f4f5; }
.admin-nav { background: var(--text); }
.admin-nav .logo { color: #fff; }
.admin-nav .nav-admin { color: #fda4af !important; }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.admin-section { background: #fff; border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.dash-card { background: #fff; padding: 1rem; border-radius: 12px; text-align: center; box-shadow: var(--shadow); }
.dash-card .v { font-size: 1.5rem; font-weight: 700; }
.dash-card .l { font-size: 0.8rem; color: var(--muted); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 0.6rem; border-bottom: 1px solid #f4f4f5; text-align: left; }
.data-table th { background: var(--rose-pale); }
.status { display: inline-block; padding: 0.15rem 0.45rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; }
.status-pending, .status-open { background: #fef3c7; color: #92400e; }
.status-done, .status-confirmed { background: #d1fae5; color: #065f46; }

/* AI tools tester */
.admin-nav-links { display: flex; gap: 1rem; align-items: center; }
.nav-highlight { color: #fda4af !important; font-weight: 600; }
.tools-main { max-width: 1200px; }
.tools-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tools-header h1 { margin: 0 0 0.35rem; }
.tools-lead { margin: 0; color: var(--muted); font-size: 0.95rem; max-width: 640px; }
.tools-header-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.auto-refresh { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 0.35rem; }
.tools-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .tools-layout { grid-template-columns: 1fr; } }
.tools-sidebar h2, .tools-panel h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.tool-search { width: 100%; padding: 0.5rem; border: 1px solid #e4e4e7; border-radius: 8px; margin-bottom: 0.75rem; font-family: inherit; }
.tool-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.tool-item { width: 100%; text-align: left; border: 1px solid #f4f4f5; background: #fafafa; border-radius: 8px; padding: 0.55rem 0.65rem; margin-bottom: 0.35rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 0.35rem; font-family: inherit; font-size: 0.82rem; }
.tool-item:hover { border-color: var(--rose); background: var(--rose-pale); }
.tool-item.active { border-color: var(--rose); background: var(--rose-pale); box-shadow: inset 3px 0 0 var(--rose); }
.tool-item-name { font-family: ui-monospace, monospace; font-weight: 600; }
.tool-panel-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tool-desc { margin: 0 0 1rem; font-size: 0.9rem; }
.tool-url-label { font-size: 0.8rem; color: var(--muted); margin: 0 0 0.25rem; }
.tool-url { display: block; font-size: 0.75rem; background: #f4f4f5; padding: 0.5rem; border-radius: 6px; word-break: break-all; margin-bottom: 1rem; }
.field-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; }
.payload-json { width: 100%; font-family: ui-monospace, monospace; font-size: 0.82rem; padding: 0.65rem; border: 1px solid #e4e4e7; border-radius: 8px; resize: vertical; }
.tool-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.run-result { margin-top: 1rem; border-top: 1px solid #f4f4f5; padding-top: 0.75rem; }
.run-result.hidden { display: none; }
.run-meta { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.run-result pre { background: #18181b; color: #fafafa; padding: 0.75rem; border-radius: 8px; overflow: auto; max-height: 280px; font-size: 0.78rem; margin: 0; }
.access-badge { font-size: 0.7rem; padding: 0.15rem 0.4rem; border-radius: 4px; font-weight: 600; text-transform: uppercase; }
.access-public { background: #dbeafe; color: #1e40af; }
.access-staff_only { background: #fef3c7; color: #92400e; }
.tools-log-section { margin-top: 0; }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.log-head h2 { margin: 0; }
.tools-tip { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0 1rem; }
.hook-log { display: flex; flex-direction: column; gap: 0.5rem; max-height: 420px; overflow-y: auto; }
.log-row { border: 1px solid #f4f4f5; border-radius: 8px; padding: 0.65rem 0.75rem; background: #fafafa; }
.log-row.log-nomi { border-left: 3px solid #10b981; }
.log-row.log-manual { border-left: 3px solid #3b82f6; }
.log-row.log-error { background: #fef2f2; }
.log-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.35rem; }
.log-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-payload { margin: 0; font-size: 0.75rem; background: #fff; padding: 0.5rem; border-radius: 6px; overflow: auto; max-height: 120px; }
.source-badge { font-size: 0.7rem; padding: 0.1rem 0.35rem; border-radius: 4px; font-weight: 600; }
.source-nomi { background: #d1fae5; color: #065f46; }
.source-manual { background: #dbeafe; color: #1e40af; }
.status-ok { color: #059669; font-weight: 600; }
.status-err { color: #dc2626; font-weight: 600; }
.muted { color: var(--muted); }
.log-empty { text-align: center; padding: 1.5rem; }

/* Unified demo dashboard */
.dash-app-body { margin: 0; background: #f1f5f9; }
.dash-app { display: flex; min-height: 100vh; }
.dash-sidebar {
  width: 240px; flex-shrink: 0; background: #0f172a; color: #e2e8f0;
  display: flex; flex-direction: column; padding: 1.25rem 0.75rem;
}
.dash-brand { display: flex; gap: 0.65rem; align-items: center; padding: 0 0.5rem 1.25rem; border-bottom: 1px solid #334155; margin-bottom: 1rem; }
.dash-brand-icon { width: 40px; height: 40px; background: var(--rose); color: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.dash-brand small { display: block; color: #94a3b8; font-size: 0.72rem; }
.dash-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.dash-nav-item {
  text-align: left; border: none; background: transparent; color: #cbd5e1;
  padding: 0.65rem 0.75rem; border-radius: 8px; cursor: pointer; font-family: inherit;
  font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center;
}
.dash-nav-item:hover { background: #1e293b; color: #fff; }
.dash-nav-item.active { background: #334155; color: #fff; font-weight: 600; }
.nav-badge { background: var(--rose); color: #fff; font-size: 0.7rem; padding: 0.1rem 0.45rem; border-radius: 999px; min-width: 1.2rem; text-align: center; }
.dash-sidebar-foot { border-top: 1px solid #334155; padding-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.dash-link { color: #94a3b8; font-size: 0.82rem; text-decoration: none; padding: 0.25rem 0.5rem; }
.dash-link:hover { color: #fff; }
.btn-danger { background: #dc2626; color: #fff; border: none; }
.dash-main { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 2rem; }
.dash-topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.dash-topbar h1 { margin: 0; font-size: 1.5rem; }
.dash-subtitle { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }
.dash-topbar-actions { display: flex; align-items: center; gap: 0.65rem; }
.live-toggle { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 0.35rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.live-dot.pulse { animation: pulse 0.5s ease; }
@keyframes pulse { 50% { transform: scale(1.8); opacity: 0.5; } }
.dash-panel { display: none; }
.dash-panel.active { display: block; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-card { background: #fff; border-radius: 12px; padding: 1rem; box-shadow: var(--shadow); }
.stat-card.stat-accent { border-left: 4px solid var(--rose); }
.stat-val { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-lbl { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .dash-sidebar { width: 100%; } .dash-app { flex-direction: column; } }
.panel-card { background: #fff; border-radius: 12px; padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.panel-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.panel-card-head h2 { margin: 0; font-size: 1rem; }
.link-btn { border: none; background: none; color: var(--rose); cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.mini-list { display: flex; flex-direction: column; gap: 0.5rem; }
.mini-row { font-size: 0.85rem; padding: 0.45rem 0; border-bottom: 1px solid #f1f5f9; }
.hint-card { background: #fff; border: 1px dashed #cbd5e1; border-radius: 12px; padding: 1rem 1.25rem; font-size: 0.88rem; color: #475569; }
.hint-card ol { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.hint-card code { background: #f1f5f9; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.82rem; }
.toolbar { margin-bottom: 0.75rem; }
.toolbar select { padding: 0.45rem 0.6rem; border-radius: 8px; border: 1px solid #e2e8f0; }
.table-wrap { background: #fff; border-radius: 12px; box-shadow: var(--shadow); overflow: auto; }
.table-wrap .data-table { margin: 0; }
.status-pill { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; text-transform: lowercase; }
.status-pending, .status-open { background: #fef3c7; color: #92400e; }
.status-paid { background: #dbeafe; color: #1e40af; }
.status-packing { background: #e0e7ff; color: #3730a3; }
.status-shipped { background: #cffafe; color: #0e7490; }
.status-delivered, .status-done, .status-confirmed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.toast {
  position: fixed; top: 1rem; right: 1rem; z-index: 200;
  background: #0f172a; color: #fff; padding: 0.75rem 1.1rem; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); font-size: 0.9rem; max-width: 360px;
}
.toast.hidden { display: none; }
.tools-in-dash .tools-layout { margin-bottom: 0; }
.tools-in-dash .tool-list { max-height: 320px; }
.run-inline { background: #18181b; color: #fafafa; padding: 0.65rem; border-radius: 8px; font-size: 0.78rem; margin-top: 0.75rem; overflow: auto; max-height: 200px; }
.run-inline.hidden { display: none; }
.product-grid-dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.product-mini { background: #fff; border-radius: 10px; padding: 0.85rem; box-shadow: var(--shadow); font-size: 0.88rem; }
.product-mini.oos { opacity: 0.55; }
.product-mini-id { font-family: ui-monospace, monospace; font-size: 0.72rem; color: var(--muted); }
.product-mini strong { display: block; margin: 0.25rem 0; }
