:root {
  --bg: #0d0f12;
  --surface: #161a20;
  --surface-2: #1e232b;
  --line: #2a303a;
  --text: #eef1f5;
  --muted: #9aa3af;
  --accent: #e10600;
  --accent-2: #ff4b3e;
  --pos: #2fbf71;
  --neg: #ff5a52;
  --warn: #f5a623;
  --radius: 10px;
  --head: 'Chakra Petch', 'Sarabun', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 'Sarabun', system-ui, sans-serif; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--head); line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; min-height: 70vh; }
section { margin: 40px 0; }

/* nav */
.nav { background: #000; border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 10; }
.nav-in { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { font-family: var(--head); font-weight: 700; color: var(--text); letter-spacing: .06em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--accent); color: #fff; padding: 2px 8px; margin-right: 8px; transform: skewX(-12deg); display: inline-block; font-family: var(--head); font-weight: 700; }
.nav-menu { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 16px; }
.nav-links, .nav-user { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav-links a, .nav-user a { color: var(--muted); }
.nav-links a.on, .nav-links a:hover, .nav-user a:hover { color: var(--text); text-decoration: none; }
.nav-links a.on { box-shadow: inset 0 -2px 0 var(--accent); }
.nav-user .cart b { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; font-size: .8rem; }
.nav-toggle, .nav-burger { display: none; }
.notice-bar { background: #3a2a05; color: #ffd98a; text-align: center; padding: 6px 16px; font-size: .9rem; }

/* buttons & forms */
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 10px 18px; font: 600 .95rem var(--head); cursor: pointer; }
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { background: #7a1410; }
.btn.full { width: 100%; }
button.link { background: none; border: 0; color: var(--accent-2); cursor: pointer; font: inherit; padding: 0; }
.inline { display: inline; }
input, select, textarea { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
.form label input, .form label select, .form label textarea { color: var(--text); font-size: 1rem; width: 100%; }
label.check { flex-direction: row; align-items: center; gap: 6px; display: inline-flex; }
input.qty { width: 70px; }
input.qty.wide { width: 110px; }
input.code { font: 700 1.6rem var(--head); letter-spacing: .4em; text-align: center; }
input[type=range] { padding: 0; accent-color: var(--accent); }

/* layout helpers */
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 12px; }
.row.gap { gap: 8px; }
.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two-one { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.span2 { grid-column: 1 / -1; }
.center { text-align: center; }
.narrow { max-width: 440px; margin: 24px auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-line; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.r { text-align: right; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.scroll-x { overflow-x: auto; }
ul.plain { list-style: none; padding: 0; margin: 8px 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.link-card { display: block; color: var(--text); transition: border-color .15s, transform .15s; }
.link-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: 16px; }
.cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-left: 4px solid var(--accent); }
.prose { max-width: 780px; }
h1.page { font-size: 1.8rem; margin: 8px 0 20px; }
h2.sec { font-size: 1.15rem; text-transform: uppercase; letter-spacing: .04em; margin: 24px 0 12px; }
h2.sec::before { content: ''; display: inline-block; width: 18px; height: 4px; background: var(--accent); margin-right: 10px; vertical-align: middle; transform: skewX(-20deg); }

/* hero */
.hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: 32px; align-items: center; padding: 48px 32px; margin: 0 0 40px; border-radius: var(--radius);
  background: linear-gradient(115deg, #1a0000 0%, #0d0f12 55%), var(--bg); border: 1px solid var(--line); position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -80px; top: 0; bottom: 0; width: 260px; background: repeating-linear-gradient(115deg, var(--accent) 0 14px, transparent 14px 40px); opacity: .12; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.hero .accent { color: var(--accent); }
.kicker { color: var(--accent-2); font: 600 .8rem var(--head); letter-spacing: .15em; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 560px; }
.hero-stats { display: grid; gap: 12px; position: relative; z-index: 1; }
.stat { background: rgba(0,0,0,.4); border-left: 3px solid var(--accent); padding: 12px 16px; display: flex; justify-content: space-between; align-items: baseline; }
.stat b { font: 700 1.8rem var(--head); }
.stat span { color: var(--muted); }
.stat-card b { display: block; font: 700 1.5rem var(--head); margin: 4px 0; }

/* products */
.product { display: flex; flex-direction: column; gap: 6px; }
.product h3 { margin: 4px 0 0; }
.thumb { aspect-ratio: 4 / 3; background: linear-gradient(135deg, var(--surface-2), #2a0a08); border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb span { font: 700 3rem var(--head); color: var(--accent); opacity: .7; }
.price { font: 700 1.2rem var(--head); color: var(--text); margin: 0; }

/* badges */
.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; font-family: 'Sarabun', sans-serif; cursor: default; }
button.badge { cursor: pointer; }
.role-guest { color: #c9ced6; }
.role-customer { color: #7cc4ff; border-color: #1f4a6b; }
.role-member { color: #6ee7a8; border-color: #1b5a3a; }
.role-project { color: #ffc15e; border-color: #6b4a12; }
.role-admin { color: #fff; background: var(--accent); border-color: var(--accent); }
.badge.ok, .st-paid, .st-done, .st-shipped { color: var(--pos); border-color: #1b5a3a; }
.badge.warn, .st-pending, .st-planning, .st-on_hold { color: var(--warn); border-color: #6b4a12; }
.badge.bad, .st-cancelled { color: var(--neg); border-color: #6b1f1b; }
.st-active { color: #7cc4ff; border-color: #1f4a6b; }

/* progress */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }
.bar.thin { height: 4px; margin: 6px 0 0; }
.bar.money i { background: #3d8bfd; }
.bar.money.over i { background: var(--neg); }
.proj-mini { padding: 8px 0; border-bottom: 1px solid var(--line); }
.proj-mini:last-child { border-bottom: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }
tfoot th { color: var(--text); font-size: 1rem; }
.add-row { margin-top: 16px; }
.filters { margin-bottom: 16px; }

/* flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash.success { background: #0e2a1c; border-color: #1b5a3a; color: #9ff0c2; }
.flash.error { background: #2a0e0c; border-color: #6b1f1b; color: #ffb3ad; }
.flash.info { background: #0e1d2a; border-color: #1f4a6b; color: #a8d8ff; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0 0 24px; border-left: 2px solid var(--line); }
.timeline li { display: flex; gap: 16px; padding: 0 0 20px 20px; position: relative; align-items: flex-start; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; background: var(--accent); transform: rotate(45deg); }
.timeline .year { font: 700 1.3rem var(--head); color: var(--accent-2); min-width: 60px; }
.timeline.compact li { padding-bottom: 12px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.dot { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 6px; font-size: .75rem; }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

.foot { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: .9rem; }
.foot-in { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three, .grid.two, .grid.two-one { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; padding: 32px 20px; }
  .nav-burger { display: flex; flex-direction: column; gap: 5px; margin-left: auto; cursor: pointer; padding: 8px; }
  .nav-burger span { width: 22px; height: 2px; background: var(--text); }
  .nav-menu { display: none; position: absolute; top: 63px; left: 0; right: 0; background: #000; flex-direction: column; align-items: stretch; padding: 16px; border-bottom: 3px solid var(--accent); }
  .nav-toggle:checked ~ .nav-menu { display: flex; }
  .nav-links, .nav-user { flex-direction: column; align-items: flex-start; gap: 12px; }
  .cta { flex-direction: column; align-items: flex-start; }
  table.tasks thead { display: none; }
  table.tasks tr, table.tasks td { display: block; border: 0; padding: 4px 0; }
  table.tasks tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
}
@media (max-width: 520px) {
  .grid.four { grid-template-columns: 1fr; }
}

/* PromptPay */
.pay-card { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pp-head { background: #113566; color: #fff; font: 600 .9rem var(--head); padding: 6px 16px; border-radius: 6px; letter-spacing: .04em; }
.qr { background: #fff; padding: 12px; border-radius: 10px; width: 280px; max-width: 100%; height: auto; }
.pay-amount { font: 700 2rem var(--head); margin: 4px 0 0; }
.steps { text-align: left; color: var(--muted); font-size: .9rem; padding-left: 20px; margin: 8px 0; }
.order-body { display: flex; gap: 20px; align-items: flex-start; }
.slip { width: 220px; display: flex; flex-direction: column; gap: 8px; }
.slip img { width: 100%; max-height: 320px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.card.needs-action { border-color: var(--warn); }
@media (max-width: 700px) { .order-body { flex-direction: column; } .slip { width: 100%; } }

/* document library */
.file-row { display: flex; gap: 16px; align-items: flex-start; }
.file-ext { display: inline-grid; place-items: center; min-width: 52px; height: 52px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font: 700 .75rem var(--head); color: var(--muted); }
.file-ext.sm { min-width: 40px; height: 20px; font-size: .65rem; border-radius: 4px; vertical-align: middle; }
.ext-pdf { color: #ff6b6b; border-color: #6b1f1b; }
.ext-doc, .ext-docx { color: #7cc4ff; border-color: #1f4a6b; }
.ext-xls, .ext-xlsx, .ext-csv { color: #6ee7a8; border-color: #1b5a3a; }
.ext-ppt, .ext-pptx { color: #ffb86b; border-color: #6b4a12; }
.ext-step, .ext-stp, .ext-stl, .ext-dwg, .ext-dxf, .ext-sldprt, .ext-sldasm, .ext-slddrw, .ext-iges, .ext-igs { color: #c9a3ff; border-color: #4a2f6b; }

/* admin editing */
.announce { background: var(--accent); color: #fff; text-align: center; padding: 8px 16px; font-weight: 600; }
.thumb.mini { width: 48px; height: 48px; aspect-ratio: auto; flex: none; }
.thumb.mini span { font-size: 1.2rem; }
.foot-contact { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
@media (max-width: 700px) { .foot-contact { align-items: flex-start; } }

/* privacy policy */
.policy h2 { margin-top: 28px; scroll-margin-top: 80px; }
.policy table { margin-bottom: 12px; }
.policy td:first-child { white-space: nowrap; color: var(--text); }
.policy li { margin-bottom: 8px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 16px; background: var(--surface-2); border-radius: 8px; font-size: .9rem; margin: 16px 0; }
@media (max-width: 700px) { .policy td:first-child { white-space: normal; } }

/* admin option lists */
.opt-table td { padding: 6px 4px; }
.opt-table .grow-cell { width: 100%; }
.opt-table tr.retired input[name=label] { opacity: .55; }
.nowrap { white-space: nowrap; }
button.link:disabled { opacity: .25; cursor: default; }

/* admin-provided branding */
.brand { display: inline-flex; align-items: center; }
.brand-logo { height: 36px; width: auto; margin-right: 10px; display: block; }
.hero.has-image { background-size: cover; background-position: center; }
.settings-group { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 20px; }
.settings-group:first-of-type { border-top: 0; margin-top: 0; }
.settings-img { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.settings-img img { max-height: 64px; max-width: 200px; background: #fff2; border-radius: 6px; padding: 4px; }

/* department tags */
.badge.dept { color: #c9a3ff; border-color: #4a2f6b; }
tr.row-on td { background: var(--surface-2); }
