/* Dentaapps — portal.css
   Gaya shell portal (nav kiri, header, kartu) di luar sistem desain prototipe,
   supaya markup hasil ekstraksi tetap utuh. */

:root {
  --c-primary: #0066FF;
  --c-primary-dark: #0052cc;
  --c-ink: #0F172A;
  --c-muted: #64748B;
  --c-line: #E2E8F0;
  --c-bg: #F8FAFC;
  --c-surface: #FFFFFF;
  --side-w: 248px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- shell ---------------- */
.portal-shell {
  display: flex;
  min-height: 100vh;
}

.portal-side {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--c-ink);
  color: #CBD5E1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.portal-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.portal-brand b {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
}
.portal-brand small {
  display: block;
  font-size: 11px;
  color: #94A3B8;
  margin-top: 3px;
  line-height: 1.35;
}

.portal-nav { padding: 10px 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: #CBD5E1;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item--active { background: var(--c-primary); color: #fff; font-weight: 700; }
.nav-item i, .nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; }

.portal-side-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 11px;
  color: #94A3B8;
}

/* ---------------- main ---------------- */
.portal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.portal-top {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  padding: 13px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.portal-top h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.portal-top p { margin: 2px 0 0; font-size: 12px; color: var(--c-muted); }

.portal-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.portal-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
}

.portal-body { padding: 22px; flex: 1; }

/* ---------------- komponen ---------------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat small { display: block; font-size: 11px; color: var(--c-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat b { display: block; font-size: 22px; font-weight: 800; margin-top: 5px; letter-spacing: -.02em; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--c-line);
  background: var(--c-surface); color: var(--c-ink);
  font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #F1F5F9; }
.btn--primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-dark); }
.btn--ghost { background: transparent; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--c-muted); font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--c-line);
  white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #F8FAFC; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1.6;
}
.badge--ok   { background: #DCFCE7; color: #166534; }
.badge--warn { background: #FEF3C7; color: #92400E; }
.badge--info { background: #DBEAFE; color: #1E40AF; }
.badge--off  { background: #F1F5F9; color: #475569; }

/* ---------------- loading & error ---------------- */
.page-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60vh; color: var(--c-muted); font-size: 13px;
}
.page-loading svg { width: 18px; height: 18px; }
.spin { animation: putar 1s linear infinite; }
@keyframes putar { to { transform: rotate(360deg); } }

.page-error {
  max-width: 560px; margin: 8vh auto; text-align: center;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); padding: 32px 26px; box-shadow: var(--shadow);
}
.page-error h1 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.page-error p { margin: 0 0 18px; color: var(--c-muted); font-size: 13px; }

/* ---------------- landing / auth (tanpa sidebar) ---------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, #DBEAFE 0%, transparent 60%),
    radial-gradient(700px 420px at 95% 10%, #E0F2FE 0%, transparent 55%),
    var(--c-bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .10);
  padding: 28px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.auth-card p.sub { margin: 0 0 20px; color: var(--c-muted); font-size: 13px; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--c-line); border-radius: 9px;
  font: inherit; font-size: 13px; background: #fff; color: var(--c-ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(0, 102, 255, .25); border-color: var(--c-primary);
}

.alert {
  padding: 9px 12px; border-radius: 9px; font-size: 12.5px; margin-bottom: 13px;
}
.alert--err { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.alert--ok  { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }

/* ---------------- responsif ---------------- */
@media (max-width: 860px) {
  .portal-shell { flex-direction: column; }
  .portal-side {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; overflow-x: auto;
  }
  .portal-brand { border-bottom: 0; border-right: 1px solid rgba(255,255,255,.08); flex: 0 0 auto; }
  .portal-nav { display: flex; gap: 4px; padding: 8px; flex: 1; }
  .nav-item { white-space: nowrap; margin: 0; }
  .portal-side-foot { display: none; }
  .portal-body { padding: 14px; }
  .portal-top { padding: 11px 14px; }
}


/* ==============================
   PRINT A4 – SURAT & INVOICE
   ============================== */
