/* ═══════════════════════════════════════════════════════════════════════════
   Theme — ระบบบุญโลงศพ วัดป่าพุทธิสุทธาราม
   ดีไซน์ใหม่ v2: Mint × Peach × Cream (ให้เข้ากับเว็บไซต์วัด)
   Font: Sarabun + Prompt + Noto Serif Thai
   * คงชื่อ class เดิมทุกตัว — JS / โครงสร้างหน้าไม่ต้องแก้ *
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&family=Noto+Serif+Thai:wght@400;500;700&display=swap');

:root {
  /* ── brand (mint × peach × gold) ── */
  --c-green-deep: #2E5645;   /* mint-700 — หัวข้อ/เน้น */
  --c-green:      #4F8970;   /* mint-500 — primary    */
  --c-green-soft: #6FAA88;   /* mint-400              */
  --c-mint-50:    #F0F7F3;
  --c-mint-100:   #DCEDE2;
  --c-gold:       #B08F4D;   /* gold-500              */
  --c-gold-light: #C9A86B;   /* gold-400              */
  --c-peach-100:  #FCE8DC;
  --c-peach-500:  #E68660;
  --c-peach-600:  #D06441;
  --c-cream:      #FBFAF6;   /* cream-50              */
  --c-cream-deep: #F5F2EA;   /* cream-100             */

  /* ── state ── */
  --c-success:   #4F8970;
  --c-warning:   #B08F4D;
  --c-danger:    #C44545;
  --c-info:      #5B6BBF;

  /* ── surface ── */
  --c-bg:        #FBFAF6;
  --c-surface:   #FFFFFF;
  --c-surface-2: #FBFAF6;
  --c-border:    #F0F1EF;   /* ink-100 */
  --c-border-2:  #DCDEDB;   /* ink-200 */

  /* ── text ── */
  --c-text:        #1C1E1D;  /* ink-900 */
  --c-text-soft:   #6B6F6C;  /* ink-500 */
  --c-text-muted:  #8B8E8B;  /* ink-400 */
  --c-text-on-dark: #FBFAF6;

  /* ── shadow ── */
  --shadow-sm: 0 1px 3px rgba(28,30,29,0.06), 0 1px 2px rgba(28,30,29,0.04);
  --shadow:    0 4px 16px rgba(28,30,29,0.06), 0 1px 3px rgba(28,30,29,0.04);
  --shadow-lg: 0 12px 32px rgba(28,30,29,0.08), 0 4px 12px rgba(28,30,29,0.04);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;

  --font-sans:  'Sarabun', 'Prompt', system-ui, sans-serif;
  --font-body:  'Sarabun', 'Prompt', system-ui, sans-serif;
  --font-serif: 'Noto Serif Thai', 'Sarabun', serif;

  --transition: all 180ms cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  word-break: keep-all;
  text-wrap: pretty;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--c-text);
  font-weight: 700;
  margin: 0 0 0.5em 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--c-green); text-decoration: none; }
a:hover { color: var(--c-green-deep); text-decoration: underline; }

/* ─── Layout ───────────────────────────────────────────────────────────── */
.admin-shell { display: flex; min-height: 100vh; background: var(--c-bg); }

