/* =========================================================
   PRESENSI ASN PEMKO PEMATANGSIANTAR — Design System v2
   Style: Gov Enterprise Modern (Navy + Emas)
   ========================================================= */
:root {
    /* Palette */
    --c-bg:           #f4f6fb;
    --c-bg-soft:      #eef2f9;
    --c-surface:      #ffffff;
    --c-surface-2:    #f8fafc;

    --c-ink:          #0f172a;
    --c-ink-2:        #1e293b;
    --c-muted:        #64748b;
    --c-muted-2:      #94a3b8;
    --c-border:       #e2e8f0;
    --c-border-soft:  #eef2f7;

    --c-brand:        #1e3a8a;   /* navy gov */
    --c-brand-2:      #2563eb;
    --c-brand-soft:   #dbeafe;
    --c-brand-dark:   #0b1d54;

    --c-gold:         #d4a73a;   /* aksen emas pemko */
    --c-gold-soft:    #fef3c7;

    --c-success:      #15803d;
    --c-success-soft: #dcfce7;
    --c-warn:         #b45309;
    --c-warn-soft:    #fef3c7;
    --c-danger:       #b91c1c;
    --c-danger-soft:  #fee2e2;
    --c-info:         #0e7490;
    --c-info-soft:    #cffafe;

    /* Type */
    --f-display: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --f-body:    'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Spacing */
    --s-1: .25rem;  --s-2: .5rem;   --s-3: .75rem;  --s-4: 1rem;
    --s-5: 1.25rem; --s-6: 1.5rem;  --s-7: 1.75rem; --s-8: 2rem;

    /* Radius */
    --r-sm: 8px;  --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-2xl: 28px; --r-pill: 999px;

    /* Shadow */
    --sh-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
    --sh-2: 0 6px 16px rgba(15,23,42,.06), 0 2px 6px rgba(15,23,42,.04);
    --sh-3: 0 12px 28px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.05);
    --sh-brand: 0 12px 28px rgba(30,58,138,.18);

    /* Z */
    --z-nav: 50; --z-toast: 90; --z-modal: 100;
}

@media (prefers-color-scheme: dark) {
    :root {
        --c-bg:           #0b1224;
        --c-bg-soft:      #0f172a;
        --c-surface:      #131c33;
        --c-surface-2:    #0f172a;
        --c-ink:          #e2e8f0;
        --c-ink-2:        #f1f5f9;
        --c-muted:        #94a3b8;
        --c-muted-2:      #64748b;
        --c-border:       #1e293b;
        --c-border-soft:  #1e293b;
        --c-brand-soft:   rgba(37,99,235,.15);
        --c-success-soft: rgba(34,197,94,.15);
        --c-warn-soft:    rgba(217,119,6,.15);
        --c-danger-soft:  rgba(220,38,38,.15);
        --c-info-soft:    rgba(8,145,178,.15);
        --sh-1: 0 1px 2px rgba(0,0,0,.4);
        --sh-2: 0 6px 16px rgba(0,0,0,.35);
        --sh-3: 0 12px 28px rgba(0,0,0,.45);
    }
}

