:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ===== Kiosk ===== */
.kiosk-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    padding: 16px;
}

.kiosk-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.kiosk-card h1 { margin-top: 0; font-size: 22px; }
.kiosk-card .subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }

.employee-input {
    width: 100%;
    font-size: 28px;
    letter-spacing: 6px;
    text-align: center;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.employee-input:focus { outline: none; border-color: var(--primary); }

.type-toggle { display: flex; gap: 10px; margin-bottom: 20px; }
.type-toggle button {
    flex: 1;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    transition: all .15s;
}
.type-toggle button.active.in { border-color: var(--success); background: #ecfdf5; color: var(--success); }
.type-toggle button.active.out { border-color: var(--danger); background: #fef2f2; color: var(--danger); }

.btn {
    display: inline-block;
    padding: 12px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.btn.secondary { background: #6b7280; }
.btn.danger { background: var(--danger); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }

.video-box {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #111827;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
    display: none;
}
.video-box.active { display: block; }
.video-box video, .video-box canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.video-box video { transform: scaleX(-1); } /* tampilan cermin, lebih natural saat memindai */

.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 58%;
    height: 78%;
    transform: translate(-50%, -50%);
    border-radius: 50% / 55%;
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 2000px rgba(17, 24, 39, 0.55);
    pointer-events: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.face-guide.detected {
    border-color: var(--success);
    box-shadow: 0 0 0 2000px rgba(17, 24, 39, 0.55), 0 0 18px 2px rgba(22, 163, 74, 0.65);
}
.face-guide.warn {
    border-color: var(--warning);
    box-shadow: 0 0 0 2000px rgba(17, 24, 39, 0.55), 0 0 18px 2px rgba(217, 119, 6, 0.55);
}
.video-box.active .face-guide {
    animation: guide-pulse 1.8s ease-in-out infinite;
}
.video-box.active .face-guide.detected,
.video-box.active .face-guide.warn {
    animation: none;
}
@keyframes guide-pulse {
    0%, 100% { border-color: rgba(255, 255, 255, 0.85); }
    50% { border-color: rgba(255, 255, 255, 0.4); }
}

.face-guide-hint {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    background: rgba(17, 24, 39, 0.65);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
    pointer-events: none;
    white-space: nowrap;
    transition: background .2s ease, color .2s ease;
}
.face-guide-hint.detected { background: rgba(22, 163, 74, 0.85); }
.face-guide-hint.warn { background: rgba(217, 119, 6, 0.85); }

.status-msg {
    margin-top: 14px;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    display: none;
}
.status-msg.show { display: block; }
.status-msg.info { background: #eff6ff; color: #1e40af; }
.status-msg.success { background: #ecfdf5; color: #15803d; }
.status-msg.error { background: #fef2f2; color: #b91c1c; }
.status-msg.warn { background: #fffbeb; color: #b45309; }

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin-right: 6px;
    vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Admin ===== */
.admin-header {
    background: #111827;
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.admin-header .brand { font-weight: 700; font-size: 17px; color: #fff; }
.admin-header nav a {
    color: #d1d5db;
    margin-left: 18px;
    font-size: 14px;
    font-weight: 500;
}
.admin-header nav a:hover, .admin-header nav a.active { color: #fff; text-decoration: none; }
.admin-header .user-info { font-size: 13px; color: #9ca3af; }

.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-title h1 { font-size: 22px; margin: 0; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .label { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 700; }

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

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.in { background: #ecfdf5; color: #15803d; }
.badge.out { background: #fef2f2; color: #b91c1c; }
.badge.on { background: #ecfdf5; color: #15803d; }
.badge.off { background: #f3f4f6; color: #6b7280; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input[type=text], .form-group input[type=password], .form-group input[type=date], .form-group input[type=time], .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert.error { background: #fef2f2; color: #b91c1c; }
.alert.success { background: #ecfdf5; color: #15803d; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #111827; }
.login-card { background: #fff; padding: 32px; border-radius: 14px; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 20px; margin-top: 0; }

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

.face-preview {
    width: 160px; height: 160px;
    border-radius: 12px;
    background: #f3f4f6;
    border: 1px solid var(--border);
    object-fit: cover;
    display: block;
    margin-bottom: 10px;
}

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
