:root {
    --primary: #1e40af;
    --bg: #f1f5f9;
    --border: #e2e8f0;
    --danger: #dc2626;
    --success: #16a34a;
}

* { box-sizing: border-box; }

body {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    margin: 0;
    background: var(--bg);
    color: #0f172a;
    line-height: 1.6;
}

header { background: var(--primary); color: #fff; padding: 0.75rem 1rem; }
header .inner { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; justify-content: space-between; }
header a { color: #fff; text-decoration: none; margin-right: 1rem; }
.brand a { display: flex; align-items: center; gap: 0.5rem; margin-right: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { font-size: 0.72rem; opacity: 0.9; font-weight: 400; }
.brand-logo { height: 44px; width: auto; background: #fff; border-radius: 6px; padding: 2px; }
nav { display: flex; flex-wrap: wrap; align-items: center; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }

.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1rem; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }

.btn { display: inline-block; padding: 0.5rem 1rem; border-radius: 6px; border: 1px solid var(--primary); background: var(--primary); color: #fff; text-decoration: none; cursor: pointer; font-size: 0.95rem; font-family: inherit; }
.btn-secondary { background: #fff; color: var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

label { display: block; margin-top: 0.75rem; font-weight: 600; }
input, select, textarea { width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.errors ul { margin: 0; padding-left: 1.2rem; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.8rem; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

.home-title { text-align: center; margin-bottom: 1.5rem; }
.home-logo-img { height: 90px; width: auto; }
.home-title h1 { margin: 0.25rem 0; color: var(--primary); }
.home-title h4 { margin: 0.25rem 0; font-weight: 500; color: #475569; }

.stat-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat-card { display: block; border-radius: 8px; overflow: hidden; color: #fff; text-decoration: none; }
.stat-card .stat-head { padding: 0.6rem 1rem; font-weight: 600; background: rgba(0,0,0,0.15); }
.stat-card .stat-body { padding: 0.75rem 1rem; }
.stat-card .stat-num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-sub { opacity: 0.9; }
.stat-success { background: #16a34a; }
.stat-danger { background: #dc2626; }
.stat-warning { background: #d97706; }
.stat-primary { background: var(--primary); }

.notice-bar { border: 3px solid #dc2626; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem; background: #fff; }
.notice-bar p { color: #dc2626; font-weight: 600; margin: 0.15rem 0; }

.calendar-card { padding: 1rem 1.25rem; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.calendar-head h2 { margin: 0; font-size: 1.25rem; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-weekdays div { text-align: center; font-weight: 600; padding: 0.4rem 0; color: #475569; }
.calendar-grid { border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-cell { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0.3rem; }
.cal-empty { background: #f8fafc; }
.cal-today { background: #eff6ff; outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-daynum { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.2rem; }
.cal-event { display: block; font-size: 0.7rem; color: #fff; text-decoration: none; padding: 0.05rem 0.25rem; border-radius: 4px; margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event:hover { opacity: 0.85; }
.calendar-foot { text-align: center; margin-top: 0.75rem; }

.pagination { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 1rem; }
.pagination a { display: inline-block; padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--primary); text-decoration: none; font-size: 0.9rem; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.participant-row { border: 1px dashed var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; }

.site-footer { background: #1e293b; color: #e2e8f0; margin-top: 2rem; padding: 1.25rem 1rem; }
.footer-inner { max-width: 1100px; margin: 0 auto; text-align: center; }
.site-footer p { margin: 0.25rem 0; font-size: 0.9rem; line-height: 1.6; }
.visit-counter { margin-top: 0.5rem; }

@media (max-width: 600px) {
    header .inner { flex-direction: column; align-items: flex-start; }
    .cal-cell { min-height: 64px; }
    .cal-event { font-size: 0.62rem; }
    table { display: block; overflow-x: auto; }
}
