:root {
    --red: #D62834;
    --red-dark: #B91F2B;
    --red-soft: #FDECEE;
    --ink: #24272E;
    --muted: #6B7280;
    --line: #E6E8EE;
    --bg: #F4F5F7;
    --card: #fff;
    --shadow: 0 12px 32px rgba(36, 39, 46, .06);
    --radius: 16px;
    --sidebar: 268px;
    --bs-primary: #D62834;
    --bs-primary-rgb: 214, 40, 52;
    --bs-link-color: #D62834;
    --bs-link-hover-color: #B91F2B;
    --bs-body-bg: #F4F5F7;
    --bs-body-color: #24272E;
    --bs-border-color: #E6E8EE;
    --bs-border-radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
}
a { color: var(--red); text-decoration: none; }
img { max-width: 100%; }

.btn-primary, .login-submit, .urban-login-submit {
    background: var(--red) !important;
    border-color: var(--red) !important;
    color: #fff !important;
}
.btn-primary:hover, .urban-login-submit:hover { background: var(--red-dark) !important; border-color: var(--red-dark) !important; }
.btn, .btn-rounded, .btn-ghost, .btn-light, .btn-outline-primary, .btn-outline-secondary, .btn-success, .btn-warning, .btn-danger {
    border-radius: 12px;
    font-weight: 700;
}
.btn-light, .btn-ghost, .btn-outline-secondary {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
}
.btn-outline-primary { color: var(--red); border-color: #f3c2c6; background: #fff; }
.btn-success { background: #178746; border-color: #178746; }
.btn-warning { background: #E5A32B; border-color: #E5A32B; color: #fff; }
.form-control, .form-select, textarea.form-control {
    border-radius: 12px;
    border-color: var(--line);
    min-height: 42px;
    color: var(--ink);
    background: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: #ef9aa1;
    box-shadow: 0 0 0 3px rgba(214, 40, 52, .12);
}
.form-label { font-weight: 700; font-size: 13px; color: var(--ink); }
.table { --bs-table-bg: transparent; color: var(--ink); margin: 0; }
.table thead th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
}
.table td, .table th { border-color: #f0f1f4; vertical-align: middle; }
.alert { border: 0; border-radius: 14px; }
.modal-content { border: 0; border-radius: 18px; box-shadow: 0 24px 60px rgba(17, 24, 39, .18); }
.dropdown-menu { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 22px 14px 16px;
    background: #fff;
    border-right: 1px solid var(--line);
    overflow: auto;
}
.urban-wordmark { display: block; padding: 6px 10px 18px; color: inherit; }
.urban-crown { color: var(--red); font-size: 22px; }
.urban-wordmark strong { display: block; color: var(--ink); font-size: 28px; line-height: .95; letter-spacing: -.04em; }
.urban-wordmark span, .brand-sub, .menu-group-label { color: var(--muted); font-size: 12px; }
.menu { display: grid; gap: 4px; }
.menu-group-label { display: none; }
.menu-group-links { display: grid; gap: 4px; }
.menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 12px;
    color: #3a404b;
    font-weight: 650;
}
.menu-link i {
    width: 28px; height: 28px; display: grid; place-items: center;
    border-radius: 8px; background: #f3f4f6; color: #4b5563; font-size: 15px;
}
.menu-link:hover { background: #f7f7f8; color: var(--ink); }
.menu-link.active { background: var(--red); color: #fff; }
.menu-link.active i { background: rgba(255,255,255,.18); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fafbfc; color: var(--muted); font-size: 12px; }
.sidebar-footer .btn { color: var(--ink); background: #fff; border-color: var(--line); }
.sidebar-backdrop { display: none; }

.main-content { width: calc(100% - var(--sidebar)); margin-left: var(--sidebar); min-height: 100vh; padding: 18px 22px 28px; }
.header-card { background: transparent; margin-bottom: 8px; }
.topbar { display: grid; grid-template-columns: minmax(180px, 280px) minmax(180px, 1fr) auto; align-items: center; gap: 16px; min-height: 58px; }
.topbar-left, .topbar-right, .welcome-kicker { display: flex; align-items: center; gap: 10px; }
.page-title { margin: 0; font-size: 22px; font-weight: 750; }
.welcome-kicker { font-weight: 650; }
.welcome-kicker i { color: #E5A32B; }
.page-subtitle, .text-muted, .form-text, .stat-label { color: var(--muted) !important; }
.urban-search, .icon-control, .user-pill, .date-pill, .soft-pill {
    display: flex; align-items: center; gap: 8px;
    height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
}
.urban-search { width: 100%; }
.urban-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.icon-control, .hamburger-btn {
    width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
.hamburger-btn { display: none; }
.user-pill { height: auto; min-height: 42px; border: 0; background: transparent; }
.user-avatar, .avatar-mini { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; background: var(--red-soft); color: var(--red); font-weight: 800; }
.role-chip { padding: 2px 8px; border-radius: 999px; background: var(--red-soft); color: var(--red); font-size: 12px; font-weight: 700; }
.notification-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; }
.notification-toggle { position: relative; }
.notification-panel { min-width: 280px; padding: 8px; }
.notification-head { padding: 8px 10px; font-weight: 800; }
.notification-item, .notification-empty { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; color: var(--ink); }
.notification-item:hover { background: #f7f7f8; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.gang-hero {
    min-height: 220px; margin-bottom: 16px; border-radius: 22px; overflow: hidden; color: #fff;
    background: linear-gradient(90deg, rgba(12,10,12,.78), rgba(12,10,12,.2)), url("../img/gang-hero.jpg") center right / cover no-repeat;
}
.gang-hero-copy { padding: 36px 40px; max-width: 640px; }
.gang-hero-kicker { letter-spacing: .18em; font-size: 12px; font-weight: 700; }
.gang-hero h2 { margin: 6px 0 0; font-size: 52px; line-height: .9; font-weight: 800; letter-spacing: -.04em; color: #fff; }
.gang-hero h2 span { display: block; color: #ff3b45; font-style: italic; }
.gang-hero p { margin: 10px 0 0; letter-spacing: .12em; font-weight: 700; }

.card-soft, .stat-card, .table-card, .mini-card, .workspace-panel, .chart-container, .insight-card, .house-card, .activity-card, .report-card, .summary-card, .settings-card, .login-card, .checkin-shell {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--ink);
}
.card-soft, .table-card, .chart-container, .insight-card, .checkin-shell { padding: 16px; }
.stat-card, .workspace-panel { display: flex; gap: 12px; align-items: center; padding: 16px; min-height: 96px; }
.stat-icon-ring, .workspace-panel-head i {
    width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--red-soft); color: var(--red); font-size: 18px;
}
.stat-number { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-suffix { margin-left: 4px; color: var(--muted); font-size: 13px; }
.section-title, .table-title, .chart-title, .workspace-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 800; }
.page-toolbar, .member-cell, .d-flex { }
.page-toolbar, .member-cell { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.member-cell { justify-content: flex-start; }
.table-responsive { overflow-x: auto; }
.status-badge, .activity-type-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #f3f4f6; color: #374151; }
.status-success, .seg-success { background: #e8f7ee; color: #178746; }
.status-danger, .seg-danger { background: #fdecee; color: #c42330; }
.status-warning, .seg-warning { background: #fff6e5; color: #a46b09; }
.status-info, .status-primary, .seg-info { background: var(--red-soft); color: var(--red); }
.mini-stack-chart { display: flex; height: 10px; overflow: hidden; border-radius: 999px; background: #eef0f3; }
.mini-stack-chart span { display: block; height: 100%; }
.seg-success { background: #22A559; }
.seg-warning { background: #E5A32B; }
.seg-info { background: #D62834; }
.seg-danger { background: #DC3545; }
.seg-muted { background: #d1d5db; }
.insight-legend, .member-stat-list { display: flex; flex-wrap: wrap; gap: 10px; }
.legend-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; margin-right: 4px; }
.live-progress { height: 8px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #eef0f3; }
.live-progress span { display: block; height: 100%; background: var(--red); }
.dashboard-widget-toolbar, .dashboard-insight-grid, .collection-metric { margin-bottom: 12px; }
.dashboard-workspace, .dashboard-insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.workspace-panel { flex-direction: column; align-items: stretch; }
.workspace-panel-value { font-size: 20px; font-weight: 800; }
.workspace-panel-meta { color: var(--muted); font-size: 13px; }
.widget-grip { display: flex; justify-content: flex-end; gap: 4px; }
.collection-metric { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 14px; background: #fafbfc; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.input-with-icon { position: relative; }
.input-with-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-with-icon .form-control { padding-left: 36px; }
.feedback-modal-content { text-align: center; padding: 22px; }
.feedback-modal-icon { width: 52px; height: 52px; margin: 0 auto 8px; display: grid; place-items: center; border-radius: 16px; background: var(--red-soft); color: var(--red); font-size: 22px; }

.urban-board, .urban-stats, .urban-split, .urban-people, .urban-metrics, .urban-notes { display: grid; gap: 14px; }
.urban-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.urban-split { grid-template-columns: 1.4fr .8fr; }
.urban-people { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.urban-metrics { grid-template-columns: 1fr 1fr; }
.urban-stat, .urban-panel, .urban-event, .urban-people article { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.urban-stat { display: flex; gap: 12px; align-items: center; min-height: 108px; padding: 16px; }
.urban-stat-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--red-soft); color: var(--red); font-size: 20px; }
.urban-notes small { display: block; color: var(--muted); font-size: 12px; }
.urban-stat-copy small, .urban-stat-copy > span { display: block; color: var(--muted); font-size: 12px; }
.urban-stat strong { display: block; font-size: 26px; line-height: 1.1; }
.urban-stat em, .urban-people em { font-style: normal; color: var(--muted); font-size: 13px; }
.urban-panel { padding: 16px; }
.urban-panel header, .urban-notes a { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.urban-panel header { margin-bottom: 12px; font-weight: 800; }
.urban-people article { padding: 12px; text-align: center; }
.urban-people img, .urban-people b { width: 72px; height: 72px; margin: 0 auto 8px; display: grid; place-items: center; border-radius: 16px; object-fit: cover; background: #F3F4F6; }
.urban-notes a { justify-content: flex-start; padding: 8px 0; border-bottom: 1px solid #F0F1F4; color: var(--ink); }
.urban-notes i { color: var(--red); font-size: 8px; }
.urban-event { display: grid; grid-template-columns: 180px 1fr; min-height: 132px; overflow: hidden; color: inherit; }
.urban-event img { width: 100%; height: 100%; object-fit: cover; }
.urban-event div { padding: 18px; }
.urban-event em { display: inline-block; margin-bottom: 6px; padding: 2px 8px; border-radius: 999px; background: var(--red); color: #fff; font-style: normal; font-size: 11px; font-weight: 800; }
.urban-event strong { display: block; font-size: 20px; }
.urban-metrics div { padding: 12px; border-radius: 14px; background: #F7F8FA; }
.urban-metrics strong { display: block; font-size: 22px; }
.urban-empty { margin: 0; color: var(--muted); }

.urban-login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 28px 16px;
    background: radial-gradient(circle at 12% 10%, rgba(214,40,52,.14), transparent 28%), radial-gradient(circle at 90% 90%, rgba(232,138,74,.16), transparent 26%), #F4F5F7;
}
.urban-login { width: min(460px, 100%); }
.urban-login-card { position: relative; overflow: hidden; padding: 22px; border: 1px solid var(--line); border-radius: 28px; background: #fff; box-shadow: 0 24px 60px rgba(36,39,46,.1); }
.urban-login-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: linear-gradient(90deg, #D62834, #E8894A); }
.urban-login-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 14px; }
.urban-login-thumb { width: 74px; height: 74px; object-fit: cover; border-radius: 20px; }
.urban-login-mark { color: var(--red); font-size: 12px; font-weight: 800; }
.urban-login-head h2 { margin: 2px 0 0; font-size: 26px; font-weight: 800; }
.urban-login-head p, .urban-login-foot { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.urban-login-chips { display: flex; gap: 8px; margin-bottom: 14px; }
.urban-login-chips span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--red-soft); color: var(--red-dark); font-size: 12px; font-weight: 700; }
.urban-discord, .urban-login-submit { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 46px; border: 0; border-radius: 14px; font-weight: 700; color: #fff; text-decoration: none; }
.urban-discord { background: #5865F2; }
.urban-discord:disabled { opacity: .55; }
.urban-login-submit { margin-top: 6px; background: var(--red); }
.urban-discord:hover, .urban-login-submit:hover { filter: brightness(1.05); color: #fff; }
.urban-login-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: 13px; }
.urban-login-or::before, .urban-login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.urban-field { display: block; margin-bottom: 12px; }
.urban-field > span:first-child { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.urban-input { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px 0 14px; border: 1px solid var(--line); border-radius: 14px; background: #F8F9FB; }
.urban-input:focus-within { border-color: #ef9aa1; background: #fff; box-shadow: 0 0 0 4px rgba(214,40,52,.12); }
.urban-input i { color: var(--red); }
.urban-input input { width: 100%; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.urban-eye { width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.urban-login-foot { margin-top: 12px !important; text-align: center; }
.checkin-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.checkin-shell { width: min(920px, 100%); }

.public-roster { background: var(--bg); }
.loading-screen, .floating-shapes, .sparkles, .theme-toggle, .scroll-to-top { display: none !important; }
.public-roster .container { max-width: 1180px; padding-top: 36px; padding-bottom: 48px; }
.public-roster .page-header { text-align: center; margin-bottom: 22px; }
.public-roster .page-header h1 { margin: 0; font-size: 32px; font-weight: 800; color: var(--ink); }
.public-roster .page-subtitle { margin: 6px 0 16px; color: var(--muted); }
.public-roster .search-box { position: relative; max-width: 460px; margin: 0 auto; }
.public-roster .search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.public-roster .search-input { width: 100%; height: 48px; padding: 0 16px 0 42px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); outline: none; }
.public-roster .search-input:focus { border-color: #ef9aa1; box-shadow: 0 0 0 4px rgba(214, 40, 52, .12); }
.public-roster .search-results { min-height: 22px; margin: 8px 0 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.public-roster .members-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.public-roster .member-card {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    min-height: 292px; padding: 18px 14px 14px; text-align: center;
    background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.public-roster .member-card:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(36, 39, 46, .1); }
.public-roster .member-avatar-wrapper { position: relative; width: 92px; height: 92px; }
.public-roster .member-avatar, .public-roster .member-avatar-placeholder {
    width: 92px; height: 92px; border-radius: 22px; object-fit: cover; background: var(--red-soft); color: var(--red);
}
.public-roster .member-avatar-placeholder {
    position: absolute; inset: 0; display: none; place-items: center; font-size: 28px; font-weight: 800;
}
.public-roster .member-name { font-weight: 800; line-height: 1.25; }
.public-roster .member-rank { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.public-roster .rank-leader { color: var(--red); }
.public-roster .rank-vice_leader { color: #A46B09; }
.public-roster .member-house { color: var(--muted); font-size: 13px; }
.public-roster .view-btn {
    margin-top: auto; width: 100%; height: 36px; border: 1px solid #f3c2c6; border-radius: 999px;
    background: #fff; color: var(--red); font-weight: 700; font-size: 13px;
}
.public-roster .view-btn:hover { background: var(--red); color: #fff; }
.public-roster .no-results { text-align: center; color: var(--muted); padding: 32px 0; }
.public-roster .info-section { margin-bottom: 16px; }
.public-roster .info-section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 800; }
.public-roster .info-item, .public-roster .leave-item, .public-roster .fine-item {
    display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f1f4;
}
.public-roster .value-positive { color: #178746; font-weight: 800; }
.public-roster .value-negative { color: #c42330; font-weight: 800; }

@media (max-width: 1100px) {
    .urban-stats, .urban-split, .urban-people, .dashboard-workspace, .dashboard-insight-grid { grid-template-columns: 1fr 1fr; }
    .topbar { grid-template-columns: 1fr; }
}
@media (max-width: 992px) {
    .hamburger-btn { display: grid; }
    .sidebar { transform: translateX(-105%); transition: transform .2s ease; width: min(86vw, 300px); box-shadow: 16px 0 40px rgba(17,24,39,.16); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 30; }
    .main-content { width: 100%; margin-left: 0; padding: 14px; }
    .gang-hero h2 { font-size: 36px; }
    .gang-hero-copy { padding: 24px; }
    .urban-event { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .urban-stats, .urban-split, .urban-people, .dashboard-workspace, .dashboard-insight-grid, .urban-metrics { grid-template-columns: 1fr; }
    .date-pill, .user-pill span:not(.role-chip) { display: none; }
}
