/* ===========================================================
   AI Investment — ธีม "Terminal Mint"
   พื้นหลังกรมท่าเข้ม + สีหลักมิ้นต์/มรกต
   =========================================================== */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&family=Manrope:wght@600;700;800&family=Hanken+Grotesk:wght@400;500;600&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block");

:root {
  color-scheme: dark;

  /* ---- พื้นผิว ---- */
  --base: #090d16;
  --lowest: #060e20;
  --surface: #0b1326;
  --card: #0f172a;
  --card-hi: #1e293b;
  --container-low: #131b2e;
  --container: #171f33;
  --container-hi: #222a3d;
  --variant: #2d3449;

  /* ---- เส้นขอบ ---- */
  --hairline: #1e293b;
  --line-2: #2b3650;
  --border-active: #059669;

  /* ---- ตัวอักษร ---- */
  --ink: #dae2fd;
  --ink-2: #bccac0;
  --slate: #64748b;

  /* ---- สีหลัก ---- */
  --primary: #68dba9;
  --mint: #10b981;
  --mint-dim: #34d399;
  --secondary: #4edea3;
  --tertiary: #45dfa4;
  --band: #064e3b;

  /* ---- สถานะ ---- */
  --up: #10b981;
  --down: #f43f5e;
  --warn: #fbbf24;

  --r: .75rem;
  --r-sm: .5rem;
  --r-xs: .375rem;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 28px -16px rgba(0, 0, 0, .85);
  --shadow-lg: 0 24px 48px -24px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 255, 255, .03);
  --mint-glow: 0 0 12px rgba(16, 185, 129, .35);

  /* ---- ผิวสัมผัสที่ต่างกันระหว่างโหมดมืด/สว่าง ---- */
  --glass: rgba(6, 14, 32, .92);      /* แถบบนแบบกระจกฝ้า */
  --sunken: rgba(6, 14, 32, .6);      /* พื้นที่จม เช่น กรอบกราฟ กล่องคำตอบ */
  --sunken-soft: rgba(6, 14, 32, .5);
  --legend-bg: rgba(19, 27, 46, .6);
  --qbody-bg: rgba(9, 13, 22, .8);
  --th-bg: rgba(34, 42, 61, .6);
  --row-hover: rgba(30, 41, 59, .6);
  --chip-bg: rgba(34, 42, 61, .8);
  --on-accent: #04281c;               /* ตัวอักษรบนพื้นสีมิ้นต์ */
  --err-ink: #ffc3cd;
  --ok-ink: #8df0cb;
  --spinner-track: rgba(255, 255, 255, .12);
  --hero-grad: linear-gradient(115deg, #ffffff 5%, var(--primary) 55%, var(--mint) 100%);

  /* ---- สีของกราฟ (chart.js อ่านค่าจากตรงนี้) ---- */
  --chart-line: #94a3b8;
  --chart-line-glow: rgba(148, 163, 184, .35);
  --chart-fill-top: rgba(148, 163, 184, .18);
  --chart-forecast: #10b981;
  --chart-band: rgba(16, 185, 129, .16);
  --chart-grid: #1e293b;
  --chart-axis: #64748b;
  --chart-frame: #1e293b;
  --chart-divider: rgba(5, 150, 105, .8);
  --chart-bar: #10b981;
  --chart-bar2: #68dba9;

  --font: "IBM Plex Sans Thai", "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-display: "Manrope", "IBM Plex Sans Thai", "Segoe UI", system-ui, sans-serif;
  --nums: "Manrope", ui-monospace, "Cascadia Mono", monospace;

  --appbar-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--base);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(16, 185, 129, .3); color: #fff; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--mint-dim); text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4rem; font-family: var(--font-display); font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .98rem; }
p { margin: 0 0 .7rem; }
small { font-size: .78rem; }
strong { font-weight: 600; }

