/* Token warna & komponen bersama untuk aplikasi HP dan Admin. */
/* Palet monokrom arang, mengikuti logo QUIVER. Hijau/merah hanya untuk status (naik/turun, habis). */
:root {
  --bg: #F4F4F2;
  --surface: #FFFFFF;
  --surface-2: #ECECEA;
  --text: #1B1B1B;
  --muted: #6A6A68;
  --primary: #2B2B2B;
  --primary-dark: #0E0E0E;
  --primary-tint: #E9E9E6;
  --on-primary: #FFFFFF;
  --logo: #404040;
  --success: #1E7A55;
  --success-tint: #E2F2EA;
  --danger: #B23B3B;
  --danger-tint: #FBEAEA;
  --warn: #9A6A00;
  --warn-tint: #FFF4D6;
  --border: #DFDFDB;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F0F0F; --surface: #1A1A1A; --surface-2: #242424; --text: #EDEDED; --muted: #9B9B9B;
    --primary: #E4E4E4; --primary-dark: #FFFFFF; --primary-tint: #2A2A2A; --on-primary: #111111; --logo: #C9C9C9;
    --success: #5CC79A; --success-tint: #16302A; --danger: #E48383; --danger-tint: #3A1E1E;
    --warn: #E8C15A; --warn-tint: #3A3018; --border: #2E2E2E;
  }
}
:root[data-theme="dark"] {
  --bg: #0F0F0F; --surface: #1A1A1A; --surface-2: #242424; --text: #EDEDED; --muted: #9B9B9B;
  --primary: #E4E4E4; --primary-dark: #FFFFFF; --primary-tint: #2A2A2A; --on-primary: #111111; --logo: #C9C9C9;
  --success: #5CC79A; --success-tint: #16302A; --danger: #E48383; --danger-tint: #3A1E1E;
  --warn: #E8C15A; --warn-tint: #3A3018; --border: #2E2E2E;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
input, select, textarea { font-size: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Login ---------- */
#loginView {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 28px;
}
/* Logo: gambar dipakai sebagai mask supaya warnanya ikut tema (terang/gelap). */
.logo-mark, .logo-word {
  display: inline-block; background: var(--logo); flex: none;
  -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat;
}
.logo-mark { --src: url(/img/logo-mark.png); width: 34px; height: 28px; }
.logo-word { --src: url(/img/logo-word.png); width: 104px; height: 10px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand-stack { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 4px 0 18px; }
.brand-stack .logo-mark { width: 84px; height: 69px; }
.brand-stack .logo-word { width: 168px; height: 16px; }
.brand-sub { font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; text-align: center; }

/* ---------- Form ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, .field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); outline: none;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; font-weight: 700; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); }
.error-text {
  color: var(--danger); background: var(--danger-tint); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 14px; display: none;
}
.error-text.show { display: block; }
.banner { border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 14px; }
.banner.warn { background: var(--warn-tint); color: var(--warn); }
.banner.info { background: var(--primary-tint); color: var(--primary-dark); }

/* ---------- Chips / segmented ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; border: none; background: none; padding: 8px 6px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Kartu statistik ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 18px; font-weight: 800; margin-top: 2px; }
.stat.hl { background: var(--primary-tint); border-color: transparent; }
.stat.hl .val { color: var(--primary-dark); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.ok { background: var(--success-tint); color: var(--success); }
.badge.low { background: var(--danger-tint); color: var(--danger); }
.badge.off { background: var(--surface-2); color: var(--muted); }
.pos { color: var(--success); }
.neg { color: var(--danger); }

.empty-note { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }

/* ---------- Bar kuota harian (bawah layar) ---------- */
.quota-bar {
  display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border);
  padding: 7px 14px;
}
.quota-bar b { color: var(--text); font-weight: 700; }
.quota-bar .qb-title { font-weight: 700; color: var(--text); }
.quota-bar .qb-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.quota-bar .qb-meter { display: inline-block; width: 64px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.quota-bar .qb-meter > i { display: block; height: 100%; border-radius: 999px; }
.quota-bar .qb-meter > i.ok { background: var(--success); }
.quota-bar .qb-meter > i.mid { background: var(--warn); }
.quota-bar .qb-meter > i.bad { background: var(--danger); }
.quota-bar .qb-reset { white-space: nowrap; }
.quota-bar .qb-link { margin-left: auto; color: var(--text); font-weight: 600; }
.quota-bar.mid { background: var(--warn-tint); }
.quota-bar.bad { background: var(--danger-tint); }

/* ---------- Indikator real-time ---------- */
.live-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.live-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live-dot.live { color: var(--success); }
.live-dot.live::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-tint); animation: livepulse 2.4s ease-in-out infinite; }
.live-dot.offline { color: var(--danger); }
.live-dot.offline::before { background: var(--danger); }
@keyframes livepulse { 50% { box-shadow: 0 0 0 5px transparent; } }
/* Sorotan singkat untuk baris yang baru berubah dari perangkat lain */
.flash-update { animation: flashupd 2.2s ease-out; }
@keyframes flashupd { 0%, 25% { background-color: var(--warn-tint); } 100% { background-color: transparent; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(84px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13px;
  z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s ease; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,18,15,.5); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(22px + var(--safe-b)); max-height: 88vh; overflow-y: auto;
}
.modal-sheet h3 { margin: 0 0 4px; font-size: 17px; }
.receipt-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.receipt-row:last-child { border-bottom: none; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--text);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
