:root {
  --bg: #f4f2ec;
  --panel: #ffffff;
  --ink: #1e2a27;
  --ink-soft: #5b6b65;
  --teal: #16423c;
  --teal-deep: #0e2c28;
  --brass: #b9822f;
  --brass-soft: #e9d5ae;
  --line: #ddd8c8;
  --ok: #3d7a56;
  --ok-bg: #e3efe5;
  --pending-bg: #fbeeda;
  --pending-ink: #8a5a16;
  --danger: #a5402f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 28, 0.06), 0 6px 20px rgba(20, 30, 28, 0.06);
  --sidebar-w: 230px;
  --topbar-h: 58px;
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1,
h2,
h3,
.disp {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.01em;
}
.mono {
  font-family: "IBM Plex Mono", monospace;
}
a {
  color: inherit;
}
button {
  font-family: inherit;
  cursor: pointer;
}
input,
select {
  font-family: inherit;
}
img,
svg {
  max-width: 100%;
}

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(
      circle at 15% 20%,
      rgba(185, 130, 47, 0.1),
      transparent 45%
    ),
    radial-gradient(circle at 85% 80%, rgba(22, 66, 60, 0.12), transparent 50%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}
.login-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    var(--teal) 0deg,
    var(--teal) 270deg,
    var(--brass-soft) 270deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  position: relative;
}
.login-badge::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--panel);
}
.login-badge span {
  position: relative;
  font-family: "IBM Plex Mono";
  font-weight: 600;
  font-size: 11px;
  color: var(--teal);
}
.login-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--teal-deep);
}
.login-card p.sub {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14.5px;
  background: #fcfbf8;
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 66, 60, 0.1);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition:
    transform 0.08s,
    filter 0.15s;
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--teal);
  color: #fff;
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover {
  background: #f1efe7;
}
.btn-brass {
  background: var(--brass);
  color: #fff;
}
.btn-brass:hover {
  filter: brightness(1.06);
}
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover {
  background: #fbebe7;
}
.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}
.btn-block {
  width: 100%;
  padding: 11px;
  font-size: 14.5px;
}
.login-error {
  background: #fbebe7;
  color: var(--danger);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 7px;
  margin-bottom: 14px;
}
.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.login-hint b {
  color: var(--ink);
}

/* ---------- APP SHELL ---------- */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--teal-deep);
  color: #edede5;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: relative;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding: 0 6px;
}
.sidebar .brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 3px rgba(185, 130, 47, 0.25);
  flex-shrink: 0;
}
.sidebar .brand span {
  font-family: "Space Grotesk";
  font-weight: 600;
  font-size: 15px;
}