/* Reset/util */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--c-bg); color: var(--c-ink); }
body {
    font-family: var(--f-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    margin: 0;
}
h1, h2, h3, h4, h5 { font-family: var(--f-display); letter-spacing: -.01em; margin: 0; }

/* Page shell */
.app-shell {
    min-height: 100vh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

.container-pwa {
    max-width: 560px;
    margin: 0 auto;
    padding: var(--s-4);
}

/* Hero header */
.hero {
    position: relative;
    background:
        radial-gradient(120% 120% at 100% 0%, rgba(212,167,58,.18), transparent 60%),
        linear-gradient(160deg, var(--c-brand) 0%, var(--c-brand-dark) 100%);
    color: #fff;
    padding: calc(env(safe-area-inset-top) + 1.1rem) 1.1rem 2.2rem;
    border-radius: 0 0 var(--r-2xl) var(--r-2xl);
    box-shadow: var(--sh-brand);
    overflow: hidden;
}
.hero::after {
    content: '';
    position: absolute; inset: auto -30% -60% auto;
    width: 70%; aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%);
    pointer-events: none;
}
.hero h1 {
    font-size: 1.5rem; font-weight: 800; margin: 0;
}
.hero h1 small { display:block; font-size: .82rem; font-weight: 500; opacity: .8; margin-top: 2px; }
.hero .crest {
    width: 42px; height: 42px; border-radius: 12px;
    background: linear-gradient(135deg, rgba(255,255,255,.2), rgba(255,255,255,.05));
    border: 1px solid rgba(255,255,255,.18);
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.hero .crest i { color: var(--c-gold); font-size: 1.25rem; }
.hero .iconbtn {
    width: 38px; height: 38px; border-radius: 12px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.14);
    color: #fff; display:inline-flex; align-items:center; justify-content:center;
    text-decoration: none;
}
.hero .iconbtn:active { transform: scale(.95); }

/* Card */
.card-pwa {
    background: var(--c-surface);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-1);
    padding: 1.05rem 1.05rem;
    margin-bottom: var(--s-4);
    border: 1px solid var(--c-border-soft);
}
.card-pwa.elevated { box-shadow: var(--sh-2); }
.card-pwa h6 { font-size: .9rem; font-weight: 700; color: var(--c-ink); margin: 0; letter-spacing: -.005em; }
.card-section-title {
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700; color: var(--c-ink); font-size: .92rem;
    margin: 1rem .25rem .5rem;
}
.card-section-title small { color: var(--c-muted); font-weight: 500; }

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; }
.stat-tile {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: .8rem .55rem;
    text-align: center;
    border: 1px solid var(--c-border-soft);
    box-shadow: var(--sh-1);
}
.stat-tile .num {
    font-family: var(--f-display);
    font-size: 1.35rem; font-weight: 800; color: var(--c-ink); line-height: 1;
}
.stat-tile .lbl {
    font-size: .67rem; color: var(--c-muted);
    text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; display:block;
}
.stat-tile.brand .num { color: var(--c-brand); }
.stat-tile.danger .num { color: var(--c-danger); }
.stat-tile.warn   .num { color: var(--c-warn); }
.stat-tile.success .num { color: var(--c-success); }

/* Pill / badge */
.pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .6rem; border-radius: var(--r-pill);
    font-size: .72rem; font-weight: 600;
    background: var(--c-bg-soft); color: var(--c-muted);
}
.pill.brand   { background: var(--c-brand-soft);   color: var(--c-brand); }
.pill.success { background: var(--c-success-soft); color: var(--c-success); }
.pill.warn    { background: var(--c-warn-soft);    color: var(--c-warn); }
.pill.danger  { background: var(--c-danger-soft);  color: var(--c-danger); }
.pill.info    { background: var(--c-info-soft);    color: var(--c-info); }

