/* BMA 2569 Drill-Down Dashboard — ย้ายมาจาก apps/index.php (inline style) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f7fb;
  --white:     #ffffff;
  --surface2:  #f0f4fa;
  --border:    #e3eaf5;
  --border2:   #c8d6ec;
  --text:      #0d1829;
  --text2:     #344563;
  --text3:     #637390;
  --text4:     #9aaec9;
  --accent:    #1d4ed8;
  --accent-l:  #dbeafe;
  --accent-m:  #93c5fd;
  --green:     #059669;
  --green-l:   #d1fae5;
  --red:       #dc2626;
  --gold:      #b45309;
  --gold-l:    #fef3c7;
  --purple:    #7c3aed;
  --purple-l:  #ede9fe;
  --shadow-xs: 0 1px 3px rgba(13,24,41,.05);
  --shadow-s:  0 2px 8px rgba(13,24,41,.07), 0 1px 2px rgba(13,24,41,.04);
  --shadow-m:  0 6px 20px rgba(13,24,41,.09), 0 2px 6px rgba(13,24,41,.05);
  --radius:    12px;
  --radius-s:  8px;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* HEADER */
header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
}
.logo-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .15em;
  color: var(--accent);
  background: var(--accent-l);
  border: 1px solid var(--accent-m);
  padding: 4px 11px;
  border-radius: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}
header h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr-stat {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--gold);
  background: var(--gold-l);
  border: 1px solid #fde68a;
  padding: 5px 14px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* BREADCRUMB */
#breadcrumb {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text3);
}
.bc-item { cursor: pointer; transition: color .12s; }
.bc-item:hover { color: var(--accent); }
.bc-active { color: var(--text2); font-weight: 600; }
.bc-sep { color: var(--text4); }

/* LAYOUT */
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: calc(100vh - 98px);
}

/* SIDEBAR */
aside {
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 14px 8px;
  position: sticky;
  top: 98px;
  height: calc(100vh - 98px);
  overflow-y: auto;
}
aside::-webkit-scrollbar { width: 4px; }
aside::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.sb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--text4);
  text-transform: uppercase;
  padding: 8px 12px 5px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  transition: all .13s;
  user-select: none;
}
.sb-item:hover { background: var(--surface2); }
.sb-item.active { background: var(--accent-l); color: var(--accent); font-weight: 600; }
.sb-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.sb-count {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 100px;
}
.sb-div { height: 1px; background: var(--border); margin: 8px 12px; }

/* MAIN */
main { min-height: calc(100vh - 98px); }
.view { display: none; padding: 28px 32px; }
.view.active { display: block; }

/* KPI STRIP */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .15s;
}
.kpi-card:hover { box-shadow: var(--shadow-s); }
.kpi-label { font-size: 11px; color: var(--text3); font-weight: 500; margin-bottom: 6px; }
.kpi-val { font-family: 'IBM Plex Mono', monospace; font-size: 26px; font-weight: 600; line-height: 1; margin-bottom: 4px; }
.kpi-unit { font-size: 11px; color: var(--text4); }

/* SECTION HEAD */
.sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sec-head h2 { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; flex-shrink: 0; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 100px; font-family: 'IBM Plex Mono', monospace; font-weight: 500; }
.pill-blue   { background: var(--accent-l);  color: var(--accent);  border: 1px solid #bfdbfe; }
.pill-green  { background: var(--green-l);   color: var(--green);   border: 1px solid #a7f3d0; }
.pill-gold   { background: var(--gold-l);    color: var(--gold);    border: 1px solid #fde68a; }
.pill-purple { background: var(--purple-l);  color: var(--purple);  border: 1px solid #ddd6fe; }
.pill-gray   { background: var(--surface2);  color: var(--text3);   border: 1px solid var(--border); }

/* STRATEGY GRID */
.strategy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.s-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  cursor: pointer;
  transition: all .18s;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.s-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--c, var(--accent));
}
.s-card:hover { box-shadow: var(--shadow-m); transform: translateY(-2px); border-color: var(--border2); }
.s-icon { font-size: 28px; margin-bottom: 10px; display: block; }
.s-name { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.s-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.s-tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--surface2); color: var(--text3); font-family: 'IBM Plex Mono', monospace; }
.s-budget { font-family: 'IBM Plex Mono', monospace; font-size: 17px; font-weight: 700; color: var(--text); }
.s-pct { font-size: 11px; color: var(--text4); margin-top: 2px; }
.s-bar { height: 4px; background: var(--border); border-radius: 3px; margin-top: 12px; }
.s-bar-fill { height: 100%; border-radius: 3px; }
.s-arrow { position: absolute; right: 18px; bottom: 22px; font-size: 20px; color: var(--text4); }

/* DETAIL HEADER */
.det-hdr {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--c, var(--accent));
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}
.det-icon { font-size: 38px; flex-shrink: 0; }
.det-body { flex: 1; min-width: 0; }
.det-title { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 5px; letter-spacing: -.02em; }
.det-sub { font-size: 13px; color: var(--text3); margin-bottom: 2px; }
.det-budget-block { text-align: right; flex-shrink: 0; }
.det-budget-val { font-family: 'IBM Plex Mono', monospace; font-size: 21px; font-weight: 700; color: var(--gold); }
.det-budget-lbl { font-size: 11px; color: var(--text4); margin-top: 2px; }

