:root {
  --primary: #2d5a27;
  --primary-light: #4a7c44;
  --primary-bg: #e8f5e9;
  --secondary: #d4a847;
  --secondary-light: #fdf6e3;
  --bg: #fafaf5;
  --card-bg: #fff;
  --text: #1a1a1a;
  --text-light: #666;
  --text-lighter: #999;
  --border: #e8e0d4;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
  --max-width: 1200px;
  --header-height: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }
img { max-width: 100%; height: auto; display: block; }

/* Layout */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.page { padding-top: calc(var(--header-height) + 20px); padding-bottom: 60px; }

/* Header */
.header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-height); background: var(--card-bg); border-bottom: 1px solid var(--border); z-index: 100; }
.header .container { display: flex; align-items: center; height: 100%; gap: 20px; }
.logo { font-size: 1.4rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.logo:hover { color: var(--primary); }
.logo-icon { width: 32px; height: 32px; background: var(--primary); color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.header-nav { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.header-nav a { font-size: 0.9rem; color: var(--text); padding: 6px 12px; border-radius: var(--radius-sm); transition: background 0.2s; }
.header-nav a:hover { background: var(--primary-bg); color: var(--primary); }
.header-nav .btn { font-size: 0.85rem; padding: 6px 16px; }

.menu-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 8px; margin-left: auto; }
.menu-toggle span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: 0.3s; }
.menu-toggle.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

.menu-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3); z-index: 98; }
.menu-overlay.show { display: block; }

@media (max-width: 768px) {
  .menu-toggle { display: flex; }
  .header-nav { position: fixed; top: 0; right: -280px; width: 260px; height: 100%; background: var(--card-bg); flex-direction: column; align-items: stretch; gap: 0; padding: 70px 20px 20px; margin: 0; z-index: 99; transition: right 0.3s; box-shadow: -4px 0 12px rgba(0,0,0,0.1); }
  .header-nav.open { right: 0; }
  .header-nav a, .header-nav span { display: block; width: 100%; }
  .header-nav a { padding: 14px 16px; font-size: 1rem; border-bottom: 1px solid var(--border); }
  .header-nav .btn { justify-content: center; margin-top: 12px; }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 24px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; border: none; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); color: white; }
.btn-secondary { background: var(--secondary); color: var(--text); }
.btn-secondary:hover { background: #c99a30; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-bg); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-ghost { background: transparent; color: var(--text-light); padding: 6px 12px; }
.btn-ghost:hover { background: var(--primary-bg); color: var(--primary); }

/* Cards */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; transition: all 0.2s; }
.card:hover { box-shadow: var(--shadow-hover); }
.card-body { padding: 10px; }
.card-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.card > div > ol {padding-left: 16px;}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-input { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.95rem; font-family: inherit; transition: border-color 0.2s; background: var(--card-bg); }
.form-input:focus { outline: none; border-color: var(--primary); }
.form-select { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.95rem; font-family: inherit; background: var(--card-bg); cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 120px; }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Hero */
.hero { text-align: center; padding: 60px 0 0 0; }
.hero h1 { font-size: 2.8rem; font-weight: 800; color: var(--primary); margin-bottom: 12px; letter-spacing: 2px; }
.hero p { font-size: 1.1rem; color: var(--text-light); max-width: 600px; margin: 0 auto 30px; }
.hero-subtitle { font-size: 1.2rem; color: var(--text-light); margin-bottom: 30px; }

/* Stats */
.stats-bar { display: flex; justify-content: center; gap: 60px; padding: 30px; background: var(--secondary-light); border-radius: var(--radius-lg); margin: 30px 0; }
.stat-item { text-align: center; }
.stat-num { font-size: 2.2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }

/* Search */
.search-bar { position: relative; margin: 0 auto; }
.search-bar input { width: 100%; padding: 14px 20px 14px 46px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; font-family: inherit; background: var(--card-bg); }
.search-bar input:focus { outline: none; border-color: var(--primary); }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-lighter); font-size: 1.1rem; }

