@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+Thai:wght@400;700&family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:      #F9F8F6;
  --surface: #FFFFFF;
  --ink:     #0E0E0E;
  --ink2:    #333333;
  --ink3:    #5A5A5A;
  --line:    #DCDAD3;
  --line2:   #EDEAE3;
  --accent:  #2438CC;
  --up:      #0F6E3F;
  --down:    #AA2C1F;
  --gold:    #8A6824;
  --r:       10px;
  --fn: 'IBM Plex Sans Thai', sans-serif;
  --fnum: 'Noto Serif Thai', serif;
}

body { font-family: var(--fn); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; min-height: 100vh; font-size: 16px; font-weight: 400; line-height: 1.5; }

/* NAV */
.nav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 200; }
.nav-inner { display: flex; align-items: center; height: 56px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; gap: 0; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav-brand { font-family: var(--fnum); font-size: 18px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; flex-shrink: 0; letter-spacing: -0.3px; }
.nav-sep { width: 1px; height: 18px; background: var(--line); margin: 0 12px; flex-shrink: 0; }
.nav-links { display: flex; flex-shrink: 0; }
.nav-link { font-size: 14px; font-weight: 500; color: var(--ink2); text-decoration: none; padding: 6px 11px; border-radius: 6px; white-space: nowrap; transition: all 0.15s; }
.nav-link:hover { color: var(--ink); background: var(--line2); }
.nav-link.active { color: var(--accent); font-weight: 600; }

/* PAGE HEADER */
.page-hd { padding: 26px 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--ink2); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.page-title { font-family: var(--fnum); font-size: 38px; font-weight: 700; line-height: 1.1; letter-spacing: -1px; color: var(--ink); }
.page-sub { font-size: 15px; color: var(--ink2); margin-top: 6px; font-weight: 500; }
.change-pill { display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 15px; font-weight: 600; padding: 5px 11px; border-radius: 5px; }
.change-pill.up   { background: #E4F2EA; color: var(--up); }
.change-pill.down { background: #FBE5E2; color: var(--down); }
.change-pill.flat { background: var(--line2); color: var(--ink2); }

/* LIVE DOT */
.live-dot { width: 7px; height: 7px; background: var(--up); border-radius: 50%; animation: blink 2s infinite; display: inline-block; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

/* SECTION */
.sec { padding: 16px; }
.sec + .sec { padding-top: 0; }
.sec-title { font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink2); margin-bottom: 12px; }

/* CARD */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.card + .card { margin-top: 8px; }

/* CARD ROW */
.c-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px; border-bottom: 1px solid var(--line2); animation: up 0.3s ease both; }
.c-row:last-child { border: none; }
@keyframes up { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }
.c-label { font-size: 16px; font-weight: 600; color: var(--ink); }
.c-sub   { font-size: 13px; color: var(--ink2); margin-top: 2px; font-weight: 500; }
.c-price { font-family: var(--fnum); font-size: 22px; font-weight: 700; letter-spacing: -0.5px; color: var(--ink); }
.c-unit  { font-size: 12px; color: var(--ink2); margin-top: 2px; text-align: right; font-weight: 500; }

/* BADGE */
.badge { font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 5px; display: inline-block; }
.badge.up   { background: #E4F2EA; color: var(--up); }
.badge.down { background: #FBE5E2; color: var(--down); }
.badge.flat { background: var(--line2); color: var(--ink2); }

/* STAT GRID */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-grid.g3 { grid-template-columns: repeat(3,1fr); }
.stat-grid.g4 { grid-template-columns: repeat(4,1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 12px; text-align: center; }
.stat-val { font-family: var(--fnum); font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.5px; }
.stat-val.up  { color: var(--up); }
.stat-val.down{ color: var(--down); }
.stat-val.accent{ color: var(--accent); }
.stat-val.gold  { color: var(--gold); }
.stat-label { font-size: 12px; color: var(--ink2); margin-top: 4px; font-weight: 500; }

/* FORM */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 16px; }
.field { margin-bottom: 16px; }
.f-label { font-size: 14px; font-weight: 600; color: var(--ink); display: block; margin-bottom: 6px; }
.f-hint  { font-size: 13px; color: var(--ink2); margin-top: 5px; font-weight: 500; }
.f-input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 8px;
  font-family: var(--fn); font-size: 16px; font-weight: 500; color: var(--ink);
  background: var(--bg); outline: none; transition: border-color 0.15s;
  appearance: none; -webkit-appearance: none;
}
.f-input:focus { border-color: var(--accent); background: var(--surface); }
select.f-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235A5A5A' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; cursor: pointer;
}
.f-group-title { font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink2); margin: 20px 0 12px; display: block; }

/* BUTTON */
.btn { width: 100%; height: 52px; border: none; border-radius: 8px; font-family: var(--fn); font-size: 16px; font-weight: 700; cursor: pointer; transition: opacity 0.15s; margin-top: 20px; }
.btn:active { opacity: 0.8; }
.btn-dark   { background: var(--ink); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }

/* RESULT */
.result { border: 1px solid var(--line); border-radius: var(--r); padding: 20px 16px; margin-top: 12px; background: var(--surface); display: none; }
.result.show { display: block; animation: up 0.3s ease; }
.r-label  { font-size: 13px; color: var(--ink2); font-weight: 600; letter-spacing: 0.5px; }
.r-val    { font-family: var(--fnum); font-size: 38px; font-weight: 700; color: var(--ink); letter-spacing: -1px; margin: 6px 0 8px; line-height: 1; }
.r-val.up { color: var(--up); }
.r-detail { font-size: 14px; color: var(--ink2); line-height: 1.7; font-weight: 500; }

/* CHART */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.chart-lbl  { font-size: 14px; font-weight: 600; color: var(--ink); }
.tab-row { display: flex; gap: 4px; }
.tab { font-family: var(--fn); font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--ink2); cursor: pointer; transition: all 0.15s; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
canvas { width:100%!important; height:120px!important; display:block; }

/* PILL ROW */
.pill-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.pill-row::-webkit-scrollbar { display: none; }
.pill { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; flex-shrink: 0; text-align: center; min-width: 82px; }
.pill-val { font-family: var(--fnum); font-size: 17px; font-weight: 700; color: var(--ink); }
.pill-label { font-size: 12px; color: var(--ink2); margin-top: 3px; font-weight: 500; }

/* FILTER */
.filter-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-btn { font-family: var(--fn); font-size: 14px; font-weight: 600; padding: 7px 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink2); white-space: nowrap; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.filter-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* HOME TOOL GRID */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 14px; text-decoration: none; color: var(--ink); display: block; transition: border-color 0.15s; animation: up 0.4s ease both; }
.tool-card:active { background: var(--bg); }
.tool-card.span2 { grid-column: span 2; display: flex; align-items: center; gap: 14px; padding: 20px 16px; }
.t-icon { font-size: 24px; margin-bottom: 8px; display: block; }
.tool-card.span2 .t-icon { font-size: 30px; margin: 0; flex-shrink: 0; }
.t-name { font-size: 16px; font-weight: 700; line-height: 1.2; color: var(--ink); }
.t-desc { font-size: 13px; color: var(--ink2); margin-top: 4px; line-height: 1.45; font-weight: 500; }

/* TABLE */
.data-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-tbl th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ink2); padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.data-tbl td { padding: 11px 0; border-bottom: 1px solid var(--line2); color: var(--ink); font-weight: 500; }
.data-tbl tr:last-child td { border: none; }
.data-tbl td:last-child { text-align: right; font-weight: 700; }

/* FOOTER */
footer { padding: 26px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink2); text-align: center; line-height: 1.7; font-weight: 500; margin-top: 8px; }

/* SKELETON */
.skel { background: linear-gradient(90deg,var(--line2) 25%,var(--line) 50%,var(--line2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* UTIL */
.num  { font-family: var(--fnum); }
.muted{ color: var(--ink2); }
.divider { height: 1px; background: var(--line); margin: 0 16px; }