.sidebar {
  width: 256px;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--c-cream) 100%);
  border-right: 1px solid var(--c-border);
  color: var(--c-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--c-border);
}
.sidebar .brand .logo {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-green-deep);
}
.sidebar .brand .sub {
  font-size: 0.76rem;
  color: var(--c-text-muted);
  margin-top: 3px;
}
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--c-text-soft);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: var(--transition);
}
.nav a span[aria-hidden="true"] { font-size: 1rem; line-height: 1; opacity: 0.9; }
.nav a:hover {
  background: var(--c-mint-50);
  color: var(--c-green-deep);
  text-decoration: none;
}
.nav a.active {
  background: #FFFFFF;
  color: var(--c-green-deep);
  font-weight: 600;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--c-border);
}
.nav a.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--c-green);
  border-radius: 0 3px 3px 0;
}
.nav .section-title {
  padding: 14px 12px 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--c-text-muted);
}
.sidebar .footer {
  padding: 14px 18px;
  border-top: 1px solid var(--c-border);
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

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

.topbar {
  background: rgba(251, 250, 246, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
  padding: 14px 30px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.topbar .user {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.92rem;
}
.topbar .user .role-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--c-mint-50);
  color: var(--c-green-deep);
  font-size: 0.72rem;
  font-weight: 600;
}
.topbar .user button {
  background: var(--c-surface);
  border: 1px solid var(--c-border-2);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--c-text-soft);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.topbar .user button:hover { border-color: var(--c-green); color: var(--c-green-deep); background: var(--c-mint-50); }

.content { padding: 28px 32px 56px; flex: 1; max-width: 1440px; width: 100%; }

/* ─── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  animation: fadeUp 400ms cubic-bezier(0.32, 0.72, 0, 1) both;
}
.card h3 { margin-top: 0; }
.card-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--c-text-soft);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}
.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  animation: fadeUp 400ms cubic-bezier(0.32, 0.72, 0, 1) both;
}
.stat:hover {
  border-color: var(--c-border-2);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.stat::before {
  content: '';
  position: absolute; left: 0; top: 16px; bottom: 16px;
  width: 3px; background: var(--c-green);
  border-radius: 0 3px 3px 0;
}
.stat .label {
  font-size: 0.82rem;
  color: var(--c-text-soft);
  margin: 0;
  font-weight: 500;
}
.stat .value {
  font-family: var(--font-sans);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--c-text);
  margin: 6px 0 0;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-feature-settings: 'tnum';
}
.stat .delta {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 4px;
}

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  transition: var(--transition);
}
.btn-primary { background: var(--c-green); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.btn-primary:hover { background: var(--c-green-deep); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-gold { background: var(--c-gold); color: #fff; }
.btn-gold:hover { background: var(--c-gold-light); color: var(--c-text); }
.btn-outline {
  background: var(--c-surface);
  color: var(--c-text-soft);
  border-color: var(--c-border-2);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover { background: var(--c-mint-50); border-color: var(--c-green-soft); color: var(--c-green-deep); }
.btn-ghost { background: transparent; color: var(--c-text-soft); }
.btn-ghost:hover { background: var(--c-cream-deep); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); }
.btn-sm { padding: 6px 13px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ─── Forms ────────────────────────────────────────────────────────────── */
.form-row { margin-bottom: 14px; }
label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--c-text-soft);
  margin-bottom: 5px;
  font-weight: 500;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--c-text);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-green-soft);
  box-shadow: 0 0 0 3px var(--c-mint-50);
}

/* ─── Tables ───────────────────────────────────────────────────────────── */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.92rem;
}
table.data th {
  text-align: left;
  padding: 11px 14px;
  background: var(--c-cream);
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--c-text-soft);
  border-bottom: 1px solid var(--c-border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
  color: var(--c-text-soft);
}
table.data tr:hover td { background: var(--c-surface-2); }
table.data tr:last-child td { border-bottom: none; }

/* ─── Status badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--c-border);
  color: var(--c-text-soft);
}
.badge-pending   { background: var(--c-peach-100); color: var(--c-peach-600); }
.badge-verifying { background: #FDF4E0; color: var(--c-gold); }
.badge-verified  { background: var(--c-mint-50); color: var(--c-green-deep); }
.badge-rejected  { background: #F5DBD2; color: var(--c-danger); }
.badge-refunded  { background: var(--c-border); color: var(--c-text-soft); }
.badge-planned       { background: #EEF0FD; color: var(--c-info); }
.badge-names_printed { background: #FDF4E0; color: var(--c-gold); }
.badge-photographed  { background: #EEF0FD; color: var(--c-info); }
.badge-pushed        { background: var(--c-mint-100); color: var(--c-green-deep); }
.badge-completed     { background: var(--c-green-deep); color: var(--c-cream); }

/* ─── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar .grow { flex: 1; }
.toolbar input[type="search"], .toolbar select {
  max-width: 240px;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    width: 256px;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 20;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-toggle {
    display: inline-block;
    background: transparent; border: none; font-size: 1.4rem;
    color: var(--c-green-deep); cursor: pointer;
  }
  .content { padding: 18px 16px 40px; }
}
@media (min-width: 801px) {
  .topbar .menu-toggle { display: none; }
}

/* ─── Utility ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--c-text-muted); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 16px; }
.thb::after { content: ' บาท'; color: var(--c-text-muted); font-size: 0.85em; }

/* ─── Animations ──────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat:nth-child(1) { animation-delay: 0ms; }
.stat:nth-child(2) { animation-delay: 45ms; }
.stat:nth-child(3) { animation-delay: 90ms; }
.stat:nth-child(4) { animation-delay: 135ms; }
.stat:nth-child(5) { animation-delay: 180ms; }
.stat:nth-child(6) { animation-delay: 225ms; }
.stat:nth-child(7) { animation-delay: 270ms; }
.stat:nth-child(8) { animation-delay: 315ms; }

/* ─── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--c-text); color: var(--c-cream);
  padding: 12px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: slideIn 0.2s ease;
}
.toast.error { background: var(--c-danger); }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ═══════════════════════════════════════════════════════════════════════════
   v2 rich components — brand, search, user card, breadcrumb, stat-card, etc.
   (markup ใหม่จาก layout.js + หน้า dashboard/reports)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Brand ── */