@page {
  size: A4;
  margin: 15mm 18mm;
}
@media print {
  .portal-side, .portal-top, .no-print { display: none !important; }
  .portal-body { padding: 0; margin: 0; }
  body { background: #fff !important; color: #000; }

  /* Area cetak penuh A4 */
  #printable-letter-area,
  #printable-invoice-area,
  [id*="printable"] {
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Kop surat/klinik tetap rapi */
  #printable-letter-area .flex.items-start { border-bottom: 2px solid #000 !important; }

  /* Tabel Invoice tanpa border aneh */
  .border-slate-200, .border-slate-100 {
    border-color: #cbd5e1 !important;
  }
  table { page-break-inside: avoid; }
  tr { page-break-inside: avoid; }

  /* Jangan potong elemen di tengah halaman */
  .space-y-6 > * { page-break-inside: avoid; }

  /* Teks editable tetap read-only look */
  [contenteditable]:hover { outline: none; }
  [contenteditable]:focus { outline: none; background: transparent; }

  /* QR/barcode jangan terpotong */
  canvas, svg { page-break-inside: avoid; }

  /* Print header kecil rapi */
  .portal-brand { display: none !important; }
  .portal-body { padding-top: 0 !important; }
}
@media print {
  .portal-side, .portal-top, .no-print { display: none !important; }
  .portal-body { padding: 0; }
  body { background: #fff; }
}


/* ===== FIX: utilitas dipakai komponen tapi tidak ada di bundle ===== */
.fixed { position: fixed !important; }
.inset-0 { top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important; }
.z-50 { z-index: 50 !important; }
.top-4 { top: 1rem !important; }
.right-4 { right: 1rem !important; }
.space-y-2 > * + * { margin-top: .5rem !important; }
.items-stretch { align-items: stretch !important; }
.mt-auto { margin-top: auto !important; }
.divide-y > * + * { border-top-width: 1px !important; border-top-style: solid !important; }
.divide-slate-100 > * + * { border-top-color: #F1F5F9 !important; }
.border-slate-50 { border-color: #F8FAFC !important; }
.h-full { height: 100% !important; }
.w-full { width: 100% !important; }

/* Modal wajib melayang di atas segalanya */
#modal-backdrop {
  position: fixed !important; inset: 0 !important; z-index: 50 !important;
  display: none; align-items: center; justify-content: center;
  background: rgba(15,23,42,.65); padding: 1rem;
  overflow-y: auto; overscroll-behavior: contain;
}
#modal-backdrop.flex { display: flex !important; }
#modal-content {
  width: 100%; max-width: 34rem; margin: auto;
  background: #ffffff; border-radius: 1.5rem;
  box-shadow: 0 25px 60px -12px rgba(15,23,42,.5);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 1.25rem;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 640px) {
  #modal-backdrop { padding: .75rem; align-items: flex-start; }
  #modal-content {
    padding: 1.15rem; border-radius: 1.25rem;
    max-height: calc(100dvh - 1.5rem);
  }
}

/* Toast wajib melayang */
#toast-container {
  position: fixed !important; top: 1rem !important; right: 1rem !important;
  z-index: 60 !important; display: flex; flex-direction: column; gap: .5rem;
}

/* ===== PANEL PLATFORM: lebar konsisten + responsif ===== */
.platform-shell { display: flex; min-height: 100vh; background: #F4F7FE; }
.platform-side {
  width: 16rem; flex: 0 0 16rem; background: #fff; border-right: 1px solid #F1F5F9;
  display: flex; flex-direction: column; justify-content: space-between; padding: 1.25rem;
}
.platform-main { flex: 1 1 auto; min-width: 0; padding: 1.5rem; overflow-y: auto; }
.platform-main > * + * { margin-top: 1.5rem; }

@media (max-width: 1024px) {
  .platform-shell { flex-direction: column; }
  .platform-side {
    width: 100%; flex: none; padding: .75rem;
    flex-direction: row; align-items: center; gap: .75rem; overflow-x: auto;
  }
  .platform-side > div:first-child { flex: 0 0 auto; }
  .platform-side nav { display: flex; gap: .25rem; flex: 1; }
  .platform-side nav a { white-space: nowrap; }
  .platform-main { padding: 1rem; }
}

@media (max-width: 640px) {
  .platform-main { padding: .75rem; }
  .platform-main h1 { font-size: 1.05rem; }
  .platform-main table { display: block; overflow-x: auto; white-space: nowrap; }
}


/* ===== FIX overflow: induk .auth-shell adalah grid tanpa kolom ===== */
.auth-shell { grid-template-columns: minmax(0, 1fr); justify-items: stretch; }
.auth-shell > .platform-shell { width: 100%; min-width: 0; max-width: 100%; }

/* Panel platform tidak boleh melebar melebihi layar */
.platform-shell { width: 100%; min-width: 0; max-width: 100vw; overflow-x: hidden; }
.platform-main { min-width: 0; max-width: 100%; }
.platform-main > *, .platform-main .grid > *, .platform-main .space-y-6 > * { min-width: 0; }
.platform-main img, .platform-main table { max-width: 100%; }

/* Kartu & grid: jangan memaksa lebar konten */
.platform-main .grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .platform-main .grid.sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)) !important; } }
@media (min-width: 1024px) { .platform-main .grid[class*="lg:grid-cols-4"] { grid-template-columns: repeat(4, minmax(0,1fr)) !important; } }
@media (min-width: 1024px) { .platform-main .grid[class*="lg:grid-cols-2"] { grid-template-columns: repeat(2, minmax(0,1fr)) !important; } }

