*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
}

.container { max-width: 800px; margin: 0 auto; padding: 1rem; }

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    min-height: 48px;
    line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
nav .nav-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
nav a { color: var(--text-muted); font-weight: 500; font-size: 0.95rem; }
nav a:hover { color: var(--text); text-decoration: none; }
nav .brand { color: var(--text); font-weight: 700; font-size: 1.1rem; }

input[type="text"], input[type="date"], textarea, input[type="file"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; }

.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.85rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.posisi-badge {
    display: inline-block;
    background: #e0e7ff; color: #3730a3;
    padding: 0.2rem 0.6rem; border-radius: 4px;
    font-size: 0.85rem; font-weight: 600;
}

.posisi-header {
    font-size: 1rem;
    font-weight: 700;
    margin: 1.25rem 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--primary);
    color: var(--primary);
}

/* ---------- password input ---------- */

input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
}

/* ---------- nav: role + sign out ---------- */

nav .nav-inner { flex-wrap: wrap; gap: 1rem; }
nav .nav-logout { margin-left: auto; }

.role-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}
.role-admin { background: #e0e7ff; color: #3730a3; }
.role-operator { background: #dcfce7; color: #166534; }

/* ---------- login ---------- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card { padding: 1.75rem; }
.login-title { font-size: 1.5rem; margin-bottom: 0.25rem; text-align: center; }
.login-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1.25rem;
}
.login-btn { width: 100%; margin-top: 0.25rem; }

/* ---------- roster rows ---------- */

.roster-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
}
.roster-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.btn-small, .btn-copy {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    min-height: auto;
}
.btn-copy {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
}
.btn-copy:hover { color: var(--text); border-color: var(--text-muted); }

code {
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* ---------- event page stats ---------- */

.stat-row { display: flex; gap: 0.5rem; text-align: center; }
.stat { flex: 1; }
.stat-num { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-of { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.stat-in  { color: var(--success); }
.stat-out { color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: 0.8rem; }

.no-checkout { color: var(--text-muted); }

/* ---------- check in / check out launchers ---------- */

.scan-launch { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.scan-launch .btn {
    flex: 1; text-align: center;
    font-size: 1.05rem; padding: 0.95rem 0.5rem;
    color: #fff;
}
.scan-in  { background: #16a34a; }
.scan-in:hover  { background: #15803d; text-decoration: none; }
.scan-out { background: #2563eb; }
.scan-out:hover { background: #1d4ed8; text-decoration: none; }

/* On a phone the check-in/check-out times matter more than the posisi badge,
   which is wide enough to push them off the edge. Drop it on narrow screens. */
@media (max-width: 560px) {
    .hide-narrow { display: none; }
    th, td { padding: 0.5rem 0.4rem; }
}

/* ---------- groups ---------- */

.group-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.group-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: #e0e7ff; color: #3730a3;
    padding: 0.15rem 0.55rem; border-radius: 999px;
    font-size: 0.78rem; font-weight: 600;
    text-decoration: none;
}
a.group-chip:hover { text-decoration: none; background: #c7d2fe; }
.chip-active { background: var(--primary); color: #fff; }
.chip-warn { background: #fef2f2; color: #b91c1c; }
.group-count {
    background: rgba(255,255,255,0.65); color: inherit;
    border-radius: 999px; padding: 0 0.35rem; font-size: 0.72rem;
}
.chip-active .group-count { background: rgba(255,255,255,0.28); }

.group-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }

.group-picker { display: flex; flex-direction: column; gap: 0.15rem; }
.group-option {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.6rem; border-radius: var(--radius);
    font-weight: 500; cursor: pointer;
}
.group-option:hover { background: #f1f5f9; }
.group-option input { width: 20px; height: 20px; flex-shrink: 0; }

.group-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.75rem; flex-wrap: wrap;
}
.rename-form {
    display: flex; gap: 0.5rem; margin-top: 0.75rem;
    padding-top: 0.75rem; border-top: 1px solid var(--border);
}
.rename-form input { flex: 1; }
