:root {
  /* Warna brand Nusanet Vending (dari logo) */
  --navy: #0b2a4a;
  --navy-2: #12385f;
  --brand: #1565c0;
  --brand-dark: #0f4f99;
  --brand-light: #eaf2fc;
  --accent: #f28c28;
  --accent-light: #fff3e6;
  --ring: rgba(21, 101, 192, .2);
  /* Hijau hanya untuk status sukses (Aktif, Berhasil, Online, laba) */
  --green: #1f9d48;
  --green-dark: #17803a;
  --green-deep: #0f5c2a;
  --green-light: #e7f6ec;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #0f1e30;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cfd8e3;
  --red: #d93025;
  --red-light: #fdecea;
  --orange: #c2410c;
  --orange-light: #fff1e7;
  --yellow: #f9a825;
  --yellow-light: #fff7db;
  --blue: #2563eb;
  --blue-light: #eaf1ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(11, 30, 52, .05);
  --shadow: 0 1px 3px rgba(11, 30, 52, .06), 0 6px 16px -8px rgba(11, 30, 52, .10);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
.hidden { display: none !important; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 650; margin: 0; }
h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red); font-size: 13px; min-height: 1em; }
a { color: var(--brand); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Brand: logo Nusanet Vending (logo.svg = monogram N dari rak produk) */
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 40px; height: 40px; flex: none; display: block; filter: drop-shadow(0 3px 6px rgba(11, 42, 74, .25)); }
.brand-text { font-weight: 800; font-size: 21px; line-height: 1; letter-spacing: -.03em; color: #0b2a4a; }
.brand-text span { display: block; margin-top: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .38em; text-transform: uppercase; color: #1565c0; }

/* Login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #dce9f8 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #fde9d6 0%, transparent 55%), var(--bg);
}
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin: 0; }
.login-card .btn.primary { padding: 11px 14px; margin-top: 4px; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: #fff; border-right: 1px solid var(--border); padding: 20px 14px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar > .brand { padding: 0 6px; }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; padding: 14px 12px 6px; }
.nav-group:first-child { padding-top: 0; }
nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  text-decoration: none; color: #334155; font-size: 14px; font-weight: 500; transition: background .15s, color .15s;
}
nav a svg { color: #94a3b8; transition: color .15s; }
nav a:hover { background: var(--bg); color: var(--text); }
nav a:hover svg { color: var(--text); }
nav a.active { background: var(--brand-light); color: var(--navy); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
nav a.active svg { color: var(--brand); }

.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: #f8fafc; }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font: inherit; background: none; border: 0; padding: 4px; border-radius: var(--radius-sm); cursor: pointer; text-align: left; color: var(--text); }
.me:hover { background: #fff; }
.me-text { min-width: 0; display: grid; line-height: 1.25; }
.me-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { font-size: 12px; color: var(--muted); }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 0; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--red-light); color: var(--red); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .02em; background: var(--navy);
}

.view { padding: 32px 36px; min-width: 0; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .muted { font-size: 14px; margin: 2px 0 0; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); gap: 12px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { display: none; }
  nav a { padding: 7px 10px; }
  nav a.active { box-shadow: none; }
  .sidebar-foot { margin-top: 0; }
  .view { padding: 18px 16px; }
  h1 { font-size: 22px; }
}

/* Card & grid */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); opacity: .85; }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat.warn::before { background: var(--red); }
.stat.warn .value { color: var(--red); }