/* Tabel panjang: scroll sendiri, jangan melebarkan halaman */
.platform-main .overflow-x-auto { max-width: 100%; }

html, body { max-width: 100%; overflow-x: hidden; }


/* ===== HP: sidebar platform = bar scroll horizontal, konten dapat lebar penuh ===== */
@media (max-width: 640px) {
  .platform-shell { flex-direction: column; gap: 14px; }

  /* Sidebar: satu baris bisa digeser, tidak memaksa lebar */
  .platform-side {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .platform-side::-webkit-scrollbar { display: none; }

  /* Blok judul + nav jadi satu baris memanjang */
  .platform-side > div:first-child { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
  .platform-side > div:first-child > div:first-child { margin-bottom: 0 !important; }
  .platform-side nav { display: flex; flex-direction: row; gap: 8px; space-y: 0; flex: 0 0 auto; }
  .platform-side nav a { white-space: nowrap; flex: 0 0 auto; padding: 8px 14px; font-size: 12.5px; }
  .platform-side nav a i:last-child { display: none; }

  /* Kartu footer sidebar: sembunyikan di HP, tombolnya pindah ke header */
  .platform-side > div:last-child { display: none; }

  /* Konten penuh */
  .platform-main { width: 100%; max-width: 100%; padding: 0; min-width: 0; }
  .platform-main > * { max-width: 100%; min-width: 0; }

  /* Padding kartu lebih ramping */
  .platform-main .p-6, .platform-main .p-8 { padding: 16px; }
  .platform-main .rounded-3xl { border-radius: 18px; }
  .platform-main h1 { font-size: 19px; line-height: 1.3; }

  /* Grid selalu satu kolom di HP */
  .platform-main .grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }

  /* Tabel: geser di dalam kotaknya sendiri */
  .platform-main .overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .platform-main table { min-width: 640px; }

  /* Input tidak melebihi layar */
  .platform-main input, .platform-main select, .platform-main textarea { max-width: 100%; box-sizing: border-box; }
  .platform-main .flex-wrap { flex-wrap: wrap; }
}

/* Tombol "Ke Panel Klinik" versi HP di header */
.platform-mobile-exit { display: none; }
@media (max-width: 640px) {
  .platform-mobile-exit { display: inline-flex; }
}

/* =====================================================================
   MOBILE REFINEMENT v2 — rme/surat/kasir/integrasi @ ≤640px
   Temuan audit 390px: track grid melebar (425px di wadah 384px) karena
   kertas A4 max-width:210mm memaksa min-content track; odontogram
   720px ter-center terpotong; log integrasi tanpa scroll.
   ===================================================================== */
@media (max-width: 640px) {
  /* -- 1. Semua grid dalam konten portal: track boleh menyusut -- */
  .portal-body .grid,
  .portal-body .grid[class*="grid-cols"],
  .portal-body .grid[class*="-cols-"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* kecuali grid 2/3/4 kolom kecil (badge, metrik) yang memang muat */
  .portal-body .grid.grid-cols-2:not([class*="-cols-"]) { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .portal-body .grid.grid-cols-3:not([class*="-cols-"]) { grid-template-columns: repeat(3, minmax(0,1fr)) !important; }

  /* -- 2. Semua anak grid boleh menyusut (kunci anti-meluber) -- */
  .portal-body .grid > * { min-width: 0; max-width: 100%; }

  /* -- 3. Kertas A4 (surat & invoice): muat layar, tanpa dorong layout -- */
  #printable-letter-area,
  #printable-invoice-area {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 22px 16px !important;
    border-radius: 16px !important;
    box-sizing: border-box;
    overflow-wrap: break-word;
  }
  /* Turunkan sisa grid 12 kolom di dalam kertas */
  #printable-letter-area .grid,
  #printable-letter-area [class*="grid-cols"],
  #printable-invoice-area .grid,
  #printable-invoice-area [class*="grid-cols"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
  }
  #printable-letter-area .grid > *,
  #printable-invoice-area .grid > * { min-width: 0 !important; }
  /* Kop surat & baris ttd: wrap, jangan dorong */
  #printable-letter-area .flex.items-start,
  #printable-invoice-area .flex.items-start { flex-wrap: wrap; gap: 12px; }
  #printable-letter-area table,
  #printable-invoice-area table { min-width: 0 !important; }

  /* -- 4. Odontogram: tetap lebar (gigi tak boleh tumpuk) tapi rata kiri
          agar tidak terpotong oleh centering, dan bisa digeser -- */
  .page-wrap--rme .flex.justify-center[class*="min-w"] { justify-content: flex-start !important; }
  .page-wrap--rme .overflow-x-auto { -webkit-overflow-scrolling: touch; }

  /* -- 5. Log Integrasi: 6 kolom → scroll di dalam kartu -- */
  #log-integrasi { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  #log-integrasi table { min-width: 560px; white-space: nowrap; }
  #log-integrasi td { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

  /* -- 6. Tidak ada elemen yang boleh melebihi lebar layar -- */
  .portal-body img, .portal-body svg, .portal-body canvas, .portal-body video {
    max-width: 100%; height: auto;
  }
  .portal-body input, .portal-body select, .portal-body textarea {
    max-width: 100%; box-sizing: border-box;
  }
  .portal-body .overflow-x-auto { -webkit-overflow-scrolling: touch; max-width: 100%; }

  /* -- 7. Padding kartu lebih ramping -- */
  .portal-body .p-8 { padding: 18px; }
  .portal-body .p-6 { padding: 16px; }
  .portal-body h1 { font-size: 19px; line-height: 1.3; }
  .portal-body h2 { font-size: 17px; }
}

/* =====================================================================
   MOBILE REFINEMENT v3 — tambahan setelah audit v2
   - kasir: tabel di dalam kertas A4 tetap 444px → paksa menyusut
   - rme: pembungkus odontogram overflow:visible → scroll di situ juga
   ===================================================================== */
@media (max-width: 640px) {
  /* Tabel dalam kertas cetak: izinkan menyusut, sel wrap */
  #printable-invoice-area table,
  #printable-letter-area table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed;
  }
  #printable-invoice-area th,
  #printable-invoice-area td,
  #printable-letter-area th,
  #printable-letter-area td {
    padding: 6px 8px !important;
    white-space: normal !important;
    word-break: break-word;
    font-size: 11px;
  }
  /* Kolom nominal tetap rapat ke kanan */
  #printable-invoice-area td[class*="text-right"],
  #printable-invoice-area th[class*="text-right"] { white-space: nowrap !important; }

  /* Odontogram: pembungkus tanpa kelas (overflow visible) → jadikan scroll */
  .page-wrap--rme .overflow-x-auto > div:has(> .flex[class*="min-w"]) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* fallback untuk browser tanpa :has() */
  .page-wrap--rme .overflow-x-auto > div { max-width: 100%; }
  .page-wrap--rme .overflow-x-auto { overflow-x: auto !important; }
}