/* สกรอลล์บาร์ */
* { scrollbar-width: thin; scrollbar-color: #243047 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #243047; border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #33425f; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ไอคอน Material Symbols */
.ms {
  font-family: "Material Symbols Outlined";
  font-weight: normal; font-style: normal; line-height: 1;
  font-size: 18px; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; direction: ltr;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  vertical-align: -.22em; flex: none;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}
.ms.fill { font-variation-settings: "FILL" 1; }
.ms.sm { font-size: 15px; }
.ms.lg { font-size: 22px; }

/* ===================== แถบบนสุด (ผู้ใช้งาน) ===================== */
.appbar {
  position: sticky; top: 0; z-index: 50;
  min-height: var(--appbar-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--hairline);
}
.appbar .left { display: flex; align-items: center; gap: 1.25rem; min-width: 0; flex: 1; }
.appbar .right { display: flex; align-items: center; gap: .75rem; }

.brand { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.brand .logo {
  width: 34px; height: 34px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: .8rem; letter-spacing: .04em;
  color: var(--on-accent); background: linear-gradient(145deg, var(--primary), var(--mint));
  box-shadow: var(--mint-glow);
}
.brand .name { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; white-space: nowrap; }
.brand .name b { font-family: var(--font-display); font-size: .95rem; color: var(--primary); letter-spacing: -.01em; }
.brand .name span { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--mint); font-weight: 600; }

/* ช่องค้นหาบนแถบบน */
.appsearch {
  display: flex; align-items: center; gap: .4rem;
  padding: .3rem .6rem; border-radius: var(--r-sm);
  background: var(--container); border: 1px solid var(--hairline);
  transition: border-color .15s;
}
.appsearch:focus-within { border-color: var(--border-active); }
.appsearch .ms { color: var(--slate); }
.appsearch input {
  width: 200px; padding: .2rem 0; border: 0; background: none; font: inherit; font-size: .82rem; color: var(--ink);
}
.appsearch input:focus { outline: none; box-shadow: none; }
.appsearch input::placeholder { color: var(--slate); }
.quick { display: flex; gap: .25rem; }
.quick button {
  padding: .1rem .4rem; border-radius: var(--r-xs);
  background: var(--card); border: 1px solid var(--hairline);
  font: inherit; font-size: .66rem; font-weight: 600; letter-spacing: .04em;
  color: var(--mint); cursor: pointer; transition: background .15s, border-color .15s;
}
.quick button:hover { background: var(--variant); border-color: var(--line-2); }

/* เมนูแบบ pill */
.navpills {
  display: flex; align-items: center; gap: .2rem; padding: .2rem;
  background: var(--lowest); border: 1px solid var(--hairline); border-radius: var(--r-sm);
}
.navpills button {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .7rem; border: 1px solid transparent; border-radius: var(--r-xs);
  background: none; font: inherit; font-size: .82rem; color: var(--ink-2);
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s;
}
.navpills button:hover { background: var(--container); color: var(--ink); }
.navpills button.active {
  background: var(--container-hi); color: var(--primary); font-weight: 600;
  border-color: rgba(5, 150, 105, .6);
}

.adminlink {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .6rem; border-radius: var(--r-xs);
  background: var(--chip-bg); border: 1px solid var(--hairline);
  font-size: .72rem; font-weight: 600; color: var(--ink-2);
  transition: border-color .15s, color .15s;
}
.adminlink:hover { border-color: var(--border-active); color: var(--primary); text-decoration: none; }
.adminlink .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--mint); box-shadow: 0 0 8px var(--mint); }

.divider-v { width: 1px; height: 20px; background: var(--hairline); }

.user-chip { display: flex; align-items: center; gap: .5rem; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 99px; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: .78rem;
  color: var(--primary); background: var(--container-hi);
  box-shadow: inset 0 0 0 1px var(--border-active);
}
.user-chip .meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip .meta b { font-size: .8rem; font-weight: 600; color: var(--ink); }
.user-chip .meta span { font-size: .66rem; color: var(--slate); }

