/* ═══ ศูนย์รวมโมดูล (/modules) — คลาสขึ้นต้น md- ทั้งหมด ═══ */

.md-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.md-kpi { padding: 16px; border-radius: 16px; position: relative; overflow: hidden; }
.md-kpi span { display: block; font-size: .78rem; color: var(--muted); }
.md-kpi b { display: block; font-family: var(--mono); font-size: 1.9rem; line-height: 1.2; margin: 4px 0 2px; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.md-kpi em { font-style: normal; font-size: .72rem; color: var(--dim); }
.md-kpi.md-fact b { background: linear-gradient(90deg, #eef2f5, #bfa5fa); -webkit-background-clip: text; background-clip: text; }
.md-kpi::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(90deg, transparent, rgba(191, 165, 250, .1), transparent); animation: md-sweep 5s ease-in-out infinite; }
.md-kpi:nth-child(2)::after { animation-delay: .6s; } .md-kpi:nth-child(3)::after { animation-delay: 1.2s; } .md-kpi:nth-child(4)::after { animation-delay: 1.8s; } .md-kpi:nth-child(5)::after { animation-delay: 2.4s; } .md-kpi:nth-child(6)::after { animation-delay: 3s; }
@keyframes md-sweep { 0%, 50% { left: -60%; } 100% { left: 130%; } }

/* อินโฟกราฟิก: วงสถานะ + แท่งต่อหมวด */
.md-info { display: grid; grid-template-columns: 300px 1fr; gap: 26px; align-items: center; padding: 22px 26px; border-radius: var(--radius); margin-bottom: 22px; }
.md-donut { position: relative; display: grid; justify-items: center; }
.md-donut svg { width: 190px; height: 190px; transform: rotate(-90deg); }
.md-donut .trk { fill: none; stroke: rgba(139, 92, 246, .1); stroke-width: 16; }
.md-donut .seg { fill: none; stroke-width: 16; stroke-dasharray: 0 390; transition: stroke-dasharray 1.2s var(--ease), stroke-dashoffset 1.2s var(--ease); }
.md-donut .s-live { stroke: #8b5cf6; filter: drop-shadow(0 0 6px rgba(139, 92, 246, .6)); }
.md-donut .s-new { stroke: #f472b6; filter: drop-shadow(0 0 6px rgba(244, 114, 182, .5)); }
.md-donut .s-addon { stroke: #fbbf24; filter: drop-shadow(0 0 6px rgba(251, 191, 36, .5)); }
.md-donut .dash { fill: none; stroke: rgba(191, 165, 250, .3); stroke-width: 1; stroke-dasharray: 2 7; transform-origin: 80px 80px; animation: ico-spin 30s linear infinite; }
.md-donut-txt { position: absolute; top: 0; height: 190px; display: grid; place-content: center; text-align: center; }
.md-donut-txt b { font-family: var(--mono); font-size: 2.4rem; line-height: 1; }
.md-donut-txt small { color: var(--muted); font-size: .78rem; }
.md-legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: .8rem; color: var(--muted); }
.md-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.md-legend b { color: var(--text); font-family: var(--mono); margin-left: 3px; }
.l-live { background: #8b5cf6; } .l-new { background: #f472b6; } .l-addon { background: #fbbf24; }
.md-bars { display: grid; gap: 8px; }
.md-bar { display: grid; grid-template-columns: 170px 1fr 34px; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; border: 1px solid transparent; background: none; text-align: left; transition: .2s; }
.md-bar:hover, .md-bar.on { border-color: var(--border-hi); background: rgba(245, 158, 11, .1); }
.md-bar-l { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-bar-t { height: 10px; border-radius: 9px; background: rgba(139, 92, 246, .1); position: relative; overflow: hidden; }
.md-bar-t i { position: absolute; inset: 0; width: 0; border-radius: 9px; background: linear-gradient(90deg, #f59e0b, #8b5cf6, #bfa5fa); box-shadow: 0 0 12px rgba(139, 92, 246, .5); transition: width 1.1s var(--spring); }
.md-info.in .md-bar-t i { width: var(--w); }
.md-bar-t i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: md-shine 2.6s linear infinite; }
@keyframes md-shine { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.md-bar b { font-family: var(--mono); text-align: right; }

/* ตัวกรอง */
.md-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.md-tools-r { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.md-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.md-chips button { padding: 7px 13px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .84rem; transition: .2s; }
.md-chips button b { font-family: var(--mono); color: var(--cyan); margin-left: 3px; }
.md-chips button:hover { color: var(--text); border-color: var(--border-hi); }
.md-chips button.on { background: linear-gradient(135deg, rgba(245, 158, 11, .5), rgba(12, 74, 58, .5)); color: #fff; border-color: var(--cyan); box-shadow: 0 0 14px rgba(139, 92, 246, .25); }
.md-chips.sm button { padding: 5px 11px; font-size: .78rem; }
.md-search { display: flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--border-hi); background: rgba(23, 18, 10, .6); color: var(--muted); }
.md-search input { border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: .86rem; width: 210px; padding: 4px 0; }
.md-live { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--dim); margin: 6px 0 14px; }
.md-flash { margin-left: 6px; color: var(--accent); animation: live 1.6s infinite; }

/* การ์ด */
.md-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.md-card { padding: 18px; border-radius: 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; transition: transform .35s var(--ease), border-color .35s, box-shadow .35s; animation: md-in .55s var(--spring) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes md-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.md-card:hover { transform: translateY(-4px); border-color: rgba(139, 92, 246, .5); box-shadow: 0 18px 40px rgba(0, 0, 0, .35), 0 0 24px rgba(245, 158, 11, .18); }
.md-card::before { content: ""; position: absolute; width: 180px; height: 180px; right: -70px; top: -70px; border-radius: 50%; background: radial-gradient(closest-side, rgba(139, 92, 246, .22), transparent); opacity: .6; transition: .4s; pointer-events: none; }
.md-card:hover::before { opacity: 1; transform: scale(1.25); }
.md-card[data-st="new"]::before { background: radial-gradient(closest-side, rgba(244, 114, 182, .22), transparent); }
.md-card[data-st="addon"]::before { background: radial-gradient(closest-side, rgba(251, 191, 36, .2), transparent); }
.md-card-h { display: flex; justify-content: space-between; align-items: flex-start; }
.md-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.45rem; position: relative; background: linear-gradient(145deg, #0f2e1b, #20180a); border: 1px solid rgba(139, 92, 246, .45); box-shadow: 0 0 18px rgba(139, 92, 246, .16); animation: ico-hop 3.2s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -270ms); }
.md-ico::after { content: ""; position: absolute; inset: -4px; border-radius: 17px; border: 1px solid rgba(139, 92, 246, .45); animation: ring-out 2.8s ease-out infinite; animation-delay: calc(var(--i, 0) * -230ms); }
.md-card h3 { font-size: 1.03rem; margin: 8px 0 0; }
.md-card p { margin: 0; color: var(--muted); font-size: .88rem; }
.md-card ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
.md-card li { position: relative; padding-left: 18px; font-size: .82rem; color: var(--text); opacity: .88; }
.md-card li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.md-cat { margin-top: auto; padding-top: 8px; font-size: .72rem; color: var(--dim); }
.md-card.flash { animation: md-flash 1.4s var(--ease); }
@keyframes md-flash { 0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, .7); border-color: var(--cyan); } 100% { box-shadow: 0 0 0 16px rgba(139, 92, 246, 0); } }
.md-empty { text-align: center; color: var(--muted); padding: 30px 0; }

@media (max-width: 1100px) { .md-kpis { grid-template-columns: repeat(3, 1fr); } .md-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .md-info { grid-template-columns: 1fr; } .md-bar { grid-template-columns: 140px 1fr 30px; } }
@media (max-width: 600px) {
  .md-kpis { grid-template-columns: repeat(2, 1fr); }
  .md-grid { grid-template-columns: 1fr; }
  .md-search input { width: 150px; }
  .md-tools-r { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .md-card, .md-ico, .md-ico::after, .md-kpi::after, .md-bar-t i::after, .md-donut .dash { animation: none; } }
