:root {
  /* Helmet Papa brand palette (sampled from official logo) */
  --blue: #408FC1;
  --blue-dark: #337AA8;
  --navy: #25495B;
  --yellow: #FFDE59;
  --cream: #FFFAE8;
  --cream-deep: #F9EBCA;

  /* semantic */
  --brand: var(--blue);           /* customer-overridable accent */
  --brand-dark: var(--blue-dark);
  --bg: #F5F1E6;                   /* warm off-white app background */
  --card: #ffffff;
  --border: #e9e4d6;
  --text: #25495B;
  --text-muted: #7c8a92;
  --danger: #d64545;
  --danger-bg: #fdecec;
  --warning: #a9791a;
  --warning-bg: #fff6e0;
  --success: #2e8b6f;
  --success-bg: #e3f4ee;

  --font-display: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-bg: #FFFDF8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

.app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; padding: 4px 6px 20px; }
.brand-logo-img { width: 100%; max-width: 210px; height: auto; object-fit: contain; }
.brand-logo-fallback {
  font-family: var(--font-display); font-weight: 800; font-size: 24px; color: var(--blue);
}

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; color: var(--navy);
  text-decoration: none; font-size: 14px; font-weight: 600;
}
.nav-link:hover { background: #fff; }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; opacity: 0.9; }
.nav-section-label {
  margin: 20px 12px 8px; font-size: 11px; font-weight: 800;
  letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase;
}

/* ---------- Main + topbar ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 30px; background: #fff; border-bottom: 1px solid var(--border);
  gap: 16px; min-height: 66px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

/* hamburger + drawer backdrop (mobile only; hidden on desktop) */
.menu-toggle {
  display: none; border: 1px solid var(--border); background: #fff; color: var(--navy);
  font-size: 20px; line-height: 1; padding: 6px 11px; border-radius: 10px; cursor: pointer;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(37,73,91,0.45);
  z-index: 40; opacity: 0; transition: opacity 0.2s ease;
}
.sidebar-backdrop.show { opacity: 1; }

.account-chip { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--navy);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-chip-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.1; color: var(--navy); }
.account-chip-sub { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-top: 1px; }

/* language toggle */
.lang-toggle, .login-lang {
  display: inline-flex; border: 1px solid var(--border); border-radius: 999px;
  overflow: hidden; background: var(--cream);
}
.lang-btn {
  border: none; background: transparent; padding: 6px 14px; font-size: 12px;
  font-weight: 800; color: var(--text-muted); cursor: pointer; font-family: var(--font-body);
}
.lang-btn.active { background: var(--brand); color: #fff; }

.demo-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--yellow); color: var(--navy);
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 800;
}
.demo-badge::before { content: "●"; font-size: 8px; color: var(--navy); }

/* ---------- Banners ---------- */
.banner-row { display: flex; flex-direction: column; gap: 0; }
.fogging-banner {
  background: var(--warning-bg); color: var(--warning);
  border-bottom: 1px solid #f1dca3; padding: 10px 30px;
  font-size: 13px; font-weight: 700;
}
.impersonation-banner {
  background: var(--yellow); color: var(--navy);
  padding: 10px 30px; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 12px;
}
.impersonation-banner button { padding: 5px 12px; font-size: 12px; }

.content { padding: 26px 30px; }

/* ---------- Grid + cards ---------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px;
}
.card-label { font-size: 13px; color: var(--text-muted); font-weight: 700; margin-bottom: 8px; }
.card-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--navy); }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }

h1.page-title { font-family: var(--font-display); font-size: 24px; margin: 0 0 20px; color: var(--navy); font-weight: 700; }
h2.section-title { font-family: var(--font-display); font-size: 16px; margin: 0 0 14px; font-weight: 600; color: var(--navy); }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
}
.pill-online { background: var(--success-bg); color: var(--success); }
.pill-offline { background: var(--danger-bg); color: var(--danger); }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 11px 14px; color: var(--text-muted); font-weight: 700; border-bottom: 1px solid var(--border); }
td { padding: 13px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

/* ---------- Machine cards ---------- */
.machine-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  display: flex; flex-direction: column; gap: 13px;
}
.machine-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.machine-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--navy); }
.machine-location { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-weight: 600; }
.machine-stats { display: flex; gap: 26px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.machine-stats b { display: block; color: var(--navy); font-size: 16px; font-family: var(--font-display); font-weight: 600; }

.liquid-track { height: 9px; border-radius: 999px; background: #eef1f0; overflow: hidden; }
.liquid-fill { height: 100%; background: var(--success); border-radius: 999px; }
.liquid-fill.warn { background: var(--yellow); }
.liquid-fill.crit { background: var(--danger); }
.liquid-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }

.alert-inline {
  background: var(--danger-bg); color: var(--danger); border: 1px solid #f3caca;
  border-radius: 9px; padding: 9px 12px; font-size: 12px; font-weight: 700;
}

/* ---------- Buttons + inputs ---------- */
button, .btn {
  font-family: var(--font-body); font-size: 13px; font-weight: 700; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--navy);
  padding: 9px 15px; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--navy); }