/* ===================== พื้นที่เนื้อหา ===================== */
.page { padding: 1.25rem 1.5rem 3rem; }
.view { animation: rise .3s cubic-bezier(.22, 1, .36, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.eyebrow {
  display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem;
  font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--slate);
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--mint); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.page-head h1 { margin: 0; }
.page-head .sub { margin: .25rem 0 0; color: var(--slate); font-size: .86rem; max-width: 70ch; }

/* ===================== การ์ด ===================== */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card > header { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.card > header h2, .card > header h3 { margin: 0; }
.card > header .spacer { flex: 1; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > header { padding: 1rem 1.1rem 0; margin-bottom: .6rem; }

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ===================== ไทล์ตัวเลข ===================== */
.tile {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: .85rem .95rem;
  transition: background .18s, border-color .18s;
}
.tile:hover { background: var(--container-hi); border-color: var(--line-2); }
.tile .label { font-size: .66rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--slate); }
.tile .value {
  margin-top: .15rem; font-family: var(--nums); font-size: 1.45rem; font-weight: 700;
  letter-spacing: -.02em; line-height: 1.2; color: var(--ink); font-variant-numeric: tabular-nums;
}
.tile .value.mint { color: var(--mint); }
.tile .hint { font-size: .76rem; color: var(--ink-2); }

.kpi { display: flex; flex-direction: column; justify-content: space-between; gap: .8rem; }
.kpi .top { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.kpi .icon {
  width: 38px; height: 38px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--container-low); color: var(--primary);
}
.kpi .foot {
  padding: .5rem .6rem; border-radius: var(--r-sm);
  background: var(--sunken-soft); font-size: .72rem; color: var(--ink-2);
  display: flex; flex-direction: column; gap: .3rem;
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

/* ===================== ปุ่ม ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .9rem; border: 1px solid transparent; border-radius: var(--r-sm);
  font: inherit; font-family: var(--font-display); font-size: .84rem; font-weight: 700;
  color: var(--on-accent); background: linear-gradient(145deg, var(--primary), var(--mint));
  cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow); transition: filter .15s, transform .12s, background .15s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; color: var(--on-accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }

.btn.ghost { background: var(--container); color: var(--ink); border-color: var(--hairline); box-shadow: none; }
.btn.ghost:hover { background: var(--container-hi); border-color: var(--line-2); color: var(--ink); filter: none; }
.btn.mint-soft { background: var(--band); color: var(--mint); border-color: rgba(5, 150, 105, .45); box-shadow: none; }
.btn.mint-soft:hover { background: rgba(6, 78, 59, .75); filter: none; color: var(--mint); }
.btn.danger { background: rgba(244, 63, 94, .12); color: var(--down); border-color: rgba(244, 63, 94, .32); box-shadow: none; }
.btn.danger:hover { background: rgba(244, 63, 94, .22); filter: none; color: var(--down); }
.btn.small { padding: .3rem .6rem; font-size: .76rem; border-radius: var(--r-xs); }
.btn.icon { padding: .45rem; }

/* ===================== ฟอร์ม ===================== */
label { display: block; margin-bottom: .3rem; font-size: .78rem; font-weight: 500; color: var(--ink-2); }
input, select, textarea {
  width: 100%; padding: .55rem .7rem;
  font: inherit; font-size: .86rem; color: var(--ink);
  background: var(--base); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--slate); }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--border-active); box-shadow: 0 0 0 3px rgba(5, 150, 105, .18);
}
select {
  appearance: none; cursor: pointer; padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--slate) 50%), linear-gradient(135deg, var(--slate) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 2px), calc(100% - 12px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
select option { background: var(--container); color: var(--ink); }
textarea { resize: vertical; min-height: 76px; }
.field { margin-bottom: .8rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; }
.row > * { flex: 1; min-width: 150px; }
.row.tight { align-items: center; }
.row.tight > * { flex: 0 0 auto; min-width: 0; }

/* ===================== แท็บ ===================== */
.tabs {
  display: flex; flex-wrap: wrap; gap: .2rem; padding: .25rem; margin-bottom: 1rem;
  background: var(--lowest); border: 1px solid var(--hairline); border-radius: var(--r-sm);
}
.tabs button {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .8rem; border: 1px solid transparent; border-radius: var(--r-xs);
  background: none; font: inherit; font-size: .82rem; color: var(--slate);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.tabs button:hover { color: var(--ink); background: var(--container); }
.tabs button.active {
  background: var(--container-hi); color: var(--primary);
  font-family: var(--font-display); font-weight: 700;
  border-color: rgba(5, 150, 105, .5);
}

/* ชิปตัวกรอง */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  padding: .35rem .75rem; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--hairline);
  font: inherit; font-size: .8rem; color: var(--slate); cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.chip:hover { background: var(--card-hi); color: var(--ink); }
.chip.active {
  background: var(--container-hi); color: var(--primary);
  font-family: var(--font-display); font-weight: 700; border-color: rgba(5, 150, 105, .5);
}

/* ===================== ตาราง ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: .7rem .8rem; text-align: left; vertical-align: middle; }
th {
  background: var(--th-bg); color: var(--slate);
  font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
tbody tr { border-top: 1px solid var(--hairline); transition: background .15s; }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; }
td.num { font-family: var(--nums); font-variant-numeric: tabular-nums; }

/* เซลล์ชื่อหุ้น */
.sym { display: flex; align-items: center; gap: .6rem; }
.sym .mark {
  width: 36px; height: 36px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--base); color: var(--primary);
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.sym .txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sym .txt b { font-family: var(--font-display); font-size: .88rem; color: var(--ink); letter-spacing: .01em; }
.sym .txt small { font-size: .7rem; color: var(--slate); }

/* ===================== ป้าย ===================== */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .55rem; border-radius: 99px;
  font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  background: var(--container-hi); color: var(--ink-2); border: 1px solid var(--hairline);
}
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge.up { background: rgba(16, 185, 129, .14); color: var(--mint); border-color: rgba(16, 185, 129, .32); }
.badge.down { background: rgba(244, 63, 94, .14); color: var(--down); border-color: rgba(244, 63, 94, .32); }
.badge.warn { background: rgba(251, 191, 36, .13); color: var(--warn); border-color: rgba(251, 191, 36, .3); }
.badge.mute { background: var(--container); color: var(--slate); border-color: var(--hairline); }
.badge.tag { border-radius: var(--r-xs); font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; }
.up-text { color: var(--up); }
.down-text { color: var(--down); }
.muted { color: var(--slate); }

/* ===================== แจ้งเตือน ===================== */
.alert {
  padding: .7rem .9rem; margin-bottom: .9rem; border-radius: var(--r-sm);
  font-size: .85rem; border: 1px solid var(--hairline); background: var(--container);
}
.alert.error { background: rgba(244, 63, 94, .12); color: var(--err-ink); border-color: rgba(244, 63, 94, .35); }
.alert.ok { background: rgba(16, 185, 129, .12); color: var(--ok-ink); border-color: rgba(16, 185, 129, .35); }
.alert.info { background: rgba(104, 219, 169, .1); color: var(--primary); border-color: rgba(5, 150, 105, .35); }
.hidden { display: none !important; }

