/* ธีมหน้าจอใหม่ (decisions.md 2026-11-03) — โครงเดียว 2 ธีม: formal = ทางการ (น้ำเงินเข้ม) · bright = สดใส
   ไม่ตั้งธีม (แบบเดิม) = ไฟล์นี้ไม่มีผล · ธีมเปลี่ยนแค่สี / รูปทรง — ตำแหน่งเหมือนกัน
   สีหลักของแบบเดิมชื่อ --green ทั้งระบบ → ธีมใหม่เปลี่ยนค่า --green เป็นสีหลักของธีม (ชื่อตัวแปรคงเดิม ไม่ต้องไล่แก้ทุกหน้า) */
html[data-theme="formal"] {
  --green: #0a6ed1; --green-dark: #0854a0; --green-light: #e5f0fb;
  --bg: #eef2f7; --border: #d5dde8; --text: #1d2d3e; --gray: #5b6b7d; --zebra: #f5f8fb;
  --radius: 6px; --radius-sm: 4px; --shadow: 0 1px 2px rgba(29,45,62,0.06);
  --hdr-bg: #1d3557; --hdr-fg: #ffffff; --hdr-sub: rgba(255,255,255,0.72); --hdr-line: rgba(255,255,255,0.3);
}
html[data-theme="bright"] {
  --green: #0176d3; --green-dark: #014486; --green-light: #e8f2fc;
  --bg: #f3f5f9; --border: #e1e6ee; --text: #181818; --gray: #5c6a7e; --zebra: #f7f9fc;
  --radius: 12px; --radius-sm: 10px; --shadow: 0 1px 3px rgba(24,24,24,0.06);
  --hdr-bg: #ffffff; --hdr-fg: #16325c; --hdr-sub: #5c6a7e; --hdr-line: #e1e6ee;
}

