:root {
  /* สีประจำมหาวิทยาลัย: เขียว ขาว เหลือง */
  --green: #006400;
  --green-dark: #004d00;
  --green-soft: #e8f5e9;
  --green-mid: #1b7a1b;
  --yellow: #ffd600;
  --yellow-soft: #fff8e1;
  --yellow-deep: #f9a825;
  --bg: #f5f7f5;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --muted: #5f6b66;
  --line: #d7ddd9;
  --line-soft: #e8ece9;
  --danger: #c62828;
  --ok: #006400;
  --shadow: 0 2px 10px rgba(0, 100, 0, 0.08);
  --radius: 10px;
  --font: "Sarabun", "Noto Sans Thai", "Segoe UI", Tahoma, sans-serif;
  --display: "Sarabun", "Noto Sans Thai", "Segoe UI", Tahoma, sans-serif;

  --stat-yellow: #f9a825;
  --stat-yellow-bg: #fff8e1;
  --stat-red: #e53935;
  --stat-red-bg: #ffebee;
  --stat-blue: #1e88e5;
  --stat-blue-bg: #e3f2fd;
  --stat-green: #2e7d32;
  --stat-green-bg: #e8f5e9;
  --stat-orange: #fb8c00;
  --stat-orange-bg: #fff3e0;
  --stat-gray: #546e7a;
  --stat-gray-bg: #eceff1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

/* ===== Header (ต้นแบบเดียวกับระบบแจ้งซ่อม) ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(90deg, var(--green) 0%, var(--green-mid) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  border-bottom: 3px solid var(--yellow);
}

.site-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-toggle {
  display: none;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 8px;
  width: 42px;
  height: 42px;
  font-size: 1.25rem;
  cursor: pointer;
  margin-left: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255,255,255,.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  border: 1px solid rgba(255,255,255,.28);
  flex-shrink: 0;
}

/* โลโก้ PNG — วางไฟล์ที่ assets/logo.png */
.brand-logo {
  height: 52px;
  width: auto;
  background: #fff;
  padding: 4px 6px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-text strong {
  font-size: 1.02rem;
  letter-spacing: .01em;
  font-weight: 700;
  white-space: nowrap;
}

.brand-text small {
  opacity: .9;
  font-size: .8rem;
  font-weight: 500;
  line-height: 1.35;
}

.brand-org {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.brand-org-line,
.brand-campus {
  white-space: nowrap;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.site-nav a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 999px;
  transition: background .18s ease, transform .18s ease;
}

.site-nav a:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transform: translateY(-1px);
}

.site-nav a.active {
  background: var(--yellow);
  color: var(--green-dark);
  font-weight: 700;
}

.site-nav a.nav-sheet {
  background: var(--yellow);
  color: var(--green-dark);
  font-weight: 700;
}

/* ===== Main ===== */
.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

.page-head h1 {
  margin: 0 0 1.15rem;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--green);
}

.content {
  display: grid;
  gap: 1.25rem;
}

/* ===== Stat cards (แถบสีซ้ายแบบภาพอ้างอิง) ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1rem 1rem;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--green-mid);
  display: grid;
  gap: 0.25rem;
}

.card.stat-yellow { border-left-color: var(--stat-yellow); background: linear-gradient(90deg, var(--stat-yellow-bg), #fff 55%); }
.card.stat-red    { border-left-color: var(--stat-red);    background: linear-gradient(90deg, var(--stat-red-bg), #fff 55%); }
.card.stat-blue   { border-left-color: var(--stat-blue);   background: linear-gradient(90deg, var(--stat-blue-bg), #fff 55%); }
.card.stat-green  { border-left-color: var(--stat-green);  background: linear-gradient(90deg, var(--stat-green-bg), #fff 55%); }
.card.stat-orange { border-left-color: var(--stat-orange); background: linear-gradient(90deg, var(--stat-orange-bg), #fff 55%); }
.card.stat-gray   { border-left-color: var(--stat-gray);   background: linear-gradient(90deg, var(--stat-gray-bg), #fff 55%); }

.card .label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.card .value {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.card.stat-yellow .value { color: #f57f17; }
.card.stat-red .value    { color: #c62828; }
.card.stat-blue .value   { color: #1565c0; }
.card.stat-green .value  { color: #2e7d32; }
.card.stat-orange .value { color: #ef6c00; }
.card.stat-gray .value   { color: #455a64; }
.card .value-sm { font-size: 1.15rem !important; }

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}


.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.chip-label {
  font-family: var(--display);
  font-weight: 500;
  color: var(--muted);
  margin-right: 0.2rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-size: 0.9rem;
  transition: background .15s ease, border-color .15s ease;
}

.chip:hover { border-color: var(--green-mid); background: var(--green-soft); }
.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 600;
}

.split-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.table-wrap { padding: 0; overflow-x: auto; }
.table-wrap table { min-width: 480px; }

tbody tr:hover { background: #f7fbf8; }

.alert-warn {
  background: var(--yellow-soft);
  color: #7a5b00;
  border-color: #ffe082;
  margin: 0;
  flex: 1;
}

.source-pill a { color: inherit; font-weight: 600; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  align-items: stretch;
}

.chart-box-faculty {
  grid-column: 1 / -1;
}

.chart-box-years .chart-scroll-wrap {
  flex: 1 1 auto;
  height: auto;
  min-height: 260px;
  position: relative;
}

.chart-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.chart-scroll-wrap.is-scrollable {
  border-radius: 8px;
  background: linear-gradient(90deg, #fafcfb 0%, #fff 8%, #fff 92%, #fafcfb 100%);
}

.chart-scroll-inner {
  height: 100%;
  min-height: 260px;
  min-width: 100%;
  position: relative;
}

.chart-hint {
  margin: -0.35rem 0 0.55rem;
  font-size: 0.82rem;
}

.chart-hint a {
  color: var(--green);
  font-weight: 600;
}

.chip-more {
  border-style: dashed;
}

.chart-box {
  background: #fafcfb;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-box:not(.chart-box-faculty) {
  min-height: 340px;
}

.chart-box h3 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}

.chart-box-faculty .chart-canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
}

.chart-box-faculty .chart-canvas-wrap canvas {
  display: block;
  width: 100%;
}

.chart-canvas-status {
  flex: 1 1 auto;
  position: relative;
  min-height: 260px;
}

.chart-canvas-status canvas {
  display: block;
}

.search-hero {
  background: linear-gradient(135deg, #e8f5e9 0%, #fff 55%, #fff8e1 100%);
  border: 1px solid #c8e6c9;
}

.search-hero-title {
  margin: 0 0 0.25rem;
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--green);
}

.search-hero-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.search-hero-form input[type="search"] {
  flex: 1 1 280px;
  min-width: 220px;
  padding: 0.8rem 1rem;
  font-size: 1.05rem;
}

.card-link {
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}

.card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 100, 0, 0.12);
}

.card-hint {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--display);
}

.filter-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.abstract-text {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.7;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.file-inline {
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
  word-break: break-word;
}

.file-inline:hover {
  text-decoration: underline;
}

.cards-status {
  grid-template-columns: repeat(3, 1fr);
}

#budget-annual,
#budget-yearly {
  scroll-margin-top: 88px;
}

.delta-up { color: #2e7d32; font-weight: 600; }
.delta-down { color: #c62828; font-weight: 600; }
.delta-flat { color: var(--muted); font-weight: 600; }

.compare-table th:nth-child(4),
.compare-table td:nth-child(4) {
  white-space: nowrap;
}

html {
  scroll-behavior: smooth;
}

/* ===== Panels / tables ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--line-soft);
  background: #fafcfb;
}

.panel-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}

.panel-body { padding: 1.15rem 1.2rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: end;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.05rem;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: var(--green);
  color: #fff;
  transition: background .15s ease, filter .15s ease;
}

.btn:hover { background: var(--green-dark); }
.btn-ghost {
  background: #fff;
  color: var(--green);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--green-soft); }
.btn-yellow {
  background: var(--yellow);
  color: var(--green-dark);
  font-weight: 600;
}
.btn-yellow:hover { filter: brightness(0.97); }

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--yellow-soft);
  border: 1px solid #ffe082;
  color: #7a5b00;
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.05rem;
}

.form-grid .full { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 0.4rem;
  font-family: var(--display);
  font-weight: 500;
  color: #495057;
  font-size: 0.95rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #ced4da;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input::placeholder,
textarea::placeholder {
  color: #adb5bd;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

textarea { min-height: 110px; resize: vertical; }

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  font-size: 0.98rem;
}

th {
  font-family: var(--display);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  background: #f8f9fa;
  white-space: nowrap;
}

td a {
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
}

td a:hover { text-decoration: underline; }

.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.export-menu {
  position: relative;
}

.export-menu > summary {
  list-style: none;
  cursor: pointer;
}

.export-menu > summary::-webkit-details-marker {
  display: none;
}

.export-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 20;
  min-width: 190px;
  padding: 0.35rem 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.export-menu:not([open]) .export-menu-panel {
  display: none;
}

.export-menu-panel a {
  display: block;
  padding: 0.55rem 0.9rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}

.export-menu-panel a:hover {
  background: #f1f8f4;
  color: var(--green);
}

.export-menu-inline {
  display: inline-block;
}

/* ===== Badges / alerts ===== */
.badge {
  display: inline-block;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--green-soft);
  color: var(--green);
}