/* =====================================================================
   MOBILE REFINEMENT v4 — odontogram RME
   Pembungkus langsung pita gigi = <div> tanpa kelas, overflow visible,
   scrollWidth 720 vs clientWidth 280 → konten terpotong & tak bisa digeser.
   Solusi: jadikan pembungkus itu scroll container.
   ===================================================================== */
@media (max-width: 640px) {
  .page-wrap--rme .overflow-x-auto > div {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
  }
  /* anak pertama (pita dewasa atas) juga, karena beberapa browser
     membungkus per-blok */
  .page-wrap--rme .overflow-x-auto > div > div {
    max-width: 100%;
  }
  /* pastikan pita gigi rata kiri supaya awal gigi selalu terlihat */
  .page-wrap--rme .flex[class*="min-w"] { justify-content: flex-start !important; }
}

/* =====================================================================
   MOBILE REFINEMENT v5 — FINAL
   Koreksi: kelas `.page-wrap--rme` TIDAK ADA di DOM.
   Rantai nyata: .portal-body > div.bg-white > div.overflow-x-auto > div
   Anak langsung .overflow-x-auto berukuran 720px (overflow:visible) →
   jadi scroll container-nya sendiri.
   ===================================================================== */
@media (max-width: 640px) {
  /* Odontogram: semua anak langsung kontainer overflow-x-auto di portal
     harus bisa digeser sendiri & rata kiri */
  .portal-body .overflow-x-auto > div {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
  }
  .portal-body .overflow-x-auto > div > div { max-width: 100%; }

  /* Pita gigi (min-w-[720px] / min-w-[520px]) rata kiri, bukan center,
     supaya gigi pertama selalu terlihat saat mulai geser */
  .portal-body .flex[class*="min-w-["] {
    justify-content: flex-start !important;
  }

  /* Jaga agar kontainer induk tidak memaksa lebar */
  .portal-body .overflow-x-auto { max-width: 100%; min-width: 0; }
}

