/* ============================================================
   ระบบวิเคราะห์ผลประเมินโครงการ — ธีม "PSU Navy Glass"
   สีกรมท่า ม.อ. + กระจกฝ้า (glassmorphism) + เลย์เอาต์ลอย
   ค่าสีข้อมูลกราฟ (--series-1, --lk*) คงชุดสีที่อ่านง่ายไว้
   ============================================================ */

@font-face {
  font-family: "Anuphan";
  src: url("vendor/fonts/anuphan-thai.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Anuphan";
  src: url("vendor/fonts/anuphan-latin.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* ===== โหมดสว่าง ===== */
:root {
  --navy-900: #001737;
  --navy-800: #002451;
  --navy-700: #002f6c;   /* กรมท่า ม.อ. */
  --navy-500: #1a54a6;
  --navy-300: #4a86d6;

  --page: #e8edf5;
  --surface-1: #ffffff;                    /* สีทึบ (กราฟใช้) */
  --surface-2: #eef2f8;
  --glass-bg: rgba(255, 255, 255, 0.62);   /* พื้นการ์ดกระจก */
  --glass-hi: rgba(255, 255, 255, 0.9);    /* เส้นไฮไลต์บนขอบ */
  --glass-border: rgba(0, 47, 108, 0.12);
  --glass-blur: 18px;

  --text-primary: #0d1b30;
  --text-secondary: #46566e;
  --muted: #7d8ba0;
  --grid: #dde5f0;
  --axis: #c3cee0;
  --border: rgba(0, 47, 108, 0.10);

  --accent: #002f6c;
  --accent-2: #1a54a6;
  --accent-grad: linear-gradient(135deg, #1a54a6 0%, #002f6c 100%);
  --accent-soft: rgba(26, 84, 166, 0.12);
  --glow: rgba(26, 84, 166, 0.14);
  --glow-2: rgba(0, 47, 108, 0.10);

  --series-1: #1c5aa8;
  --lk5: #123c78; --lk4: #4a86d6; --lk3: #cdd6e4; --lk2: #ef9392; --lk1: #d64545;
  --good: #0a6b3f;

  --shadow-card: 0 1px 1px rgba(0, 23, 55, 0.04), 0 14px 34px -18px rgba(0, 23, 55, 0.28);
  --shadow-pop: 0 26px 60px -22px rgba(0, 23, 55, 0.42);
  --paper: #ffffff;
  --r: 24px;
  --r-sm: 14px;
  --gap: 18px;
}

/* ===== โหมดมืด (สองบล็อกต้องเหมือนกันเสมอ) ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #04070f;
    --surface-1: #101a2e;
    --surface-2: #142138;
    --glass-bg: rgba(18, 30, 54, 0.55);
    --glass-hi: rgba(120, 160, 225, 0.18);
    --glass-border: rgba(120, 160, 225, 0.14);
    --text-primary: #eef3fb;
    --text-secondary: #a9b8d0;
    --muted: #6f7f9b;
    --grid: #1e2c46;
    --axis: #2a3b5a;
    --border: rgba(140, 175, 235, 0.10);
    --accent: #5896e8;
    --accent-2: #3f7fd8;
    --accent-grad: linear-gradient(135deg, #5896e8 0%, #2f66c2 100%);
    --accent-soft: rgba(88, 150, 232, 0.16);
    --glow: rgba(63, 127, 216, 0.20);
    --glow-2: rgba(20, 60, 140, 0.16);
    --series-1: #4f8fe6;
    --lk5: #2f66c2; --lk4: #7fb0ef; --lk3: #3a4a68; --lk2: #f0a8a7; --lk1: #e66767;
    --good: #34c77e;
    --shadow-card: 0 1px 0 rgba(140, 175, 235, 0.05) inset, 0 18px 40px -20px rgba(0, 0, 0, 0.7);
    --shadow-pop: 0 30px 70px -24px rgba(0, 0, 0, 0.8);
    --paper: #ffffff;
  }
}
:root[data-theme="dark"] {
  --page: #04070f;
  --surface-1: #101a2e;
  --surface-2: #142138;
  --glass-bg: rgba(18, 30, 54, 0.55);
  --glass-hi: rgba(120, 160, 225, 0.18);
  --glass-border: rgba(120, 160, 225, 0.14);
  --text-primary: #eef3fb;
  --text-secondary: #a9b8d0;
  --muted: #6f7f9b;
  --grid: #1e2c46;
  --axis: #2a3b5a;
  --border: rgba(140, 175, 235, 0.10);
  --accent: #5896e8;
  --accent-2: #3f7fd8;
  --accent-grad: linear-gradient(135deg, #5896e8 0%, #2f66c2 100%);
  --accent-soft: rgba(88, 150, 232, 0.16);
  --glow: rgba(63, 127, 216, 0.20);
  --glow-2: rgba(20, 60, 140, 0.16);
  --series-1: #4f8fe6;
  --lk5: #2f66c2; --lk4: #7fb0ef; --lk3: #3a4a68; --lk2: #f0a8a7; --lk1: #e66767;
  --good: #34c77e;
  --shadow-card: 0 1px 0 rgba(140, 175, 235, 0.05) inset, 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 30px 70px -24px rgba(0, 0, 0, 0.8);
  --paper: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 640px at 82% -10%, var(--glow), transparent 60%),
    radial-gradient(1000px 560px at -6% 12%, var(--glow-2), transparent 58%),
    radial-gradient(900px 700px at 50% 120%, var(--accent-soft), transparent 62%),
    var(--page);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: "Anuphan", "Sarabun", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.004em;
}
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--axis); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* พื้นผิวกระจก (mixin ผ่าน utility) */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.5);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
}

/* ============================================================
   เลย์เอาต์: sidebar ลอยเป็นแผงกระจก + คอนเทนต์มีระยะหายใจ
   ============================================================ */
.app-shell { display: flex; gap: var(--gap); padding: var(--gap); min-height: 100vh; }

.sidebar {
  width: 236px; flex-shrink: 0;
  position: sticky; top: var(--gap);
  height: calc(100vh - var(--gap) * 2);
  border-radius: var(--r);
  padding: 20px 14px 16px;
  display: flex; flex-direction: column;
  overflow-y: auto;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
}
.side-logo { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.logo-mark {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad);
  box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--accent) 70%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.side-logo b { display: block; font-size: 14.5px; line-height: 1.25; letter-spacing: -0.015em; }
.side-logo div span { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.side-nav { flex: 1; }
.side-group { margin-bottom: 20px; }
.side-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); padding: 0 12px 8px;
}
.side-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: none; background: none; font-family: inherit; text-align: left;
  font-size: 13.5px; font-weight: 500; color: var(--text-secondary);
  padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer;
  position: relative;
  transition: background 0.16s, color 0.16s, transform 0.16s;
}
.side-btn i { font-style: normal; width: 21px; text-align: center; }
.side-btn:hover { background: var(--accent-soft); color: var(--text-primary); }
.side-btn.active {
  background: linear-gradient(100deg, var(--accent-soft), transparent);
  color: var(--accent); font-weight: 700;
}
.side-btn.active::before {
  content: ""; position: absolute; left: 3px; top: 22%; bottom: 22%; width: 3px;
  border-radius: 99px; background: var(--accent-grad);
}
.side-bottom { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.side-bottom .btn.primary { width: 100%; justify-content: center; }
.side-user { display: flex; align-items: center; gap: 6px; }
.side-user .user-chip { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 6px 8px 0; margin-bottom: 4px; flex-wrap: wrap;
}
.topbar h1 {
  font-size: 24px; margin: 0; letter-spacing: -0.025em; font-weight: 700;
  background: linear-gradient(120deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar .sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.file-info {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); flex-wrap: wrap;
  padding: 7px 10px 7px 14px; border-radius: 99px;
  background: var(--glass-bg);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
}
.file-info .chip-file { background: var(--accent-soft); color: var(--accent); padding: 4px 12px; border-radius: 99px; font-weight: 600; }

main { width: 100%; max-width: 1260px; margin: 0 auto; padding: 16px 8px 90px; }
.hidden { display: none !important; }

/* จอแคบ: sidebar พับเป็นแถบเลื่อนแนวนอนด้านบน */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; gap: 12px; padding: 12px; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 8px; z-index: 30;
    flex-direction: row; align-items: center; gap: 6px;
    padding: 9px 12px; overflow-x: auto; overflow-y: hidden; border-radius: 18px;
  }
  .side-logo { padding: 0 8px 0 0; }
  .side-logo div { display: none; }
  .side-nav { display: flex; gap: 4px; flex: initial; }
  .side-group { display: flex; gap: 4px; margin: 0; }
  .side-label { display: none; }
  .side-btn { width: auto; white-space: nowrap; padding: 8px 11px; }
  .side-btn.active::before { display: none; }
  .side-bottom { border: none; padding: 0; flex-direction: row; align-items: center; }
  .side-user .user-chip { max-width: 108px; }
  main { padding: 8px 4px 60px; }
  .topbar { padding: 8px 4px 0; }
}