/* ===================== แถบคะแนน / ปัจจัย ===================== */
.meter { height: 7px; border-radius: 99px; background: var(--container-hi); overflow: hidden; }
.meter > span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--mint), var(--primary));
  box-shadow: 0 0 10px rgba(16, 185, 129, .5);
  transition: width .6s cubic-bezier(.22, 1, .36, 1);
}
.meter.down > span { background: linear-gradient(90deg, var(--down), #fb7185); box-shadow: none; }
.factor { padding: .7rem 0; border-bottom: 1px solid var(--hairline); }
.factor:last-child { border-bottom: 0; }
.factor .head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .35rem; }
.factor .head strong { flex: 1; font-weight: 600; }

/* วงแหวนคะแนน */
.ring { position: relative; width: 84px; height: 84px; flex: none; display: grid; place-items: center; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--container-hi); stroke-width: 8; }
.ring .bar { fill: none; stroke: var(--mint); stroke-width: 8; stroke-linecap: round; }
.ring .mid { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; line-height: 1.1; }
.ring .mid b { font-family: var(--nums); font-size: 1.3rem; font-weight: 700; color: var(--mint); }
.ring .mid span { font-size: .62rem; color: var(--slate); }
.ring.sm { width: 36px; height: 36px; }
.ring.sm .track, .ring.sm .bar { stroke-width: 3.4; }
.ring.sm .mid b { font-size: .58rem; color: var(--ink); }

/* ===================== กราฟ ===================== */
.chart-box {
  position: relative; width: 100%;
  padding: .6rem .3rem .2rem; border-radius: var(--r-sm);
  background: var(--sunken);
}
canvas { display: block; width: 100%; }
.legend {
  display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .6rem;
  padding: .5rem .7rem; border-radius: var(--r-sm);
  background: var(--legend-bg); font-size: .72rem; color: var(--slate);
}
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }

/* ===================== รายการ / ข่าว ===================== */
.list { display: grid; gap: .6rem; }
.item {
  padding: .8rem .9rem; border-radius: var(--r-sm);
  background: var(--container-low); border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.item:hover { background: var(--container); border-color: var(--hairline); }
.item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .3rem; font-size: .72rem; color: var(--slate); }
.item h4 { margin: 0 0 .2rem; font-size: .9rem; }
.item p { margin: 0; font-size: .82rem; color: var(--ink-2); }

.answer {
  position: relative; white-space: pre-wrap;
  padding: .85rem 1rem .85rem 1.1rem; border-radius: var(--r-sm);
  background: var(--sunken); border: 1px solid var(--hairline);
  font-size: .86rem; line-height: 1.75; color: var(--ink);
}
.answer::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: 3px 0 0 3px; background: linear-gradient(180deg, var(--primary), var(--mint));
}

/* ===================== แถบคำสั่งของหุ้น (Ribbon) ===================== */
.ribbon {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.1rem; margin-bottom: 1rem;
  background: var(--lowest); border: 1px solid var(--hairline); border-radius: var(--r);
}
.ribbon .idblock { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; min-width: 0; }
.ribbon .glyph {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--container-hi); color: var(--primary);
}
.ribbon .titles { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.ribbon .titles .top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ribbon .titles h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; }
.ribbon .titles .co { font-size: .78rem; color: var(--slate); }
.ribbon .price { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; }
.ribbon .price .last {
  font-family: var(--nums); font-size: 1.85rem; font-weight: 700; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.ribbon .price .delta {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .6rem; border-radius: var(--r-sm);
  font-family: var(--nums); font-weight: 700; font-size: .9rem;
}
.ribbon .price .delta.up { background: rgba(6, 78, 59, .7); color: var(--mint); box-shadow: 0 0 12px rgba(16, 185, 129, .22); }
.ribbon .price .delta.down { background: rgba(244, 63, 94, .14); color: var(--down); }
.ribbon .price .delta.flat { background: var(--container-hi); color: var(--slate); }
.ribbon .actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ribbon .sep { width: 1px; height: 32px; background: var(--variant); }
.statline { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ชุดปุ่มช่วงเวลา */
.segmented {
  display: inline-flex; padding: .2rem; border-radius: var(--r-sm);
  background: var(--container-low); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .4);
}
.segmented button {
  padding: .3rem .6rem; border: 0; border-radius: var(--r-xs);
  background: none; font: inherit; font-size: .72rem; font-weight: 600;
  color: var(--slate); cursor: pointer; transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--card-hi); color: var(--primary); box-shadow: var(--shadow); }

/* ===================== เลย์เอาต์ Hub (8/4) ===================== */
.hub { display: grid; grid-template-columns: minmax(0, 8fr) minmax(330px, 4fr); gap: 1rem; align-items: start; }
.hub-main { min-width: 0; }
.hub-side { position: sticky; top: calc(var(--appbar-h) + 1rem); min-width: 0; }