.sidebar .brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-green), var(--c-green-deep));
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79,137,112,0.25);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { line-height: 1.2; min-width: 0; }
.brand-name { font-family: var(--font-sans); font-weight: 600; font-size: 0.92rem; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 0.7rem; color: var(--c-text-muted); margin-top: 2px; }

/* ── Sidebar search ── */
.search-wrap { padding: 12px 14px 6px; position: relative; }
.search-input {
  width: 100%; background: var(--c-border); border: 1px solid transparent;
  border-radius: 10px; padding: 8px 12px 8px 32px; font-size: 0.85rem; color: var(--c-text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238B8E8B' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m21 21-4.35-4.35'/></svg>");
  background-repeat: no-repeat; background-position: 10px 50%; transition: var(--transition);
}
.search-input:focus { outline: none; background-color: #fff; border-color: var(--c-mint-100); box-shadow: 0 0 0 3px var(--c-mint-50); }
.search-shortcut { position: absolute; right: 22px; top: 18px; font-size: 0.68rem; color: var(--c-text-muted); background: #fff; border: 1px solid var(--c-border-2); border-radius: 4px; padding: 1px 5px; pointer-events: none; }

/* ── Nav icon (SVG) ── */
.nav-icon { width: 18px; height: 18px; display: inline-flex; flex-shrink: 0; opacity: 0.8; }
.nav-icon svg { width: 18px; height: 18px; }
.nav a.active .nav-icon { opacity: 1; color: var(--c-green); }

/* ── Sidebar footer / user card ── */
.sidebar-footer { margin-top: auto; padding: 12px 14px; border-top: 1px solid var(--c-border); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; transition: var(--transition); }
.user-card:hover { background: var(--c-border); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--c-gold-light), var(--c-peach-500)); display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 0.85rem; flex-shrink: 0; }
.user-info { line-height: 1.25; min-width: 0; flex: 1; }
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--c-text-muted); }

/* ── Topbar breadcrumb + icon buttons ── */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--c-text-soft); }
.breadcrumb-sep { color: var(--c-border-2); }
.breadcrumb-current { color: var(--c-text); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--c-text-soft); cursor: pointer; transition: var(--transition); }
.icon-btn:hover { background: var(--c-border); color: var(--c-text); }
.icon-btn .notif-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; background: var(--c-peach-500); border-radius: 50%; border: 2px solid var(--c-cream); }

