:root {
  --bg: #f5f7fb;
  --bg2: #ffffff;
  --card: rgba(255, 255, 255, 0.92);
  --stroke: rgba(15, 23, 42, 0.10);
  --text: #0f172a;
  --muted: #64748b;
  --green: #16a34a;
  --red: #dc2626;
  --accent: #0284c7;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "LINE Seed Sans TH", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(14,165,233,.14), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(34,197,94,.10), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cpath d='M160 0H0V160' fill='none' stroke='rgba(15,23,42,0.04)'/%3E%3C/svg%3E");
  opacity: .7;
}

.top, .tape-wrap, .layout, .foot { position: relative; z-index: 1; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1.25rem 1.5rem .75rem; max-width: 1400px; margin: 0 auto;
}
.brand { display: flex; gap: .9rem; align-items: center; }
.mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #22c55e, #38bdf8); color: #041018; font-weight: 700;
  box-shadow: 0 8px 24px rgba(56,189,248,.25);
}
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.brand p { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.meta { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.badge {
  border: 1px solid var(--stroke); background: rgba(2,132,199,.08); color: var(--accent);
  padding: .35rem .7rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge.open { background: rgba(34,197,94,.12); color: var(--green); border-color: rgba(34,197,94,.25); }
.badge.closed { background: rgba(148,163,184,.08); color: var(--muted); }
.updated { color: var(--muted); font-size: .8rem; font-family: "LINE Seed Sans TH", ui-monospace, monospace; }
.btn {
  border: 1px solid var(--stroke); background: rgba(15,23,42,.03); color: var(--text);
  border-radius: 999px; padding: .45rem .9rem; cursor: pointer; font: inherit; font-weight: 600; font-size: .8rem;
}
.btn:hover { border-color: rgba(56,189,248,.45); background: rgba(56,189,248,.08); }

.tape-wrap {
  max-width: 1400px; margin: 0 auto 1rem; padding: 0 1rem;
  border: 1px solid var(--stroke); border-radius: var(--radius);
  background: rgba(255,255,255,.85); overflow: hidden;
}

.layout {
  max-width: 1400px; margin: 0 auto; padding: 0 1rem 2rem;
  display: grid; grid-template-columns: 1.15fr 1.55fr .95fr; gap: 1rem;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}

.section-head {
  display: flex; justify-content: space-between; align-items: end; gap: .75rem;
  margin-bottom: .85rem;
}
.section-head h2 { margin: 0; font-size: 1rem; }
.section-head p { margin: 0; color: var(--muted); font-size: .8rem; }

.cards {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem;
}
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

.card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 16px;
  padding: .9rem .95rem; backdrop-filter: blur(10px); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease; cursor: pointer;
}
.card:hover { transform: translateY(-2px); border-color: rgba(56,189,248,.35); }
.card.active { border-color: rgba(56,189,248,.55); box-shadow: 0 0 0 1px rgba(56,189,248,.2), var(--shadow); }
.sym { font-weight: 700; letter-spacing: .02em; }
.name { color: var(--muted); font-size: .72rem; margin-top: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price {
  margin-top: .7rem; font-family: "LINE Seed Sans TH", ui-monospace, monospace; font-size: 1.15rem; font-weight: 500;
}
.chg { margin-top: .25rem; font-size: .82rem; font-weight: 600; font-family: "LINE Seed Sans TH", ui-monospace, monospace; }
.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--muted); }

.chart-panel, .widget-card, .quotes {
  background: rgba(255,255,255,.88); border: 1px solid var(--stroke); border-radius: calc(var(--radius) + 4px);
  padding: 1rem; min-height: 420px;
}
.chart-frame {
  height: 520px; border-radius: 14px; overflow: hidden; border: 1px solid var(--stroke);
  background: #ffffff;
}
#tv-chart { width: 100%; height: 100%; }

.symbol-pills { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; }
.pill {
  border: 1px solid var(--stroke); background: transparent; color: var(--muted);
  border-radius: 999px; padding: .25rem .6rem; font-size: .72rem; cursor: pointer; font: inherit;
}
.pill.on { color: var(--text); border-color: rgba(56,189,248,.5); background: rgba(56,189,248,.12); }

.side .widget-card { height: 100%; display: flex; flex-direction: column; min-height: 640px; }
.side .fill { flex: 1; min-height: 560px; }

.foot {
  max-width: 1400px; margin: 0 auto 1.5rem; padding: 0 1.5rem;
  display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .75rem;
}

.skeleton {
  height: 96px; border-radius: 16px; border: 1px solid var(--stroke);
  background: linear-gradient(90deg, rgba(15,23,42,.03), rgba(15,23,42,.07), rgba(15,23,42,.03));
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.error {
  grid-column: 1 / -1; padding: 1rem; border-radius: 14px;
  border: 1px solid rgba(239,68,68,.3); background: rgba(239,68,68,.08); color: #fecaca;
}


.quote-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--stroke); border-radius: 16px;
  padding: .75rem .8rem .35rem; backdrop-filter: blur(10px); box-shadow: var(--shadow);
  color: inherit; font: inherit; transition: transform .15s ease, border-color .15s ease;
}
.quote-card:hover { transform: translateY(-2px); border-color: rgba(56,189,248,.35); }
.quote-card.active { border-color: rgba(56,189,248,.55); box-shadow: 0 0 0 1px rgba(56,189,248,.2), var(--shadow); }
.quote-head { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .15rem; }
.quote-head .sym { font-weight: 700; }
.quote-head .name { color: var(--muted); font-size: .72rem; }
.tv-mini { min-height: 72px; }
.tv-mini .tradingview-widget-container { min-height: 72px; }