/* ISSUE LIST */
.issue-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 28px; }
.i-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all .13s;
  box-shadow: var(--shadow-xs);
}
.i-card:hover { border-color: var(--border2); box-shadow: var(--shadow-s); }
.i-id { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text4); width: 28px; flex-shrink: 0; }
.i-name { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.tag-row { display: flex; gap: 5px; margin-top: 4px; }
.i-tag { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--surface2); color: var(--text3); font-family: 'IBM Plex Mono', monospace; }
.i-budget-val { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 700; color: var(--gold); text-align: right; }
.i-budget-lbl { font-size: 10px; color: var(--text4); text-align: right; }
.chevron { color: var(--text4); font-size: 18px; flex-shrink: 0; }

/* OKR TABLE */
.okr-table { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow-xs); }
.okr-th {
  display: grid;
  grid-template-columns: 72px 1fr 150px 90px;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface2);
  font-size: 10px;
  font-weight: 700;
  color: var(--text4);
  text-transform: uppercase;
  letter-spacing: .1em;
  border-bottom: 1px solid var(--border);
}
.okr-row {
  display: grid;
  grid-template-columns: 72px 1fr 150px 90px;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background .1s;
}
.okr-row:last-child { border-bottom: none; }
.okr-row:hover { background: var(--surface2); }
.okr-code { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text4); }
.okr-name { font-size: 13px; color: var(--text); line-height: 1.4; }
.okr-target { font-size: 12px; color: var(--green); font-family: 'IBM Plex Mono', monospace; font-weight: 500; }
.okr-ag { font-family: 'IBM Plex Mono', monospace; font-size: 11px; padding: 3px 8px; border-radius: 5px; border: 1px solid; display: inline-block; }

/* PROJECTS */
.proj-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }
.proj-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .12s, background .12s;
}
.proj-item:hover { border-color: var(--border2); background: var(--surface2); }
.proj-name { font-size: 13px; color: var(--text); font-weight: 500; flex: 1; line-height: 1.4; }
.proj-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.ag-pill { font-size: 10px; padding: 2px 8px; border-radius: 5px; border: 1px solid; font-family: 'IBM Plex Mono', monospace; font-weight: 500; }
.proj-budget { font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 700; color: var(--gold); flex-shrink: 0; white-space: nowrap; }

/* BUDGET BARS */
.bbar-section { display: flex; flex-direction: column; gap: 0; margin-bottom: 28px; }
.bbar-item {
  display: grid;
  grid-template-columns: 200px 1fr 130px;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity .13s;
}
.bbar-item:last-child { border-bottom: none; }
.bbar-item:hover { opacity: .75; }
.bbar-label { font-size: 12px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bbar-track { background: var(--surface2); border-radius: 3px; height: 8px; overflow: hidden; }
.bbar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.bbar-val { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text3); text-align: right; }

/* AGENCY GRID */
.agency-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.ag-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 14px; box-shadow: var(--shadow-xs); transition: all .13s; }
.ag-card:hover { box-shadow: var(--shadow-s); border-color: var(--border2); }
.ag-code { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.ag-name { font-size: 12px; color: var(--text2); line-height: 1.4; margin-bottom: 10px; }
.ag-stats { display: flex; gap: 12px; }
.ag-stat .sv { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 700; color: var(--text); }
.ag-stat .sl { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* FLOW PATH */
.flow-path { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.flow-node { font-size: 12px; padding: 5px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 100px; cursor: pointer; transition: all .12s; color: var(--text2); font-weight: 500; }
.flow-node:hover { border-color: var(--border2); background: var(--accent-l); color: var(--accent); }
.flow-node.current { background: var(--accent-l); color: var(--accent); border-color: #93c5fd; font-weight: 700; }
.flow-arrow { color: var(--text4); font-size: 16px; }

/* BACK BTN */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--white); border: 1px solid var(--border);
  color: var(--text2); padding: 8px 16px; border-radius: var(--radius-s);
  cursor: pointer; font-size: 13px; font-family: 'Sarabun', sans-serif;
  margin-bottom: 20px; transition: all .13s; box-shadow: var(--shadow-xs);
}
.back-btn:hover { border-color: var(--border2); background: var(--surface2); }

/* SEARCH */
.search-wrap { position: relative; margin-bottom: 20px; }
.search-input {
  width: 100%; background: var(--white); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px 10px 40px;
  border-radius: var(--radius-s); font-size: 14px; font-family: 'Sarabun', sans-serif;
  outline: none; transition: border .13s, box-shadow .13s; box-shadow: var(--shadow-xs);
}
.search-input:focus { border-color: var(--accent-m); box-shadow: 0 0 0 3px rgba(29,78,216,.08); }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text4); pointer-events: none; }

/* HR */
hr.div { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.loading { padding: 60px; text-align: center; color: var(--text3); font-size: 14px; }

@media (max-width: 1200px) { .kpi-strip { grid-template-columns: repeat(3, 1fr); } .strategy-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } aside { position: static; height: auto; } .view { padding: 20px 16px; } .kpi-strip { grid-template-columns: repeat(2, 1fr); } .strategy-grid { grid-template-columns: 1fr; } .agency-grid { grid-template-columns: repeat(2, 1fr); } header h1 { display: none; } }