/* ===================== ผู้ช่วย AI (Copilot) ===================== */
.copilot {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r);
  box-shadow: var(--shadow-lg);
}
.copilot > header {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .8rem .9rem; background: var(--lowest); border-bottom: 1px solid var(--hairline);
}
.copilot .ident { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.copilot .bot {
  position: relative; width: 34px; height: 34px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--band); color: var(--mint);
  box-shadow: 0 0 10px rgba(16, 185, 129, .3);
}
.copilot .bot::after {
  content: ""; position: absolute; top: -2px; right: -2px;
  width: 9px; height: 9px; border-radius: 99px; background: var(--mint);
  box-shadow: 0 0 0 2px var(--lowest);
}
.copilot .ident .txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.copilot .ident .txt b { font-family: var(--font-display); font-size: .88rem; }
.copilot .ident .txt span { font-size: .66rem; color: var(--mint); }

.chat { display: flex; flex-direction: column; gap: .8rem; padding: .9rem; max-height: 560px; overflow-y: auto; }
.chat .empty { padding: 1.5rem .5rem; text-align: center; color: var(--slate); font-size: .82rem; }
.chat .empty .ms { display: block; margin: 0 auto .5rem; font-size: 36px; color: var(--variant); }

.bubble-user { display: flex; justify-content: flex-end; }
.bubble-user > div {
  max-width: 88%; padding: .6rem .8rem;
  background: var(--card-hi); border-radius: var(--r) var(--r) 0 var(--r);
  font-size: .84rem; line-height: 1.6;
}
.bubble-user time { display: block; margin-top: .25rem; text-align: right; font-size: .65rem; color: var(--slate); }

.bubble-ai { display: flex; align-items: flex-start; gap: .5rem; }
.bubble-ai .face {
  width: 28px; height: 28px; flex: none; margin-top: .2rem; border-radius: 99px;
  display: grid; place-items: center; background: var(--band); color: var(--mint);
}
.synth {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .5rem;
  padding: .8rem; border-radius: var(--r) var(--r) var(--r) 0;
  background: var(--container-low); box-shadow: var(--shadow);
}
.synth > .head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.synth > .head b { font-family: var(--font-display); font-size: .86rem; color: var(--primary); }
.synth .point { padding: .55rem .65rem; border-radius: var(--r-sm); background: var(--card); }
.synth .point .ph { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.synth .point .ph b { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 600; }
.synth .point .conf {
  padding: .05rem .4rem; border-radius: var(--r-xs);
  background: var(--lowest); color: var(--mint); font-size: .66rem; font-weight: 600; white-space: nowrap;
}
.synth .point p { margin: 0; font-size: .78rem; color: var(--ink-2); line-height: 1.6; }
.synth .verdict { padding: .6rem .7rem; border-radius: var(--r-sm); background: rgba(6, 78, 59, .32); }
.synth .verdict .vh { display: flex; align-items: center; gap: .35rem; margin-bottom: .2rem; color: var(--mint); font-size: .8rem; font-weight: 600; }
.synth .verdict p { margin: 0; font-size: .8rem; line-height: 1.65; white-space: pre-wrap; }
.synth .foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .66rem; color: var(--slate); }

.prompts {
  display: flex; gap: .35rem; padding: .5rem .9rem; overflow-x: auto;
  background: var(--lowest); border-top: 1px solid var(--hairline); white-space: nowrap;
}
.prompts button {
  display: inline-flex; align-items: center; gap: .3rem; flex: none;
  padding: .3rem .7rem; border: 0; border-radius: 99px;
  background: var(--container-hi); font: inherit; font-size: .72rem; color: var(--ink);
  cursor: pointer; transition: background .15s;
}
.prompts button:hover { background: var(--card-hi); }
.prompts button:first-child { color: var(--primary); font-weight: 600; }

.composer { padding: .8rem .9rem; background: var(--lowest); border-top: 1px solid var(--hairline); }
.composer form {
  display: flex; align-items: center; gap: .4rem; padding: .35rem;
  background: var(--base); border: 1px solid var(--hairline); border-radius: var(--r);
}
.composer form:focus-within { border-color: var(--border-active); }
.composer .caret { padding-left: .5rem; color: var(--mint); font-family: var(--nums); font-weight: 700; }
.composer input {
  flex: 1; min-width: 0; padding: .35rem .2rem; border: 0; background: none; font-size: .84rem;
}
.composer input:focus { outline: none; box-shadow: none; }
.composer button[type="submit"] {
  width: 38px; height: 38px; flex: none; border: 0; border-radius: var(--r-sm);
  display: grid; place-items: center; cursor: pointer;
  background: var(--border-active); color: var(--on-accent);
  box-shadow: 0 0 12px rgba(5, 150, 105, .4); transition: background .15s;
}
.composer button[type="submit"]:hover { background: var(--mint); }
.composer button:disabled { opacity: .5; cursor: not-allowed; }
.composer .hintline { margin-top: .4rem; font-size: .68rem; color: var(--slate); }

.recent { padding: .7rem .9rem .9rem; background: var(--lowest); border-top: 1px solid var(--hairline); }
.recent .rh {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem;
  font-size: .66rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--slate);
}
.recent .q {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%;
  padding: .3rem .4rem; border: 0; border-radius: var(--r-xs);
  background: none; font: inherit; font-size: .78rem; color: var(--slate); text-align: left; cursor: pointer;
}
.recent .q:hover { background: var(--card); color: var(--ink); }
.recent .q .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .q time { flex: none; font-size: .66rem; }