.btn-ghost:hover { background: var(--cream); }
.btn-block { width: 100%; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* sleek call-to-action link button (e.g. Withdraw on Midtrans) */
.btn-cta {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--brand); color: #fff; font-family: var(--font-body); font-weight: 700;
  font-size: 14px; padding: 11px 22px; border-radius: 11px; cursor: pointer;
  box-shadow: 0 5px 14px rgba(64, 143, 193, 0.28); transition: background 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
}
.btn-cta:hover { background: var(--brand-dark); box-shadow: 0 6px 18px rgba(64, 143, 193, 0.34); }
.btn-cta:active { transform: translateY(1px); box-shadow: 0 3px 10px rgba(64, 143, 193, 0.28); }

input, select {
  font-family: var(--font-body); font-size: 13px; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--navy);
}
input:focus, select:focus { outline: none; border-color: var(--brand); }
input:disabled { background: var(--cream); color: var(--text-muted); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { min-width: 140px; }
.spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.form-field input { width: 100%; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; }

.upload-row { display: flex; align-items: center; gap: 16px; }
.upload-preview {
  width: 68px; height: 68px; border-radius: 14px; background: var(--cream);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-weight: 700; color: var(--text-muted); border: 1px solid var(--border);
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview.round { border-radius: 50%; }

.toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--navy); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 13px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(37,73,91,0.25); opacity: 0; transform: translateY(8px);
  transition: all 0.2s ease; pointer-events: none; z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }

.empty-state { text-align: center; color: var(--text-muted); padding: 44px 0; font-size: 13px; font-weight: 600; }

.admin-account-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.admin-account-row:last-child { border-bottom: none; }
.admin-account-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 16px; margin-top: 5px; flex-wrap: wrap; font-weight: 600; }
.admin-account-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--navy); }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 820px) { .login-screen { grid-template-columns: 1fr; } .login-hero { display: none; } }
.login-hero {
  background: var(--blue); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 40px;
}
.login-hero-logo { width: 78%; max-width: 420px; }
.login-hero-tag {
  font-family: var(--font-display); color: var(--cream); font-size: 22px;
  font-weight: 600; margin: 0; text-align: center; letter-spacing: 0.01em;
}
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 360px; }
.login-title { font-family: var(--font-display); font-size: 30px; margin: 0 0 6px; color: var(--navy); font-weight: 700; }
.login-sub { font-size: 14px; color: var(--text-muted); margin: 0 0 26px; font-weight: 600; }
.login-hint {
  font-size: 11px; color: var(--text-muted); margin-top: 20px; line-height: 1.6;
  border-top: 1px solid var(--border); padding-top: 16px; font-weight: 600;
}
.login-lang { margin-top: 18px; }

.sparkline { width: 100%; height: 70px; }

/* interactive sales chart */
.chart-wrap { position: relative; width: 100%; }
.chart-svg { width: 100%; height: 120px; display: block; cursor: crosshair; }
.chart-dot { transition: r 0.08s ease; }
.chart-tooltip {
  position: absolute; top: 2px; transform: translate(-50%, -100%);
  background: var(--navy); color: #fff; padding: 8px 11px; border-radius: 9px;
  font-size: 12px; pointer-events: none; white-space: nowrap; z-index: 5;
  box-shadow: 0 6px 18px rgba(37,73,91,0.25); min-width: 108px;
}
.chart-tip-date { font-weight: 800; margin-bottom: 4px; font-size: 11px; opacity: 0.85; }
.chart-tip-row { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.chart-tip-row b { font-family: var(--font-display); font-weight: 700; }
.chart-tip-sub { font-size: 11px; opacity: 0.8; margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ============================ Mobile ============================ */
@media (max-width: 820px) {
  body { overflow-x: hidden; }

  /* sidebar becomes an off-canvas drawer */
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: 264px; max-width: 82vw;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 3px 0 22px rgba(37, 73, 91, 0.18); overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; opacity: 1; }

  /* topbar */
  .topbar { position: sticky; top: 0; z-index: 30; padding: 10px 14px; gap: 10px; min-height: 58px; }
  .topbar-left { gap: 10px; }
  .topbar-right { gap: 10px; }
  .account-chip { gap: 8px; }
  .avatar { width: 38px; height: 38px; font-size: 14px; }
  .account-chip-name { font-size: 15px; }

  /* spacing */
  .content { padding: 18px 14px; }
  .fogging-banner, .impersonation-banner { padding: 10px 14px; font-size: 12px; }
  h1.page-title { font-size: 20px; margin-bottom: 16px; }
  .card { padding: 18px; }
  .card-value { font-size: 24px; }

  /* stack layouts */
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  /* wide tables scroll horizontally rather than squishing */
  .card:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 520px; }

  /* transactions filter toolbar wraps and fills width */
  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 130px; }
  .toolbar .spacer { display: none; }
  .toolbar > button { flex: 1 1 100%; }

  /* admin customer rows stack */
  .admin-account-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .admin-account-row > button { width: 100%; }

  /* login */
  .login-panel { padding: 28px 20px; }
  .login-title { font-size: 26px; }
}

@media (max-width: 480px) {
  .account-chip-text { display: none; }   /* avatar only — save room */
  .machine-stats { gap: 16px; flex-wrap: wrap; }
  .card-value { font-size: 22px; }
  #logout-btn { padding: 8px 11px; }
}