.badge.ongoing { background: #e3f2fd; color: #1565c0; }
.badge.completed { background: #e8f5e9; color: #2e7d32; }
.badge.refunded { background: #fff3e0; color: #e65100; }
.badge.published { background: #f3e5f5; color: #6a1b9a; }
.badge.cancelled { background: #ffebee; color: #c62828; }
.badge.draft { background: #eceff1; color: #546e7a; }

.alert {
  padding: 0.9rem 1.05rem;
  border-radius: 8px;
  margin-bottom: 0.15rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.alert-success {
  background: var(--green-soft);
  color: var(--green);
  border-color: #c8e6c9;
}
.alert-error {
  background: #ffebee;
  color: var(--danger);
  border-color: #ffcdd2;
}

.muted { color: var(--muted); }
.empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-family: var(--display);
}

.site-footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--line-soft);
  background: #fff;
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .split-panels { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .site-header-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 16px;
  }
  .site-header-inner { position: relative; padding-right: 56px; }
  .site-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .site-nav.is-open { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .cards, .cards-status { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.45rem; }
}

@media print {
  .site-header, .site-footer, .no-print, .nav-toggle, .chip-row, .page-head { display: none !important; }
  body { background: #fff; color: #000; }
  .main { max-width: none; padding: 0; }
  .content { padding: 0; }
  .panel, .card { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .print-only { display: block !important; }
  .print-report-head {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #222;
    line-height: 1.5;
  }
  a { color: inherit; text-decoration: none; }
}

.print-only { display: none; }

.th-sort {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.th-sort:hover,
.th-sort.is-active {
  color: var(--green);
}
