*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #e61a23;
    --primary-dark: #c9151d;
    --primary-darker: #a81218;
    --primary-light: #fff1f2;
    --sidebar-bg: #222222;
    --table-head: #e61a23;
    --bg: #f5f5f5;
    --card-bg: #fff;
    --text: #1a1a1a;
    --text-muted: #666666;
    --border: #e8e8e8;
    --success: #059669;
    --error: #c9151d;
    --warning: #d97706;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --primary-rgb: 230, 26, 35;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-icon {
    width: 40px; height: 40px;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    flex-shrink: 0;
    padding: 3px;
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand-text strong { display: block; font-size: 14px; }
.brand-text span { font-size: 11px; opacity: .6; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,.85);
    margin-bottom: 4px;
    transition: all .18s;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: none;
}
.nav-icon { font-size: 16px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.1);
}

.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
    width: 36px; height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; opacity: .6; }
.sidebar-links { display: flex; gap: 12px; font-size: 12px; }
.sidebar-links a { color: rgba(255,255,255,.6); }

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* Page */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 { font-size: 22px; font-weight: 600; }
.page-header-modern { align-items: flex-start; gap: 16px; }
.page-header-modern h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}
.page-meta {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
}
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.breadcrumb { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 4px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 10px;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.back-link:hover {
    color: var(--primary);
    border-color: #f5c2c5;
    background: var(--primary-light);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.1);
}

.back-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

.page-header-detail h2 { margin-top: 0; }

.btn-modern {
    border-radius: 6px;
    padding: 10px 22px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid #eee;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center;
}

.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.dashboard-hero {
    display: flex;
    gap: 20px;
    align-items: stretch;
    margin-bottom: 24px;
}

.dashboard-stats-panel {
    width: 228px;
    flex-shrink: 0;
    display: flex;
    min-height: 0;
}

.dashboard-stats-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.dashboard-stats-header h3 {
    font-size: 15px;
}

.dashboard-stat-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
    padding: 12px !important;
}

.dashboard-stat-item {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-height: 0;
    padding: 14px 16px;
    background: #fafbfd;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: none;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.dashboard-stat-item:hover {
    transform: translateY(-1px);
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.dashboard-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.dashboard-stat-body { min-width: 0; flex: 1; }

.dashboard-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.dashboard-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.35;
}