/* =====================================================================
   MOBILE REFINEMENT v6 — toolbar tombol RME
   Grup tombol `.flex.items-center.gap-2` (3 tombol, 467px) tidak wrap
   walau induknya flex-wrap → melebar keluar layar.
   ===================================================================== */
@media (max-width: 640px) {
  .portal-body .flex.items-center.gap-2,
  .portal-body .flex.items-center.gap-2\.5,
  .portal-body .flex.items-center.gap-3 {
    flex-wrap: wrap !important;
    max-width: 100%;
    min-width: 0;
  }
  /* tombol di dalam toolbar boleh menyusut & teksnya turun baris */
  .portal-body .flex-wrap > button,
  .portal-body .flex-wrap > a {
    flex: 0 1 auto;
    max-width: 100%;
  }
  /* label panjang di tombol: jangan paksa satu baris */
  .portal-body button span,
  .portal-body a span { white-space: normal; }
}


/* =====================================================================
   ANTREAN (Appointment) — tabel + filter tanggal + pencarian
   Ditambahkan karena app.css (Tailwind v4 build beku) tidak memuat
   kelas utilitas berikut: hover:*, focus:*, pl-9, min-w, lg:col-span-*,
   top-1/2, whitespace-nowrap, align-top, bg-rose-100, dsb.
   ===================================================================== */
