/* ============================================================
   INDIEKOS — App Shell (operator + penghuni)
   ============================================================ */

/* ===================== OPERATOR SHELL ===================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 240px) 1fr;
  grid-template-rows: 100vh;
  height: 100vh; overflow: hidden;
  transition: grid-template-columns var(--dur) var(--ease-out);
}
.app.collapsed { --sidebar-w: 64px; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  display: flex; flex-direction: column;
  overflow: hidden; position: relative; z-index: 30;
}
.sidebar.light { background: var(--surface); color: var(--ink-700); border-right: 1px solid var(--ink-200); }
.sb-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: 60px;
  border-bottom: 1px solid rgba(255,255,255,0.12); flex: none;
}
.sidebar.light .sb-head { border-bottom-color: var(--ink-200); }
.sb-logo {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-on-primary); color: var(--brand-primary); font-weight: 800; font-size: 17px; overflow: hidden;
}
.sb-logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar.light .sb-logo { background: var(--brand-primary); color: #fff; }
.sb-name { display: flex; flex-direction: column; min-width: 0; }
.sb-name b { font-size: var(--fs-md); font-weight: 700; line-height: 1.15; white-space: nowrap; }
.sb-name span { font-size: var(--fs-2xs); letter-spacing: var(--ls-caps); text-transform: uppercase; opacity: 0.7; white-space: nowrap; }
.app.collapsed .sb-name { display: none; }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; display: flex; flex-direction: column; gap: 1px; }
.sb-nav::-webkit-scrollbar { width: 0; }
.sb-section { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-caps); opacity: 0.55; padding: 12px 12px 5px; font-weight: 700; }
.app.collapsed .sb-section { opacity: 0; height: 14px; padding: 6px 0; }
.sb-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-2);
  color: inherit; text-decoration: none; font-size: var(--fs-md); font-weight: 500; cursor: pointer;
  position: relative; transition: background var(--dur-fast); white-space: nowrap;
}
.sb-link svg { width: 19px; height: 19px; flex: none; opacity: 0.92; }
.sb-link:hover { background: rgba(255,255,255,0.10); }
.sidebar.light .sb-link:hover { background: var(--ink-100); }
.sb-link.active { background: rgba(255,255,255,0.16); font-weight: 600; }
.sidebar.light .sb-link.active { background: var(--brand-primary-50); color: var(--brand-primary); }
.sb-link.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--brand-accent);
}
.sb-link .badge {
  margin-left: auto; font-size: var(--fs-2xs); font-weight: 700; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: var(--r-pill); background: var(--brand-accent); color: var(--brand-on-accent);
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.app.collapsed .sb-link { justify-content: center; padding: 9px 0; }
.app.collapsed .sb-link span.lbl, .app.collapsed .sb-link .badge { display: none; }
.sb-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,0.12); flex: none; }
.sidebar.light .sb-foot { border-top-color: var(--ink-200); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-2); cursor: pointer; }
.sb-user:hover { background: rgba(255,255,255,0.10); }
.sidebar.light .sb-user:hover { background: var(--ink-100); }
.sb-user .meta { min-width: 0; }
.sb-user .meta b { font-size: var(--fs-sm); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .meta span { font-size: var(--fs-2xs); opacity: 0.7; }
.app.collapsed .sb-user .meta { display: none; }
.powered { font-size: var(--fs-2xs); opacity: 0.6; text-align: center; padding: 8px 0 4px; }
.app.collapsed .powered { display: none; }

/* ---- Main column ---- */
.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  height: 60px; flex: none; background: var(--surface); border-bottom: 1px solid var(--ink-200);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; z-index: 20;
}
.topbar .page-t { font-size: var(--fs-lg); font-weight: 700; letter-spacing: var(--ls-heading); }
.topbar .page-sub { font-size: var(--fs-xs); color: var(--ink-500); }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-2); border: 1px solid transparent; background: none;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-600); flex: none; position: relative;
  transition: background var(--dur-fast);
}
.icon-btn:hover { background: var(--ink-100); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot-badge { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 1.5px solid var(--surface); }

.loc-filter { display: flex; align-items: center; gap: 6px; }
.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 22px; background: var(--bg); }
.content-inner { max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: var(--fs-2xl); letter-spacing: var(--ls-heading); }
.page-head .lede { font-size: var(--fs-sm); color: var(--ink-500); margin-top: 4px; }