/* ── Page header + filter chips ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.01em; color: var(--c-text); margin: 0; }
.page-desc { font-size: 0.92rem; color: var(--c-text-soft); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-group { display: inline-flex; background: var(--c-border); border-radius: 9px; padding: 3px; gap: 2px; }
.filter-chip { padding: 6px 13px; font-size: 0.85rem; font-weight: 500; border-radius: 7px; color: var(--c-text-soft); cursor: pointer; background: transparent; border: none; transition: var(--transition); font-family: var(--font-sans); }
.filter-chip:hover { color: var(--c-text); }
.filter-chip.active { background: #fff; color: var(--c-text); font-weight: 600; box-shadow: var(--shadow-sm); }
.btn-icon { width: 16px; height: 16px; }

/* ── Rich stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 18px 20px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  transition: var(--transition); animation: fadeUp 400ms cubic-bezier(0.32,0.72,0,1) both;
}
.stat-card:hover { border-color: var(--c-border-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card .stat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-card .stat-label { font-size: 0.82rem; font-weight: 500; color: var(--c-text-soft); }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; flex-shrink: 0; }
.stat-icon svg { width: 17px; height: 17px; }
.stat-card .stat-value { font-family: var(--font-sans); font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; color: var(--c-text); font-feature-settings: 'tnum'; display: flex; align-items: baseline; gap: 5px; margin: 0; }
.stat-unit { font-size: 0.8rem; font-weight: 500; color: var(--c-text-soft); }
.stat-card .stat-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 0.75rem; font-weight: 600; margin-top: 7px; color: var(--c-green); }
.stat-card .stat-delta.down { color: var(--c-peach-600); }
.stat-delta-period { color: var(--c-text-muted); font-weight: 400; }
.stat-hint { font-size: 0.74rem; color: var(--c-text-muted); margin-top: 7px; }
.stat-sparkline { position: absolute; bottom: 0; right: 0; width: 104px; height: 34px; opacity: 0.55; }
.si-mint   { background: var(--c-mint-50);  color: var(--c-green); }
.si-peach  { background: var(--c-peach-100); color: var(--c-peach-600); }
.si-gold   { background: #FDF4E0; color: var(--c-gold); }
.si-indigo { background: #EEF0FD; color: var(--c-info); }
.stats-grid .stat-card:nth-child(1){animation-delay:0ms;}
.stats-grid .stat-card:nth-child(2){animation-delay:45ms;}
.stats-grid .stat-card:nth-child(3){animation-delay:90ms;}
.stats-grid .stat-card:nth-child(4){animation-delay:135ms;}
.stats-grid .stat-card:nth-child(5){animation-delay:180ms;}
.stats-grid .stat-card:nth-child(6){animation-delay:225ms;}
.stats-grid .stat-card:nth-child(7){animation-delay:270ms;}
.stats-grid .stat-card:nth-child(8){animation-delay:315ms;}
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .stats-grid { grid-template-columns: 1fr; } }

/* ── Card head + legend ── */
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.card-head h3 { margin: 0; }
.card-sub { font-size: 0.78rem; color: var(--c-text-muted); margin-top: 3px; }
.legend { display: flex; gap: 14px; font-size: 0.78rem; color: var(--c-text-soft); flex-wrap: wrap; }
.legend-dot { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c-green); }
.legend-dot.peach::before { background: var(--c-peach-500); }