/* Form */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: #475569; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text); padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: #a8b5c6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
input:disabled, select:disabled { background: var(--bg); color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 14px; font-weight: 550; border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer; box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f6f8fb; border-color: #b8c4d3; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 100%); border-color: var(--navy); color: #fff; box-shadow: 0 1px 2px rgba(11, 42, 74, .35), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover { background: #082038; }
.btn.danger { color: var(--red); border-color: #f2c4c0; }
.btn.danger:hover { background: var(--red-light); }
.btn.link { border: 0; background: none; box-shadow: none; color: var(--brand); padding: 4px 6px; }
.btn.link:hover { text-decoration: underline; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Table */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #edf1f6; white-space: nowrap; vertical-align: middle; }
th { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: #6b7a8f; background: #f8fafc; border-bottom-color: var(--border); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background .12s; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f5f8fc; }
tbody tr.dim td { opacity: .6; }
.chev { color: #b4bfcc; font-size: 20px; line-height: 1; }
tbody tr.click:hover .chev { color: var(--brand); }
/* Kolom tetap di kiri saat tabel digeser ke kanan (gambar + kode) */
.stick-img, .stick-code { position: sticky; z-index: 1; background: #fff; }
th.stick-img, th.stick-code { background: #f8fafc; }
.stick-img { left: 0; width: 68px; min-width: 68px; max-width: 68px; } /* 40px gambar + padding 2x14px */
.stick-code { left: 68px; box-shadow: inset -1px 0 0 var(--border); }
tbody tr.click:hover .stick-img, tbody tr.click:hover .stick-code { background: #f5f8fc; }

/* Badge: warna lembut (latar muda + teks tegas) */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650; line-height: 1.4; color: #475569; background: #eef2f6; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
}
.badge.ok { color: var(--green-deep); background: var(--green-light); }
.badge.err { color: #b3261e; background: var(--red-light); }
.badge.warn { color: var(--orange); background: var(--orange-light); }
.badge.low { color: #7a5a00; background: var(--yellow-light); }
.badge.off { color: #64748b; background: #eef2f6; }
.badge.soft { font-size: 11px; padding: 1px 8px; color: var(--blue); background: var(--blue-light); vertical-align: 1px; }
.badge.role-admin { color: #7c2d12; background: #ffedd5; }
.badge.role-admin::before, .badge.role-staff::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.role-staff { color: #1e40af; background: var(--blue-light); }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #b9c1bc; }
.status.on { color: var(--text); }
.status.on::before { background: var(--green); box-shadow: 0 0 0 3px rgba(31, 157, 72, .18); }

/* Pengguna */
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell .muted { font-size: 12.5px; margin-top: 1px; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.role-card p { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.role-card ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.role-card li::marker { color: var(--accent); }

/* Slot grid */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; }
.slot {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; cursor: pointer; display: grid; gap: 6px;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.slot:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-1px); }
.slot.disabled { opacity: .55; }
.slot .img { aspect-ratio: 1; border-radius: var(--radius-sm); background: var(--brand-light); display: grid; place-items: center; overflow: hidden; color: var(--brand); font-size: 28px; font-weight: 700; }
.slot .img img { width: 100%; height: 100%; object-fit: contain; }
.slot .top { display: flex; justify-content: space-between; align-items: center; }
.slot .code { font-weight: 750; }
.slot .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .price { font-weight: 750; color: var(--navy); font-size: 14px; }
td .slot .img { border-radius: 8px; background: #f4f7fb; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 550; background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--navy); border-color: var(--accent); font-weight: 650; }

.token-box { font-family: ui-monospace, Menlo, monospace; background: var(--navy); color: #a9d0ff; padding: 14px; border-radius: var(--radius-sm); word-break: break-all; }
.note { background: var(--yellow-light); border: 1px solid #f3e2a9; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(11, 30, 52, .45); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 24px 48px -12px rgba(11, 30, 52, .35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: var(--radius-sm); z-index: 20; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.toast.err { background: var(--red); }

a.btn { text-decoration: none; display: inline-block; }

/* Dropdown dengan pencarian (combo.js) */
.combo { position: relative; display: inline-flex; min-width: 0; }
label > .combo, .form-grid .combo { display: flex; }
.combo-native { display: none !important; }
.combo-btn {
  font: inherit; font-size: 14px; color: var(--text); text-align: left; width: 100%; min-width: 140px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.combo-btn:hover { border-color: #a8b5c6; }
.combo-btn:focus-visible, .combo-btn.open { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.combo-btn:disabled { background: var(--bg); color: var(--muted); cursor: default; }
.combo-btn.placeholder .combo-label { color: var(--muted); }
.combo-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn svg { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.combo-btn.open svg { transform: rotate(180deg); }
.combo-panel {
  position: fixed; z-index: 30; display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 36px -10px rgba(11, 30, 52, .28);
}
.combo-search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--muted); }
.combo-search svg { width: 16px; height: 16px; }
.combo-search input { flex: 1; border: 0; padding: 6px 0; box-shadow: none !important; font-size: 14px; }
.combo-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.combo-list li { padding: 8px 10px; border-radius: 8px; font-size: 14px; line-height: 1.35; cursor: pointer; overflow-wrap: anywhere; }
.combo-list li.active { background: var(--brand-light); }
.combo-list li.selected { font-weight: 650; color: var(--navy); }
.combo-list li.selected::after { content: " ✓"; }
.combo-list li.empty { color: var(--muted); }
.combo-list li.disabled { opacity: .45; cursor: default; }
.combo-list li.none { color: var(--muted); cursor: default; text-align: center; padding: 14px; }
.row > .combo { width: 200px; max-width: 100%; } /* baris filter: lebar tetap, tidak menggeser tombol */