/* ===================== การ์ดประวัติคำถาม (accordion) ===================== */
.qcard { padding: .9rem 1rem; border-radius: var(--r); background: var(--card); border: 1px solid var(--hairline); }
.qcard + .qcard { margin-top: .6rem; }
.qcard .qtop { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.qcard .qtitle { margin: .5rem 0 .4rem; font-size: .95rem; line-height: 1.5; cursor: pointer; }
.qcard .qtags { display: flex; flex-wrap: wrap; gap: .35rem; }
.qcard .qtag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .5rem; border-radius: var(--r-sm);
  background: var(--container); font-size: .7rem; color: var(--ink-2);
}
.qcard .qtag .dot { width: 6px; height: 6px; border-radius: 99px; background: var(--mint); }
.qcard .qbody { margin-top: .7rem; padding: .85rem; border-radius: var(--r); background: var(--qbody-bg); }
.qcard .toggle {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border: 0; border-radius: var(--r-xs); background: none; color: var(--slate); cursor: pointer;
}
.qcard .toggle:hover { background: var(--card-hi); color: var(--ink); }
.qcard .toggle .ms { transition: transform .2s; }
.qcard.open .toggle .ms { transform: rotate(180deg); }

/* ===================== แผงผู้ดูแลระบบ ===================== */
.adminshell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; justify-content: space-between; gap: 1rem;
  padding: 1rem .75rem; background: var(--lowest); border-right: 1px solid var(--hairline);
}
.sidebar .mark { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem .75rem; }
.sidebar .mark .led { width: 10px; height: 10px; border-radius: 3px; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.sidebar .mark .txt { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar .mark .txt b { font-family: var(--font-display); font-size: .86rem; color: var(--primary); letter-spacing: .02em; }
.sidebar .mark .txt span { font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--slate); }
.sidebar .group {
  padding: 0 .5rem; margin-bottom: .4rem;
  font-size: .64rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--slate);
}
.sidebar nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar nav button {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .55rem .6rem; border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; font: inherit; font-size: .84rem; color: var(--ink-2);
  text-align: left; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.sidebar nav button:hover { background: var(--container-hi); color: var(--ink); }
.sidebar nav button.active {
  background: var(--container-hi); color: var(--primary);
  font-family: var(--font-display); font-weight: 700; border-color: rgba(5, 150, 105, .6);
}
.sidebar .backlink {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .6rem .7rem; border-radius: var(--r-sm);
  background: var(--container); border: 1px solid var(--hairline);
  font-size: .8rem; color: var(--mint); transition: border-color .15s;
}
.sidebar .backlink:hover { border-color: var(--border-active); text-decoration: none; }
.sidebar .backlink .tagx { font-size: .62rem; letter-spacing: .1em; color: var(--slate); }

.adminbar {
  position: sticky; top: 0; z-index: 40;
  min-height: var(--appbar-h); display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.5rem; background: var(--glass);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--hairline);
}
.status-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .6rem; border-radius: var(--r-xs);
  background: var(--container); border: 1px solid var(--hairline);
  font-size: .66rem; font-weight: 600; letter-spacing: .08em; color: var(--mint);
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--mint); animation: pulse 2s ease-in-out infinite; }

/* แบนเนอร์หัวแผงแอดมิน */
.banner {
  position: relative; overflow: hidden;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.2rem; margin-bottom: 1.25rem;
  background: var(--container-low); border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.banner::after {
  content: ""; position: absolute; right: -48px; top: -48px; width: 220px; height: 220px;
  border-radius: 99px; background: rgba(104, 219, 169, .07); filter: blur(28px); pointer-events: none;
}
.banner > * { position: relative; z-index: 1; }
.banner h1 { margin: .4rem 0 .2rem; font-size: 1.45rem; }
.banner p { margin: 0; font-size: .84rem; color: var(--ink-2); max-width: 72ch; }
.banner .live {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .9rem; border-radius: var(--r-sm); background: var(--container-hi);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .35);
}
.banner .live .txt { display: flex; flex-direction: column; line-height: 1.3; }
.banner .live .txt b { font-family: var(--font-display); font-size: .82rem; color: var(--mint); }
.banner .live .txt span { font-size: .68rem; color: var(--slate); }

/* ===================== สถานะโหลด / ท้ายหน้า ===================== */
.spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 99px;
  border: 2px solid var(--spinner-track); border-top-color: var(--mint);
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: .5rem; padding: .6rem 0; color: var(--slate); font-size: .84rem; }

.footer-note { margin-top: 1.5rem; padding-top: .9rem; border-top: 1px solid var(--hairline); font-size: .74rem; color: var(--slate); }

.appfoot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .9rem 1.5rem; background: var(--lowest); border-top: 1px solid var(--hairline);
  font-size: .72rem; color: var(--slate);
}
.appfoot .brandline { display: flex; align-items: center; gap: .5rem; }
.appfoot .brandline b { font-family: var(--font-display); color: var(--primary); }
.appfoot .led { width: 6px; height: 6px; border-radius: 99px; background: var(--mint); }