/* Filters */
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { padding: 8px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.9rem; background: var(--card-bg); font-family: inherit; cursor: pointer; }

/* Tags */
.tag { display: inline-block; padding: 2px 10px; border-radius: 50px; font-size: 0.75rem; font-weight: 500; }
.tag-green { background: var(--primary-bg); color: var(--primary); }
.tag-gold { background: var(--secondary-light); color: #8a6d1b; }
.tag-red { background: #fce4e4; color: #c62828; }
.tag-blue { background: #e3f2fd; color: #1565c0; }

/* Township card */
.twp-card { cursor: pointer; transition: transform 0.2s; }
.twp-card:hover { transform: translateY(-2px); }
.twp-card .card-body { display: flex; flex-direction: column; gap: 8px; }
.twp-card h3 { font-size: 1.1rem; font-weight: 600; }
.twp-card .dt-badge { font-size: 0.75rem; color: var(--text-lighter); font-family: monospace; }
.twp-card .location { font-size: 0.85rem; color: var(--text-light); display: flex; align-items: center; gap: 4px; }
.twp-card .card-footer { padding: 10px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }

/* Section headers */
.section { margin-bottom: 20px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.section-header .subtitle { font-size: 0.9rem; color: var(--text-light); }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab { padding: 10px 20px; font-size: 0.9rem; font-weight: 500; color: var(--text-light); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Announcements */
.announcement { border-bottom: 1px solid var(--border); }
.announcement:last-child { border-bottom: none; }
.announcement-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.announcement h4 { font-size: 1rem; font-weight: 600; }
.announcement .meta { font-size: 0.8rem; color: var(--text-lighter); }

/* Products */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.product-card { position: relative; }
.product-card .price { font-size: 1.2rem; font-weight: 700; color: #c62828; }
.product-card .original-price { font-size: 0.85rem; color: var(--text-lighter); text-decoration: line-through; margin-left: 8px; }
.product-card .product-name { font-size: 0.95rem; font-weight: 500; margin: 8px 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Posts */
.post-list { display: flex; flex-direction: column; gap: 16px; }
.post-item { padding: 20px; }
.post-item h4 { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.post-item .post-meta { font-size: 0.8rem; color: var(--text-lighter); display: flex; gap: 16px; margin-bottom: 8px; }
.post-item .post-excerpt { font-size: 0.9rem; color: var(--text-light); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Members */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.member-card { text-align: center; padding: 20px 16px; }
.member-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; margin: 0 auto 8px; font-weight: 600; }
.member-name { font-size: 0.9rem; font-weight: 500; }
.member-role { font-size: 0.75rem; color: var(--text-light); }

/* Honor */
.honor-list { display: flex; flex-direction: column; }
.honor-item { display: flex; align-items: center; gap: 16px; padding: 10px 20px; }
.honor-rank { width: 32px; height: 32px; border-radius: 50%; background: var(--secondary-light); color: #8a6d1b; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.honor-rank.top1 { background: #ffd700; color: #5a4500; }
.honor-rank.top2 { background: #c0c0c0; color: #333; }
.honor-rank.top3 { background: #cd7f32; color: white; }

/* Emergency contacts */
.emergency-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.emergency-item { display: flex; align-items: center; gap: 16px; padding: 16px 20px; }
.emergency-icon { width: 44px; height: 44px; border-radius: 50%; background: #fce4e4; color: #c62828; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.emergency-info .name { font-weight: 600; }
.emergency-info .role { font-size: 0.8rem; color: var(--text-light); }
.emergency-phone { margin-left: auto; font-size: 1.1rem; font-weight: 700; color: #c62828; }

/* Township header */
.twp-header { padding: 20px; margin-bottom: 24px; }
.twp-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 4px; }
.twp-header .dt-badge { font-size: 0.85rem; color: var(--text-lighter); font-family: monospace; }
.twp-header .twp-location { font-size: 0.95rem; color: var(--text-light); margin-top: 8px; }
.twp-header .twp-stats { display: flex; gap: 30px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.twp-header .twp-stat { text-align: center; }
.twp-header .twp-stat-num { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.twp-header .twp-stat-label { font-size: 0.8rem; color: var(--text-light); }
.twp-admin { padding: 20px; background: var(--secondary-light); border-radius: var(--radius); margin-bottom: 24px; }
.twp-admin h3 { font-size: 1rem; margin-bottom: 8px; }
.twp-admin .phone { font-size: 1.2rem; font-weight: 600; color: var(--primary); }

/* Loading */
.loading { text-align: center; padding: 60px; color: var(--text-lighter); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Honor name clickable */
.honor-name { color: var(--text); transition: color 0.2s; }
.honor-name:hover { color: var(--primary); }

/* Modal/Overlay */
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:200; overflow-y:auto; }
.modal-overlay.show { display:block; }
.modal-content { background:var(--card-bg); min-height:100vh; padding:20px; max-width:600px; margin:0 auto; }
.modal-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; padding-bottom:12px; border-bottom:1px solid var(--border); }
.modal-header h3 { margin:0; font-size:1.1rem; }
.modal-close { background:none; border:none; font-size:1.5rem; cursor:pointer; padding:4px 8px; color:var(--text-light); }
@media(min-width:768px) { .modal-content { min-height:auto; border-radius:var(--radius-sm); margin:40px auto; } }

/* Responsive */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  .stats-bar { gap: 24px; flex-wrap: wrap; }
  .tab { padding: 10px 14px; font-size: 0.8rem; }
  .twp-header .twp-stats { gap: 16px; flex-wrap: wrap; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .member-grid { grid-template-columns: repeat(3, 1fr); }

}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: 1fr; }
  .member-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Toast */
.toast { position: fixed; top: 80px; right: 20px; padding: 12px 20px; border-radius: var(--radius-sm); color: white; font-size: 0.9rem; z-index: 300; animation: slideIn 0.3s ease; max-width: 360px; }
.toast-success { background: var(--primary); }
.toast-error { background: #c62828; }
.toast-info { background: #1565c0; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Footer */
.footer { text-align: center; padding: 30px; color: var(--text-lighter); font-size: 0.85rem; border-top: 1px solid var(--border); margin-top: 40px; }

/* Risk monitoring */
.risk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.risk-card { padding: 16px 20px; border-left: 4px solid var(--primary); }
.risk-card.status-warning { border-left-color: #f9a825; }
.risk-card.status-danger { border-left-color: #c62828; }
.risk-card h4 { font-size: 1rem; margin-bottom: 4px; }
.risk-card .risk-status { font-size: 0.8rem; font-weight: 500; }
.risk-card .risk-location { font-size: 0.8rem; color: var(--text-light); }

/* Like button */
.like-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; border-radius: 50px; font-size: 0.9rem; font-weight: 500; border: 1.5px solid var(--border); cursor: pointer; transition: all 0.2s; background: var(--card-bg); font-family: inherit; color: var(--text-light); }
.like-btn:hover { border-color: #e57373; color: #c62828; background: #fff5f5; }
.like-btn.liked { border-color: #e57373; background: #fff5f5; color: #c62828; font-weight: 600; }
.like-btn.liked .like-icon { color: #c62828; }

/* Comments */
.comment-list { margin-top: 20px; }
.comment-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 600; flex-shrink: 0; }
.comment-avatar img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.comment-author { font-size: 0.9rem; font-weight: 500; }
.comment-time { font-size: 0.75rem; color: var(--text-lighter); }
.comment-content { font-size: 0.9rem; color: var(--text); line-height: 1.6; margin-left: 46px; white-space: pre-wrap; }
.comment-form { display: flex; gap: 12px; align-items: flex-start; margin-top: 20px; }
.comment-form textarea { flex: 1; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.9rem; font-family: inherit; resize: vertical; min-width: 150px; min-height: 80px; transition: border-color 0.2s; }
.comment-form textarea:focus { outline: none; border-color: var(--primary); }
.comment-empty { text-align: center; padding: 30px; color: var(--text-light); font-size: 0.9rem; }
