/* สไตล์ร่วมของแดชบอร์ด IDP (ภาพรวม, รายหน่วยงาน, ความเชี่ยวชาญ) */
.idp-dash {
  --surface: #ffffff;
  --plane: #f3f6f5;
  --ink: #0f1f1d;
  --ink-2: #475652;
  --muted: #7b8986;
  --line: #e2e8e6;
  --line-2: #eef2f1;
  --brand: #0f766e;
  --brand-2: #0d9488;
  --brand-ink: #0f766e;
  --brand-deep: #134e4a;
  --brand-soft: #e6f4f2;
  --good: #0ca30c;
  --warn: #fab219;
  --crit: #d03b3b;
  --none: #c3c2b7;
  --s-blue: #2a78d6;
  --s-orange: #eb6834;
  --shadow: 0 1px 2px rgba(16, 40, 36, .05), 0 2px 10px rgba(16, 40, 36, .05);
  --shadow-hover: 0 2px 4px rgba(16, 40, 36, .06), 0 10px 28px rgba(16, 40, 36, .09);
  --radius: 16px;
  font-family: 'Kanit', system-ui, sans-serif;
  font-weight: 300;
  color: var(--ink);
  background: var(--plane);
  margin: 0 -16px;
  padding: 0 16px 40px;
  font-size: 15px;
  line-height: 1.55;
  position: relative;
}
/* แถบสีหัวหน้า (hero): เต็มความกว้างจอ อยู่หลังหัวเรื่อง ตัวกรอง และแท็บปี */
.idp-dash { overflow-x: clip; }
.idp-hero { position: relative; color: #fff; padding-bottom: 6px; margin-bottom: 4px; }
.idp-hero::before {
  content: ''; position: absolute; z-index: -1; top: -26px; bottom: -34px; left: 50%; width: 100vw; transform: translateX(-50%);
  background:
    radial-gradient(900px 260px at 85% -40px, rgba(45, 212, 191, .35), transparent 70%),
    radial-gradient(700px 240px at 0% 0%, rgba(13, 148, 136, .5), transparent 70%),
    linear-gradient(135deg, #115e59 0%, #134e4a 55%, #0f3d3a 100%);
}
.idp-dash * { box-sizing: border-box; }
.idp-dash b, .idp-dash strong { font-weight: 500; }
.idp-dash h2, .idp-dash h3, .idp-dash h4 { font-family: 'Kanit', system-ui, sans-serif; margin: 0; font-weight: 500; }
.idp-wrap { max-width: 1320px; margin: 0 auto; position: relative; z-index: 0; padding-top: 26px; isolation: isolate; }

/* ---- หัวเรื่อง (บนแถบสี) ---- */
.idp-head { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.idp-subfilters { margin: -4px 0 14px; }
.idp-head h2 { font-size: 26px; line-height: 1.25; font-weight: 500; letter-spacing: -.005em; }
.idp-hero .sub { color: rgba(255, 255, 255, .75); font-size: 14px; margin-top: 4px; }
.idp-hero .idp-rank { color: rgba(255, 255, 255, .85) !important; }
.idp-crumb { position: relative; }
.idp-dash .idp-crumb a { color: rgba(255, 255, 255, .8) !important; }
.idp-dash .idp-crumb a:hover { color: #fff !important; }
.idp-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.idp-filters label { font-size: 13px; color: var(--ink-2); }
.idp-hero .idp-filters label { color: rgba(255, 255, 255, .8); }
.idp-filters select { font-family: inherit; font-size: 14px; padding: 8px 32px 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23475652' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E") no-repeat right 11px center; -webkit-appearance: none; appearance: none; color: var(--ink); max-width: 280px; cursor: pointer; box-shadow: var(--shadow); }
.idp-filters select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(13, 148, 136, .2); }
.idp-seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; box-shadow: var(--shadow); }
.idp-hero .idp-seg { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .18); box-shadow: none; }
.idp-seg button { font-family: inherit; font-size: 14px; border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; cursor: pointer; color: var(--ink-2); transition: background .15s, color .15s; }
.idp-hero .idp-seg button { color: rgba(255, 255, 255, .85); }
.idp-seg button:hover { color: var(--brand); }
.idp-hero .idp-seg button:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.idp-seg button.on, .idp-hero .idp-seg button.on { background: var(--brand); color: #fff; font-weight: 500; box-shadow: 0 1px 4px rgba(15, 118, 110, .35); }
.idp-hero .idp-seg button.on { background: #fff; color: var(--brand-deep); }
.idp-reset { font-family: inherit; font-size: 13px; border: 0; background: none; color: var(--brand-ink); cursor: pointer; text-decoration: underline; padding: 4px; }
.idp-hero .idp-reset { color: #fff; }

/* ---- ตัวเลขสรุป ---- */
.idp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.idp-kpi { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px; box-shadow: var(--shadow); overflow: hidden; transition: box-shadow .2s, transform .2s; }
.idp-kpi::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); opacity: .9; }
.idp-kpi:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.idp-kpi .lbl { font-size: 13px; color: var(--ink-2); font-weight: 400; }
.idp-kpi .val { font-size: 32px; font-weight: 600; line-height: 1.15; margin-top: 6px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.idp-kpi .val small { font-size: 15px; font-weight: 400; color: var(--ink-2); margin-left: 4px; letter-spacing: 0; }
.idp-kpi .ft { font-size: 13px; color: var(--muted); margin-top: 4px; }
.idp-kpi .meter { height: 8px; background: var(--line-2); border-radius: 999px; margin-top: 12px; position: relative; overflow: visible; }
.idp-kpi .meter i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); }
.idp-kpi .meter b { position: absolute; top: -4px; width: 2px; height: 16px; border-radius: 1px; background: var(--ink); }
.idp-kpi.good .val { color: var(--ink); }

/* ---- การ์ด ---- */
.idp-grid { display: grid; gap: 18px; grid-template-columns: repeat(12, 1fr); }
.idp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; box-shadow: var(--shadow); }
.idp-card h3 { font-size: 17px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.idp-card h3::before { content: ''; width: 4px; height: 18px; border-radius: 2px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); flex: none; }
.idp-card .hint { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }
.c-12 { grid-column: span 12; } .c-7 { grid-column: span 7; } .c-5 { grid-column: span 5; }
.c-6 { grid-column: span 6; } .c-4 { grid-column: span 4; } .c-8 { grid-column: span 8; }
@media (max-width: 1000px) { .c-7, .c-5, .c-6, .c-4, .c-8 { grid-column: span 12; } }

/* ---- ประเด็นสำหรับการตัดสินใจ ---- */
.idp-insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.idp-insights li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; padding: 12px 14px; border-radius: 12px; background: #f7f9f8; border: 1px solid var(--line-2); border-left: 3px solid var(--muted); }
.idp-insights li.crit { border-left-color: var(--crit); background: #fdf6f6; }
.idp-insights li.warn { border-left-color: var(--warn); background: #fffaf0; }
.idp-insights li.good { border-left-color: var(--good); background: #f4fbf4; }
.idp-insights li.info { border-left-color: var(--s-blue); background: #f4f8fd; }
.idp-insights .ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; margin-top: 1px; }
.idp-insights .crit .ic { background: var(--crit); }
.idp-insights .warn .ic { background: var(--warn); color: #16201e; }
.idp-insights .good .ic { background: var(--good); }
.idp-insights .info .ic { background: var(--s-blue); }
.idp-insights .t { font-weight: 500; }
.idp-insights .d { font-size: 13px; color: var(--ink-2); }
.idp-insights .act { font-size: 13px; color: var(--brand-ink); margin-top: 3px; font-weight: 400; }

/* ---- กรวย ---- */
.idp-funnel { display: grid; gap: 12px; }
.idp-funnel .row { display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: center; }
.idp-funnel .name { font-size: 14px; color: var(--ink-2); }
.idp-funnel .bar { position: relative; height: 36px; background: var(--line-2); border-radius: 10px; overflow: hidden; }
.idp-funnel .bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 10px; }
.idp-funnel .bar span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; color: #fff; white-space: nowrap; font-weight: 500; }
.idp-funnel .bar span.out { color: var(--ink); }
.idp-funnel .drop { font-size: 12px; color: var(--crit); grid-column: 2; margin-top: -7px; }
@media (max-width: 600px) { .idp-funnel .row { grid-template-columns: 1fr; gap: 4px; } .idp-funnel .drop { grid-column: 1; } }

.idp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.idp-legend span { display: inline-flex; align-items: center; gap: 6px; }
.idp-legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.idp-chart { position: relative; width: 100%; }

/* ---- ตาราง ---- */
.idp-table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: 12px; }
.idp-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.idp-table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 500; color: var(--ink-2); font-size: 13px; padding: 10px; background: #f7f9f8; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; }
.idp-table th:hover { color: var(--brand); }
.idp-table th.num, .idp-table td.num { text-align: right; }
.idp-table th .arr { color: var(--muted); font-size: 11px; }
.idp-table td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.idp-table tbody tr:last-child td { border-bottom: 0; }
.idp-table tr.sel td { background: var(--brand-soft); }
.idp-table tbody tr:hover td { background: #f5f9f8; cursor: pointer; }
.idp-table .pbar { display: grid; grid-template-columns: 1fr 42px; gap: 8px; align-items: center; min-width: 120px; }
.idp-table .pbar div { height: 8px; background: var(--line-2); border-radius: 999px; position: relative; }
.idp-table .pbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--brand); }
.idp-table .pbar b { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--ink); opacity: .5; }
.idp-table .pbar span { text-align: right; }
.idp-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.idp-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.idp-badge.good { background: #e7f6e7; color: #0b5d0b; } .idp-badge.good::before { background: var(--good); }
.idp-badge.warn { background: #fff4d9; color: #7a5200; } .idp-badge.warn::before { background: var(--warn); }
.idp-badge.crit { background: #fbe7e7; color: #8f1d1d; } .idp-badge.crit::before { background: var(--crit); }
.idp-table a { color: var(--brand-ink); text-decoration: none; font-weight: 400; }
.idp-table a:hover { text-decoration: underline; }

/* ---- รายการอันดับ ---- */
.idp-xlist { display: grid; gap: 10px; }
.idp-xlist .r { display: grid; grid-template-columns: 1fr 56px; gap: 8px; align-items: center; font-size: 14px; }
.idp-xlist .r .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idp-xlist .r .bg { grid-column: 1 / -1; height: 7px; background: var(--line-2); border-radius: 999px; margin-top: -4px; }
.idp-xlist .r .bg i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #5598e7, var(--s-blue)); }
.idp-xlist .r .n { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.idp-empty { color: var(--muted); font-size: 14px; padding: 12px 0; }

.idp-dash .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.idp-note { font-size: 12px; color: var(--muted); margin-top: 20px; line-height: 1.7; padding: 14px 16px; border-radius: 12px; background: rgba(255, 255, 255, .6); border: 1px dashed var(--line); }
.idp-note b { color: var(--ink-2); font-weight: 500; }

/* ---- แท็บเลือกปีงบประมาณ (บนแถบสี) ---- */
.idp-years { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 0 0 18px; }
.idp-years .lbl { align-self: center; font-size: 14px; color: rgba(255, 255, 255, .8); margin-right: 4px; }
.idp-ytab { display: flex; flex-direction: column; justify-content: center; min-width: 120px; padding: 8px 16px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 14px; background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; line-height: 1.25; transition: background .15s, border-color .15s; backdrop-filter: blur(4px); }
.idp-ytab:hover { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .4); color: #fff; }
.idp-ytab .y { font-size: 19px; font-weight: 600; }
.idp-ytab .m { font-size: 12px; color: rgba(255, 255, 255, .7); }
.idp-ytab.on { background: #fff; border-color: #fff; color: var(--brand-deep); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.idp-ytab.on .m { color: var(--brand); }
@media (max-width: 600px) {
  .idp-head h2 { font-size: 21px; }
  .idp-years .lbl { width: 100%; }
  .idp-ytab { min-width: 0; flex: 1 1 28%; padding: 7px 10px; }
  .idp-kpi .val { font-size: 27px; }
  .idp-card { padding: 16px; }
}
@media print { .idp-hero::before { display: none; } .idp-hero, .idp-years .lbl, .idp-ytab { color: var(--ink) !important; } }
.idp-seg button { white-space: nowrap; }
@media (max-width: 600px) {
  .idp-filters { width: 100%; min-width: 0; }
  .idp-seg { display: flex; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .idp-seg button { flex: 1 0 auto; padding: 6px 10px; font-size: 13px; }
  .idp-filters select { max-width: 100%; width: 100%; min-width: 0; flex: 1 1 100%; }
}

/* ---- กราฟแท่งแบบเดียวกับ "ความคืบหน้า" (js/idp_bars.js) ---- */
.idp-bars { display: grid; gap: 10px; }
.idp-bars .row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr; gap: 12px; align-items: center; border-radius: 10px; }
.idp-bars.top .row { grid-template-columns: 1fr; gap: 4px; }
.idp-bars .name { font-size: 14px; color: var(--ink-2); line-height: 1.3; overflow-wrap: anywhere; }
.idp-bars .name small { display: block; font-size: 12px; color: var(--muted); }
.idp-bars .bar { position: relative; height: 34px; background: var(--line-2); border-radius: 10px; overflow: hidden; }
.idp-bars .fill { position: absolute; left: 0; top: 0; bottom: 0; display: flex; width: 100%; }
.idp-bars .fill i { display: block; height: 100%; flex: none; box-shadow: inset -2px 0 0 rgba(255, 255, 255, .55); }
.idp-bars .fill i:first-child { border-radius: 10px 0 0 10px; }
.idp-bars .fill i:last-child { border-radius: 0 10px 10px 0; box-shadow: none; }
.idp-bars .fill i:only-child { border-radius: 10px; }
.idp-bars .bar span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; color: #fff; white-space: nowrap; font-weight: 500; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); pointer-events: none; }
.idp-bars .bar span.out { color: var(--ink); text-shadow: none; }
.idp-bars .tgt { position: absolute; top: 3px; bottom: 3px; width: 2px; border-radius: 1px; background: var(--ink); opacity: .55; z-index: 1; }
.idp-bars .row.click { cursor: pointer; }
.idp-bars .row.click:hover .name { color: var(--brand); }
.idp-bars .row.click:hover .bar { box-shadow: 0 0 0 2px var(--brand-soft); }
.idp-bars .row.click:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 3px; }
.idp-bars .row.sel .name { color: var(--ink); font-weight: 500; }
.idp-bars .row.sel .bar { box-shadow: 0 0 0 2px var(--ink); }
@media (max-width: 600px) { .idp-bars .row { grid-template-columns: 1fr; gap: 4px; } }
.idp-scroll { max-height: 372px; overflow-y: auto; padding: 3px 8px 3px 3px; margin: -3px; scrollbar-width: thin; }
.idp-bars .bar span.pill { left: 6px; padding: 2px 9px; border-radius: 7px; background: rgba(255, 255, 255, .92); color: var(--ink); text-shadow: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
