:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff4ff;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --green: #16a34a;
    --green-soft: #dcfce7;
    --amber: #d97706;
    --amber-soft: #fef3c7;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --radius: 18px;
    --shadow: 0 6px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
svg { display: block; }
/* Ikon <x-app-icon>: ukuran dari atribut width/height, jangan menyusut di flex */
.app-ico { flex: 0 0 auto; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    padding-bottom: 76px;
}
a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.app-bar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; background: var(--primary);
    color: #fff; border-radius: 0 0 24px 24px;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .22);
}
.app-bar .brand { font-weight: 800; font-size: 18px; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-bar .brand small { display: block; font-weight: 500; font-size: 11px; opacity: .85; }
.app-bar .brand > span:last-child { min-width: 0; overflow: hidden; }
.app-bar .brand > span:last-child small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar .avatar-sm {
    width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px;
    overflow: hidden;
}
.app-bar .avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.app-bar .bell {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,.15);
}
.app-bar .bell .dot-badge {
    position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px;
    background: #ef4444; color: #fff; border-radius: 10px; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
    border: 2px solid var(--primary);
}
.container { max-width: 640px; margin: 0 auto; padding: 16px 16px 8px; }
.page-title { font-size: 18px; font-weight: 700; margin: 4px 0 14px; }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; margin-bottom: 14px; border: 1px solid rgba(15,23,42,.03);
}
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-weight: 700; font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- Stat cards ---------- */
.stat { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 14px 18px; border: 0; border-radius: 14px;
    font-size: 15px; font-weight: 700; cursor: pointer; transition: .15s;
    background: var(--primary); color: #fff;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-ghost { background: #eef2f7; color: var(--text); }
.btn-sm { padding: 9px 14px; font-size: 13px; width: auto; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
    border-radius: 999px; font-size: 11px; font-weight: 700;
    background: #eef2f7; color: var(--muted);
}
.badge.success { background: var(--green-soft); color: var(--green); }
.badge.warning { background: var(--amber-soft); color: var(--amber); }
.badge.danger { background: var(--red-soft); color: var(--red); }
.badge.info { background: var(--primary-soft); color: var(--primary); }

/* ---------- Forms ---------- */
label.field { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
    border-radius: 12px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }

/* ---------- Selfie / face ---------- */
.camera-wrap {
    position: relative; width: 100%; aspect-ratio: 3/4; max-height: 340px;
    background: #0f172a; border-radius: 16px; overflow: hidden; display: flex;
    align-items: center; justify-content: center;
}
.camera-wrap video, .camera-wrap img { width: 100%; height: 100%; object-fit: cover; }
.camera-wrap .hint { color: #94a3b8; font-size: 13px; text-align: center; padding: 20px; }
.face-ring {
    position: absolute; inset: 12% 18%; border: 3px dashed rgba(255,255,255,.7);
    border-radius: 50%; pointer-events: none;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    display: flex; align-items: stretch;
    background: #fff; border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px rgba(15, 23, 42, .05);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 6px 2px; border-radius: 12px;
    font-size: 10px; line-height: 1.15; font-weight: 700;
    color: var(--muted); transition: color .15s, background .15s;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a .nav-label {
    display: block; max-width: 100%; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }

/* ---------- Desktop: batasi lebar shell agar tetap rapi ---------- */
@media (min-width: 700px) {
    .app-bar {
        max-width: 640px; margin: 0 auto;
        border-left: 1px solid var(--border); border-right: 1px solid var(--border);
    }
    .bottom-nav {
        max-width: 640px; width: 100%; left: 50%; right: auto;
        transform: translateX(-50%);
        border-left: 1px solid var(--border); border-right: 1px solid var(--border);
        border-radius: 18px 18px 0 0;
    }
}

/* ---------- Toast ---------- */
#toast {
    position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
    background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px;
    font-size: 13.5px; max-width: 90%; opacity: 0; pointer-events: none;
    transition: .25s; z-index: 100; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
#toast.error { background: var(--red); }
#toast.success { background: var(--green); }

/* ---------- Misc ---------- */
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13.5px; }
.chip { display: inline-block; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1.5px solid var(--border); font-size: 12.5px; margin: 0 6px 6px 0; cursor: pointer; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.section-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 8px; }
.install-bar {
    display: none; align-items: center; justify-content: space-between; gap: 10px;
    background: #111827; color: #fff; padding: 12px 16px; border-radius: 14px; margin-bottom: 14px; font-size: 13px;
}
.install-bar.show { display: flex; }
.timer { font-variant-numeric: tabular-nums; font-size: 40px; font-weight: 800; letter-spacing: -1px; text-align: center; }
.offline-banner { display: none; background: var(--amber-soft); color: var(--amber); padding: 8px 16px; font-size: 12.5px; text-align: center; font-weight: 600; }
body.is-offline .offline-banner { display: block; }

/* ---------- Hero (beranda) ---------- */
.hero-card {
    background: linear-gradient(145deg, #2563eb 0%, #4f46e5 100%);
    color: #fff; border-radius: 22px; padding: 20px; margin-bottom: 16px;
    box-shadow: 0 12px 30px rgba(37, 99, 235, .28);
    position: relative; overflow: hidden;
}
.hero-card::after {
    content: ''; position: absolute; right: -40px; top: -40px;
    width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.08);
}
.hero-card .hi { font-size: 12.5px; opacity: .85; }
.hero-card .nm { font-size: 19px; font-weight: 800; margin-top: 2px; }
.hero-card .sub { font-size: 12.5px; opacity: .9; margin-top: 6px; }
.hero-badge {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
    background: rgba(255,255,255,.18); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700;
}

/* ---------- Quick actions ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-item {
    background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
    padding: 12px 6px; text-align: center; display: flex; flex-direction: column;
    align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; color: var(--text);
    border: 1px solid rgba(15,23,42,.03);
}
.quick-item .qi-ico {
    width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft);
    color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.quick-item.q-green .qi-ico { background: var(--green-soft); color: var(--green); }
.quick-item.q-amber .qi-ico { background: var(--amber-soft); color: var(--amber); }
.quick-item.q-red .qi-ico { background: var(--red-soft); color: var(--red); }

/* ---------- Status ring / clock ---------- */
.clock-wrap { text-align: center; padding: 10px 0 4px; }
.clock-big { font-size: 44px; font-weight: 800; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; line-height: 1; }
.clock-date { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- Stat pills ---------- */
.stat-pill {
    flex: 1; background: #f8fafc; border-radius: 14px; padding: 12px; text-align: center;
    border: 1px solid rgba(15,23,42,.04);
}
.stat-pill .n { font-size: 20px; font-weight: 800; }
.stat-pill .l { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 600; }

/* ---------- List rows with icon ---------- */
.row {
    display: flex; align-items: center; gap: 12px; padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row .ico-box {
    flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft);
    color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.row .ico-box.green { background: var(--green-soft); color: var(--green); }
.row .ico-box.amber { background: var(--amber-soft); color: var(--amber); }
.row .ico-box.red { background: var(--red-soft); color: var(--red); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 700; font-size: 14px; }
.row .s { color: var(--muted); font-size: 12px; margin-top: 1px; }

/* ---------- Segmented tabs ---------- */
.seg { display: flex; background: #eef2f7; border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button {
    flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 11px;
    font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer; font-family: inherit;
}
.seg button.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.seg button .cnt {
    display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 5px;
    border-radius: 8px; background: var(--red); color: #fff;
    font-size: 9.5px; line-height: 16px; font-weight: 800; vertical-align: middle;
}
.seg button.active .cnt { background: var(--primary); }

/* ---------- Pesan ---------- */
.msg-item { border-bottom: 1px solid var(--border); padding: 13px 0; cursor: pointer; }
.msg-item:last-child { border-bottom: 0; }
.msg-item .msg-head { display: flex; align-items: center; gap: 11px; }
.msg-item .msg-body { display: none; padding: 10px 0 0 51px; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.msg-item.open .msg-body { display: block; }
.msg-item .msg-chev { transition: transform .2s; color: var(--muted); }
.msg-item.open .msg-chev { transform: rotate(180deg); }
.msg-item.is-unread .t { font-weight: 800; }
.dot-unread {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--red); margin-right: 7px; vertical-align: middle;
}
.msg-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- Section head ---------- */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.sec-head .st { font-size: 14.5px; font-weight: 800; }
.sec-head a { font-size: 12px; font-weight: 700; color: var(--primary); }

/* ---------- Avatar besar ---------- */
.avatar-lg { width: 62px; height: 62px; border-radius: 20px; overflow: hidden;
    background: var(--primary-soft); color: var(--primary); display: flex; align-items: center;
    justify-content: center; font-weight: 800; font-size: 20px; }
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Buttons: varian blok ---------- */
.btn-block { display: flex; gap: 10px; }
.btn-block .btn { width: 100%; }

/* ---------- Camera status ---------- */
.cam-status { font-size: 12.5px; font-weight: 700; margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.notice {
    display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.5;
    background: var(--primary-soft); color: var(--primary-dark); padding: 10px 12px; border-radius: 12px;
}
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.notice.danger { background: var(--red-soft); color: var(--red); }
.state-chip { display:inline-flex; align-items:center; gap:5px; font-weight:700; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pl 1.2s infinite; }
@keyframes pl { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