/* ============================================================
   หน้าเริ่มต้น
   ============================================================ */
.dropzone {
  border: 1.5px dashed var(--axis);
  border-radius: var(--r);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
  padding: 60px 24px; text-align: center; cursor: pointer; margin-top: 20px;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.dropzone:hover { border-color: var(--accent); transform: translateY(-2px); }
.dropzone.dragover { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft), var(--shadow-pop); }
.dropzone .dz-icon {
  width: 74px; height: 74px; margin: 0 auto; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad);
  box-shadow: 0 16px 34px -12px color-mix(in srgb, var(--accent) 66%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.dropzone h2 { margin: 20px 0 5px; font-size: 20px; letter-spacing: -0.015em; }
.dropzone p { margin: 0; color: var(--text-secondary); font-size: 13.5px; }
.dz-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.hint-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: var(--gap); margin-top: var(--gap); }
.hint-card {
  border-radius: var(--r-sm); padding: 17px 18px; font-size: 13px; color: var(--text-secondary); line-height: 1.6;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
}
.hint-card b { color: var(--text-primary); display: flex; align-items: center; gap: 7px; margin-bottom: 6px; font-size: 13.5px; }

/* ============================================================
   ปุ่ม / ชิป
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text-primary);
  border-radius: 12px; padding: 8px 15px; font-size: 13.5px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 2px 8px -3px rgba(0, 23, 55, 0.2);
  transition: background 0.14s, transform 0.14s, box-shadow 0.14s, border-color 0.14s;
}
.btn:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent-grad); border: none; color: #fff; font-weight: 600;
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--accent) 75%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--accent-grad); }
.btn.small { padding: 5px 11px; font-size: 12.5px; border-radius: 10px; }

.filter-bar { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.filter-bar .label { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 2px; min-width: 96px; }
.chip {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 99px; padding: 5px 15px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  color: var(--text-secondary); font-family: inherit;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.chip:hover { background: var(--accent-soft); }
.chip.active {
  background: var(--accent-grad); border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* ============================================================
   การ์ด
   ============================================================ */