/* Hamburger toggle: hidden on desktop, only relevant <=760px */
.nav-toggle-checkbox {
  display: none;
}
.nav-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #edede5;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #c7d3ce;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(185, 130, 47, 0.18);
  color: #f4d9a9;
}
.sidebar .who {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 14px;
  margin-top: 10px;
}
.sidebar .who .name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  overflow-wrap: anywhere;
}
.sidebar .who .role {
  font-size: 11px;
  color: var(--brass-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.sidebar .who form {
  margin-top: 12px;
}
.sidebar .who button {
  width: 100%;
}
.sidebar .who .btn-ghost {
  border-color: rgba(255, 255, 255, 0.25);
  color: #edede5;
  background: rgba(255, 255, 255, 0.04);
}
.sidebar .who .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 34px 60px;
  overflow-y: auto;
  overflow-x: hidden;
}
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar h2 {
  font-size: 21px;
  margin: 0;
  color: var(--teal-deep);
}
.topbar .desc {
  color: var(--ink-soft);
  font-size: 13px;
  margin-top: 3px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 0;
}
.stat .num {
  font-family: "Space Grotesk";
  font-size: 26px;
  font-weight: 700;
  color: var(--teal-deep);
}
.stat .label {
  font-size: 11.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
  min-width: 0;
}
.panel h3 {
  font-size: 15px;
  margin: 0 0 14px;
  color: var(--teal-deep);
  display: flex;
  align-items: center;
  gap: 8px;
}

.type-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.type-btn {
  flex: 1;
  min-width: 160px;
  padding: 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fcfbf8;
  text-align: left;
  transition: all 0.15s;
  text-decoration: none;
  display: block;
}
.type-btn .ttitle {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.type-btn .tsub {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 3px;
}
.type-btn.sel {
  border-color: var(--teal);
  background: #eff4f1;
}
.type-btn.sel .ttitle {
  color: var(--teal-deep);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 16px;
  margin-bottom: 18px;
}

table.ledger {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 12.8px;
}
table.ledger th {
  background: #f1efe7;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 10.5px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  text-align: center;
}
table.ledger td {
  border: 1px solid var(--line);
  padding: 4px;
  text-align: center;
}
table.ledger tbody tr:nth-child(even) {
  background: #fbfaf6;
}
table.ledger td.month {
  font-weight: 600;
  text-align: left;
  padding-left: 10px;
  color: var(--ink);
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: #fff;
}
table.ledger tbody tr:nth-child(even) td.month {
  background: #fbfaf6;
}
table.ledger input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 4px;
  border-radius: 5px;
  font-size: 12.8px;
  text-align: center;
}
table.ledger input:hover {
  border-color: var(--line);
}
table.ledger input:focus {
  border-color: var(--teal);
  background: #fff;
  outline: none;
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfbf8;
  flex-wrap: wrap;
}
.card-row .ci {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.type-pill {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.type-pill.air {
  background: #dcebf0;
}
.type-pill.listrik {
  background: #f5e6c8;
}
.card-row .cname {
  font-weight: 600;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.card-row .cmeta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status-badge.pending {
  background: var(--pending-bg);
  color: var(--pending-ink);
}
.status-badge.reviewed {
  background: var(--ok-bg);
  color: var(--ok);
}
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty .big {
  font-size: 32px;
  margin-bottom: 8px;
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: none;
  margin-bottom: 16px;
  padding: 0;
  text-decoration: none;
}
.detail-back:hover {
  text-decoration: underline;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 20px;
  margin-bottom: 6px;
}
.info-grid .k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 600;
}
.info-grid .v {
  font-size: 14px;
  margin-top: 2px;
  font-family: "IBM Plex Mono";
  overflow-wrap: anywhere;
}
.info-grid input {
  font-family: "IBM Plex Mono";
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 3px;
}

.users-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.users-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13.5px;
}
.users-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.users-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.role-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: capitalize;
  white-space: nowrap;
}
.role-chip.superadmin {
  background: #ede1f5;
  color: #6a3d9c;
}
.role-chip.admin {
  background: #dcebf0;
  color: #1e5e75;
}
.role-chip.user {
  background: #eaeae0;
  color: var(--ink-soft);
}

.flash {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 18px;
}
.flash.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.flash.err {
  background: #fbebe7;
  color: var(--danger);
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ---------- RESPONSIVE ---------- */

/* Tablet: tighten spacing, keep sidebar but slimmer */
@media (max-width: 1024px) {
  .main {
    padding: 24px 22px 50px;
  }
  .sidebar {
    width: 200px;
    padding: 20px 12px;
  }
}

/* Mobile: sidebar becomes a collapsible top bar */
@media (max-width: 760px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .sidebar .brand {
    margin-bottom: 0;
    padding: 0;
    flex: 1;
    min-width: 0;
  }

  .nav-toggle-btn {
    display: flex;
    order: 2;
  }

  .sidebar nav {
    order: 4;
    width: 100%;
    flex-direction: column;
    flex: none;
    max-height: 0;
    overflow: hidden;
    gap: 2px;
    transition: max-height 0.2s ease;
  }
  .nav-toggle-checkbox:checked ~ nav {
    max-height: 400px;
  }
  .nav-item {
    padding: 11px 12px;
    font-size: 14px;
  }

  .sidebar .who {
    order: 3;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .sidebar .who .name,
  .sidebar .who .role {
    display: none;
  }
  .sidebar .who form {
    margin-top: 0;
  }
  .sidebar .who button {
    width: auto;
    white-space: nowrap;
  }
  .nav-toggle-checkbox:checked ~ .who {
    display: none;
  }

  .main {
    padding: 18px 14px 50px;
  }
  .topbar h2 {
    font-size: 18px;
  }

  .panel {
    padding: 16px 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
  .type-btn {
    min-width: 0;
    flex-basis: 100%;
  }

  .card-row {
    flex-direction: column;
    align-items: stretch;
  }
  .card-row .ci {
    width: 100%;
  }
  .row-actions {
    width: 100%;
  }
  .row-actions .btn {
    flex: 1;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

/* Small phones: extra breathing room fixes */
@media (max-width: 420px) {
  .login-card {
    padding: 26px 20px 22px;
  }
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat {
    padding: 12px 14px;
  }
  .stat .num {
    font-size: 21px;
  }
  .btn {
    padding: 9px 13px;
    font-size: 13.5px;
  }
}

@media (max-width: 760px) {
  body {
    -webkit-tap-highlight-color: transparent;
  }
}
