:root {
  --pico-font-size: 15px;
  --pico-border-radius: .6rem;

  /* ---- palet ungu (mengikuti referensi) ---- */
  --sl-primary: #7c3aed;
  --sl-primary-dark: #6d28d9;
  --sl-primary-light: #f5f3ff;
  --sl-bg: #f7f7fb;
  --sl-card: #ffffff;
  --sl-border: #e5e7eb;
  --sl-text: #1f2937;
  --sl-muted: #6b7280;

  --pico-primary: var(--sl-primary);
  --pico-primary-background: var(--sl-primary);
  --pico-primary-border: var(--sl-primary);
  --pico-primary-underline: var(--sl-primary);
  --pico-primary-hover: var(--sl-primary-dark);
  --pico-primary-hover-background: var(--sl-primary-dark);
  --pico-primary-hover-border: var(--sl-primary-dark);
  --pico-primary-focus: rgba(124, 58, 237, .25);
  --pico-primary-inverse: #fff;
}

body { margin: 0; background: var(--sl-bg); color: var(--sl-text); }
nav { margin-bottom: 1rem; }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat {
  padding: .9rem 1.1rem; border-radius: .9rem; background: var(--sl-card);
  border: 1px solid var(--sl-border); box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; color: var(--sl-text); }
.stat span { font-size: .85rem; color: var(--sl-muted); }
.stat.red b { color: #dc2626; } .stat.yellow b { color: #d97706; }

/* ---------- tabel ---------- */
table { font-size: .88rem; }
th, td { white-space: nowrap; vertical-align: top; }
td.wrap { white-space: normal; min-width: 180px; }
tr.overdue td, tr.today td { background: rgba(220,38,38,.08); }
tr.soon td { background: rgba(217,119,6,.10); }
tr.week td { background: rgba(217,119,6,.05); }

/* wrapper tabel (div[style="overflow-x:auto"]) dibungkus jadi kartu putih */
main.content div[style*="overflow-x"] {
  background: var(--sl-card); border: 1px solid var(--sl-border); border-radius: .9rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.04); padding: .2rem;
}
main.content div[style*="overflow-x"] table { margin: 0; }
main.content div[style*="overflow-x"] table thead th {
  background: #fafafb; color: var(--sl-muted); text-transform: uppercase;
  font-size: .68rem; letter-spacing: .04em; border-bottom: 1px solid var(--sl-border);
}
main.content div[style*="overflow-x"] table td { border-bottom: 1px solid #f3f4f6; }
main.content div[style*="overflow-x"] table tr:last-child td { border-bottom: none; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--sl-primary-light); }

