/* ===== Tema (terang = default, gelap lewat data-theme="dark") ===== */
:root {
  --bg: #f3f4fa;
  --card: #ffffff;
  --text: #1d2230;
  --muted: #7a8196;
  --border: #e7e9f2;
  --topbar: #ffffff;
  --sidebar: #ffffff;
  --primary: #d2202f;
  --primary-d: #a8141f;
  --primary-soft: #fde8ea;
  --ok: #17a673;       --ok-soft: #e3f6ee;
  --info: #4f6bed;     --info-soft: #e9edff;
  --warn: #d98a00;     --warn-soft: #fff3d6;
  --danger: #e03a3a;   --danger-soft: #fde8e8;
  --violet: #8a5cf6;   --violet-soft: #f0e9ff;
  --shadow: 0 2px 10px rgba(30, 40, 80, .07);
  --shadow-lg: 0 18px 50px rgba(30, 40, 80, .18);
  --banner: linear-gradient(120deg, #b81c1c 0%, #d8423f 60%, #e8706b 100%);
  --hero: linear-gradient(135deg, #7a0f1f 0%, #c4142c 50%, #e8532d 100%);
  --radius: 14px;
  --topbar-h: 64px;
  --side-w: 256px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101218;
  --card: #1a1d26;
  --text: #e9ebf2;
  --muted: #9aa2b8;
  --border: #2a2e3b;
  --topbar: #161922;
  --sidebar: #161922;
  --primary: #ef4455;
  --primary-d: #d02a3b;
  --primary-soft: rgba(239, 68, 85, .16);
  --ok-soft: rgba(23, 166, 115, .17);
  --info-soft: rgba(79, 107, 237, .2);
  --warn-soft: rgba(230, 155, 0, .17);
  --danger-soft: rgba(224, 58, 58, .17);
  --violet-soft: rgba(138, 92, 246, .2);
  --shadow: 0 2px 12px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  --banner: linear-gradient(120deg, #7d1219 0%, #a8222c 60%, #c0424b 100%);
  --hero: linear-gradient(135deg, #3d0711 0%, #8c0f20 50%, #b3361c 100%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Roboto", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.i { width: 20px; height: 20px; flex: none; }
.i-sm { width: 14px; height: 14px; }
.i-xl { width: 56px; height: 56px; }

/* Ikon tema: bulan di mode terang, matahari di mode gelap */
.ic-sun { display: none; }
:root[data-theme="dark"] .ic-sun { display: inline-flex; }
:root[data-theme="dark"] .ic-moon { display: none; }
.ic-moon, .ic-sun { align-items: center; }

/* ===== Topbar ===== */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--topbar);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; margin-left: 4px; }
.logo-wrap { display: inline-flex; align-items: center; border-radius: 10px; padding: 4px 8px; }
.logo-wrap img { height: 40px; width: auto; display: block; }
:root[data-theme="dark"] .logo-wrap { background: #fff; }
.spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.user-name { font-weight: 500; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #f08a4b);
  color: #fff; font-weight: 700; font-size: 14px;
}
.avatar-lg { width: 44px; height: 44px; font-size: 18px; }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 20;
  width: var(--side-w);
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  transition: transform .2s ease;
  overflow-y: auto;
}
.side-user { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.side-user-name { font-weight: 600; word-break: break-all; }
.side-user-role { font-size: 11px; letter-spacing: .06em; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; padding: 8px 0; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  color: var(--text); font-size: 15px;
  border-left: 3px solid transparent;
}
.side-nav a:hover { background: var(--bg); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); border-left-color: var(--primary); font-weight: 500; }
.nav-badge {
  margin-left: auto; font-style: normal; font-size: 12px; font-weight: 700;
  min-width: 22px; padding: 1px 7px; text-align: center;
  background: var(--primary); color: #fff; border-radius: 999px;
}
.side-foot { padding: 14px 24px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.overlay { display: none; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .45); z-index: 15; }

/* ===== Konten ===== */
.main { margin-left: var(--side-w); padding: calc(var(--topbar-h) + 24px) 24px 40px; transition: margin .2s ease; max-width: 1400px; }
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }

.banner {
  position: relative; overflow: hidden;
  padding: 22px 26px; border-radius: 16px;
  background: var(--banner); color: #fff;
  box-shadow: var(--shadow);
}
.banner::before, .banner::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .13); }
.banner::before { width: 170px; height: 170px; right: -30px; top: -60px; }
.banner::after { width: 110px; height: 110px; right: 120px; bottom: -60px; }
.banner h1 { font-size: 24px; font-weight: 700; margin: 8px 0 4px; position: relative; }
.banner p { display: flex; align-items: center; gap: 6px; font-size: 13px; opacity: .92; position: relative; }
.banner p .i { width: 15px; height: 15px; }
.chip-banner { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .2); font-size: 12px; font-weight: 500; }
.chip-banner .i { width: 14px; height: 14px; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 14px; font-size: 15px; font-weight: 600; }
.sec-ic { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: var(--info-soft); color: var(--info); }
.sec-ic .i { width: 16px; height: 16px; }
.sec-warn { background: var(--warn-soft); color: var(--warn); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat {
  position: relative; overflow: hidden;
  display: block; padding: 20px; border-radius: 16px;
  box-shadow: var(--shadow); transition: transform .15s ease;
  background: var(--card);
}
.stat:hover { transform: translateY(-2px); }
.stat::after { content: ""; position: absolute; right: -26px; top: -26px; width: 104px; height: 104px; border-radius: 50%; opacity: .14; background: currentColor; }
.stat-ic { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; color: #fff; margin-bottom: 12px; }
.stat-num { font-size: 32px; font-weight: 700; line-height: 1.1; color: var(--text); position: relative; z-index: 1; }
.stat-label { color: var(--text); font-weight: 500; margin-top: 4px; position: relative; z-index: 1; }
.stat-link { display: inline-flex; align-items: center; gap: 5px; margin-top: 12px; font-size: 12.5px; font-weight: 500; position: relative; z-index: 1; }
.stat-info { background: var(--info-soft); color: var(--info); }   .stat-info .stat-ic { background: linear-gradient(135deg, #6d7cf5, #4f6bed); }
.stat-warn { background: var(--warn-soft); color: var(--warn); }   .stat-warn .stat-ic { background: linear-gradient(135deg, #f5b73d, #e69b00); }
.stat-ok { background: var(--ok-soft); color: var(--ok); }         .stat-ok .stat-ic { background: linear-gradient(135deg, #2cc58c, #17a673); }
.stat-violet { background: var(--violet-soft); color: var(--violet); } .stat-violet .stat-ic { background: linear-gradient(135deg, #a07af8, #8a5cf6); }
.stat-danger { background: var(--danger-soft); color: var(--danger); } .stat-danger .stat-ic { background: linear-gradient(135deg, #ee5d5d, #e03a3a); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { color: var(--muted); margin-top: 2px; }

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; margin: 16px 0; font-size: 13.5px; }
.alert .i { margin-top: 1px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(224, 58, 58, .25); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(23, 166, 115, .25); }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 0 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; }
.panel-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; width: 190px; }
.select { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg); }
.td-action { text-align: right; white-space: nowrap; }
.no-match { padding: 24px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border: 0; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; transition: filter .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn .i { width: 17px; height: 17px; }
.btn-primary { color: #fff; background: linear-gradient(120deg, #a1124f 0%, #c4142c 45%, #d8452a 100%); box-shadow: 0 6px 16px rgba(196, 20, 44, .28); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; height: 48px; font-size: 15px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 20px; color: var(--muted); text-align: center; }
.empty .i-xl { opacity: .6; }

/* ===== Modal ===== */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10, 12, 20, .55); }
.modal { width: 100%; max-width: 420px; padding: 28px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow-lg); text-align: center; }
.modal-ic { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); margin-bottom: 12px; }
.modal-ic .i { width: 26px; height: 26px; }
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }

/* ===== Login ===== */
.login-body { background: var(--card); }
.login { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.login-theme { position: fixed; top: 16px; right: 16px; z-index: 5; background: var(--card); box-shadow: var(--shadow); }
.login-hero { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--hero); }
.orb { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.orb-1 { width: 260px; height: 260px; left: -90px; top: 70px; }
.orb-2 { width: 54px; height: 54px; left: 22%; top: 12%; background: rgba(255, 255, 255, .13); }
.orb-3 { width: 120px; height: 120px; right: 12%; bottom: 20%; background: rgba(255, 255, 255, .09); }
.orb-4 { width: 250px; height: 250px; left: 8%; bottom: -110px; background: rgba(255, 255, 255, .09); }
.glass {
  position: relative; z-index: 1;
  width: 100%; max-width: 470px; padding: 38px 32px; text-align: center; color: #fff;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 26px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}
.logo-pill { display: inline-block; background: #fff; border-radius: 18px; padding: 12px 20px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.logo-pill img { height: 54px; width: auto; display: block; }
.glass h1 { font-size: 28px; font-weight: 700; margin-top: 22px; }
.hero-sub { margin-top: 4px; opacity: .95; font-weight: 500; }
.hero-line { display: block; width: 50px; height: 2px; margin: 18px auto; background: rgba(255, 255, 255, .55); border-radius: 2px; }
.hero-desc { opacity: .9; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.chip-glass { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 999px; background: rgba(255, 255, 255, .15); border: 1px solid rgba(255, 255, 255, .3); }
.chip-glass .i { width: 14px; height: 14px; }

.login-side { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg); }
:root:not([data-theme="dark"]) .login-side { background: #fff; }
.login-card { width: 100%; max-width: 430px; padding: 30px; background: var(--card); border-radius: 20px; box-shadow: 0 10px 40px rgba(30, 40, 80, .1); }
:root[data-theme="dark"] .login-card { box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.login-mobile-logo { display: none; }
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-head h2 { font-size: 21px; font-weight: 700; }
.login-head p { color: var(--muted); font-size: 13px; }
.login-ic { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px; color: #fff; background: linear-gradient(135deg, #b3122f, #e0452a); box-shadow: 0 6px 16px rgba(196, 20, 44, .3); flex: none; }
.field-label { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.field-label .i { width: 14px; height: 14px; color: var(--muted); }
.field { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; font-size: 14.5px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-wrap { position: relative; }
.field-wrap .field { padding-right: 46px; }
.field-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.field-eye:hover { color: var(--text); }
.eye-hide { display: none; }
.field-wrap.showing .eye-show { display: none; }
.field-wrap.showing .eye-hide { display: inline-flex; }
.login-card .btn-block { margin-top: 22px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }

/* ===== Responsif ===== */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; padding: calc(var(--topbar-h) + 18px) 14px 32px; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .overlay { display: block; }
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed.sidebar-open .sidebar { transform: translateX(0); }
  .user-name { display: none; }
  .topbar { padding: 0 10px; }

  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-side { min-height: 100vh; padding: 20px 16px; background: var(--bg); }
  .login-mobile-logo { display: flex; justify-content: center; margin-bottom: 18px; }
  .login-mobile-logo img { height: 46px; width: auto; }
  :root[data-theme="dark"] .login-mobile-logo { background: #fff; border-radius: 12px; padding: 8px 14px; width: fit-content; margin-left: auto; margin-right: auto; }
}
@media (max-width: 720px) {
  .banner { padding: 18px; }
  .banner h1 { font-size: 20px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat { padding: 16px; }
  .stat-num { font-size: 26px; }
  .search input { width: 100%; }
  .search { flex: 1; }
  .toolbar { width: 100%; }

  /* Tabel jadi kartu di layar kecil */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-weight: 500; text-align: left; flex: none; }
  .table td.td-action { justify-content: flex-end; padding-top: 10px; }
  .table td.td-action::before { content: none; }
}
@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
}

/* Form unggah firmware */
.fw-form { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 20px 20px; align-items: center; }
.fw-form .input { min-width: 180px; flex: 1 1 180px; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
.fw-form input[type=file] { padding-top: 6px; }
.fw-form .select { flex: 0 0 auto; }