.stat-township .dashboard-stat-icon { background: #fff1f2; color: var(--primary); }
.stat-township .dashboard-stat-value { color: var(--primary); }

.stat-village .dashboard-stat-icon { background: #eff6ff; color: #2563eb; }
.stat-village .dashboard-stat-value { color: #2563eb; }

.stat-staff .dashboard-stat-icon { background: #ecfdf5; color: #059669; }
.stat-staff .dashboard-stat-value { color: #059669; }

.stat-ledger .dashboard-stat-icon { background: #fff7ed; color: #d97706; }
.stat-ledger .dashboard-stat-value { color: #d97706; }

.stat-assessment .dashboard-stat-icon { background: #f5f3ff; color: #7c3aed; }
.stat-assessment .dashboard-stat-value { color: #7c3aed; }

.dashboard-map-wrap {
    flex: 1;
    min-width: 0;
}

.dashboard-map-wrap .dashboard-map-card {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dashboard-map-wrap .dashboard-map-card > .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px;
}

.dashboard-map-wrap .yucheng-map {
    flex: 1;
    height: auto;
    min-height: 520px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: #f9fafb; }
.table tr:hover td { background: #f9fafb; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

.form-actions { display: flex; gap: 10px; align-items: center; }
.form-actions.full-width { grid-column: 1 / -1; }

.inline-form { display: inline; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    font-family: inherit;
}

.btn:hover { background: #f9fafb; text-decoration: none; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.btn-danger { color: var(--error); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e8eef5;
}

.tab {
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
    transition: all .15s;
    border-radius: 8px 8px 0 0;
}

.tab:hover { color: var(--primary); text-decoration: none; background: #fafafa; }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
    background: linear-gradient(180deg, var(--primary-light) 0%, transparent 100%);
}

/* Tags & Badges */
.tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag-blue {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.badge-draft { background: #f3f4f6; color: var(--text-muted); }
.badge-submitted { background: #fef3c7; color: var(--warning); }
.badge-approved { background: #d1fae5; color: var(--success); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Detail */
.detail-list { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; font-size: 14px; }
.detail-list dt { color: var(--text-muted); font-weight: 500; }
.detail-view { display: flex; gap: 24px; align-items: flex-start; }
.village-preview-actions { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

.detail-photo img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
    flex-shrink: 0;
}

.photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: #f9fafb;
    color: var(--text-muted);
}

.detail-photo .photo-placeholder {
    width: 200px;
    height: 200px;
    flex-shrink: 0;
}

.photo-preview img { max-width: 200px; border-radius: var(--radius); border: 1px solid var(--border); }

/* Photo upload */
.photo-upload { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

.photo-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.photo-upload-box {
    display: block;
    width: 120px;
    height: 120px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: #f9fafb;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: border-color .15s, background .15s;
}

.photo-upload-box:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.photo-upload-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
}

.photo-upload-plus {
    font-size: 36px;
    line-height: 1;
    font-weight: 300;
    color: #9ca3af;
}

.photo-upload-text {
    font-size: 12px;
}

.photo-upload-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-upload-file {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    text-align: center;
}

.photo-upload-file-icon {
    font-size: 13px;
    font-weight: 600;
    color: var(--error);
    background: #fee2e2;
    padding: 4px 8px;
    border-radius: 4px;
}

.photo-upload-file-name {
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.3;
}

.photo-upload-remove {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 4px;
}

.photo-upload-remove:hover { color: var(--error); }

[hidden] { display: none !important; }

.content-view { font-size: 14px; line-height: 1.8; white-space: pre-wrap; }

/* Item grid */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.item-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.item-photo-wrap { width: 100%; height: 160px; background: #f9fafb; }
.item-photo { width: 100%; height: 160px; object-fit: cover; display: block; }
.item-photo-placeholder { width: 100%; height: 160px; border-bottom: 1px solid var(--border); border-radius: 0; }
.item-body { padding: 14px; }
.item-body h4 { font-size: 15px; margin-bottom: 6px; }
.item-body p { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.item-actions { margin-top: 10px; display: flex; gap: 6px; }

.staff-group { margin-bottom: 24px; }
.staff-group h4 { font-size: 14px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }

/* Staff organization */
.staff-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.staff-stat {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.staff-stat strong {
    display: block;
    font-size: 28px;
    line-height: 1.2;
    color: var(--text);
    margin-bottom: 4px;
}

.staff-stat span {
    font-size: 12px;
    color: var(--text-muted);
}

.staff-stat-primary {
    background: var(--primary-light);
    border-color: #f5c2c5;
}

.staff-stat-primary strong { color: var(--primary); }

.staff-section { margin-bottom: 28px; }

.staff-section-leaders {
    padding: 20px;
    border-radius: var(--radius);
    background: #fafafa;
    border: 1px solid var(--border);
}

.staff-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.staff-section-head h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.staff-section-count {
    font-size: 12px;
    color: var(--text-muted);
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 999px;
}

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

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

.staff-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 16px;
    border-top: 3px solid var(--staff-accent, #6b7280);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    transition: box-shadow .15s, transform .15s;
}

.staff-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    transform: translateY(-1px);
}

.staff-card-leader {
    padding: 20px;
    background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}

.staff-card-top {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}

.staff-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--staff-accent) 12%, white);
    color: var(--staff-accent);
    border: 2px solid color-mix(in srgb, var(--staff-accent) 35%, white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.staff-card-leader .staff-avatar {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

.staff-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.staff-card-leader .staff-name { font-size: 20px; }

.staff-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.staff-pos-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.staff-fulltime-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.staff-fulltime-badge.is-yes { background: #d1fae5; color: #065f46; }
.staff-fulltime-badge.is-no { background: #f3f4f6; color: #6b7280; }

.staff-card-meta {
    display: grid;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
    margin-bottom: 12px;
}

.staff-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.staff-meta-row span { color: var(--text-muted); flex-shrink: 0; min-width: 2.5em; }
.staff-meta-row strong {
    color: var(--text);
    font-weight: 600;
    text-align: left;
}

.staff-card-actions {
    display: flex;
    gap: 8px;
}

.pos-director { --staff-accent: #e61a23; }
.pos-deputy { --staff-accent: #0891b2; }
.pos-grid { --staff-accent: #059669; }
.pos-mediation { --staff-accent: #d97706; }
.pos-security { --staff-accent: #7c3aed; }
.pos-psych { --staff-accent: #db2777; }
.pos-legal { --staff-accent: #4f46e5; }
.pos-other { --staff-accent: #6b7280; }

@media (max-width: 768px) {
    .staff-overview { grid-template-columns: repeat(2, 1fr); }
}

/* Score grid */
.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.score-item { text-align: center; padding: 16px; background: #f9fafb; border-radius: var(--radius); }
.score-item span { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.score-item strong { font-size: 24px; color: var(--primary); }
.score-item.total { background: var(--primary-light); }
.score-item.total strong { font-size: 28px; }

/* Quick links */
.quick-links { display: flex; flex-wrap: wrap; gap: 12px; }
.quick-link {
    padding: 12px 20px;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    transition: all .15s;
}
.quick-link:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }

.text-muted { color: var(--text-muted); font-size: 14px; }
.link { font-size: 13px; }

/* Tag filters */
.filter-panel {
    background: var(--card-bg);
    border: 1px solid #e8eef5;
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.filter-panel-inset {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
    border-bottom: 1px solid #eef2f7;
}

.data-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid #e8eef5;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-card-footer {
    border-top: 1px solid #eef2f7;
    padding: 0;
}

.data-card-footer .pagination-bar {
    margin-top: 0;
    border: none;
    border-radius: 0;
    background: #fafbfd;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.filter-tags-label {
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    padding-top: 8px;
    min-width: 56px;
}

.filter-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.filter-tag {
    border: none;
    background: #f1f5f9;
    color: #475569;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    line-height: 1.4;
}

.filter-tag em {
    font-style: normal;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    background: rgba(15, 23, 42, .06);
    padding: 2px 7px;
    border-radius: 999px;
    margin-left: 8px;
}

.filter-tag:hover {
    color: var(--primary);
    background: var(--primary-light);
    text-decoration: none;
}

.filter-tag:hover em { color: var(--primary); background: rgba(var(--primary-rgb), .12); }

.filter-tag.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.25);
}

.filter-tag.active em { color: #fff; background: rgba(255, 255, 255, .22); }

.empty-state-inset {
    padding: 32px 16px;
}

.filter-tags + .filter-tags {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8ecf1;
}
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8ecf1;
}

.filter-tag-grade.grade-excellent {
    background: rgba(34, 197, 94, 0.14);
    color: #15803d;
}
.filter-tag-grade.grade-excellent em { color: #15803d; background: rgba(34, 197, 94, 0.18); }
.filter-tag-grade.grade-excellent:hover,
.filter-tag-grade.grade-excellent.active {
    background: #22c55e;
    color: #fff;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.35);
}
.filter-tag-grade.grade-excellent:hover em,
.filter-tag-grade.grade-excellent.active em { color: #fff; background: rgba(255, 255, 255, 0.22); }

.filter-tag-grade.grade-good {
    background: rgba(59, 130, 246, 0.14);
    color: #1d4ed8;
}
.filter-tag-grade.grade-good em { color: #1d4ed8; background: rgba(59, 130, 246, 0.18); }
.filter-tag-grade.grade-good:hover,
.filter-tag-grade.grade-good.active {
    background: #3b82f6;
    color: #fff;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35);
}
.filter-tag-grade.grade-good:hover em,
.filter-tag-grade.grade-good.active em { color: #fff; background: rgba(255, 255, 255, 0.22); }

.filter-tag-grade.grade-pass {
    background: rgba(245, 158, 11, 0.16);
    color: #b45309;
}
.filter-tag-grade.grade-pass em { color: #b45309; background: rgba(245, 158, 11, 0.2); }
.filter-tag-grade.grade-pass:hover,
.filter-tag-grade.grade-pass.active {
    background: #f59e0b;
    color: #fff;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}
.filter-tag-grade.grade-pass:hover em,
.filter-tag-grade.grade-pass.active em { color: #fff; background: rgba(255, 255, 255, 0.22); }

.filter-tag-grade.grade-fail {
    background: rgba(239, 68, 68, 0.14);
    color: #dc2626;
}
.filter-tag-grade.grade-fail em { color: #dc2626; background: rgba(239, 68, 68, 0.18); }
.filter-tag-grade.grade-fail:hover,
.filter-tag-grade.grade-fail.active {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}
.filter-tag-grade.grade-fail:hover em,
.filter-tag-grade.grade-fail.active em { color: #fff; background: rgba(255, 255, 255, 0.22); }

/* Org list */
.org-list-card {
    background: transparent;
    border: none;
    box-shadow: none;
    margin-bottom: 0;
}

.org-list-card > .card-body { padding: 0; }

.table-wrap {
    background: var(--card-bg);
    border: none;
    border-radius: 0;
    overflow-x: auto;
}

.table-modern {
    table-layout: fixed;
    width: 100%;
    min-width: 860px;
    border-collapse: separate;
    border-spacing: 0;
}

.table-modern th,
.table-modern td {
    border-bottom: 1px solid #eef2f7;
    text-align: left;
    vertical-align: middle;
}

.table-modern th {
    background: var(--table-head);
    font-weight: 600;
    color: #fff;
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0;
    padding: 14px 18px;
    border-bottom: none;
    white-space: nowrap;
}

.table-modern thead th:first-child { border-top-left-radius: 0; }
.table-modern thead th:last-child { border-top-right-radius: 0; }

.data-card:not(:has(.filter-panel-inset)) .table-modern thead th:first-child { border-top-left-radius: var(--radius); }
.data-card:not(:has(.filter-panel-inset)) .table-modern thead th:last-child { border-top-right-radius: var(--radius); }

.table-modern td {
    padding: 13px 18px;
    font-size: 14px;
    line-height: 1.5;
    color: #334155;
}

.table-modern tbody tr:nth-child(even) td { background: #f8fafc; }
.table-modern tbody tr:nth-child(odd) td { background: #fff; }

.table-modern tbody tr:last-child td { border-bottom: none; }

.table-modern tbody tr {
    transition: background .12s;
}

.table-modern tbody tr:hover td { background: var(--primary-light) !important; }

.table-modern .col-name { width: 18%; }
.table-modern .col-address { width: 24%; }
.table-modern .col-contact { width: 8%; }
.table-modern .col-phone { width: 12%; }
.table-modern .col-grade { width: 8%; text-align: center; }
.table-modern th.col-grade { text-align: center; }
.table-modern .col-township { width: 10%; }

.grade-badge {
    display: inline-block;
    min-width: 48px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.grade-excellent { background: #22c55e; color: #fff; }
.grade-good { background: #3b82f6; color: #fff; }
.grade-pass { background: #f59e0b; color: #fff; }
.grade-fail { background: #ef4444; color: #fff; }

.table-modern .col-grade .grade-badge {
    min-width: 52px;
}

.table-modern .col-contact,
.table-modern .col-phone,
.table-modern th.col-contact,
.table-modern th.col-phone {
    text-align: center;
}

.table-modern .col-action {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    text-align: center;
    white-space: nowrap;
    padding-left: 8px;
    padding-right: 12px;
}

.table-modern th.col-action { text-align: center; }

.table-modern.module-table .col-name { width: 22%; }
.table-modern.module-table .col-address { width: 18%; }
.table-modern.module-table .col-contact { width: 10%; }
.table-modern.module-table .col-category { width: 10%; text-align: center; }
.table-modern.module-table th.col-category { text-align: center; }
.table-modern.module-table .col-date { width: 10%; text-align: center; white-space: nowrap; }
.table-modern.module-table th.col-date { text-align: center; }
.table-modern.module-table .col-action {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.btn-table {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    border: 1px solid var(--border);
    background: #fff;
    color: #475569;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: border-color .15s, color .15s, background .15s;
}

.btn-table:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f8fafc;
    text-decoration: none;
}

.btn-table-danger {
    color: var(--error);
    border-color: #fecaca;
    background: #fef2f2;
}

.btn-table-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: var(--error);
}

.org-name {
    font-weight: 600;
    color: #1e293b;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.org-name-link {
    display: block;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .15s;
}

.org-name-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.col-muted {
    color: var(--text-muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-phone {
    font-variant-numeric: tabular-nums;
    color: #475569;
    font-size: 13px;
    white-space: nowrap;
}

.township-tag {
    display: inline-block;
    padding: 4px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

.table-action {
    display: inline-block;
    padding: 6px 14px;
    background: var(--primary);
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    white-space: nowrap;
    transition: background .15s;
    box-shadow: none;
}

.table-action:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: #fff !important;
    transform: none;
    box-shadow: none;
}

.empty-state {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding: 14px 20px;
    background: var(--card-bg);
    border: 1px solid #e8eef5;
    border-radius: var(--radius);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pagination-btn {
    min-width: 36px;
    height: 34px;
    padding: 0 10px;
    border: none;
    border-radius: 6px;
    background: #f5f5f5;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    line-height: 34px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.pagination-btn:hover:not(.disabled):not(.active) {
    background: var(--primary-light);
    color: var(--primary);
}

.pagination-btn.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: none;
}

.pagination-btn.disabled {
    color: #cbd5e1;
    background: #f8fafc;
    cursor: not-allowed;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #222 100%);
}

.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.login-header h1 { font-size: 18px; margin-bottom: 4px; }
.login-header p { font-size: 13px; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-hint { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
    display: none !important;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    visibility: hidden;
}

.modal-overlay.is-open {
    display: flex !important;
    visibility: visible;
}

body.modal-open { overflow: hidden; }

.modal {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    border: none;
    background: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-lg { max-width: 860px; }

/* Yucheng map */
.dashboard-map-card { margin-bottom: 24px; }
.dashboard-map-header {
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.dashboard-map-header .page-meta { margin-top: 6px; }

.map-grade-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-left: auto;
}

.map-grade-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.map-grade-item i {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.yucheng-map {
    width: 100%;
    height: 480px;
    min-height: 320px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #eef2f6;
}

.yucheng-map .leaflet-container { background: #eef2f6; font-family: inherit; }
.yucheng-map .map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
}

.map-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.92);
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 11px;
    color: #475569;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.map-legend .lg-grad {
    display: inline-block;
    width: 80px;
    height: 9px;
    border-radius: 5px;
    background: linear-gradient(90deg, #fee2e2, #fca5a5, #f87171, #ef4444, #dc2626, #b91c1c);
}

.map-tools {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.map-mode-switch {
    display: flex;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.map-mode-btn {
    border: none;
    background: #fff;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: #555;
    font-family: inherit;
    line-height: 1.4;
}

.map-mode-btn + .map-mode-btn {
    border-left: 1px solid var(--border);
}

.map-mode-btn:hover {
    background: #f5f5f5;
}

.map-mode-btn.active {
    background: var(--primary);
    color: #fff;
}

.map-mode-btn.active:hover {
    background: var(--primary-dark);
}

.map-fs-btn a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 15px;
    color: #334155;
    cursor: pointer;
    text-decoration: none;
}

.yucheng-map:fullscreen,
.yucheng-map:-webkit-full-screen {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.leaflet-tooltip {
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .brand-text, .sidebar .nav-item span:not(.nav-icon), .sidebar-footer .user-info > div, .sidebar-links { display: none; }
    .main-content { margin-left: 60px; padding: 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .dashboard-hero { flex-direction: column; }
    .dashboard-stats-panel { width: 100%; }
    .dashboard-stat-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        flex: none;
    }
    .dashboard-stat-item { flex: none; min-height: auto; }
    .dashboard-map-wrap .yucheng-map { min-height: 360px; }
    .yucheng-map { height: 360px; }
}