/* ---------- badge pill ---------- */
.badge { display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.orange { background: #ffedd5; color: #c2410c; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.grey { background: #f3f4f6; color: #4b5563; }

.small { font-size: .78rem; color: var(--sl-muted); }
form.inline { display: inline; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar input, .toolbar select { margin: 0; width: auto; }
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box input[type="search"] { border-radius: 999px; min-width: 260px; margin: 0; }
#map { height: 75vh; border-radius: .9rem; }
.filter-chip { font-size: .82rem; background: var(--sl-primary-light); color: var(--sl-primary-dark); border: 1px solid #ddd6fe; border-radius: 999px; padding: .3rem .8rem; }
.filter-chip a { color: var(--sl-primary-dark); }

/* ---------- layout sidebar ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sl-card); color: var(--sl-text); padding: 1.1rem .9rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; font-size: .9rem;
  border-right: 1px solid var(--sl-border);
}
.sidebar .brand { font-weight: 700; font-size: 1.05rem; margin-bottom: 1.2rem; color: var(--sl-text); }
.sb-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sl-muted); margin: 1.1rem 0 .35rem; }
.sb-list { list-style: none; padding: 0; margin: 0; }
.sb-list li { margin: 0; padding: 0; }
.sb-list a {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .42rem .6rem; border-radius: .55rem; color: #374151; text-decoration: none; font-weight: 500;
}
.sb-list a:hover { background: #f9fafb; }
.sb-list a.active { background: var(--sl-primary-light); color: var(--sl-primary-dark); font-weight: 700; }
.sb-list .cnt { background: #f3f4f6; color: var(--sl-muted); border-radius: 1rem; padding: 0 .5rem; font-size: .75rem; min-width: 1.6rem; text-align: center; }
.sb-list a.active .cnt { background: rgba(124,58,237,.15); color: var(--sl-primary-dark); }
.sb-bottom { margin-top: 1.5rem; padding-top: .8rem; border-top: 1px solid var(--sl-border); }
.sb-bottom a { color: var(--sl-muted); font-size: .85rem; }
.content { padding: 1.2rem 1.6rem; min-width: 0; }

.bottomnav { display: none; }
.menu-backdrop { display: none; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }

  /* Menu utama (Dashboard/Akun/Peta/Atur lokasi/Export) sudah jadi tab bawah;
     sembunyikan duplikatnya di sidebar. Sisanya (Lokasi, Akun, +Akun, dst)
     tetap di sidebar dan dibuka lewat tab "Lainnya". */
  .sidebar .menu-primary { display: none; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    height: auto; max-height: 75vh; overflow-y: auto;
    transform: translateY(100%);
    transition: transform .25s ease;
    z-index: 70;
    border-radius: 1rem 1rem 0 0;
    border-right: none;
    box-shadow: 0 -8px 28px rgba(17,24,39,.18);
  }
  .sidebar.open { transform: translateY(0); }
  .content { padding: 1rem 1rem 4.8rem; }

  .bottomnav {
    display: flex;
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
    width: 100%; max-width: 480px; height: 3.9rem;
    background: var(--sl-card); border-top: 1px solid var(--sl-border); z-index: 60;
    box-shadow: 0 -2px 10px rgba(17,24,39,.06);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a, .bottomnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .15rem; background: none; border: none; color: var(--sl-muted);
    font-size: .66rem; font-weight: 600; font-family: inherit;
    text-decoration: none; cursor: pointer;
  }
  .bottomnav .ic { font-size: 1.15rem; }
  .bottomnav a.active, .bottomnav a.active .ic { color: var(--sl-primary); }

  .menu-backdrop.show {
    display: block; position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 65;
  }
}

/* ---------- form kompak & tombol seragam ---------- */
article {
  padding: 1.2rem 1.4rem 1.3rem; max-width: 760px; margin: 0;
  background: var(--sl-card); border: 1px solid var(--sl-border); border-radius: .9rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
article h4 { margin-bottom: .8rem; font-size: 1.1rem; color: var(--sl-text); }
article form { --pico-form-element-spacing-vertical: .42rem; --pico-form-element-spacing-horizontal: .65rem; }
article form label { font-size: .82rem; margin-bottom: .15rem; color: var(--sl-muted); }
article form input, article form select, article form textarea { font-size: .9rem; margin-bottom: .55rem; }
article form textarea { min-height: 3.2rem; }
article form .grid { gap: .7rem; }
.actions { display: flex; gap: .6rem; align-items: center; margin-top: .5rem; }
.actions button, .actions a[role="button"] {
  width: auto; min-width: 112px; margin: 0; padding: .48rem 1.1rem;
  font-size: .9rem; line-height: 1.25; display: inline-flex; align-items: center; justify-content: center;
}
.actions .danger { margin-left: auto; border-color: #dc2626; color: #dc2626; background: transparent; }
.actions .danger:hover { background: rgba(220,38,38,.08); }

/* ---- halaman penagihan ---- */
.bill-card { padding: 1rem 1.2rem; margin-bottom: 1rem; }
.bill-card.overdue, .bill-card.today { border-left: 4px solid #dc2626; }
.bill-card.soon, .bill-card.week { border-left: 4px solid #d97706; }
.bill-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.bill-grid { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: .8rem; margin-bottom: .6rem; }
@media (max-width: 720px) { .bill-grid { grid-template-columns: 1fr; } }
.bill-box { background: var(--sl-bg); border-radius: .7rem; padding: .7rem .9rem; display: flex; flex-direction: column; gap: .2rem; }
.bill-box .big { font-size: 1.5rem; line-height: 1.2; }
.bill-box .big.red { color: #dc2626; }
.bill-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
.bill-actions form.inline button, .bill-actions .pay-btn { margin: 0; padding: .35rem .8rem; font-size: .82rem; width: auto; }
.bill-actions .pay-btn { background: #16a34a; border-color: #16a34a; color: #fff; }
.bill-actions .job-line { flex-basis: 100%; }
.otp-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; width: 100%; }
.otp-form label { margin: 0; flex: 1; }
.otp-form input { margin: 0; }
.otp-form button { margin: 0; width: auto; }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #9ca3af; margin-right: .3rem; }
.dot.ok { background: #16a34a; } .dot.bad { background: #dc2626; }
.bill-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .5rem; }
@media (max-width: 900px) { .bill-tables { grid-template-columns: 1fr; } }
.bill-tables > div { overflow-x: auto; min-width: 0; }
table.compact { font-size: .8rem; }
table.compact td, table.compact th { padding: .3rem .5rem; white-space: normal; }
table.compact code { white-space: nowrap; }
dialog article { max-width: 520px; }