/* ── Donor leaderboard list ── */
.donor-list { display: flex; flex-direction: column; }
.donor-item { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.donor-item:last-child { border-bottom: none; }
.donor-rank { font-size: 0.75rem; font-weight: 700; color: var(--c-text-muted); font-feature-settings: 'tnum'; }
.donor-item:nth-child(-n+3) .donor-rank { color: var(--c-gold); }
.donor-name { font-size: 0.88rem; font-weight: 500; color: var(--c-text); display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donor-times { font-size: 0.72rem; color: var(--c-text-soft); background: var(--c-border); padding: 1px 7px; border-radius: 100px; font-weight: 500; }
.donor-amount { font-size: 0.9rem; font-weight: 600; color: var(--c-green-deep); font-feature-settings: 'tnum'; }
.donor-amount .baht { font-size: 0.7rem; color: var(--c-text-muted); margin-left: 2px; font-weight: 500; }

/* ── two-column content grid ── */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }


/* ===== ต่อท้ายอัตโนมัติ: เมนูแยกบุญ v3 ===== */
/* ═══════════════════════════════════════════════════════════════════════════
   theme-additions.css — ส่วนเสริมสำหรับเมนูแยกประเภทบุญ (v3)
   วิธีใช้: นำเนื้อหาไฟล์นี้ไปต่อท้าย /admin/_shared/theme.css
   (ใช้ตัวแปรสีเดิมจาก theme.css — ถ้าตัวแปรชื่อต่าง ปรับ fallback ด้านล่างได้)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── กลุ่มเมนูพับได้ ───────────────────────────────────────────────────── */
.nav-group { margin: 1px 0; }
.nav-parent {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 12px; margin: 1px 0;
  border: none; background: transparent; cursor: pointer; text-align: left;
  border-radius: 8px;
  font-family: inherit; font-size: 0.92rem; font-weight: 600;
  color: var(--c-text-soft, #6B6F6C);
  transition: all 180ms cubic-bezier(0.32,0.72,0,1);
}
.nav-parent:hover { background: var(--c-mint-50, #F0F7F3); color: var(--c-green-deep, #2E5645); }
.nav-parent .nav-icon { opacity: .85; }
.nav-parent .nav-chevron { width: 14px; height: 14px; margin-left: auto; opacity: .55; transition: transform .22s ease; }
.nav-group.open  .nav-parent { color: var(--c-green-deep, #2E5645); }
.nav-group.open  .nav-parent .nav-chevron { transform: rotate(90deg); }
.nav-group.has-active .nav-parent { color: var(--c-green-deep, #2E5645); }

.nav-children {
  max-height: 0; overflow: hidden;
  margin: 2px 0 2px 13px; padding-left: 8px;
  border-left: 1.5px solid var(--c-border, #F0F1EF);
  transition: max-height .26s ease;
}
.nav-group.open .nav-children { max-height: 460px; }
.nav-children .nav-item { font-size: 0.88rem; padding: 7px 11px; gap: 10px; }
.nav-children .nav-item .nav-icon { width: 16px; height: 16px; opacity: .7; }
.nav-children .nav-item.active .nav-icon { opacity: 1; }

/* ── ป้ายประเภทบุญ (ใช้ในหน้าแยกบุญ) ─────────────────────────────────── */
.merit-band { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; flex-wrap: wrap; }
.tag-merit { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.tag-coffin { background: #FDF4E0; color: var(--c-gold, #B08F4D); }
.tag-child  { background: #EEF0FD; color: var(--c-info, #5B6BBF); }

/* ── การ์ดสรุปตัวเลข (ถ้าหน้ายังไม่มี .stats-grid ของเดิมก็ใช้ชุดนี้ได้) ─ */
.merit-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px){ .merit-stats { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px){ .merit-stats { grid-template-columns: 1fr; } }
.merit-stats .ms-card { background: var(--c-surface,#fff); border: 1px solid var(--c-border,#F0F1EF); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(28,30,29,.06)); }
.merit-stats .ms-label { font-size: .8rem; color: var(--c-text-soft,#6B6F6C); font-weight: 500; }
.merit-stats .ms-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.merit-stats .ms-hint { font-size: .74rem; color: var(--c-text-muted,#8B8E8B); margin-top: 5px; }

/* ── progress bar (ความคืบหน้าจารึก/โควตา) ───────────────────────────── */
.bar { height: 8px; border-radius: 999px; background: var(--c-cream-deep,#F5F2EA); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--c-green,#4F8970); }

/* ── helper ──────────────────────────────────────────────────────────── */
.grow { flex: 1; }
.text-right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.muted2 { color: var(--c-text-muted,#8B8E8B); }

.tag-general { background: var(--c-mint-50,#F0F7F3); color: var(--c-green-deep,#2E5645); }


/* ═══════════════════════════════════════════════════════════════════════════
   WORLD-CLASS POLISH LAYER (v3.1) — ปรับความประณีตทั้งระบบ
   * ทับค่าฐานด้วย cascade (อยู่ท้ายไฟล์) ไม่แตะคลาส/โครงสร้าง — ลบบล็อกนี้เพื่อย้อน *
   ═══════════════════════════════════════════════════════════════════════════ */
:root{
  --shadow-sm: 0 1px 2px rgba(28,30,29,.04), 0 1px 3px rgba(28,30,29,.05);
  --shadow:    0 2px 4px rgba(28,30,29,.04), 0 6px 16px -4px rgba(28,30,29,.08);
  --shadow-lg: 0 4px 8px rgba(28,30,29,.04), 0 18px 40px -8px rgba(28,30,29,.14);
  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --transition: all .2s cubic-bezier(.4,0,.2,1);
}
html{ scroll-behavior:smooth; }
body{
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(79,137,112,.05), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, rgba(230,134,96,.05), transparent 55%),
    var(--c-bg);
  background-attachment: fixed;
  text-rendering: optimizeLegibility;
}
::selection{ background: var(--c-mint-100); color: var(--c-green-deep); }

/* ── scrollbar ประณีต ── */
*{ scrollbar-width: thin; scrollbar-color: #D7DAD6 transparent; }
*::-webkit-scrollbar{ width:10px; height:10px; }
*::-webkit-scrollbar-thumb{ background:#D7DAD6; border:3px solid transparent; background-clip:content-box; border-radius:999px; }
*::-webkit-scrollbar-thumb:hover{ background:#B9BDB8; border:3px solid transparent; background-clip:content-box; }
*::-webkit-scrollbar-track{ background:transparent; }

/* ── โฟกัสเข้าถึงได้ (accessibility) ── */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.nav-item:focus-visible, .nav-parent:focus-visible{
  outline: 2px solid var(--c-green-soft); outline-offset: 2px; border-radius: var(--radius-sm);
}

/* ── typography คมขึ้น ── */
.page-title{ font-size:1.72rem; font-weight:750; letter-spacing:-.022em; }
.page-desc{ color:var(--c-text-muted); }
h3{ letter-spacing:-.012em; }
.mono,.stat-value,.ms-value,.mc-amt,.donor-amount,td.text-right{ font-variant-numeric: tabular-nums; }

/* ── การ์ดละมุน ── */
.card{ border-color: rgba(28,30,29,.07); transition: box-shadow .25s ease, border-color .25s ease; }
.card:hover{ border-color: rgba(28,30,29,.10); }
.merit-card, .ms-card{ transition: var(--transition); }
.merit-card:hover, .ms-card:hover{ box-shadow: var(--shadow); transform: translateY(-2px); }

/* ── stat cards ── */
.stat-card{ transition: var(--transition); }
.stat-card:hover{ transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon{ box-shadow: inset 0 0 0 1px rgba(28,30,29,.04); }
.stat-value{ font-weight:750; letter-spacing:-.025em; }

/* ── sidebar ลื่นขึ้น ── */
.sidebar{ box-shadow: 1px 0 0 rgba(28,30,29,.04); }
.nav-item, .nav-parent{ transition: var(--transition); }
.nav-item:hover{ transform: translateX(2px); }
.nav-item.active{ box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(28,30,29,.05); }
.brand-mark{ box-shadow: 0 2px 8px rgba(79,137,112,.25); }

/* ── topbar แก้วใส ── */
.topbar{ background: rgba(251,250,246,.72); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); }

/* ── ตารางหายใจได้ + หัวตารางคม ── */
table.data th{
  text-transform: none; font-size:.74rem; font-weight:600; letter-spacing:.02em;
  color: var(--c-text-muted); padding:13px 16px;
  border-bottom:1px solid var(--c-border); background:transparent;
}
table.data td{ padding:14px 16px; border-bottom:1px solid rgba(28,30,29,.05); vertical-align: middle; }
table.data tbody tr{ transition: background .15s ease; }
table.data tbody tr:hover td{ background: var(--c-mint-50); }
table.data tbody tr:hover td:first-child{ border-top-left-radius:10px; border-bottom-left-radius:10px; }
table.data tbody tr:hover td:last-child{ border-top-right-radius:10px; border-bottom-right-radius:10px; }

/* ── ปุ่มประณีต + micro-interaction ── */
.btn{ border-radius:11px; font-weight:600; transition: var(--transition); }
.btn:active{ transform: translateY(0) scale(.98); }
.btn-primary{ box-shadow: 0 1px 2px rgba(46,86,69,.18), 0 4px 12px -4px rgba(46,86,69,.35); }
.btn-primary:hover{ box-shadow: 0 2px 4px rgba(46,86,69,.22), 0 8px 20px -6px rgba(46,86,69,.45); }
.btn-sm{ border-radius:9px; }

/* ── input / select / search ── */
input, select, textarea, .search-input, .field input, .field select{
  border-radius:11px; transition: var(--transition);
}
input:focus, select:focus, textarea:focus{ box-shadow: 0 0 0 3px var(--c-mint-50); border-color: var(--c-green-soft); }

/* ── badge / pill / tag ── */
.badge, .pill, .tag-merit, .tier-badge{ letter-spacing:.01em; box-shadow: inset 0 0 0 1px rgba(28,30,29,.03); }

/* ── segmented control ── */
.seg{ box-shadow: inset 0 0 0 1px rgba(28,30,29,.04); }
.seg button{ transition: var(--transition); }
.seg button.active{ box-shadow: 0 1px 3px rgba(28,30,29,.12); }

/* ── เข้าหน้าแบบนุ่มนวล ── */
@keyframes contentIn{ from{ opacity:0; transform: translateY(6px); } to{ opacity:1; transform:none; } }
.content > .page-header, .content > .stats-grid, .content > .merit-stats,
.content > .merit-overview, .content > .grid-2, .content > .dn-grid,
.content > .card, .content > .merit-band, .content > .toolbar{
  animation: contentIn .42s cubic-bezier(.32,.72,0,1) both;
}
.content > *:nth-child(2){ animation-delay:.04s; }
.content > *:nth-child(3){ animation-delay:.08s; }
.content > *:nth-child(4){ animation-delay:.12s; }
.content > *:nth-child(5){ animation-delay:.16s; }
@media (prefers-reduced-motion: reduce){ *{ animation:none !important; transition:none !important; } html{ scroll-behavior:auto; } }
