/* App responsive — mobile & tablet friendly untuk seluruh modul (.app-shell) */

/* Tab navigasi — desktop */
.app-shell .pf-tabs,
.app-shell .pgm-tabs,
.app-shell .ums-tabs,
.app-shell .sc-service-tabs,
.app-shell .rev627-tabs,
.app-shell .fl-tabs,
.app-shell .asr-fin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.app-shell .pf-tab,
.app-shell .pgm-tabs a,
.app-shell .ums-tabs a,
.app-shell .sc-service-tab,
.app-shell .rev627-tabs a,
.app-shell .fl-tabs a,
.app-shell .asr-fin-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid var(--app-line, #e2e8f0);
  background: #fff;
  border-radius: 999px;
  padding: 9px 14px;
  color: #334155;
  font-weight: 600;
  font-size: 13px;
  min-height: 40px;
  box-sizing: border-box;
}

.app-shell .pf-tab.active,
.app-shell .pgm-tabs a.active,
.app-shell .ums-tabs a.active,
.app-shell .sc-service-tab.active,
.app-shell .rev627-tabs a.active,
.app-shell .fl-tabs a.active,
.app-shell .asr-fin-tabs a.active {
  background: var(--app-accent, #0f1115);
  border-color: var(--app-accent, #0f1115);
  color: #fff;
}

/* Tablet landscape / small laptop */
@media (max-width: 1100px) {
  .app-shell .fin-kpi,
  .app-shell .kar-kpi,
  .app-shell .dashboard-grid,
  .app-shell .stat-grid,
  .app-shell .pf-stats,
  .app-shell .cards,
  .app-shell .wa-report-kpi,
  .app-shell .sc-service-page .fin-kpi {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .app-shell .pf-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Tablet portrait & mobile */
@media (max-width: 900px) {
  .app-shell main.app-main {
    padding: 12px 12px calc(22px + env(safe-area-inset-bottom, 0px));
  }

  .app-shell .page-title-row.ws-auto-page-title {
    padding: 14px 16px;
    margin-bottom: 12px;
  }

  .app-shell .page-title-row h2,
  .app-shell .ws-auto-page-title h2 {
    font-size: 1.15rem;
    line-height: 1.25;
  }

  .app-shell .ws-auto-page-title .note {
    font-size: 13px;
    line-height: 1.5;
    max-width: none;
  }

  .app-shell .pf-card,
  .app-shell .card,
  .app-shell .ws-panel,
  .app-shell .menu-page-card,
  .app-shell .fin-card,
  .app-shell .page-card {
    padding: 14px 14px;
    margin-bottom: 12px;
    border-radius: 14px;
  }

  /* Tab — scroll horizontal, mudah disentuh */
  .app-shell .pf-tabs,
  .app-shell .pgm-tabs,
  .app-shell .ums-tabs,
  .app-shell .sc-service-tabs,
  .app-shell .rev627-tabs,
  .app-shell .fl-tabs,
  .app-shell .asr-fin-tabs,
  .app-shell .status-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    padding-bottom: 6px;
    margin-left: -2px;
    margin-right: -2px;
    padding-left: 2px;
    padding-right: 2px;
  }

  .app-shell .pf-tab,
  .app-shell .pgm-tabs a,
  .app-shell .ums-tabs a,
  .app-shell .sc-service-tab,
  .app-shell .rev627-tabs a,
  .app-shell .fl-tabs a,
  .app-shell .asr-fin-tabs a,
  .app-shell .status-tabs a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Filter & form toolbar */
  .app-shell .fin-filter,
  .app-shell .finance-filter,
  .app-shell .form-grid,
  .app-shell .filter-bar,
  .app-shell .topbar,
  .app-shell .filter-panel,
  .app-shell .pf-form,
  .app-shell form.filter,
  .app-shell .sc-service-filter {
    display: grid !important;
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100%;
  }

  .app-shell .sc-fu-filter,
  .app-shell .filter-grid,
  .app-shell .list-filter-grid,
  .app-shell .crm-search-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .app-shell .sc-crm-stat-grid,
  .app-shell .sc-fu-stat-grid,
  .app-shell .crm-summary-clean {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell .ws-list-tabs,
  .app-shell .quick-fu-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }

  .app-shell .fin-filter label,
  .app-shell .finance-filter label,
  .app-shell .form-grid label,
  .app-shell .pf-form label,
  .app-shell .sc-service-filter label {
    width: 100%;
    min-width: 0;
  }

  .app-shell .fin-filter input,
  .app-shell .fin-filter select,
  .app-shell .finance-filter input,
  .app-shell .finance-filter select,
  .app-shell .form-grid input,
  .app-shell .form-grid select,
  .app-shell .pf-form input,
  .app-shell .pf-form select,
  .app-shell .pf-form textarea {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px; /* hindari zoom iOS */
  }

  .app-shell .fin-filter .btn,
  .app-shell .finance-filter .btn,
  .app-shell .form-grid .btn,
  .app-shell .form-grid button,
  .app-shell .topbar .btn,
  .app-shell .pf-actions,
  .app-shell .sc-service-actions,
  .app-shell .action-row,
  .app-shell .quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .app-shell .fin-filter .btn,
  .app-shell .finance-filter .btn,
  .app-shell .form-grid .btn,
  .app-shell .form-grid button[type="submit"],
  .app-shell .topbar .btn,
  .app-shell .pf-btn,
  .app-shell .btn,
  .app-shell button.btn {
    min-height: 44px;
    width: 100%;
    justify-content: center;
  }

  .app-shell .pf-actions .pf-btn,
  .app-shell .pf-actions .btn,
  .app-shell .sc-service-notice-actions .pf-btn,
  .app-shell .pgm-actions .pf-btn,
  .app-shell .pgm-actions .btn {
    width: auto;
    flex: 1 1 auto;
    min-width: min(100%, 140px);
  }

  /* KPI grids */
  .app-shell .fin-kpi,
  .app-shell .kar-kpi,
  .app-shell .fst-kpi,
  .app-shell .dashboard-grid,
  .app-shell .stat-grid,
  .app-shell .kpi-row,
  .app-shell .rev627-kpi,
  .app-shell .flpt-grid,
  .app-shell .finance-kpi,
  .app-shell .pf-stats,
  .app-shell .cards,
  .app-shell .wa-report-kpi,
  .app-shell .ums-grid,
  .app-shell .ws-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .app-shell .fin-kpi-card,
  .app-shell .kar-kpi-card,
  .app-shell .pf-stat,
  .app-shell .stat-card,
  .app-shell .dashboard-card {
    padding: 12px 14px !important;
  }

  .app-shell .fin-kpi-card b,
  .app-shell .kar-kpi-card b,
  .app-shell .pf-stat b,
  .app-shell .stat-card b {
    font-size: 1.25rem !important;
  }

  /* Tabel — mode kartu (ws-responsive-table dari layout.php) */
  .app-shell .pf-table-wrap,
  .app-shell .table-scroll,
  .app-shell .table-wrap,
  .app-shell .table-responsive,
  .app-shell .apm-lap-table-wrap {
    overflow: visible !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }

  .app-shell table.ws-responsive-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  .app-shell table.ws-responsive-table thead {
    display: none !important;
  }

  .app-shell table.ws-responsive-table tbody {
    display: grid !important;
    gap: 12px !important;
  }

  .app-shell table.ws-responsive-table tbody tr {
    display: block !important;
    background: var(--app-card, #fff) !important;
    border: 1px solid var(--app-line, #e2e8f0) !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06) !important;
    padding: 12px 14px !important;
    margin: 0 !important;
  }

  .app-shell table.ws-responsive-table tbody td {
    display: grid !important;
    grid-template-columns: minmax(88px, 36%) minmax(0, 1fr) !important;
    gap: 8px 10px !important;
    align-items: start !important;
    padding: 8px 0 !important;
    border: 0 !important;
    border-bottom: 1px dashed #edf0f5 !important;
    background: transparent !important;
    font-size: 13px !important;
    line-height: 1.45 !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    text-align: left !important;
  }

  .app-shell table.ws-responsive-table tbody td:last-child {
    border-bottom: 0 !important;
    padding-bottom: 2px !important;
  }

  .app-shell table.ws-responsive-table tbody td::before {
    content: attr(data-label) !important;
    display: block !important;
    color: var(--app-muted, #64748b) !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    line-height: 1.3 !important;
  }

  .app-shell table.ws-responsive-table tbody td.cell-stack::before,
  .app-shell table.ws-responsive-table tbody td.ws-mobile-status::before {
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-self: start !important;
  }

  .app-shell table.ws-responsive-table tbody td.ws-mobile-title,
  .app-shell table.ws-responsive-table tbody td[data-label*="Nama"],
  .app-shell table.ws-responsive-table tbody td[data-label*="nama"],
  .app-shell table.ws-responsive-table tbody td[data-label*="Pelanggan"],
  .app-shell table.ws-responsive-table tbody td[data-label*="Customer"] {
    grid-template-columns: 1fr !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    padding-top: 2px !important;
    padding-bottom: 10px !important;
    border-bottom: 1px solid var(--app-line, #e2e8f0) !important;
  }

  .app-shell table.ws-responsive-table tbody td.ws-mobile-title::before,
  .app-shell table.ws-responsive-table tbody td[data-label*="Nama"]::before,
  .app-shell table.ws-responsive-table tbody td[data-label*="Pelanggan"]::before {
    display: none !important;
  }

  .app-shell table.ws-responsive-table tbody td.ws-mobile-actions,
  .app-shell table.ws-responsive-table tbody td[data-label*="Aksi"],
  .app-shell table.ws-responsive-table tbody td[data-label*="aksi"] {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: flex-start !important;
    padding-top: 10px !important;
  }

  .app-shell table.ws-responsive-table tbody td.ws-mobile-actions::before,
  .app-shell table.ws-responsive-table tbody td[data-label*="Aksi"]::before {
    flex: 0 0 100%;
    margin-bottom: 2px;
  }

  .app-shell table.ws-responsive-table tbody td.ws-mobile-actions a,
  .app-shell table.ws-responsive-table tbody td[data-label*="Aksi"] a {
    display: inline-flex !important;
    align-items: center !important;
    align-self: flex-start !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-height: 40px !important;
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
    background: #f1f5f9 !important;
    border: 1px solid var(--app-line, #e2e8f0) !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    color: var(--app-text, #0f172a) !important;
  }
  .app-shell table.ws-responsive-table tbody td.ws-mobile-actions a.mini.primary,
  .app-shell table.ws-responsive-table tbody td[data-label*="Aksi"] a.mini.primary {
    background: #111827 !important;
    border-color: #111827 !important;
    color: #fff !important;
  }

  .app-shell table.ws-responsive-table tbody td[colspan] {
    display: block !important;
    text-align: center !important;
    padding: 16px !important;
    color: var(--app-muted, #64748b) !important;
  }

  .app-shell table.ws-responsive-table tbody td[colspan]::before {
    display: none !important;
  }

  /* Tabel lebar — opsi scroll horizontal (class no-mobile-card) */
  .app-shell .pf-table-wrap--scroll,
  .app-shell .table-scroll-h {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid var(--app-line, #e2e8f0) !important;
    border-radius: 12px !important;
    background: #fff !important;
  }

  .app-shell .pf-table-wrap--scroll table,
  .app-shell .table-scroll-h table {
    min-width: 720px;
  }

  .app-shell .pf-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .app-shell .profile-wrap,
  .app-shell .ufp-wrap,
  .app-shell .absen-workspace {
    grid-template-columns: 1fr !important;
  }

  .app-shell .ws-pagination-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .app-shell .ws-pagination-limit,
  .app-shell .ws-pagination-nav {
    width: 100%;
    justify-content: center;
  }
}

/* Mobile kecil */
@media (max-width: 560px) {
  .app-shell .fin-kpi,
  .app-shell .kar-kpi,
  .app-shell .dashboard-grid,
  .app-shell .pf-stats,
  .app-shell .cards,
  .app-shell .wa-report-kpi,
  .app-shell .ums-grid,
  .app-shell .ws-cards {
    grid-template-columns: 1fr !important;
  }

  .app-shell .pf-grid,
  .app-shell .finance-grid-2,
  .app-shell .finance-hero {
    grid-template-columns: 1fr !important;
  }

  .app-shell .wa-funnel-step {
    min-height: 100px;
  }

  .app-shell .pgm-actions,
  .app-shell .pgm-head {
    flex-direction: column;
    align-items: stretch !important;
  }

  .app-shell .pgm-actions .pf-btn,
  .app-shell .pgm-actions .btn {
    width: 100%;
  }

  .app-shell .absen-grid-top,
  .app-shell .absen-timeline,
  .app-shell .absen-workspace {
    grid-template-columns: 1fr !important;
  }

  .app-shell .absen-hero {
    flex-direction: column;
    align-items: stretch;
  }
}