/* Buttons */
.btn-action {
    border: 0; border-radius: var(--r-lg);
    padding: 1rem 1.1rem;
    font-weight: 700; font-size: 1rem;
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    width: 100%;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    box-shadow: var(--sh-1);
}
.btn-action:active { transform: translateY(1px); }
.btn-action.primary  { background: var(--c-brand);   color: #fff; box-shadow: var(--sh-brand); }
.btn-action.success  { background: var(--c-success); color: #fff; }
.btn-action.warn     { background: var(--c-warn);    color: #fff; }
.btn-action.danger   { background: var(--c-danger);  color: #fff; }
.btn-action.ghost    { background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-border); box-shadow:none; }
.btn-action[disabled] { opacity: .55; cursor: not-allowed; }
.btn-action.loading::before {
    content: ''; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.45); border-top-color: #fff;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-link {
    background: transparent; border: 0; padding: 0;
    color: var(--c-brand); font-weight: 600; font-size: .85rem;
}
.btn-icon-sm {
    width: 36px; height: 36px; border-radius: var(--r-md);
    background: var(--c-bg-soft); color: var(--c-ink);
    border: 0; display:inline-flex; align-items:center; justify-content:center;
}

/* Form */
.field-label {
    display:block; font-weight: 600; font-size: .82rem;
    color: var(--c-ink); margin-bottom: .4rem;
}
.field {
    background: var(--c-surface); border: 1.5px solid var(--c-border);
    border-radius: var(--r-lg); padding: .85rem 1rem;
    font-size: 1rem; color: var(--c-ink); width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
    font-family: inherit;
}
.field:focus {
    outline: 0; border-color: var(--c-brand);
    box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.field.has-icon { padding-left: 2.8rem; }
.field-wrap { position: relative; }
.field-wrap > i.bi {
    position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
    color: var(--c-muted); font-size: 1.05rem;
}
.field-wrap > .toggle-pwd {
    position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
    background: transparent; border: 0; color: var(--c-muted);
    width: 36px; height: 36px; border-radius: 10px;
}
.field-error {
    color: var(--c-danger); font-size: .8rem; margin-top: .35rem;
    display: flex; align-items: center; gap: .35rem;
}
.field-help { color: var(--c-muted); font-size: .78rem; margin-top: .35rem; }

/* Bottom nav */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border-soft);
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom));
    z-index: var(--z-nav);
    box-shadow: 0 -8px 24px rgba(15,23,42,.06);
}
.bottom-nav a {
    color: var(--c-muted-2); text-decoration: none; text-align: center;
    font-size: .68rem; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: .35rem .25rem; position: relative;
}
.bottom-nav a i { font-size: 1.35rem; }
.bottom-nav a.active { color: var(--c-brand); }
.bottom-nav a.active::before {
    content: ''; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    width: 28px; height: 3px; border-radius: 0 0 6px 6px; background: var(--c-brand);
}
.bottom-nav .badge-dot {
    position: absolute; top: 4px; right: calc(50% - 16px);
    width: 8px; height: 8px; border-radius: 50%; background: var(--c-danger);
    box-shadow: 0 0 0 2px var(--c-surface);
}

