:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
    --header-h: 72px;
}
* { -webkit-tap-highlight-color: transparent; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; margin:0; }
code { background:#eef2f6; padding:.1em .4em; border-radius:4px; font-size:.85em; }

/* ══ LOGIN PAGE ══ */
.login-page { min-height:100dvh; background:#f8fafc; }
.login-wrapper { min-height:100dvh; display:flex; flex-direction:column; }
.login-panel { display:none; }
.login-main { flex:1; display:flex; align-items:center; justify-content:center; padding:2rem 1.25rem; }
.login-card { width:100%; max-width:420px; background:var(--surface); border-radius:20px; padding:2rem 1.75rem; box-shadow:0 20px 60px rgba(15,23,42,.1), 0 4px 16px rgba(15,23,42,.06); }
.login-card-brand { text-align:center; margin-bottom:1.75rem; }
.login-card-brand h1 { font-size:1.5rem; font-weight:700; margin:.75rem 0 .35rem; }
.login-card-brand p { font-size:.875rem; color:var(--text-muted); }
.logo-frame { display:flex; align-items:center; justify-content:center; margin:0 auto; }
.logo-frame--card-mobile { width:56px;height:56px;border-radius:16px;background:linear-gradient(135deg,var(--primary),var(--accent)); color:#fff; font-size:1.4rem; }
.login-input-group .login-input-wrap { position:relative; display:flex; align-items:center; }
.login-input-wrap i { position:absolute; left:14px; color:var(--text-muted); font-size:.9rem; }
.login-input-wrap .form-control { padding-left:2.5rem; border-radius:12px; padding-top:.65rem; padding-bottom:.65rem; border-color:var(--border); }
.btn-login-submit { background:var(--primary); border:none; border-radius:12px; padding:.7rem; font-weight:600; color:#fff; }
.btn-login-submit:hover { opacity:.9; color:#fff; }
.login-help-text { text-align:center; font-size:.8rem; color:var(--text-muted); margin-top:1.25rem; }
.app-alert { padding:.7rem .9rem; border-radius:10px; font-size:.83rem; display:flex; gap:.5rem; align-items:flex-start; margin-bottom:1rem; }
.app-alert-danger { background:#fee2e2; color:#991b1b; }

@media (min-width:992px) {
    .login-wrapper { flex-direction:row; }
    .login-panel { display:flex; flex-direction:column; justify-content:space-between; width:42%; background:linear-gradient(160deg,var(--primary-dark),var(--primary) 60%,var(--accent)); padding:3rem 3rem 2rem; color:#fff; }
    .login-panel-inner { max-width:380px; }
    .logo-frame--panel { width:56px;height:56px;border-radius:16px;background:rgba(255,255,255,.15); font-size:1.5rem; margin-bottom:1.5rem; margin-left:0; }
    .login-panel-title { font-size:1.7rem; font-weight:800; margin-bottom:.75rem; }
    .login-panel-desc { font-size:.92rem; opacity:.85; line-height:1.7; margin-bottom:2rem; }
    .login-features { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:.9rem; }
    .login-features li { font-size:.88rem; display:flex; align-items:center; gap:.7rem; opacity:.92; }
    .login-panel-footer { opacity:.6; font-size:.78rem; }
    .login-main { width:58%; }
    .logo-frame--card-mobile { display:none; }
}

/* ══ APP LAYOUT (dashboard) ══ */
.app-body { background:var(--bg); }
.app-layout { display:flex; min-height:100dvh; }

.app-sidebar {
    display:flex; flex-direction:column; width:250px;
    background:linear-gradient(180deg,var(--primary-dark),var(--primary));
    position:fixed; top:0; bottom:0; left:0; z-index:1040;
    transform:translateX(-100%); transition:transform .25s ease;
}
.app-sidebar.show { transform:translateX(0); box-shadow:var(--shadow-lg); }

.sidebar-backdrop {
    display:none; position:fixed; inset:0; background:rgba(15,23,42,.5); z-index:1035;
}
.sidebar-backdrop.show { display:block; }

.sidebar-brand { padding:1.25rem 1.1rem; display:flex; align-items:center; gap:.65rem; }
.logo-frame--sidebar { width:40px;height:40px;border-radius:11px;background:rgba(255,255,255,.15); color:#fff; font-size:1.15rem; flex-shrink:0; }
.sidebar-brand-text { color:#fff; font-weight:700; font-size:.95rem; flex:1; }
.btn-close-sidebar { background:none; border:none; color:rgba(255,255,255,.75); font-size:1.1rem; padding:.25rem; }

.sidebar-nav { flex:1; padding:.5rem .75rem; display:flex; flex-direction:column; gap:.2rem; }
.sidebar-item { width:100%; display:flex; align-items:center; gap:.7rem; padding:.65rem .85rem; border-radius:10px; background:none; border:none; color:rgba(255,255,255,.78); font-size:.88rem; font-weight:500; text-align:left; cursor:pointer; text-decoration:none; }
.sidebar-item:hover { background:rgba(255,255,255,.1); color:#fff; text-decoration:none; }
.sidebar-item.active { background:rgba(255,255,255,.18); color:#fff; }
.sidebar-footer { padding:.75rem; border-top:1px solid rgba(255,255,255,.12); }
.sidebar-logout { color:rgba(255,255,255,.78); }

.app-content { flex:1; min-width:0; }

@media (min-width:992px) {
    .app-sidebar { transform:translateX(0); box-shadow:none; }
    .app-content { margin-left:250px; }
    .sidebar-backdrop { display:none !important; }
    .btn-close-sidebar { display:none; }
}

.btn-hamburger { width:36px;height:36px; border-radius:9px; border:1px solid var(--border); background:#fff; color:var(--text-muted); flex-shrink:0; display:inline-flex; align-items:center; justify-content:center; }
.app-header { background:var(--surface); border-bottom:1px solid var(--border); padding:1rem 1.25rem; position:sticky; top:0; z-index:10; }
.header-content { display:flex; align-items:center; justify-content:space-between; max-width:900px; margin:0 auto; }
.header-user { display:flex; align-items:center; gap:.75rem; }
.user-avatar { width:42px;height:42px;border-radius:50%; background:#dbeafe; color:var(--primary); display:flex; align-items:center; justify-content:center; }
.greeting { margin:0; font-size:.75rem; color:var(--text-muted); }
.user-name { margin:0; font-size:1rem; font-weight:700; }
.btn-header-icon { width:38px;height:38px; border-radius:10px; border:1px solid var(--border); background:#fff; display:flex; align-items:center; justify-content:center; color:var(--text-muted); }

.app-main { max-width:900px; margin:0 auto; padding:1.25rem; }

.stat-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:.75rem; margin-bottom:1rem; }
.stat-card { background:var(--surface); border-radius:var(--radius-sm); padding:1rem; box-shadow:var(--shadow); border:1px solid var(--border); display:flex; align-items:center; gap:.75rem; }
.stat-icon { width:40px;height:40px;border-radius:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.stat-icon.blue { background:#dbeafe; color:var(--primary); }
.stat-icon.orange { background:#fef3c7; color:var(--warning); }
.stat-value { font-size:1.15rem; font-weight:700; }
.stat-label { font-size:.72rem; color:var(--text-muted); }

.info-card { background:var(--surface); border-radius:var(--radius-sm); padding:1.1rem 1.2rem; box-shadow:var(--shadow); border:1px solid var(--border); margin-bottom:.85rem; }
.info-card-header { margin-bottom:.75rem; }
.info-card-title { font-weight:700; font-size:.95rem; margin:0; }
.form-label-sm { font-size:.78rem; font-weight:600; margin-bottom:.3rem; display:block; }
.app-hint { font-size:.76rem; color:var(--text-muted); }

.btn-connect { background:var(--primary); border:none; border-radius:10px; padding:.65rem; font-weight:600; color:#fff; }
.btn-connect:hover { opacity:.9; color:#fff; }

.conn-status-box { margin-top:.85rem; font-size:.85rem; padding:.6rem .8rem; border-radius:8px; background:var(--bg); display:none; }
.conn-status-box.show { display:block; }
.conn-status-box.ok { color:#065f46; background:#d1fae5; }
.conn-status-box.warn { color:#92400e; background:#fef3c7; }
.conn-status-box.err { color:#991b1b; background:#fee2e2; }

.qr-wrap { text-align:center; margin-top:1rem; }
.qr-wrap img { max-width:220px; border:1px solid var(--border); border-radius:10px; padding:8px; background:#fff; }

.apikey-box { font-family:monospace; font-size:.8rem; background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:.6rem .75rem; word-break:break-all; display:flex; align-items:center; gap:.5rem; }
.btn-icon-copy { border:1px solid var(--border); background:#fff; width:30px;height:30px;border-radius:7px; flex-shrink:0; color:var(--text-muted); }

.code-block { background:#0f172a; color:#e2e8f0; padding:.9rem 1rem; border-radius:10px; font-size:.76rem; overflow-x:auto; white-space:pre; }

#toastHost { position:fixed; bottom:20px; right:20px; z-index:2000; display:flex; flex-direction:column; gap:8px; }
.app-toast { background:#111827; color:#fff; padding:.7rem 1rem; border-radius:10px; font-size:.85rem; box-shadow:var(--shadow-lg); min-width:220px; }

/* ══ DOKUMENTASI ══ */
.doc-table { width:100%; font-size:.83rem; border-collapse:collapse; }
.doc-table td { padding:.5rem .4rem; border-bottom:1px solid var(--border); vertical-align:top; }
.doc-table td:first-child { font-weight:600; white-space:nowrap; width:130px; }
.doc-table tr:last-child td { border-bottom:none; }
.doc-badge { display:inline-block; padding:.15em .55em; border-radius:6px; font-size:.72rem; font-weight:700; background:#dbeafe; color:#1e40af; }
.doc-badge-red { background:#fee2e2; color:#991b1b; }
.doc-badge-orange { background:#fef3c7; color:#92400e; }

.code-tabs { display:flex; gap:.4rem; margin-bottom:.75rem; flex-wrap:wrap; }
.code-tab { padding:.4rem .9rem; border-radius:8px; border:1px solid var(--border); background:#fff; font-size:.8rem; font-weight:600; color:var(--text-muted); cursor:pointer; }
.code-tab.active { background:var(--primary); border-color:var(--primary); color:#fff; }
.btn-copy-code { margin-top:.75rem; border:1px solid var(--border); background:#fff; border-radius:8px; padding:.5rem 1rem; font-size:.82rem; font-weight:600; color:var(--text); }
.btn-copy-code:hover { background:var(--bg); }

.doc-tips { margin:0; padding-left:1.1rem; font-size:.83rem; color:var(--text); }
.doc-tips li { margin-bottom:.55rem; line-height:1.6; }
.doc-tips li:last-child { margin-bottom:0; }

.code-block { max-height:420px; }

/* ══ REGISTER PAGE ══ */
.app-alert-success { background:#d1fae5; color:#065f46; }
.btn-register-link { display:flex; align-items:center; justify-content:center; margin-top:.6rem; border:1px solid var(--border); border-radius:12px; padding:.65rem; font-weight:600; font-size:.9rem; color:var(--text); text-decoration:none; background:#fff; }
.btn-register-link:hover { background:var(--bg); color:var(--text); text-decoration:none; }

.register-wrap { min-height:100dvh; padding:2.5rem 1.25rem; max-width:1000px; margin:0 auto; }
.register-header { text-align:center; margin-bottom:2rem; }
.register-header h1 { font-size:1.6rem; font-weight:800; margin-bottom:.35rem; }
.register-header p { color:var(--text-muted); font-size:.9rem; }

.package-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:1rem; margin-bottom:2rem; }
@media (max-width:900px){ .package-grid { grid-template-columns:repeat(2,1fr); } }
@media (max-width:560px){ .package-grid { grid-template-columns:1fr; } }

.package-card { position:relative; display:block; background:var(--surface); border:2px solid var(--border); border-radius:var(--radius-sm); padding:1.25rem 1.1rem; cursor:pointer; transition:border-color .15s, box-shadow .15s; }
.package-card input { position:absolute; opacity:0; }
.package-card:hover { border-color:var(--primary-light); }
.package-card.selected { border-color:var(--primary); box-shadow:0 0 0 3px rgba(30,64,175,.12); }
.package-name { font-weight:800; font-size:1.05rem; margin-bottom:.25rem; }
.package-price { font-size:1.1rem; font-weight:700; color:var(--primary); margin-bottom:.75rem; }
.package-price span { font-size:.7rem; font-weight:500; color:var(--text-muted); }
.package-feat { list-style:none; padding:0; margin:0 0 .75rem; }
.package-feat li { font-size:.78rem; color:var(--text); margin-bottom:.35rem; }
.package-feat li i { color:var(--success); margin-right:.35rem; }
.package-note { font-size:.7rem; font-weight:600; color:var(--text-muted); background:var(--bg); padding:.3rem .5rem; border-radius:6px; text-align:center; }
.package-card.selected .package-note { background:#dbeafe; color:var(--primary); }

.register-card { max-width:460px; margin:0 auto; background:var(--surface); border-radius:20px; padding:2rem 1.75rem; box-shadow:0 20px 60px rgba(15,23,42,.1), 0 4px 16px rgba(15,23,42,.06); }
.register-card .form-control { border-radius:10px; padding:.6rem .8rem; border-color:var(--border); font-size:.9rem; }

/* ══ DEVICE TABLE (mirip Fonnte) ══ */
.btn-add-device { background:var(--primary); border:none; border-radius:8px; padding:.45rem .9rem; font-size:.78rem; font-weight:600; color:#fff; white-space:nowrap; }
.btn-add-device:hover { opacity:.9; color:#fff; }

.device-table-wrap { margin-top:.9rem; }
.device-table { width:100%; border-collapse:collapse; font-size:.83rem; }
.device-table thead th { text-align:left; font-size:.7rem; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted); padding:.4rem .3rem; border-bottom:1px solid var(--border); }
.device-table tbody td { padding:.55rem .3rem; border-bottom:1px solid var(--border); vertical-align:middle; }
.device-table tbody tr:last-child td { border-bottom:none; }

.device-status-badge { display:inline-block; padding:.2em .6em; border-radius:6px; font-size:.72rem; font-weight:600; }
.device-status-badge.unknown { background:#f1f5f9; color:var(--text-muted); }
.device-status-badge.checking { background:#fef3c7; color:#92400e; }
.device-status-badge.ok { background:#d1fae5; color:#065f46; }
.device-status-badge.err { background:#fee2e2; color:#991b1b; }

.device-actions { text-align:right; white-space:nowrap; }
.btn-device-action { width:30px;height:30px; border-radius:7px; border:1px solid var(--border); background:#fff; color:var(--text-muted); margin-left:.3rem; }
.btn-device-action:hover { background:var(--bg); }
.btn-device-action.danger:hover { background:#fee2e2; color:var(--danger); border-color:#fecaca; }

.add-device-form { margin-top:1rem; padding-top:1rem; border-top:1px dashed var(--border); }