.card {
  border-radius: var(--r); padding: 20px 22px; margin-bottom: var(--gap);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
}
.card h3 { margin: 0 0 4px; font-size: 15.5px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 7px; }
.card .card-sub { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
@media (max-width: 880px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============================================================
   Stat tiles
   ============================================================ */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.tile {
  border-radius: var(--r-sm); padding: 17px 18px; display: flex; gap: 13px; align-items: flex-start;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
  transition: transform 0.16s, box-shadow 0.16s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.tile .t-icon {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
}
.tile .t-label { font-size: 12.5px; color: var(--text-secondary); }
.tile .t-value { font-size: 27px; font-weight: 700; margin-top: 2px; line-height: 1.12; letter-spacing: -0.02em; }
.tile .t-extra { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.tile.accent .t-value { color: var(--accent); }
.tile.hero { background: var(--accent-grad); border: none; }
.tile.hero .t-label, .tile.hero .t-extra { color: rgba(255, 255, 255, 0.82); }
.tile.hero .t-value { color: #fff; }
.tile.hero .t-icon { background: rgba(255, 255, 255, 0.22); }

/* ============================================================
   แถบฮีโร่ภาพรวม
   ============================================================ */
.hero-band {
  display: flex; gap: 28px; align-items: stretch; flex-wrap: wrap;
  border-radius: var(--r); padding: 26px 30px; margin-bottom: var(--gap); color: #fff;
  background:
    radial-gradient(600px 280px at 88% -30%, rgba(255, 255, 255, 0.18), transparent 60%),
    var(--accent-grad);
  box-shadow: 0 22px 50px -18px color-mix(in srgb, var(--accent) 60%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.hero-left { flex: 1; min-width: 250px; }
.hero-label { font-size: 12.5px; font-weight: 600; opacity: 0.9; display: flex; align-items: center; gap: 6px; }
.hero-label svg.lucide { color: #fff; }
.hero-score { font-size: 54px; font-weight: 700; line-height: 1.05; letter-spacing: -0.035em; margin: 8px 0 10px; }
.hero-outof { font-size: 19px; font-weight: 500; opacity: 0.62; margin-left: 8px; }
.hero-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; opacity: 0.95; }
.hero-meta .lv { background: rgba(255, 255, 255, 0.22); color: #fff; }
.hero-resp { margin-top: 15px; font-size: 13px; opacity: 0.95; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hero-resp b { font-size: 16px; }
.hero-resp input {
  width: 74px; font-family: inherit; font-size: 13px; text-align: center;
  padding: 5px 7px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.16); color: #fff;
}
.hero-resp input::placeholder { color: rgba(255, 255, 255, 0.6); }
.hero-resp input:focus { outline: none; border-color: #fff; }
.hero-right { flex: 1.1; min-width: 280px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.hb-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.hb-name { flex: 0 0 42%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.9; text-align: right; }
.hb-track { flex: 1; height: 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.24); overflow: hidden; }
.hb-track i { display: block; height: 100%; border-radius: 99px; background: #fff; }
.hb-val { width: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hb-empty { font-size: 13px; opacity: 0.8; }
@media (max-width: 700px) { .hero-right { min-width: 100%; } .hero-score { font-size: 44px; } }

/* ============================================================
   ตาราง
   ============================================================ */
.tbl-wrap { overflow-x: auto; border-radius: var(--r-sm); }
table.app { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.app th, table.app td { padding: 8px 12px; border-bottom: 1px solid var(--grid); text-align: center; vertical-align: top; }
table.app th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 0.02em; }
table.app td.item, table.app th.item { text-align: left; }
table.app td.num { font-variant-numeric: tabular-nums; }
table.app tr.total td { font-weight: 700; border-top: 1.5px solid var(--axis); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
table.app tr:hover td { background: var(--accent-soft); }
table.app tr.total:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }

.lv { display: inline-block; padding: 2px 11px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.lv.l5 { background: rgba(10, 107, 63, 0.14); color: #0a6b3f; }
.lv.l4 { background: rgba(26, 84, 166, 0.13); color: #1a54a6; }
.lv.l3 { background: rgba(200, 150, 20, 0.16); color: #8a6200; }
.lv.l2 { background: rgba(214, 100, 60, 0.16); color: #a84d22; }
.lv.l1 { background: rgba(214, 69, 69, 0.14); color: #b02f2f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lv.l5 { color: #47d68d; }
  :root:not([data-theme="light"]) .lv.l4 { color: #7fb0ef; }
  :root:not([data-theme="light"]) .lv.l3 { color: #fac95e; }
  :root:not([data-theme="light"]) .lv.l2 { color: #f0a882; }
  :root:not([data-theme="light"]) .lv.l1 { color: #ee7d7d; }
}
:root[data-theme="dark"] .lv.l5 { color: #47d68d; }
:root[data-theme="dark"] .lv.l4 { color: #7fb0ef; }
:root[data-theme="dark"] .lv.l3 { color: #fac95e; }
:root[data-theme="dark"] .lv.l2 { color: #f0a882; }
:root[data-theme="dark"] .lv.l1 { color: #ee7d7d; }

.meanbar { display: block; height: 4.5px; border-radius: 99px; background: var(--grid); margin-top: 5px; min-width: 56px; overflow: hidden; }
.meanbar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent-grad); }

.chart-box { position: relative; width: 100%; }
ul.sugg { margin: 6px 0 0; padding-left: 22px; }
ul.sugg li { margin-bottom: 6px; }
.sugg-count { color: var(--muted); font-size: 12.5px; }
select.coltype {
  font-family: inherit; font-size: 13px; padding: 5px 8px; border-radius: 10px;
  border: 1px solid var(--glass-border); background: var(--surface-1); color: var(--text-primary);
}
td.sample-vals { color: var(--muted); font-size: 12px; text-align: left; max-width: 320px; }

/* ============================================================
   แถวสรุป + SDG
   ============================================================ */
.sum-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--grid); font-size: 13.5px; color: var(--text-secondary);
}
.sum-row:last-of-type { border-bottom: none; }
.sum-row b { color: var(--text-primary); font-weight: 600; text-align: right; }
.sum-row .num { font-variant-numeric: tabular-nums; font-weight: 700; }
.sdg-mini { display: flex; gap: 7px; flex-wrap: wrap; padding-top: 12px; }
.sdg-mini img { width: 36px; height: 36px; border-radius: 9px; box-shadow: 0 5px 12px -4px rgba(0, 23, 55, 0.4); }

.sdg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.sdg-card {
  display: flex; gap: 13px; align-items: center; border-radius: var(--r-sm); padding: 14px 15px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
  transition: transform 0.16s, box-shadow 0.16s;
}
.sdg-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.sdg-card img { width: 62px; height: 62px; border-radius: 13px; flex-shrink: 0; box-shadow: 0 7px 16px -6px rgba(0, 23, 55, 0.4); }
.sdg-card .sdg-pct { font-size: 22px; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
.sdg-card .sdg-name { font-size: 11.5px; color: var(--text-secondary); line-height: 1.35; margin-top: 3px; }
.sdg-card .sdg-n { font-size: 11px; color: var(--muted); margin-top: 3px; }
.sdg-bar { height: 5.5px; border-radius: 99px; background: var(--grid); margin-top: 7px; overflow: hidden; }
.sdg-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent-grad); }
.sdg-card.no .sdg-bar > i { background: var(--lk1); }
.sdg-card .sdg-body { flex: 1; min-width: 0; }

/* ============================================================
   ผู้ใช้ / login / modal
   ============================================================ */
.user-chip { background: var(--accent-soft); color: var(--accent); padding: 4px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; padding: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 15, 0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.modal {
  border-radius: var(--r); padding: 30px 32px; max-width: 420px; width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(1.5); -webkit-backdrop-filter: blur(26px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-hi);
}
.modal-wide { max-width: 580px; }
.modal h2 { margin: 0 0 8px; font-size: 21px; letter-spacing: -0.015em; display: flex; align-items: center; gap: 8px; }
.modal p { margin: 0 0 18px; font-size: 13.5px; color: var(--text-secondary); }
.modal label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 13px; }
.modal input {
  display: block; width: 100%; margin-top: 5px;
  font-family: inherit; font-size: 14.5px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: var(--surface-1); color: var(--text-primary);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.modal input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.modal .btn { width: 100%; justify-content: center; margin-top: 8px; padding: 11px; }
.days-left { font-size: 11.5px; color: var(--muted); }
.days-left.warn { color: #d64545; font-weight: 600; }

/* ============================================================
   รวมหลายแบบประเมิน (การ์ดในรายงาน)
   ============================================================ */
.combine-card { margin-bottom: 14px; }
.combine-item { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--grid); font-size: 13.5px; }
.combine-item:last-child { border-bottom: none; }
.combine-item b { font-weight: 600; }

/* ============================================================
   สแต็กแบบประเมิน (หน้าแรก) — การ์ดกระจกซ้อนแบบพัด
   ============================================================ */
.deck-wrap { margin: 32px 0 4px; }
.deck-title { font-size: 15px; margin: 0 0 22px; letter-spacing: -0.01em; }
.deck { display: flex; justify-content: center; align-items: flex-end; padding: 14px 0 32px; }
.deck-card {
  position: relative; width: 176px; min-height: 208px; margin: 0 -36px;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  padding: 17px; border-radius: 22px; text-align: left;
  font-family: inherit; font-size: 13px; cursor: pointer; color: var(--text-primary);
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
  transform: rotate(var(--r, 0deg)) translateY(var(--y, 0px));
  transition: transform 0.26s cubic-bezier(0.2, 0.7, 0.3, 1.3), box-shadow 0.26s, border-color 0.26s;
}
.deck-card:hover, .deck-card:focus-visible {
  transform: rotate(0deg) translateY(-26px) scale(1.07); z-index: 10;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 30px 60px -18px color-mix(in srgb, var(--accent) 46%, transparent), var(--shadow-pop);
}
.deck-card b { font-size: 12.5px; line-height: 1.4; font-weight: 600; }
.dc-icon {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; margin-bottom: 3px;
  background: var(--accent-grad); display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.dc-icon svg.lucide { color: #fff; }
.dc-meta { font-size: 11px; color: var(--muted); }
.dc-score { margin-top: auto; font-size: 23px; font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
.dc-score i { font-style: normal; font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 3px; }
@media (max-width: 760px) {
  .deck { flex-wrap: wrap; gap: 12px; }
  .deck-card { margin: 0; transform: none; }
}

/* ============================================================
   Heatmap ความถี่ (โทนกรมท่า)
   ============================================================ */
.hm-wrap { max-height: 560px; overflow: auto; padding-right: 4px; }
.hm-row { display: grid; grid-template-columns: minmax(150px, 1fr) repeat(5, 46px); gap: 6px; align-items: center; margin-bottom: 6px; min-width: 420px; }
.hm-head { position: sticky; top: 0; z-index: 2; padding: 2px 0; background: color-mix(in srgb, var(--surface-1) 70%, transparent); backdrop-filter: blur(6px); }
.hm-col { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.hm-name { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.hm-cell {
  height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--grid);
  cursor: default; transition: transform 0.12s, box-shadow 0.12s;
}
.hm-cell:hover { transform: scale(1.16); box-shadow: var(--shadow-pop); z-index: 3; }
.hm-group { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.hm-group:first-of-type { margin-top: 4px; }
.hm-legend { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.hm-scale-wrap { display: inline-flex; align-items: center; gap: 7px; }
.hm-scale { display: inline-block; width: 130px; height: 8px; border-radius: 99px; background: linear-gradient(90deg, #dbe6f5, #123c78); }

/* ============================================================
   รายงานราชการ (กระดาษทึบ — ไม่ใช้กระจก)
   ============================================================ */
.report-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.report-controls label.ck { font-size: 13.5px; color: var(--text-secondary); display: inline-flex; gap: 6px; align-items: center; }
.report-controls input[type="text"] {
  font-family: inherit; font-size: 14px; padding: 9px 14px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: var(--surface-1); color: var(--text-primary); min-width: 300px; flex: 1;
}
.report-controls input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.paper {
  background: var(--paper); color: #000; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: var(--shadow-pop); max-width: 850px; margin: 0 auto; padding: 56px 64px;
}
.paper, .paper * { font-family: "Sarabun", "Leelawadee UI", "Thonburi", "Noto Sans Thai", sans-serif !important; }
.report-block { position: relative; border-radius: 6px; }
.report-block:hover { outline: 2px dashed var(--accent); outline-offset: 6px; }
.report-block .blk-copy { position: absolute; top: -4px; right: -8px; z-index: 5; opacity: 0; transition: opacity 0.12s; font-family: "Anuphan", system-ui, sans-serif !important; }
.report-block:hover .blk-copy { opacity: 1; }

/* ---------- สรุปผู้บริหาร 1 หน้า ---------- */
.executive-page { max-width: 980px; margin: 0 auto; }
.exec-toolbar { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 14px; }
.exec-toolbar b { display: block; font-size: 16px; }
.exec-toolbar span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.exec-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.exec-paper {
  max-width: 860px; margin: 0 auto; padding: 34px 38px; border-radius: 8px; background: #fff; color: #102233;
  box-shadow: 0 10px 40px -12px rgba(0, 23, 55, .35); font-family: "Anuphan", "Sarabun", sans-serif;
}
.exec-paper * { box-sizing: border-box; }
.exec-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 3px solid #147d8c; padding-bottom: 12px; }
.exec-kicker { display: block; color: #147d8c; font-size: 10px; font-weight: 800; letter-spacing: .075em; }
.exec-head h1 { margin: 5px 0; font-size: 25px; line-height: 1.25; letter-spacing: -.025em; }
.exec-meta { margin: 0; color: #5d6974; font-size: 12px; }
.exec-level { flex-shrink: 0; padding-top: 8px; }
.exec-score { display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); gap: 9px; margin: 15px 0; }
.exec-kpi { min-height: 92px; padding: 12px; border: 1px solid #d9e4e7; border-radius: 10px; }
.exec-kpi b { display: block; color: #147d8c; font-size: 22px; line-height: 1.05; }
.exec-kpi small { font-size: 12px; font-weight: 600; }
.exec-kpi span { display: block; margin-top: 7px; color: #60727b; font-size: 10px; line-height: 1.35; }
.exec-kpi.main { background: #147d8c; border-color: #147d8c; }
.exec-kpi.main b, .exec-kpi.main span { color: #fff; }
.exec-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.exec-section { border-top: 1px solid #d9e4e7; margin-top: 13px; padding-top: 10px; }
.exec-section h2 { margin: 0 0 7px; font-size: 13px; }
.exec-section p { margin: 0 0 7px; font-size: 12px; line-height: 1.55; }
.exec-paper table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.exec-paper th, .exec-paper td { padding: 6px; border-bottom: 1px solid #e5edef; text-align: left; vertical-align: top; }
.exec-paper th { color: #60727b; font-size: 10px; font-weight: 700; }
.exec-paper .num { text-align: right; white-space: nowrap; }
.exec-note { padding: 9px 11px; border-left: 3px solid #147d8c; border-radius: 0 7px 7px 0; background: #f1f8f8; }
.exec-footer { margin-top: 13px; padding-top: 8px; border-top: 1px solid #d9e4e7; color: #70818a; font-size: 10px; }
@media (max-width: 720px) {
  .exec-toolbar, .exec-head { align-items: flex-start; flex-direction: column; }
  .exec-score, .exec-grid { grid-template-columns: 1fr 1fr; }
  .exec-paper { padding: 24px 18px; }
}

/* ============================================================
   Toast + ไอคอน + print
   ============================================================ */
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy-800); color: #fff; padding: 11px 22px; border-radius: 99px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-pop);
  border: 1px solid var(--glass-border);
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

svg.lucide { width: 15px; height: 15px; stroke-width: 2; vertical-align: -2.5px; flex-shrink: 0; }
.side-btn svg.lucide { width: 17px; height: 17px; }
.logo-mark svg.lucide { width: 21px; height: 21px; color: #fff; }
.dz-icon svg.lucide { width: 32px; height: 32px; color: #fff; }
.t-icon svg.lucide { width: 20px; height: 20px; color: var(--accent); }
.tile.hero .t-icon svg.lucide { color: #fff; }
.hint-card b svg.lucide { width: 15px; height: 15px; color: var(--accent); }
.card h3 svg.lucide { width: 16px; height: 16px; color: var(--accent); }
.btn svg.lucide { width: 14px; height: 14px; }
.modal h2 svg.lucide { width: 20px; height: 20px; color: var(--accent); vertical-align: -3px; }
.user-chip svg.lucide { width: 13px; height: 13px; vertical-align: -2px; }
.lv svg.lucide { width: 12px; height: 12px; vertical-align: -1.5px; stroke-width: 3; }

@media print {
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; }
  .paper { position: absolute; left: 0; top: 0; box-shadow: none; border: none; max-width: none; width: 100%; padding: 0; }
  .blk-copy { display: none !important; }
}

/* ============================================================
   หน้ารายงานราชการ — เลย์เอาต์สองคอลัมน์ (ตั้งค่า | เอกสาร)
   ============================================================ */
.report-layout { display: grid; grid-template-columns: 340px 1fr; gap: var(--gap); align-items: start; } /* (เลิกใช้) */
.report-side { position: sticky; top: var(--gap); display: flex; flex-direction: column; gap: 14px; }
.rp-card {
  border-radius: var(--r-sm); padding: 16px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
}
.rp-title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 7px; margin-bottom: 14px; }
.rp-title svg.lucide { width: 16px; height: 16px; color: var(--accent); }
.rp-field { display: block; margin-bottom: 14px; }
.rp-field:last-child { margin-bottom: 0; }
.rp-field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.rp-field input, .rp-field select, .rp-field textarea {
  width: 100%; font-family: inherit; font-size: 13.5px; padding: 9px 12px; border-radius: 11px;
  border: 1px solid var(--glass-border); background: var(--surface-1); color: var(--text-primary);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.rp-field input:focus, .rp-field select:focus, .rp-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rp-toggles { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

/* สวิตช์แบบเลื่อน */
.rp-switch { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.rp-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.rp-switch .sw {
  flex-shrink: 0; width: 38px; height: 22px; border-radius: 99px; position: relative;
  background: var(--axis); transition: background 0.2s;
}
.rp-switch .sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 23, 55, 0.35); transition: transform 0.2s;
}
.rp-switch input:checked + .sw { background: var(--accent); }
.rp-switch input:checked + .sw::after { transform: translateX(16px); }
.rp-switch input:focus-visible + .sw { box-shadow: 0 0 0 4px var(--accent-soft); }

.rp-actions { display: flex; flex-direction: column; gap: 8px; }
.rp-actions .btn { width: 100%; justify-content: center; }
.rp-hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 2px 2px 0; }

.combine-card .combine-item { border: none; padding: 9px 0; gap: 10px; align-items: center; }
.combine-card .combine-item .ci-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.combine-card .combine-item .ci-body b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* คอลัมน์ขวา = แผงเอกสาร */
.report-main {
  border-radius: var(--r); overflow: hidden;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
}
.rp-docbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--glass-border);
}
.rp-dots { display: inline-flex; gap: 6px; }
.rp-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--axis); }
.rp-dots i:nth-child(1) { background: #e0655a; } .rp-dots i:nth-child(2) { background: #e5b23a; } .rp-dots i:nth-child(3) { background: #4aa06a; }
.rp-docname { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.rp-docname svg.lucide { width: 14px; height: 14px; color: var(--accent); }
.rp-pages { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.report-scroll { max-height: calc(100vh - 150px); overflow-y: auto; padding: 26px; display: flex; justify-content: center; }
.report-scroll .paper { margin: 0; box-shadow: 0 10px 40px -12px rgba(0, 23, 55, 0.35); }

@media (max-width: 960px) {
  .report-layout { grid-template-columns: 1fr; }
  .report-side { position: static; }
  .report-scroll { max-height: none; padding: 16px; }
  .report-scroll .paper { padding: 36px 28px; }
}

/* ============================================================
   แอนิเมชัน
   ============================================================ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes slideL { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@keyframes slideR { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes blockIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* เนื้อหาเลื่อนเข้าเมื่อเปลี่ยนแท็บ (ไล่ทีละก้อน) */
.anim-page > * { animation: fadeUp 0.42s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.anim-page > *:nth-child(2) { animation-delay: 0.05s; }
.anim-page > *:nth-child(3) { animation-delay: 0.1s; }
.anim-page > *:nth-child(4) { animation-delay: 0.15s; }
.anim-page > *:nth-child(n+5) { animation-delay: 0.2s; }

.anim-slide-l { animation: slideL 0.44s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.anim-slide-r { animation: slideR 0.44s cubic-bezier(0.2, 0.7, 0.3, 1) 0.06s both; }
.anim-block { animation: blockIn 0.4s ease both; }

/* hover ยกตัว (ทั่วไป) */
.chip, .side-btn, .btn { will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  .anim-page > *, .anim-slide-l, .anim-slide-r, .anim-block { animation: none !important; }
  * { scroll-behavior: auto !important; }
}

/* ===== แถบตรวจงาน (.evalproj) ===== */
.review-card { border-left: 3px solid var(--accent); }
.rv-ta {
  width: 100%; margin-top: 10px; min-height: 76px; resize: vertical;
  font-family: inherit; font-size: 13.5px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: var(--surface-1); color: var(--text-primary);
}
.rv-ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rv-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ===== ตั้งค่า Google Sheet ในโมดัล ===== */
.gs-setup { margin: 4px 0 16px; border: 1px solid var(--glass-border); border-radius: 12px; padding: 4px 12px; background: var(--surface-2); }
.gs-setup summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-secondary); padding: 8px 0; }
.gs-setup ol { margin: 4px 0 8px; padding-left: 20px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.7; }
.gs-setup code { background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 6px; font-size: 11.5px; word-break: break-all; }
.gs-setup label { margin-bottom: 0; }

/* โลโก้คลิกกลับหน้าแรกได้ */
.side-logo { border-radius: 14px; transition: opacity 0.15s; }
.side-logo:hover { opacity: 0.82; }
.side-logo:hover .logo-mark { box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--accent) 80%, transparent), inset 0 1px 0 rgba(255,255,255,0.35); }

/* ---------- แผงรายงาน: วัตถุประสงค์ + การ์ดตรวจสอบ ---------- */
.rp-field textarea { resize: vertical; min-height: 68px; line-height: 1.5; font-size: 13px; }
.todo-card { border-left: 3px solid #e08b1e; }
.todo-card .todo-item { margin: 5px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }

/* ============================================================
   หน้ารายงานแบบใหม่: ทูลบาร์บน + แผงตั้งค่าพับได้ + เอกสารอ่านจอเต็มหน้า
   (ฟอร์แมตราชการยังอยู่ครบใน inline style — ใช้ตอนคัดลอก/ดาวน์โหลด .docx)
   ============================================================ */
.report-page {
  border-radius: var(--r); overflow: hidden;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
}
.rp-topbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--glass-border);
}
.rp-topbar-sp { flex: 1; }
.rp-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; margin-left: 2px;
  border-radius: 99px; background: #e08b1e; color: #fff; font-size: 10.5px; font-weight: 700;
}
.active-btn { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rp-drawer {
  display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 14px;
  padding: 16px; border-bottom: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--surface-2) 40%, transparent);
}
.rp-drawer-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.report-page .report-scroll { max-height: calc(100vh - 200px); padding: 0; display: block; }

/* ---------- เอกสารอ่านจอ: ฟอนต์ปกติ เต็มความกว้าง อ่านง่าย ---------- */
.paper.doc-view, .paper.doc-view * {
  font-family: "Anuphan", "Leelawadee UI", "Thonburi", system-ui, sans-serif !important;
}
.paper.doc-view {
  background: transparent; border: none; box-shadow: none; border-radius: 0;
  max-width: 980px; margin: 0 auto; padding: 34px 46px 60px; color: var(--text-primary);
}
.paper.doc-view p {
  font-size: 15px !important; line-height: 1.85 !important;
  text-indent: 0 !important; text-align: left !important;
  color: var(--text-primary); margin: 0 0 10px;
}
.paper.doc-view b { color: inherit; }
.paper.doc-view .rp-doc-title {
  font-size: 23px !important; text-align: center !important; font-weight: 800 !important;
  letter-spacing: -0.01em; margin: 6px 0 18px !important;
}
.paper.doc-view .rp-sec {
  font-size: 18px !important; font-weight: 800 !important;
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  padding: 10px 14px !important; border-radius: 10px;
  margin: 30px 0 14px !important;
}
.paper.doc-view .report-block:first-child .rp-sec { margin-top: 0 !important; }
.paper.doc-view .rp-sub { font-size: 15.5px !important; font-weight: 700 !important; margin: 20px 0 8px !important; }
.paper.doc-view .rp-cap { font-size: 13px !important; color: var(--text-secondary) !important; margin: 14px 0 6px !important; }
.paper.doc-view .rp-cap b { color: var(--text-primary) !important; }
.paper.doc-view .rp-chartcap { text-align: center !important; margin: 6px 0 18px !important; }
.paper.doc-view .rp-base {
  display: inline-block; font-size: 13px !important; line-height: 1.5 !important;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 7px 13px !important; border-radius: 99px; margin: 0 0 12px !important;
}
.paper.doc-view .rp-base b { color: var(--accent) !important; }
.paper.doc-view .rp-note { font-size: 12.5px !important; color: var(--muted) !important; margin: 4px 0 10px !important; }
.paper.doc-view table.rp-tbl { width: 100% !important; margin: 2px 0 16px; }
.paper.doc-view table.rp-tbl td {
  border: 1px solid var(--border) !important;
  padding: 7px 11px !important; font-size: 13.5px !important; line-height: 1.6 !important;
  color: var(--text-primary);
}
.paper.doc-view table.rp-tbl tr:first-child td { background: var(--surface-2) !important; font-size: 12.5px !important; }
.paper.doc-view table.rp-tbl td[colspan] { background: var(--accent-soft) !important; }
.paper.doc-view .rp-img img { border-radius: 12px; border: 1px solid var(--border); background: #fff; }

@media (max-width: 960px) {
  .rp-drawer { grid-template-columns: 1fr; }
  .paper.doc-view { padding: 20px 16px 40px; }
  .report-page .report-scroll { max-height: none; }
}
@media print {
  .rp-topbar, .rp-drawer { display: none !important; }
}

/* ============================================================
   Guided Analysis: ตรวจข้อมูล + ความมั่นใจ + ความพร้อมรายงาน
   ============================================================ */
.hlth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.hlth-tile {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.hlth-tile b { font-size: 19px; letter-spacing: -0.01em; }
.hlth-tile span { font-size: 11px; color: var(--muted); font-weight: 600; }
.hlth-pass { border-color: color-mix(in srgb, #2e9e5b 45%, transparent); }
.hlth-pass b { color: #2e9e5b; }
.hlth-warn { border-color: color-mix(in srgb, #e08b1e 50%, transparent); }
.hlth-warn b { color: #e08b1e; }
.hlth-crit { border-color: color-mix(in srgb, #d64545 55%, transparent); }
.hlth-crit b { color: #d64545; }
.hl-issue { margin: 6px 0 0; font-size: 13px; line-height: 1.55; padding: 8px 12px; border-radius: 10px; }
.hl-crit { background: color-mix(in srgb, #d64545 12%, transparent); color: var(--text-primary); }
.hl-warn { background: color-mix(in srgb, #e08b1e 12%, transparent); }
.hl-info { background: var(--surface-2); color: var(--text-secondary); }
.hl-pass { background: color-mix(in srgb, #2e9e5b 10%, transparent); }
.conf-chip {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  vertical-align: middle; margin-left: 4px;
}
.conf-chip.ok { background: color-mix(in srgb, #2e9e5b 15%, transparent); color: #2e9e5b; }
.conf-chip.mid { background: color-mix(in srgb, #e08b1e 16%, transparent); color: #c07515; }
.conf-chip.low { background: color-mix(in srgb, #d64545 14%, transparent); color: #d64545; }
tr.row-lowconf td { background: color-mix(in srgb, #e08b1e 6%, transparent); }
.mapping-confirm { margin-bottom: var(--gap); }
.rm-label {
  width: 100%; min-width: 140px; font: inherit; font-size: 12.5px; padding: 6px 9px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
.rp-ready { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.rp-ready-pass { background: color-mix(in srgb, #2e9e5b 14%, transparent); color: #2e9e5b; }
.rp-ready-warn { background: color-mix(in srgb, #e08b1e 15%, transparent); color: #c07515; }
.rp-ready-crit { background: color-mix(in srgb, #d64545 14%, transparent); color: #d64545; }
.draft-band {
  margin: 14px auto 0; max-width: 980px; padding: 10px 16px; border-radius: 12px;
  background: color-mix(in srgb, #e08b1e 13%, transparent);
  border: 1px dashed color-mix(in srgb, #e08b1e 55%, transparent);
  font-size: 13px; font-weight: 600;
}

/* ---------- ไอคอนระดับปัญหา (แทนอีโมจิ) ---------- */
.hl-issue svg.lucide, .todo-item svg.lucide, .draft-band svg.lucide {
  width: 14px; height: 14px; vertical-align: -2.5px; margin-right: 5px; flex-shrink: 0;
}
.hl-crit svg.lucide, .todo-crit svg.lucide { color: #d64545; }
.hl-warn svg.lucide, .todo-warn svg.lucide { color: #e08b1e; }
.hl-pass svg.lucide { color: #2e9e5b; }
.hl-info svg.lucide, .todo-info svg.lucide { color: var(--muted); }
.draft-band svg.lucide { color: #c07515; width: 15px; height: 15px; }

/* ---------- แท็บคู่มือการใช้งาน ---------- */
.guide-wrap { max-width: 940px; }
.guide-head h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.g-sec {
  margin-top: var(--gap);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-border); border-radius: var(--r);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-hi);
  overflow: hidden;
}
.g-sec summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; font-weight: 700; font-size: 14.5px;
}
.g-sec summary::-webkit-details-marker { display: none; }
.g-sec summary::after { content: "+"; margin-left: auto; font-size: 18px; color: var(--muted); font-weight: 600; }
.g-sec[open] summary::after { content: "−"; }
.g-sec summary svg.lucide { width: 17px; height: 17px; color: var(--accent); }
.g-sec[open] summary { border-bottom: 1px solid var(--border); }
.g-sec summary:hover { background: var(--accent-soft); }
.g-body { padding: 14px 20px 18px; font-size: 13.5px; line-height: 1.9; color: var(--text-secondary); }
.g-body p { margin: 0 0 10px; }
.g-body b { color: var(--text-primary); }
.g-body code {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 7px; font-size: 12.5px; color: var(--text-primary);
}
.g-step { display: flex; gap: 12px; margin: 0 0 12px; align-items: flex-start; }
.g-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; margin-top: 2px;
}
.g-formula {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin: 8px 0; font-size: 13px;
}

/* ---------- กล่องโต้ตอบ + รายการจัดการ/รับทราบ ---------- */
.dyn-modal { z-index: 1200; }
.modal.dlg { max-width: 580px; width: min(94vw, 580px); text-align: left; }
.modal.dlg h2 { display: flex; align-items: center; gap: 9px; font-size: 16.5px; margin: 0 0 12px; }
.modal.dlg h2 svg.lucide { width: 19px; height: 19px; color: var(--accent); }
.dlg-body { font-size: 13.5px; line-height: 1.75; color: var(--text-secondary); max-height: 62vh; overflow-y: auto; }
.dlg-body b { color: var(--text-primary); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.dlg-sample { margin: 3px 0; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.impact-tbl { width: 100%; border-collapse: collapse; margin-top: 4px; }
.impact-tbl th, .impact-tbl td { padding: 7px 10px; font-size: 13px; text-align: left; border-bottom: 1px solid var(--border); }
.impact-tbl th { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.issue-row { display: flex; align-items: flex-start; gap: 7px; }
.issue-row .ir-msg { flex: 1; min-width: 0; }
.issue-row .ir-btns { display: flex; gap: 6px; flex-shrink: 0; margin-left: 8px; }
.acked-row { opacity: 0.62; }
.busy-overlay {
  position: fixed; inset: 0; z-index: 1300; display: none; place-items: center;
  background: color-mix(in srgb, var(--bg) 52%, transparent); backdrop-filter: blur(3px);
}
.busy-overlay.show { display: grid; }
.busy-card {
  display: flex; align-items: center; gap: 12px; min-width: min(90vw, 280px); padding: 16px 20px;
  border: 1px solid var(--glass-border); border-radius: 14px; background: var(--surface-1);
  color: var(--text-primary); font-size: 13.5px; font-weight: 650; box-shadow: var(--shadow-pop);
}
.busy-spinner { width: 18px; height: 18px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: busy-spin .7s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
.import-preview { max-width: 630px; }
.preview-summary { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.preview-summary p { margin: 8px 0 0; font-size: 12.5px; line-height: 1.65; }
.preview-stats { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 4px 9px; align-items: baseline; }
.preview-stats b { font-size: 20px; color: var(--accent); }
.preview-stats span { color: var(--muted); font-size: 12px; }
@media (max-width: 720px) {
  .issue-row { flex-wrap: wrap; }
  .issue-row .ir-btns { margin-left: 21px; }
}

/* ---------- แจ้งเตือนเมื่อเปิดระบบไม่สำเร็จ (เบราว์เซอร์เก่า / เบราว์เซอร์ในแอป) ---------- */
.boot-error {
  position: fixed; inset: 0; z-index: 2000; overflow-y: auto;
  background: var(--bg, #0b1220); color: var(--text-primary, #eef3fb);
  padding: 32px 22px; font-size: 15px; line-height: 1.85;
}
.boot-error h2 { font-size: 19px; margin: 0 0 12px; }
.boot-error p { max-width: 560px; margin: 0 auto 12px; }
.boot-error .boot-detail { font-size: 12.5px; opacity: 0.6; word-break: break-word; }

/* ---------- เลขเวอร์ชันบนแถบข้าง (ใช้ยืนยันว่าเบราว์เซอร์โหลดไฟล์ใหม่แล้ว) ---------- */
.app-version {
  margin-top: 8px; text-align: center; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em; color: var(--muted); opacity: 0.75;
}