.apt-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.apt-title { font-size: 1.125rem; font-weight: 800; color: #0F172A; margin: 0; }
.apt-sub { font-size: .75rem; color: #64748B; margin: 2px 0 0; }

.apt-sum { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
@media (min-width: 640px) { .apt-sum { grid-template-columns: repeat(3, minmax(0,1fr)); } }
.apt-sum-card { padding: 12px; border-radius: 16px; background: #F8FAFC; border: 1px solid #F1F5F9; }
.apt-sum-card--wide { grid-column: span 2; }
@media (min-width: 640px) { .apt-sum-card--wide { grid-column: span 1; } }
.apt-sum-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #94A3B8; }
.apt-sum-val { font-size: 1.25rem; font-weight: 800; color: #0F172A; line-height: 1.2; }
.apt-sum-val--blue { color: #0066FF; }

.apt-filter { border-radius: 16px; border: 1px solid #E2E8F0; background: rgba(248,250,252,.6); padding: 12px; }
@media (min-width: 640px) { .apt-filter { padding: 16px; } }
.apt-filter-grid { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: end; }
@media (min-width: 640px) { .apt-filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (min-width: 1024px) { .apt-filter-grid { grid-template-columns: repeat(12, minmax(0,1fr)); } }
.apt-f { min-width: 0; }
.apt-f--3 { grid-column: span 3; }
@media (min-width: 640px) and (max-width: 1023px) { .apt-f--3 { grid-column: span 1; } }
.apt-f-label { display: block; font-size: 11px; font-weight: 700; color: #64748B; margin-bottom: 4px; }
.apt-input, .apt-select {
  width: 100%; padding: 8px 12px; border-radius: 12px; border: 1px solid #E2E8F0;
  background: #fff; font-size: .875rem; color: #1E293B; font-family: inherit;
  box-sizing: border-box; min-height: 40px;
}
.apt-input:focus, .apt-select:focus { outline: none; border-color: #0066FF; box-shadow: 0 0 0 3px rgba(0,102,255,.15); }
.apt-search { position: relative; }
.apt-search .apt-input { padding-left: 34px; }
.apt-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: #94A3B8; pointer-events: none; }

.apt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.apt-btn-mini {
  padding: 6px 12px; border-radius: 8px; background: #fff; border: 1px solid #E2E8F0;
  font-size: 11px; font-weight: 700; color: #475569; cursor: pointer; font-family: inherit;
}
.apt-btn-mini:hover { background: #F1F5F9; }
.apt-filter-info { font-size: 11px; font-weight: 600; color: #0066FF; }

.apt-table-wrap { overflow-x: auto; border-radius: 16px; border: 1px solid #F1F5F9; -webkit-overflow-scrolling: touch; }
.apt-table { width: 100%; min-width: 940px; border-collapse: collapse; text-align: left; font-size: .875rem; }
.apt-table thead th {
  background: #F8FAFC; font-size: 11px; text-transform: uppercase; color: #64748B;
  font-weight: 700; padding: 12px; border-bottom: 1px solid #F1F5F9; white-space: nowrap;
}
.apt-table tbody td { padding: 12px; border-bottom: 1px solid #F1F5F9; vertical-align: top; }
.apt-table tbody tr:last-child td { border-bottom: 0; }
.apt-table tbody tr:hover { background: rgba(248,250,252,.85); }
.apt-table .num { text-align: right; }
.apt-tgl { white-space: nowrap; font-weight: 600; color: #334155; }
.apt-jam { white-space: nowrap; font-weight: 800; color: #0066FF; }
.apt-pasien-nama { font-weight: 700; color: #0F172A; }
.apt-rm { font-size: 11px; color: #94A3B8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.apt-catatan { color: #475569; max-width: 260px; word-break: break-word; }
.apt-status-cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.apt-chip {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.apt-chip--terjadwal { background: #F1F5F9; color: #334155; }
.apt-chip--checkin    { background: #FEF3C7; color: #B45309; }
.apt-chip--diperiksa  { background: #DBEAFE; color: #1D4ED8; }
.apt-chip--selesai    { background: #D1FAE5; color: #047857; }
.apt-chip--dibayar    { background: #059669; color: #fff; }
.apt-chip--noshow     { background: #FFE4E6; color: #BE123C; }
.apt-chip--batal      { background: #FFE4E6; color: #BE123C; }
.apt-chip--bpjs       { background: #D1FAE5; color: #047857; }
.apt-chip--umum       { background: #DBEAFE; color: #1D4ED8; }
.apt-select-sm {
  font-size: 11px; font-weight: 700; color: #1E293B; background: #fff;
  border: 1px solid #E2E8F0; border-radius: 8px; padding: 4px 8px; font-family: inherit; min-height: 30px;
}
.apt-btn-rme {
  padding: 6px 12px; border-radius: 8px; background: #0066FF; color: #fff; border: 0;
  font-size: 11px; font-weight: 700; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.apt-btn-rme:hover { background: #0052CC; }
.apt-empty { padding: 40px 12px; text-align: center; }
.apt-empty-t { font-size: .875rem; font-weight: 600; color: #94A3B8; }
.apt-empty-s { font-size: 11px; color: #94A3B8; margin-top: 4px; }
.apt-foot { font-size: 11px; color: #94A3B8; }

.apt-card { background: #fff; border-radius: 24px; border: 1px solid #F1F5F9; padding: 20px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
@media (min-width: 640px) { .apt-card { padding: 24px; } }
.apt-card > * + * { margin-top: 18px; }


/* =====================================================================
   RME — TABEL CATATAN KLINIS SOAP, TINDAKAN & RESEP
   app.css Tailwind beku → tabel ditulis manual di sini.
   ===================================================================== */
.rme-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.rme-table {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.rme-table thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.rme-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  color: #1e293b;
}
.rme-table tbody tr:last-child td { border-bottom: none; }
.rme-table tbody tr:hover { background: #f8fbff; }
.rme-table tfoot td {
  padding: 9px 10px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #334155;
}
.rme-table .rme-no {
  font-weight: 800;
  color: #94a3b8;
  text-align: center;
}
.rme-table .rme-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  padding: 22px 10px !important;
}

/* Input di dalam sel tabel */
.rme-inp {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
  line-height: 1.4;
  resize: vertical;
}
.rme-inp:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.rme-inp:disabled {
  background: #f8fafc;
  color: #64748b;
  cursor: not-allowed;
}
.rme-inp::placeholder { color: #cbd5e1; }

/* Tombol aksi */
.rme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
  white-space: nowrap;
}
.rme-btn:hover:not(:disabled) { transform: translateY(-1px); }
.rme-btn-primary { background: #eff6ff; color: #1d4ed8; }
.rme-btn-primary:hover:not(:disabled) { background: #dbeafe; }
.rme-btn-ok { background: #059669; color: #fff; }
.rme-btn-ok:hover:not(:disabled) { background: #047857; }
.rme-btn-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: #fef2f2;
  color: #dc2626;
  cursor: pointer;
}
.rme-btn-del:hover { background: #fee2e2; }
.rme-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: #94a3b8;
}
.rme-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

/* Mobile: tabel tetap bisa di-scroll horizontal, kontrol menumpuk */
@media (max-width: 640px) {
  .rme-table { min-width: 720px; }
  .rme-foot { flex-direction: column; align-items: flex-start; }
}

/* ==== Asisten AI button ==== */
.btn-asisten-ai{display:inline-flex;align-items:center;gap:6px;padding:8px 14px;border:none;border-radius:12px;
background:linear-gradient(135deg,#7c3aed,#c026d3);color:#fff;font-weight:700;font-size:12px;cursor:pointer;
box-shadow:0 2px 8px rgba(124,58,237,.25);transition:all .15s ease}
.btn-asisten-ai:hover{background:linear-gradient(135deg,#6d28d9,#a21caf);box-shadow:0 4px 12px rgba(124,58,237,.35)}
.btn-asisten-ai:disabled{opacity:.55;cursor:wait}
/* badge gaya kesimpulan */
.ai-style-badge{display:inline-block;background:#ede9fe;color:#6d28d9;font-weight:700;font-size:11px;padding:2px 10px;border-radius:999px;margin-bottom:8px}

/* Pemisah grup menu Marketplace di sidebar */
.portal-nav-sep {
  margin: 18px 12px 7px; padding-top: 12px; border-top: 1px solid #E2E8F0;
  font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: #94A3B8;
}