/* ===================== หน้าเข้าสู่ระบบ ===================== */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 1rem;
  padding: 3.25rem; border-right: 1px solid var(--hairline);
}
.auth-hero::before {
  content: ""; position: absolute; left: -160px; top: -140px; width: 520px; height: 520px;
  border-radius: 99px; background: radial-gradient(circle, rgba(16, 185, 129, .22), transparent 65%);
  filter: blur(12px); animation: float1 20s ease-in-out infinite;
}
.auth-hero::after {
  content: ""; position: absolute; right: -140px; bottom: -180px; width: 460px; height: 460px;
  border-radius: 99px; background: radial-gradient(circle, rgba(104, 219, 169, .16), transparent 65%);
  filter: blur(12px); animation: float2 24s ease-in-out infinite;
}
@keyframes float1 { 50% { transform: translate(40px, 50px) scale(1.08); } }
@keyframes float2 { 50% { transform: translate(-45px, -35px) scale(1.1); } }
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h1 {
  margin: .5rem 0 .2rem; font-size: 2.35rem; line-height: 1.22; letter-spacing: -.025em;
  background: var(--hero-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-hero > p { max-width: 52ch; color: var(--ink-2); font-size: .9rem; }
.auth-hero ul { display: grid; gap: .6rem; margin: .4rem 0 0; padding: 0; list-style: none; max-width: 56ch; }
.auth-hero li { position: relative; padding-left: 1.75rem; font-size: .88rem; color: var(--ink-2); }
.auth-hero li::before {
  content: ""; position: absolute; left: 0; top: .45rem; width: 1rem; height: 1rem;
  border-radius: var(--r-xs); background: linear-gradient(145deg, var(--primary), var(--mint));
  box-shadow: 0 4px 12px -4px rgba(16, 185, 129, .8);
}
.auth-hero li strong { color: var(--ink); }

.auth-panel { display: grid; place-items: center; padding: 2.5rem 1.5rem; }
.auth-card {
  width: 100%; max-width: 410px; padding: 1.5rem;
  background: var(--card); border: 1px solid var(--hairline); border-radius: 1rem;
  box-shadow: var(--shadow-lg);
}
.auth-card h2 { font-size: 1.2rem; margin-bottom: .9rem; }
.auth-card .tabs { margin-bottom: 1.1rem; }
.auth-card .btn { width: 100%; margin-top: .2rem; }
.demo-divider {
  display: flex; align-items: center; gap: .6rem;
  margin: .9rem 0 .2rem; font-size: .72rem; color: var(--slate);
}
.demo-divider::before, .demo-divider::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.auth-foot { margin-top: .9rem; font-size: .82rem; color: var(--slate); }
.demo-box {
  margin-top: 1rem; padding: .75rem .9rem; border-radius: var(--r-sm);
  background: rgba(6, 78, 59, .25); border: 1px dashed rgba(5, 150, 105, .4);
  font-size: .8rem; color: var(--ink-2);
}
.demo-box strong { font-family: var(--nums); font-size: .78rem; color: var(--primary); }

/* ===================== ตอบสนองหน้าจอ ===================== */
@media (max-width: 1280px) {
  .hub { grid-template-columns: minmax(0, 1fr); }
  .hub-side { position: static; }
  .chat { max-height: 420px; }
  .appsearch { display: none; }
}
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .adminshell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; z-index: 45; height: auto;
    flex-direction: row; align-items: center; gap: .5rem;
    padding: .55rem .9rem; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--hairline);
  }
  .sidebar .mark, .sidebar .group, .sidebar .backlink .tagx { display: none; }
  .sidebar > div { display: contents; }
  .sidebar nav { flex-direction: row; gap: .3rem; }
  .sidebar nav button { width: auto; white-space: nowrap; }
  .sidebar .backlink { white-space: nowrap; }
}
@media (max-width: 900px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appbar { flex-wrap: wrap; padding: .6rem 1rem; }
  .appbar .left { flex-wrap: wrap; gap: .75rem; }
  .navpills { order: 3; width: 100%; overflow-x: auto; }
  .auth-page { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { padding: 2.25rem 1.4rem; border-right: 0; border-bottom: 1px solid var(--hairline); }
  .auth-hero h1 { font-size: 1.8rem; }
}
@media (max-width: 720px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 1rem .9rem 2.5rem; }
  .appbar { padding: .6rem .9rem; gap: .5rem; }
  .appbar .left { gap: .5rem; flex: 1 1 100%; }
  .appbar .right { flex: 1 1 100%; justify-content: flex-end; gap: .5rem; }
  .brand { flex: 1; }
  .brand .name { min-width: 0; }
  .brand .name b { font-size: .86rem; white-space: nowrap; }
  .brand .name span { display: none; }
  .adminlink .lbl, .user-chip .meta { display: none; }
  .navpills { order: 0; }
  .navpills button { font-size: .78rem; padding: .35rem .55rem; }
  .copilot .ident .txt span { display: none; }
  .ribbon .titles h1 { font-size: 1.2rem; }
  .ribbon .price .last { font-size: 1.5rem; }
  .ribbon .sep { display: none; }
  h1 { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ===========================================================
   โหมดกลางวัน (ขาว–เขียวมิ้นต์)
   ใช้เมื่อ <html data-theme="light"> หรือเครื่องตั้งค่าเป็นธีมสว่างและผู้ใช้ยังไม่ได้เลือกเอง
   =========================================================== */
:root[data-theme="light"] {
  color-scheme: light;

  --base: #f4f7fa;
  --lowest: #ffffff;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hi: #eef3f8;
  --container-low: #f5f8fb;
  --container: #eef3f8;
  --container-hi: #e4ebf3;
  --variant: #d6dfea;

  --hairline: #e2e8f0;
  --line-2: #cbd5e1;
  --border-active: #059669;

  --ink: #0f172a;
  --ink-2: #334155;
  --slate: #64748b;

  --primary: #0d9668;
  --mint: #059669;
  --mint-dim: #10b981;
  --secondary: #0f9d6e;
  --tertiary: #0ea371;
  --band: #d1fae5;

  --up: #047857;
  --down: #e11d48;
  --warn: #b45309;

  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 24px -18px rgba(15, 23, 42, .4);
  --shadow-lg: 0 18px 40px -24px rgba(15, 23, 42, .35), 0 0 0 1px rgba(15, 23, 42, .04);
  --mint-glow: 0 6px 16px -8px rgba(5, 150, 105, .5);

  --glass: rgba(255, 255, 255, .88);
  --sunken: #f5f8fb;
  --sunken-soft: #f5f8fb;
  --legend-bg: #f1f5f9;
  --qbody-bg: #f5f8fb;
  --th-bg: #eef3f8;
  --row-hover: #f1f6fb;
  --chip-bg: #eef3f8;
  --on-accent: #ffffff;
  --err-ink: #9f1239;
  --ok-ink: #065f46;
  --spinner-track: rgba(15, 23, 42, .12);
  --hero-grad: linear-gradient(115deg, #0f172a 5%, #047857 55%, var(--mint) 100%);

  --chart-line: #475569;
  --chart-line-glow: rgba(71, 85, 105, .25);
  --chart-fill-top: rgba(71, 85, 105, .14);
  --chart-forecast: #059669;
  --chart-band: rgba(5, 150, 105, .14);
  --chart-grid: #e2e8f0;
  --chart-axis: #64748b;
  --chart-frame: #cbd5e1;
  --chart-divider: rgba(5, 150, 105, .7);
  --chart-bar: #059669;
  --chart-bar2: #34d399;
}

/* โหมดสว่างปรับรายละเอียดบางจุดที่ออกแบบมาเพื่อพื้นมืด */
:root[data-theme="light"] ::selection { background: rgba(5, 150, 105, .18); color: #04281c; }
:root[data-theme="light"] .appbar,
:root[data-theme="light"] .adminbar { box-shadow: 0 1px 0 var(--hairline); }
:root[data-theme="light"] .tile::after { display: none; }
:root[data-theme="light"] .meter > span { box-shadow: none; }
:root[data-theme="light"] .brand .logo,
:root[data-theme="light"] .copilot .bot { box-shadow: var(--mint-glow); }
:root[data-theme="light"] .ribbon .price .delta.up { background: var(--band); box-shadow: none; }
:root[data-theme="light"] .ribbon .price .delta.down { background: #ffe4e6; }
:root[data-theme="light"] .synth .verdict { background: var(--band); }
:root[data-theme="light"] .synth .point .conf { background: var(--band); }
:root[data-theme="light"] .badge.up { background: var(--band); }
:root[data-theme="light"] .bubble-user > div { background: var(--container-hi); }
:root[data-theme="light"] .sidebar .mark .led,
:root[data-theme="light"] .adminlink .dot { box-shadow: none; }
:root[data-theme="light"] .auth-hero::before { background: radial-gradient(circle, rgba(5, 150, 105, .14), transparent 65%); }
:root[data-theme="light"] .auth-hero::after { background: radial-gradient(circle, rgba(13, 150, 104, .1), transparent 65%); }
:root[data-theme="light"] .btn.mint-soft { background: var(--band); color: #065f46; }
:root[data-theme="light"] .btn.mint-soft:hover { background: #a7f3d0; color: #065f46; }
:root[data-theme="light"] .btn.danger { background: #fff1f2; }
:root[data-theme="light"] .composer form { background: var(--container-low); }
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea { background: #ffffff; }

.auth-theme { position: fixed; top: 1rem; right: 1rem; z-index: 10; }

/* ปุ่มสลับโหมดสี */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  background: var(--container); color: var(--ink-2);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--container-hi); color: var(--primary); border-color: var(--line-2); }
.theme-toggle .ms { font-size: 19px; }
.theme-toggle .icon-dark { display: none; }
:root[data-theme="light"] .theme-toggle .icon-dark { display: block; }
:root[data-theme="light"] .theme-toggle .icon-light { display: none; }
