:root {
    --bg-dark: #050505;
    --panel-bg: rgba(20, 20, 20, 0.85);
    --panel-border: rgba(255, 255, 255, 0.15);
    
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    
    --accent-primary: #dc2626; /* Red */
    --accent-hover: #b91c1c;
    --accent-gradient: linear-gradient(135deg, #ef4444, #b91c1c);
    
    --success: #dc2626; /* Using Red for present/success */
    --success-bg: rgba(220, 38, 38, 0.12);
    --success-border: rgba(220, 38, 38, 0.35);
    --danger: #737373; /* Grey for absent */
    
    /* Touch-friendly sizes */
    --touch-target: 56px;
    --border-radius: 16px;
    --border-radius-sm: 10px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Outfit', 'Sarabun', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport height for mobile */
    overflow-x: hidden;
    position: relative;
}

/* Background blobs */
.background-elements {
    display: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.4;
    animation: float 12s ease-in-out infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -20%;
    width: 70vw;
    height: 70vw;
    background: radial-gradient(circle, #8b5cf6, rgba(139, 92, 246, 0));
}

.blob-2 {
    bottom: -15%;
    right: -20%;
    width: 80vw;
    height: 80vw;
    background: radial-gradient(circle, #3b82f6, rgba(59, 130, 246, 0));
    animation-delay: -6s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 8%) scale(1.08); }
}

/* ====== APP SHELL ====== */
.app-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* ====== HEADER ====== */
.app-header {
    padding: 1.5rem 1.25rem 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(15, 15, 15, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--panel-border);
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.accent-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

/* ====== STATS BAR ====== */
.stats-box {
    display: flex;
    justify-content: space-around;
    padding: 0.9rem 1rem;
    background: rgba(15, 15, 15, 0.5);
    border-bottom: 1px solid var(--panel-border);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ====== CONTROLS ====== */
.controls-section {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: rgba(15, 15, 15, 0.4);
    border-bottom: 1px solid var(--panel-border);
    position: sticky;
    top: 100px;
    z-index: 9;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.search-box input {
    width: 100%;
    height: var(--touch-target);
    background: rgba(20, 20, 20, 0.7);
    border: 1.5px solid var(--panel-border);
    border-radius: var(--border-radius);
    padding: 0 1rem 0 2.75rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--accent-primary);
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

/* ====== FILTER DROPDOWNS ====== */
.filter-dropdowns {
    display: flex;
    gap: 0.5rem;
}

.custom-select {
    flex: 1;
    height: 44px;
    background: rgba(20, 20, 20, 0.7);
    border: 1.5px solid var(--panel-border);
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0 1rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
    transition: var(--transition);
}

.custom-select:focus {
    border-color: var(--accent-primary);
}

.custom-select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* ====== PEOPLE LIST ====== */
.list-section {
    flex: 1;
    padding: 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    overflow-y: auto;
    padding-bottom: 100px; /* room for reset btn */
}

/* List header hidden on mobile (not needed) */
.list-header {
    display: none;
}

.people-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* ====== PERSON CARD ====== */
.person-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--border-radius);
    transition: var(--transition);
    cursor: pointer;
    user-select: none;
    min-height: 70px;
    -webkit-user-select: none;
}

.person-card:active {
    transform: scale(0.97);
    background: rgba(255,255,255, 0.08);
}

.person-card.is-present {
    background: var(--success-bg);
    border-color: var(--success-border);
}

.person-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex: 1;
    min-width: 0;
}

.person-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
    flex-shrink: 0;
}

.person-card.is-present .person-avatar {
    background: var(--success);
}

.person-text {
    min-width: 0;
}

.person-name {
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-id {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Status Badge on Card */
.person-status-badge {
    flex-shrink: 0;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.person-status-badge.badge-present {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.person-status-badge.badge-absent {
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.08);
}

/* Divider label */
.section-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.25rem;
    margin-top: 0.25rem;
}

/* Hidden */
.check-toggle {
    display: none;
}

/* ====== EMPTY STATE ====== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
    color: var(--text-secondary);
    gap: 1rem;
}

.empty-state.hidden {
    display: none;
}

/* ====== BOTTOM ACTIONS ====== */
.actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem 1rem;
    background: rgba(15, 15, 15, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--panel-border);
    z-index: 10;
    max-width: 600px;
    margin: 0 auto;
}

.btn {
    width: 100%;
    height: var(--touch-target);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    user-select: none;
    -webkit-user-select: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    box-shadow: none;
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid rgba(239, 68, 68, 0.4);
    color: rgba(239, 68, 68, 0.75);
}

.btn-outline:active {
    background: rgba(239, 68, 68, 0.1);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
}

.btn-primary:active {
    opacity: 0.9;
}

/* ====== MODAL ====== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(9, 14, 30, 0.82);
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Slide up from bottom like native mobile */
    z-index: 100;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease, visibility 0.25s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    padding: 1.5rem 1.5rem 2rem;
    background: #111111;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border: 1px solid var(--panel-border);
    border-bottom: none;
    box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.hidden .modal-content {
    transform: translateY(100%);
}

/* Bottom sheet drag handle */
.modal-content::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 0 auto 1.25rem;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.close-btn:active {
    background: rgba(255,255,255,0.15);
}

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.modal-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 2rem;
    color: white;
    margin-bottom: 0.25rem;
}

.modal h2 {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin: 0;
}

.modal .person-id {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.modal-room-large {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-primary);
    background: rgba(220, 38, 38, 0.15);
    padding: 0.6rem 2rem;
    border-radius: 16px;
    margin: 0.75rem 0;
    border: 2px solid var(--accent-primary);
    text-align: center;
    letter-spacing: -0.02em;
}

.person-room-badge {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    margin-right: 0.5rem;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.modal-status {
    margin-top: 0.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.modal-actions {
    width: 100%;
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.modal-actions .btn {
    height: 58px;
    font-size: 1.05rem;
}

.hidden {
    display: none !important;
}

/* ====== GLASS PANEL (unused but kept) ====== */
.glass-panel {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ====== DESKTOP BREAKPOINT ====== */
@media (min-width: 600px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: 24px;
        border-bottom: 1px solid var(--panel-border);
        max-width: 420px;
        padding: 2rem;
    }

    .modal-content::before {
        display: none;
    }
    
    .actions {
        left: 50%;
        transform: translateX(-50%);
        width: 600px;
        border-radius: 0;
    }
}