/* grids */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.grid-main { display: grid; grid-template-columns: 1.6fr minmax(0,1fr); gap: 16px; }
@media (max-width: 1180px) and (min-width: 901px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

/* hamburger + mobile-only / desktop-only */
.hamburger { display: none; }
.mobile-only { display: none; }
.bottom-nav { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(26,26,23,0.45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ===================== RESPONSIVE: operator → mobile ===================== */
@media (max-width: 900px) {
  html { font-size: 14px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 50;
    transform: translateX(-100%); transition: transform var(--dur) var(--ease-out);
    box-shadow: var(--shadow-3);
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .app.collapsed { --sidebar-w: 1fr; }
  .app.collapsed .sb-name, .app.collapsed .sb-link span.lbl, .app.collapsed .sb-link .badge { display: revert; }
  .app.collapsed .sb-link { justify-content: flex-start; padding: 9px 11px; }
  .hamburger { display: grid; }
  .desktop-only { display: none !important; }
  .mobile-only { display: revert; }
  .content { padding: 16px 14px 84px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-main { grid-template-columns: 1fr; }
  .desktop-table { display: none; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 62px; z-index: 35;
    background: var(--surface); border-top: 1px solid var(--ink-200); padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .bn-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--ink-500); text-decoration: none; font-size: 10px; font-weight: 600; cursor: pointer; position: relative;
  }
  .bn-link svg { width: 22px; height: 22px; }
  .bn-link.active { color: var(--brand-primary); }
  .bn-link.active::after { content:""; position:absolute; top:0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand-accent); }
  .bn-link .badge { position: absolute; top: 6px; right: 50%; margin-right: -20px; background: var(--danger); color:#fff; font-size: 9px; font-weight: 700; min-width: 15px; height: 15px; border-radius: var(--r-pill); display: grid; place-items: center; padding: 0 4px; }
}
@media (min-width: 901px) { .stacked-mobile { display: none; } }

/* ===================== PENGHUNI MOBILE APP ===================== */
.phone-stage {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 600px at 50% -10%, var(--brand-primary-50), transparent 60%),
    var(--bg);
}
.phone {
  width: 390px; height: min(844px, calc(100vh - 32px)); background: var(--surface); border-radius: 44px; overflow: hidden;
  position: relative; box-shadow: var(--shadow-3); border: 1px solid var(--ink-200);
  display: flex; flex-direction: column;
}
@media (max-width: 460px) {
  .phone-stage { padding: 0; }
  .phone { width: 100vw; height: 100vh; border-radius: 0; border: 0; }
}
.statusbar { height: 46px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 26px 0 30px; font-size: 13px; font-weight: 700; color: var(--ink-900); }
.statusbar.on-brand { color: #fff; }
.statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
.statusbar .sb-icons svg { width: 16px; height: 16px; }
.p-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.p-body::-webkit-scrollbar { width: 0; }
.p-tabbar {
  flex: none; height: 64px; background: var(--surface); border-top: 1px solid var(--ink-200);
  display: flex; padding-bottom: 4px;
}
.p-tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-400); cursor: pointer; font-size: 10px; font-weight: 600; position: relative; }
.p-tab svg { width: 24px; height: 24px; }
.p-tab.active { color: var(--brand-primary); }
.p-pad { padding: 16px; }
.p-appbar { padding: 4px 18px 14px; display: flex; align-items: center; justify-content: space-between; }
.p-appbar h1 { font-size: 22px; font-weight: 700; }

/* big status hero on penghuni home */
.status-hero {
  border-radius: var(--r-5); padding: 22px; color: #fff; position: relative; overflow: hidden;
}
.status-hero.paid { background: linear-gradient(135deg, var(--success), #226e45); }
.status-hero.due { background: linear-gradient(135deg, var(--brand-accent-600), var(--brand-accent)); color: var(--brand-on-accent); }
.status-hero.overdue { background: linear-gradient(135deg, var(--danger), var(--danger-fg)); }

/* fab */
.fab { position: absolute; right: 18px; bottom: 80px; width: 56px; height: 56px; border-radius: 50%; background: var(--brand-primary); color:#fff; border:0; display:grid; place-items:center; box-shadow: var(--shadow-pop); cursor: pointer; z-index: 5; }
.fab svg { width: 26px; height: 26px; }

/* bottom sheet */
.sheet-scrim { position: absolute; inset: 0; background: rgba(26,26,23,0.45); z-index: 60; opacity:0; pointer-events:none; transition: opacity var(--dur); }
.sheet-scrim.show { opacity:1; pointer-events:auto; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); z-index: 61;
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom,0));
  transform: translateY(100%); transition: transform var(--dur-slow) var(--ease-out); max-height: 90%; overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--ink-300); margin: 6px auto 14px; }

/* modal (operator) */
.modal-scrim { position: fixed; inset: 0; background: rgba(26,26,23,0.5); z-index: 100; display: grid; place-items: center; padding: 24px; opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.modal-scrim.show { opacity: 1; pointer-events: auto; }
.modal { background: var(--surface); border-radius: var(--r-4); box-shadow: var(--shadow-3); width: 100%; max-width: 520px; max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; transform: translateY(8px) scale(0.98); transition: transform var(--dur) var(--ease-out); }
.modal-scrim.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--ink-200); }
.modal-head h3 { font-size: var(--fs-lg); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--ink-200); display: flex; justify-content: flex-end; gap: 10px; }

/* drawer detail panel (right side) */
.detail-scrim { position: fixed; inset: 0; background: rgba(26,26,23,0.4); z-index: 90; opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.detail-scrim.show { opacity: 1; pointer-events: auto; }
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 92vw; background: var(--surface);
  z-index: 91; box-shadow: var(--shadow-3); transform: translateX(100%); transition: transform var(--dur-slow) var(--ease-out);
  display: flex; flex-direction: column;
}
.detail-panel.show { transform: translateX(0); }
.detail-head { padding: 16px 20px; border-bottom: 1px solid var(--ink-200); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-body { flex: 1; overflow-y: auto; padding: 20px; }
.detail-foot { padding: 14px 20px; border-top: 1px solid var(--ink-200); display: flex; gap: 10px; }