/* ---------- หัวโปรแกรม ---------- */
html[data-theme] .topbar { background: var(--hdr-bg); color: var(--hdr-fg); border-bottom: 1px solid var(--hdr-line); }
html[data-theme] .topbar .brand-sub { color: var(--hdr-sub); }
html[data-theme] .topbar .brand-icon { background: var(--green-light); color: var(--green); }
html[data-theme="formal"] .topbar .brand-icon { background: rgba(255,255,255,0.16); color: #fff; }
html[data-theme] .topbar button.logout-btn { color: var(--hdr-fg); border-color: var(--hdr-line); }
html[data-theme] .topbar button.logout-btn::before { background: var(--hdr-line); }
html[data-theme="bright"] .topbar .help-btn { background: var(--green-light); }

/* ช่องค้นหาเมนูที่หัว + แถบเมนูบน: เฉพาะธีมใหม่บนคอม (มือถือ / แบบเดิมไม่แสดง) */
.hdr-search, .topnav { display: none; }
@media (min-width: 1024px) {
  html[data-theme] .hdr-search { display: block; position: relative; flex: 0 1 420px; }
  html[data-theme] .hdr-search input { width: 100%; height: 34px; margin: 0; padding: 0 12px; border-radius: var(--radius-sm); font-size: 13px;
    background: rgba(255,255,255,0.14); border: 1px solid var(--hdr-line); color: var(--hdr-fg); }
  html[data-theme] .hdr-search input::placeholder { color: var(--hdr-sub); }
  html[data-theme="bright"] .hdr-search input { background: var(--bg); }
  html[data-theme] .hdr-results:not(:empty) { position: absolute; top: 40px; left: 0; right: 0; max-height: 60vh; overflow: auto; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 4px 12px; z-index: 30; }
  html[data-theme] .topbar { overflow: visible; }

  html[data-theme] .topnav { display: flex; gap: 2px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 62px; z-index: 9; }
  html[data-theme="bright"] .topnav { background: var(--green-light); padding: 5px 16px; gap: 4px; }
  .tn-item { position: relative; }
  .tn-item > a { display: block; padding: 10px 14px; font-size: 13.5px; font-weight: 500; color: var(--text); text-decoration: none; white-space: nowrap; }
  .tn-has > a::after { content: "▾"; font-size: 10px; margin-left: 5px; color: var(--gray); }
  html[data-theme="formal"] .tn-item > a.active { color: var(--green); box-shadow: inset 0 -2px 0 var(--green); }
  html[data-theme="bright"] .tn-item > a { padding: 6px 14px; border-radius: 999px; }
  html[data-theme="bright"] .tn-item > a.active { background: var(--green); color: #fff; }
  html[data-theme="bright"] .tn-item > a.active::after { color: #fff; }
  .tn-menu { display: none; position: absolute; top: 100%; left: 0; min-width: 280px; max-width: min(880px, 92vw); max-height: 72vh; overflow: auto;
    background: #fff; border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); box-shadow: 0 14px 36px rgba(15,23,42,0.14); padding: 14px 16px;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; z-index: 30; }
  .tn-item:hover .tn-menu:not(:empty), .tn-item:focus-within .tn-menu:not(:empty) { display: grid; }
  .tn-col { min-width: 0; break-inside: avoid; }
  .tn-h { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; color: var(--gray); margin: 4px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
  .tn-col a { display: block; padding: 6px 8px; margin: 1px -8px; border-radius: 6px; font-size: 13px; color: var(--text); text-decoration: none; transition: background .12s ease, color .12s ease; }
  .tn-col a:hover { background: var(--green-light); color: var(--green); font-weight: 500; }

  /* บนคอมไม่มีแถบล่าง · เนื้อหากว้างขึ้น */
  html[data-theme] .bottomnav { display: none; }
  html[data-theme] .content { max-width: 1240px; padding: 18px 20px 28px; }
}

/* ---------- การ์ด / ตัวเลข ---------- */
html[data-theme] .card, html[data-theme] .kpi, html[data-theme] .type-btn { border-radius: var(--radius); }
html[data-theme] .dash-ico { border-radius: var(--radius-sm); }
html[data-theme] .tone-green { background: #2e8540; } html[data-theme] .tone-blue { background: #0a6ed1; }
html[data-theme] .tone-amber { background: #d97706; } html[data-theme] .tone-purple { background: #7c3aed; }
html[data-theme] .tone-red { background: #c0392b; } html[data-theme] .tone-teal { background: #0f766e; }
/* ทางการ: ไอคอนโปร่ง + แถบสีซ้ายของการ์ดตัวเลข */
html[data-theme="formal"] .dash-kpis .kpi { border-left: 4px solid var(--tone, var(--green)); flex-direction: row; align-items: center; gap: 12px; }
html[data-theme="formal"] .dash-kpis .kpi .dash-ico { margin: 0; background: transparent; color: var(--tone, var(--green)); }
html[data-theme="formal"] .dash-kpis .kpi .dash-ico .ico { filter: none; }
html[data-theme] .dash-kpis .kpi.tone-k-green { --tone: #2e8540; } html[data-theme] .dash-kpis .kpi.tone-k-blue { --tone: #0a6ed1; }
html[data-theme] .dash-kpis .kpi.tone-k-amber { --tone: #d97706; } html[data-theme] .dash-kpis .kpi.tone-k-purple { --tone: #7c3aed; }
html[data-theme] .dash-kpis .kpi.tone-k-teal { --tone: #0f766e; } html[data-theme] .dash-kpis .kpi.tone-k-red { --tone: #c0392b; }
/* สดใส: ไอคอนพื้นทึบข้างตัวเลข + หัวกล่องเป็นแถบสี */
html[data-theme="bright"] .dash-kpis .kpi { flex-direction: row; align-items: center; gap: 12px; }
html[data-theme="bright"] .dash-kpis .kpi .dash-ico { margin: 0; }
html[data-theme="bright"] .dash-grid .card > h3:first-child { margin: -16px -16px 10px; padding: 9px 16px; background: var(--green); color: #fff;
  border-radius: var(--radius) var(--radius) 0 0; font-size: 14px; }
/* มือถือ: การ์ดตัวเลขเอาไอคอนไว้บน (ไอคอนข้างตัวเลขทำให้ยอดเงินถูกตัดบรรทัด) · หัวกล่องแถบสีเท่าขอบการ์ด (การ์ดจอแคบ padding 12px) */
@media (max-width: 759px) {
  html[data-theme] .dash-kpis .kpi { flex-direction: column; align-items: stretch; gap: 2px; }
  html[data-theme] .dash-kpis .kpi .dash-ico { margin: 0 0 6px; }
  html[data-theme="formal"] .dash-kpis .kpi { padding-left: 11px; }
}
@media (max-width: 420px) { html[data-theme="bright"] .dash-grid .card > h3:first-child { margin: -12px -12px 10px; padding: 9px 12px; } }
html[data-theme="formal"] .dash-grid .card > h3:first-child { color: #1d3557; font-size: 14.5px; }
@media (min-width: 760px) { html[data-theme] .dash-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1024px) { html[data-theme] .dash-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); } }

/* ปุ่มหลัก / หัวข้อ */
html[data-theme] h2.section-title { color: var(--text); }
html[data-theme="formal"] h2.section-title { color: #1d3557; }

/* กราฟ: ยอดขายเขียว ยอดซื้อสีหลักของธีม · ชื่อรุ่นบนหัวขาว (สดใส) ใช้สีหลักแทนสีทองที่มองไม่เห็นบนพื้นขาว */
html[data-theme] .dash-svg .ch-bar-sales { fill: #2e8540; } html[data-theme] .dash-legend .lg-sales { background: #2e8540; }
html[data-theme] .dash-svg .ch-bar-purchases { fill: var(--green); } html[data-theme] .dash-legend .lg-purchases { background: var(--green); }
html[data-theme="bright"] .topbar .su-b2c4dc { color: var(--green) !important; }