/* Toast */
.toast-pwa {
    position: fixed; left: 16px; right: 16px; bottom: 100px;
    background: var(--c-ink); color: #fff;
    padding: .9rem 1rem; border-radius: var(--r-lg);
    box-shadow: var(--sh-3);
    display: none;
    z-index: var(--z-toast);
    font-size: .9rem;
}
.toast-pwa.show { display: flex; align-items: center; gap: .6rem; animation: slideUp .25s ease; }
.toast-pwa.success { background: var(--c-success); }
.toast-pwa.error   { background: var(--c-danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }

/* Modal / sheet */
.sheet-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,.55);
    z-index: var(--z-modal); display: none;
    backdrop-filter: blur(4px);
}
.sheet-backdrop.show { display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet {
    background: var(--c-surface);
    width: 100%; max-width: 560px;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    padding: 1.25rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
    box-shadow: 0 -16px 40px rgba(15,23,42,.25);
    transform: translateY(0);
    animation: slideUpSheet .25s ease;
}
@keyframes slideUpSheet { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet h4 { font-size: 1.1rem; font-weight: 800; margin-bottom: .35rem; }
.sheet .grabber {
    width: 42px; height: 4px; border-radius: 4px;
    background: var(--c-border); margin: 0 auto .75rem;
}

/* Skeleton */
.skel {
    background: linear-gradient(90deg, var(--c-bg-soft), var(--c-border-soft), var(--c-bg-soft));
    background-size: 200% 100%;
    border-radius: var(--r-md);
    animation: shimmer 1.4s linear infinite;
}
.skel-line { height: 12px; margin: 8px 0; }
.skel-circle { border-radius: 50%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Empty */
.empty-state {
    text-align: center; padding: 1.6rem 1rem; color: var(--c-muted);
}
.empty-state i { font-size: 2.6rem; opacity: .35; }
.empty-state p { margin: .5rem 0 0; font-size: .9rem; }

/* Section list (history etc) */
.list-row {
    display: flex; align-items: center; gap: .75rem; padding: .7rem .25rem;
    border-bottom: 1px solid var(--c-border-soft);
}
.list-row:last-child { border-bottom: 0; }
.list-row .avatar {
    width: 38px; height: 38px; border-radius: var(--r-md);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--c-brand-soft); color: var(--c-brand);
    font-weight: 700; flex: 0 0 auto;
}

/* Map */
.map-wrap { position: relative; border-radius: var(--r-lg); overflow: hidden; }
.map-wrap .map-overlay {
    position: absolute; left: 12px; right: 12px; bottom: 12px;
    background: rgba(15,23,42,.86); color: #fff;
    padding: .55rem .8rem; border-radius: var(--r-md);
    font-size: .8rem; backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: space-between;
}

/* Camera overlay */
.cam {
    position: relative;
    background: #0b1224;
    border-radius: var(--r-xl);
    overflow: hidden;
    aspect-ratio: 3/4;
}
.cam video { width:100%; height:100%; object-fit: cover; transform: scaleX(-1); }
.cam .face-guide {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -55%);
    width: 62%; aspect-ratio: 3/4; border-radius: 50%;
    border: 3px dashed rgba(255,255,255,.55);
    pointer-events: none;
}
.cam .pose-bottom {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: linear-gradient(transparent, rgba(0,0,0,.85));
    color: #fff; padding: 1rem;
}
.cam .pose-bottom .progress { font-size: .78rem; opacity: .85; }
.cam .pose-bottom .label { font-size: 1.2rem; font-weight: 800; margin-top: 4px; }
.cam .pose-bottom .hint { font-size: .82rem; opacity: .85; }

/* Stepper */
.stepper {
    display: flex; align-items: center; gap: .35rem;
    margin: .5rem 0 1rem;
}
.stepper .seg {
    flex: 1; height: 6px; border-radius: 4px;
    background: var(--c-border);
}
.stepper .seg.done { background: var(--c-success); }
.stepper .seg.active { background: var(--c-brand); }

/* Greeting block */
.greet {
    display: flex; align-items: center; gap: .8rem;
}
.greet .av {
    width: 46px; height: 46px; border-radius: 14px;
    background: linear-gradient(135deg, rgba(255,255,255,.25), rgba(255,255,255,.05));
    border: 1px solid rgba(255,255,255,.18);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-family: var(--f-display);
}
.greet h1 { font-size: 1.05rem; font-weight: 700; }
.greet .sub { font-size: .82rem; opacity: .85; }

/* Hero status today */
.today-card {
    background: var(--c-surface);
    border-radius: var(--r-xl);
    padding: 1rem;
    margin-top: -1.6rem;
    border: 1px solid var(--c-border-soft);
    box-shadow: var(--sh-2);
}

/* Time blocks check-in / out */
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.time-block {
    background: var(--c-surface-2);
    border: 1px solid var(--c-border-soft);
    border-radius: var(--r-md);
    padding: .7rem .8rem;
}
.time-block.in    { border-left: 3px solid var(--c-success); }
.time-block.out   { border-left: 3px solid var(--c-warn); }
.time-block .lbl  { font-size: .68rem; color: var(--c-muted); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.time-block .time { font-family: var(--f-display); font-size: 1.55rem; font-weight: 800; line-height: 1; margin-top: 4px; color: var(--c-ink); }

/* Sparkline */
.spark { width: 100%; height: 56px; }

/* Misc */
.muted { color: var(--c-muted); }
.tiny { font-size: .72rem; }
hr.soft { border: 0; border-top: 1px solid var(--c-border-soft); margin: 1rem 0; }

.fab-action {
    position: fixed;
    right: 16px; bottom: calc(96px + env(safe-area-inset-bottom));
    width: 60px; height: 60px; border-radius: 18px;
    background: var(--c-brand); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: var(--sh-brand);
    z-index: 40;
    border: 0;
}
.fab-action i { font-size: 1.6rem; }
