:root {
  font-family: Geist, "Noto Sans Thai", "Thonburi", system-ui, sans-serif;
  color: #202a40;
  background: #f4f6fa;
  --muted: #5b687e;
  --line: #e2e7ef;
  --primary: #2156e0;
  --teal: #008273;
  --teal-bg: #e3f6f1;
  --nav: #151d33;
  --orange: #c34c32;
  --purple: #7051cf;
  --blue: #235acb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 310px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
a { color: var(--primary); }
h1,h2,h3,p,dl,dd { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 35px); letter-spacing: -.035em; }
h2 { font-size: 19px; letter-spacing: -.016em; }
h3 { font-size: 16px; }
:focus-visible { outline: 3px solid #7d9fff; outline-offset: 2px; }
.loading { padding: 48px; color: var(--muted); }
.shell { min-height: 100dvh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { background: var(--nav); color: #fff; display: flex; flex-direction: column; gap: 24px; padding: 26px 16px; position: sticky; top: 0; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 24px; letter-spacing: -.06em; font-weight: 750; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.sidebar .brand { padding-inline: 9px; }
.shop-name { border-top: 1px solid #35415d; padding: 15px 9px 0; font-size: 15px; color: #d6e1f6; }
.sidebar nav { display: grid; gap: 5px; }
.nav { padding: 11px 11px; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid transparent; border-radius: 8px; background: none; color: #d8e1f2; font-size: 15px; }
.nav span { width: 18px; text-align: center; color: #a5baff; font-size: 17px; }
.nav:hover, .nav.current { color: white; background: #293655; }
.nav.current { border-color: #455b92; }
.sidebar-foot { margin-top: auto; padding: 8px; color: #bac8e7; font-size: 14px; }
.header { background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; min-height: 64px; justify-content: space-between; gap: 8px; padding: 10px 32px; }
.identity { display: flex; gap: 10px; align-items: center; }
.identity strong { font-size: 14px; }
.mode { border-radius: 16px; background: #fff1d0; color: #664518; padding: 4px 11px; font-size: 14px; font-weight: 650; }
.main { max-width: 1470px; margin-inline: auto; padding: 26px 32px 52px; }
.title { display:flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 21px; }
.subtext { font-size: 14px; color: var(--muted); margin-top: 5px; }
.controls { display:flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters { margin-bottom: 17px; }
.date-presets { margin-bottom: 10px; gap: 6px; }
.date-presets .soft { min-height: 31px; padding-block: 3px; }
label { font-size: 14px; font-weight: 650; display: grid; gap: 5px; }
input, select { padding: 8px 10px; min-height: 39px; min-width: 0; border: 1px solid #cbd4e3; border-radius: 7px; color: #24314a; background-color: #fff; }
input[type=checkbox] { min-height: auto; width: 17px; height: 17px; accent-color: var(--primary); }
input[type=search] { width: min(100%, 280px); }
select { appearance: none; padding-right: 28px; border-color: #cbd4e3; background: linear-gradient(45deg, transparent 50%, #53617c 50%) calc(100% - 15px) 50% / 5px 5px no-repeat, linear-gradient(135deg, #53617c 50%, transparent 50%) calc(100% - 10px) 50% / 5px 5px no-repeat white; }
button.primary,button.soft,button.outline,button.link,button.danger { font-size: 14px; font-weight: 650; border-radius: 7px; min-height: 39px; padding: 7px 12px; }
.primary { border: 1px solid var(--primary); background: var(--primary); color: white; }
.primary:hover { background: #1543bd; }
.soft { border: 1px solid #d6e1fa; color: #1d469e; background: #edf3ff; }
.outline { border: 1px solid #d2dbe9; color: #263650; background: white; }
button.link { border: 0; padding-inline: 4px; color: #194bbf; background: none; }
.danger { border: 1px solid #f0c8c0; color: #8b3527; background: #fff5f3; }
.note { color: var(--muted); font-size: 14px; }
.cards { display:grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.panel, .metric { background: white; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.metric { padding: 16px 17px; border-top: 3px solid var(--accent,var(--primary)); }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { display: block; font-size: clamp(22px, 2.5vw, 29px); margin-block: 5px; font-variant-numeric: tabular-nums; }
.panel { padding: 17px 19px; }
.metric b { font-size: 13px; list-style: none; font-weight: 650; color: #315193; }
.grid { display:grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.panel-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap: 8px; margin-bottom: 12px; }
.chart { width:100%; height: 214px; display: block; }
.legend { display:flex; gap: 13px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i, .swatch { width: 9px; height: 9px; border-radius: 3px; display:inline-block; margin-right: 4px; background: var(--color); }
.legend span { white-space: nowrap; }
.channel-list { display:grid; gap: 13px; padding-block: 11px; }
.bar-row { display:grid; grid-template-columns: 85px minmax(45px, 1fr) 43px; align-items:center; font-size:14px; gap:9px; }
.bar-row progress { appearance:none; border:0; width:100%; height:10px; border-radius:5px; overflow:hidden; }
progress::-webkit-progress-bar { background:#eef1f7; }
progress::-webkit-progress-value { background:var(--color); }
progress::-moz-progress-bar { background:var(--color); }
.bar-row b { text-align: right; }
.table-box { overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:14px; text-align:left; }
th,td { border-bottom:1px solid #edf0f5; padding:10px 9px; vertical-align:middle; }
th { color:#51627b; font-size:13px; background:#f6f8fc; white-space:nowrap; }
tr:last-child td { border-bottom:0; }
td b { display:block; }
.code { font-size:12px; color:var(--muted); overflow-wrap:anywhere; }
.empty { color:var(--muted); padding: 20px 0; }
.pill { display:inline-flex; white-space:nowrap; border-radius:15px; padding:3px 8px; font-size:12px; font-weight:650; background:#edf1f7; color:#495773; }
.pill.ok { color:#00685b; background:#e1f5ef; }
.pill.warn { color:#804210; background:#fff0d8; }
.pill.bad { color:#9c3e32; background:#fcebe8; }
.sync-heading, .sync-quantity, .sync-status { display:inline-flex; align-items:center; gap:6px; white-space:nowrap; }
.info-button { display:inline-grid; place-items:center; width:25px; height:25px; border:1px solid #c7d3e8; border-radius:50%; background:#fff; color:#2350ae; font-size:14px; font-weight:750; }
.info-button:hover, .quantity-button:hover { background:#eaf1ff; }
.sync-help-copy { display:grid; gap:10px; line-height:1.7; }
dialog:has(.sync-help-copy) { max-width:480px; }
dialog:has(.sync-help-copy) .panel-head { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; }
.sync-quantity { font-variant-numeric:tabular-nums; }
.quantity-button { min-height:34px; min-width:38px; background:#f0f5ff; border:1px solid #d0dff9; border-radius:6px; padding:3px 7px; color:#1c4ea7; font-weight:700; }
.quantity-form { display:grid; gap:5px; width:136px; max-width:100%; }
.quantity-form input { width:100%; }
.quantity-actions { display:flex; flex-wrap:wrap; align-items:center; gap:3px; }
.quantity-actions button { min-height:32px; }
.quantity-actions .primary { padding-inline:8px; }
.quantity-form .form-error { font-size:13px; }
dialog:has(.quantity-form) { max-width:390px; }
dialog .quantity-form { width:100%; gap:10px; margin-top:12px; }
.sync-status { border:1px solid #d4deee; background:#fff; color:#28374f; border-radius:18px; min-height:34px; padding:3px 9px; font-weight:650; }
button.sync-status:hover { background:#f2f6fc; }
.sync-status-compact { display:none; }
.sync-light { width:11px; height:11px; border-radius:50%; flex:none; }
.sync-light.off { background:#232932; }
.sync-light.on { background:#008345; }
.sync-light.paused { background:#bd7200; }
.sync-toolbar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; }
.sync-toolbar form { flex:1 1 280px; }
.sync-toolbar input[type=search] { flex:1; width:auto; max-width:280px; }
.sync-toolbar .sync-heading { font-size:13px; color:var(--muted); }
.sync-summary { margin-block:12px 8px; }
.sync-table { table-layout:fixed; }
.sync-table thead th { padding:10px 12px; }
.sync-product-head { width:27%; }
.sync-table tbody tr > * { padding:12px; vertical-align:top; }
.sync-table tbody tr:last-child > * { border-bottom:0; }
.sync-product-cell { color:#263650; background:#fafbfe; white-space:normal; overflow-wrap:anywhere; font-size:14px; }
.sync-product-cell .code { display:block; font-weight:400; margin-top:4px; }
.sync-market-label { display:inline-flex; align-items:center; gap:7px; font-weight:700; color:#28374f; }
.sync-market-label .swatch { flex:none; margin:0; }
.sync-listing-cell { border-inline-start:1px solid #edf0f5; }
.sync-values dt { font-size:12px; color:var(--muted); margin-bottom:4px; }
.sync-values .sync-quantity { gap:4px; flex-wrap:wrap; white-space:normal; overflow-wrap:anywhere; }
.sync-values .sync-quantity > span { font-size:12px; }
.sync-listing-status { display:grid; justify-items:start; gap:4px; margin-top:8px; }
.sync-unmapped { color:var(--muted); font-size:13px; }
.sync-pager { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:10px; margin-top:12px; }
.stack { display:grid; gap:16px; }
.shop-sync { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; background:#f2f6fe; border:1px solid #dce6f7; border-radius:10px; margin-bottom:14px; }
.shop-sync .subtext { margin-top:2px; }
.switches { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr)); align-items:start; gap:12px; }
.channel-card { border:1px solid var(--line); border-radius:10px; padding:14px; }
.channel-card header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.channel-card .swatch { margin-right:8px; }
.channel-alert { margin-top:6px; padding:4px 8px; border-radius:5px; background:#fff0d8; color:#713d0b; font-size:13px; }
.channel-alert p, .channel-alert .channel-control { margin-top:5px; }
.channel-control { display:flex; align-items:center; gap:4px; }
.channel-card > .channel-control { margin-top:10px; }
.channel-control button:not(.info-button) { min-height:44px; }
.channel-control .info-button { width:44px; height:44px; flex:none; border:none; background:transparent; padding:0; }
.channel-control .info-button span { display:grid; place-items:center; width:25px; height:25px; border:1px solid #bdcbe2; border-radius:50%; background:white; }
.channel-control .info-button:hover span { background:#eaf1ff; border-color:#8aa8db; }
.channel-tests { margin-top:10px; border-top:1px solid var(--line); }
.channel-tests summary { padding:11px 2px 8px; min-height:44px; cursor:pointer; color:#4b5d77; font-size:14px; font-weight:650; }
.channel-tests .channel-control { margin-top:5px; }
.channel-tests .channel-control button:first-child { flex:1; text-align:start; line-height:1.45; }
.check { display:inline-flex; align-items:center; gap:6px; }
.form { display:grid; gap:13px; }
.order-line { display:grid; grid-template-columns:minmax(130px,3fr) minmax(60px,1fr) minmax(75px,1fr) auto; gap:7px; align-items:end; }
.login { width:min(100% - 28px,440px); margin: clamp(38px, 10vh, 100px) auto; padding:29px; }
.login h1 { font-size:28px; margin-top:22px; }
.login form { margin-top:18px; }
dialog { border:1px solid var(--line); border-radius:13px; color:#202a40; padding:21px; width:min(calc(100% - 22px),730px); max-height:90dvh; overflow:auto; }
dialog::backdrop { background:rgba(12,19,37,.55); }
.toast { position:fixed; z-index:9; bottom:17px; right:17px; padding:12px 15px; background:#17395a; color:white; border-radius:8px; max-width:calc(100% - 34px); }
.toast.invalid { background:#8c342b; }
.form-error { padding:9px; color:#823426; background:#fff0eb; border-radius:6px; }
@media(max-width:1060px) {
  .shell { grid-template-columns:190px minmax(0,1fr); }
  .sidebar { padding-inline:12px; }
  .main,.header { padding-inline:19px; }
  .cards { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:960px) {
  .sync-product-head { width:36%; }
  .sync-table thead th { position:sticky; top:0; z-index:1; padding:8px 3px; font-size:11px; line-height:1.25; text-align:center; white-space:normal; }
  .sync-table .sync-product-head { text-align:left; padding-inline:6px; }
  .sync-table .sync-market-label { display:inline; }
  .sync-table .sync-market-label .swatch { display:none; }
  .sync-table tbody tr > * { padding:7px 3px; vertical-align:middle; }
  .sync-table tbody .sync-product-cell { padding-inline:6px; font-size:12px; line-height:1.35; }
  .sync-product-cell .code { font-size:10px; }
  .sync-listing-cell { text-align:center; }
  .sync-values dt { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .sync-values .sync-quantity { display:flex; flex-direction:column; gap:1px; font-size:13px; }
  .sync-values .sync-quantity > span { font-size:10px; line-height:1.2; }
  .sync-table .quantity-button { max-width:100%; min-width:38px; min-height:36px; padding:2px; }
  .sync-listing-status { justify-items:center; gap:3px; margin-top:3px; }
  .sync-listing-status .code, .sync-unmapped { font-size:10px; line-height:1.25; overflow-wrap:anywhere; }
  .sync-table .sync-status { gap:3px; min-height:32px; min-width:38px; max-width:100%; padding:2px 3px; justify-content:center; font-size:10px; }
  .sync-status-full { display:none; }
  .sync-status-compact { display:inline; }
  .sync-table .sync-light { width:7px; height:7px; }
}
@media(max-width:760px) {
  .shell { display:block; }
  .sidebar { position:static; height:auto; padding:12px; gap:8px; }
  .sidebar nav { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .nav { padding:7px 6px; gap:4px; font-size:14px; }
  .nav span { width:14px; flex:none; }
  .sidebar .brand { padding-inline:3px; }
  .shop-name,.sidebar-foot { display:none; }
  .header,.main { padding-inline:13px; }
  .main { padding-top:18px; }
  .grid,.switches { grid-template-columns:minmax(0,1fr); }
  .panel { padding:13px; }
  .order-line { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .order-line label:first-child { grid-column:1 / -1; }
}
.metric-blue { --accent: #2462e7; }
.metric-purple { --accent: #7051cf; }
.metric-teal { --accent: #008273; }
.metric-orange { --accent: #c34c32; }
.shopee { --color: #d94c2d; }
.lazada { --color: #7549d3; }
.tiktok { --color: #008273; }
