/* ============================================================
   MEI ASTRA — Design System (Light Theme)
   Brand: Astra Motor — Red #CC1F1F | Navy #1B3E8C
   WCAG 2.1 AA compliant
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root {
  /* Brand — Astra Motor */
  --brand-red:        #CC1F1F;
  --brand-red-light:  #E53535;
  --brand-red-dim:    rgba(204,31,31,0.08);
  --brand-red-border: rgba(204,31,31,0.20);
  --brand-navy:       #1B3E8C;
  --brand-navy-light: #2551B3;
  --brand-navy-dim:   rgba(27,62,140,0.08);

  /* Primary CTA */
  --brand:        var(--brand-red);
  --brand-hover:  var(--brand-red-light);

  /* Background surfaces — Light */
  --bg-page:      #F3F4F8;
  --bg-panel:     #FFFFFF;
  --bg-surface:   #FFFFFF;
  --bg-elevated:  #FFFFFF;
  --bg-hover:     #F1F3F5;
  --bg-active:    #E8EAED;
  --bg-sidebar:   #0F1B2D;

  /* Text */
  --text-primary:   #111827;
  --text-secondary: #374151;
  --text-muted:     #6B7280;
  --text-subtle:    #9CA3AF;
  --text-sidebar:   #6B7280;
  --text-sidebar-muted: #9CA3AF;

  /* Borders */
  --border-subtle:   #E5E7EB;
  --border-standard: #D1D5DB;
  --border-strong:   #9CA3AF;

  /* Status */
  --green:       #16a34a;
  --green-dim:   rgba(22,163,74,0.08);
  --red:         #dc2626;
  --red-dim:     rgba(220,38,38,0.08);
  --yellow:      #d97706;
  --yellow-dim:  rgba(217,119,6,0.08);
  --blue:        #2563eb;
  --blue-dim:    rgba(37,99,235,0.08);
  --orange:      #ea580c;
  --orange-dim:  rgba(234,88,12,0.08);

  /* WA green */
  --wa-green:       #16a34a;
  --wa-green-hover: #15803d;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', Menlo, monospace;

  /* Spacing */
  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;
  --space-4: 16px;  --space-5: 20px;  --space-6: 24px;
  --space-8: 32px;  --space-10: 40px;

  /* Radius */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-xl:   12px;
  --radius-pill: 9999px;

  /* Layout */
  --sidebar-w: 200px;
  --topbar-h:  52px;
  --transition: 150ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family:    var(--font-sans);
  background:     #eef3f9;
  color:          var(--text-secondary);
  font-size:      14px;
  line-height:    1.6;
  font-weight:    400;
  -webkit-font-smoothing: antialiased;
  min-height:     100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

:focus-visible {
  outline:        2px solid var(--brand-red);
  outline-offset: 2px;
  border-radius:  var(--radius-md);
}

/* ============================================================
   3. LAYOUT
   ============================================================ */
.app-shell {
  display:    flex;
  min-height: 100vh;
  position: relative;
  background:
    linear-gradient(135deg, rgba(220, 38, 38, 0.08) 0%, rgba(255, 255, 255, 0) 34%),
    linear-gradient(225deg, rgba(27, 62, 140, 0.11) 0%, rgba(255, 255, 255, 0) 40%),
    linear-gradient(180deg, #f8fafc 0%, #eef3f9 48%, #f7f9fd 100%);
  overflow: hidden;
}

.app-shell::before,
.app-shell::after {
  display: none;
}

.app-shell::before {
  width: 220px;
  height: 220px;
  top: -64px;
  left: -64px;
  background: #fca5a5;
}

.app-shell::after {
  width: 190px;
  height: 190px;
  right: -54px;
  top: 72px;
  background: #93c5fd;
}

/* --- SIDEBAR (navy) --- */
.sidebar {
  width:          var(--sidebar-w);
  min-height:     100vh;
  background:     rgba(255,255,255,0.56);
  backdrop-filter: blur(16px);
  display:        flex;
  flex-direction: column;
  position:       fixed;
  top:            0;
  left:           0;
  z-index:        200;
  transition:     transform var(--transition);
  overflow-y:     auto;
  border-right:   1px solid rgba(255,255,255,0.78);
  box-shadow:     0 10px 30px rgba(15, 23, 42, 0.08);
  z-index:        2;
}

.sidebar-logo {
  display:       flex;
  align-items:   center;
  gap:           10px;
  padding:       18px 14px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  min-height:    72px;
  background:    transparent;
}

.sidebar-logo-mark {
  width:         34px;
  height:        34px;
  display:       flex;
  align-items:   center;
  justify-content:center;
  border-radius: 10px;
  background:    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(244,246,250,0.96) 100%);
  box-shadow:    0 10px 24px rgba(6, 16, 38, 0.22);
  flex-shrink:   0;
}

.sidebar-logo img {
  height:      100%;
  width:       100%;
  object-fit:  cover;
  display:     block;
}

.sidebar-logo-copy {
  min-width: 0;
}

.sidebar-logo-title {
  font-size:    12.5px;
  font-weight:  600;
  color:        #111827;
  letter-spacing: 0;
}

.sidebar-logo-subtitle {
  margin-top:   2px;
  font-size:    10px;
  color:        #9CA3AF;
  line-height:  1.25;
}

.sidebar-logo-text {
  font-size:   10px;
  font-weight: 600;
  color:       rgba(255,255,255,0.70);
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex:    1;
  padding: 12px 8px;
}

.nav-section-label {
  font-size:      10px;
  font-weight:    600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color:          rgba(255,255,255,0.35);
  padding:        var(--space-3) var(--space-3) var(--space-1);
}

.nav-item {
  display:       flex;
  align-items:   center;
  gap:           9px;
  padding:       8px 10px;
  border-radius: 10px;
  font-size:     12px;
  font-weight:   400;
  color:         #6B7280;
  transition:    background var(--transition), color var(--transition), transform var(--transition), border-color var(--transition);
  line-height:   1;
  margin-bottom: 2px;
  border:        1px solid transparent;
  position:      relative;
}

.nav-item:hover {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.05);
  color:      #374151;
  transform:  translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
  color:      #fff;
  font-weight: 500;
  border-color: rgba(220,38,38,0.40);
  box-shadow: 0 4px 12px rgba(220,38,38,0.30);
}

.nav-item.active::before {
  display: none;
}

.nav-item svg {
  width:       15px;
  height:      15px;
  flex-shrink: 0;
  opacity:     0.95;
}
.nav-item.active svg { opacity: 1; }

.nav-icon {
  width:         22px;
  height:        22px;
  display:       inline-flex;
  align-items:   center;
  justify-content:center;
  border-radius: 7px;
  background:    rgba(0,0,0,0.04);
  flex-shrink:   0;
}

.nav-item.active .nav-icon {
  background: rgba(255,255,255,0.18);
}

.nav-label {
  flex: 1;
  min-width: 0;
}

.sidebar-footer {
  padding:       10px 12px 12px;
  border-top:    1px solid rgba(0,0,0,0.06);
  background:    transparent;
}

.sidebar-user {
  display:       flex;
  align-items:   center;
  gap:           8px;
  padding:       8px;
  border-radius: 10px;
  margin-bottom: 8px;
  background:    rgba(255,255,255,0.72);
  border:        1px solid rgba(0,0,0,0.06);
}

.sidebar-user-trigger {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.sidebar-user-trigger:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.12);
}

.sidebar-user-avatar {
  width:       30px;
  height:      30px;
  border-radius: 50%;
  background:  linear-gradient(135deg, #f04a4a 0%, #cc1f1f 100%);
  display:     flex;
  align-items: center;
  justify-content: center;
  font-size:   11px;
  font-weight: 600;
  color:       #fff;
  flex-shrink: 0;
  box-shadow:  0 10px 20px rgba(204, 31, 31, 0.22);
  overflow:    hidden;
}

.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-name {
  font-size:    11.5px;
  font-weight:  500;
  color:        #111827;
  overflow:     hidden;
  text-overflow: ellipsis;
  white-space:  nowrap;
}

.sidebar-user-role {
  margin-top: 2px;
  font-size:  10px;
  color:      #9CA3AF;
  text-transform: capitalize;
  letter-spacing: 0.04em;
}

.nav-item-logout {
  margin-top: 4px;
  color: #9CA3AF;
  font-size: 11px;
}

.nav-item-logout:hover {
  color: #6B7280;
}

.profile-modal-grid {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 18px;
}

.profile-photo-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.profile-photo-preview {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  background: linear-gradient(135deg, #f04a4a 0%, #cc1f1f 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(204, 31, 31, 0.18);
}

.profile-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-upload-btn {
  position: relative;
  overflow: hidden;
}

.profile-help-text {
  font-size: 11px;
  color: var(--text-subtle);
  text-align: center;
  line-height: 1.5;
}

.profile-form-panel .form-group {
  margin-bottom: 14px;
}

/* --- MAIN CONTENT --- */
.main-content {
  margin-left: var(--sidebar-w);
  flex:        1;
  min-height:  100vh;
  display:     flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* --- TOP BAR --- */
.topbar {
  height:         var(--topbar-h);
  background:     rgba(255,255,255,0.58);
  backdrop-filter: blur(12px);
  border-bottom:  1px solid rgba(255,255,255,0.8);
  display:        flex;
  align-items:    center;
  justify-content: space-between;
  padding:        0 var(--space-6);
  position:       sticky;
  top:            0;
  z-index:        100;
  gap:            var(--space-3);
  box-shadow:     var(--shadow-sm);
}

.topbar-title {
  font-size:   15px;
  font-weight: 600;
  color:       var(--text-primary);
  letter-spacing: -0.01em;
  min-width:   0;
  overflow:    hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display:     flex;
  align-items: center;
  gap:         var(--space-3);
}

.hamburger {
  display:       none;
  background:    none;
  border:        1px solid var(--border-standard);
  color:         var(--text-muted);
  padding:       5px 8px;
  border-radius: var(--radius-md);
  font-size:     14px;
  line-height:   1;
  align-items:   center;
}

.page-body {
  padding:   var(--space-6);
  flex:      1;
  max-width: 100%;
  width:     100%;
  margin:    0 auto;
}

/* ============================================================
   4. PAGE HEADER
   ============================================================ */
.page-header {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  margin-bottom:   var(--space-5);
  gap:             var(--space-4);
  flex-wrap:       wrap;
}

.page-header-title {
  font-size:      20px;
  font-weight:    600;
  color:          var(--text-primary);
  letter-spacing: -0.3px;
  line-height:    1.2;
}

.page-header-subtitle {
  font-size:  13px;
  color:      var(--text-subtle);
  margin-top: 3px;
}

.page-header-actions {
  display:     flex;
  gap:         var(--space-2);
  align-items: center;
  flex-wrap:   wrap;
}

/* ============================================================
   5. CARDS
   ============================================================ */
.card {
  background:    var(--bg-panel);
  border:        1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding:       var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow:    var(--shadow-sm);
}

.card-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  margin-bottom:   var(--space-4);
  padding-bottom:  var(--space-3);
  border-bottom:   1px solid var(--border-subtle);
  gap:             var(--space-3);
}

.card-title {
  font-size:   14px;
  font-weight: 600;
  color:       var(--text-primary);
}

/* ============================================================
   6. KPI CARDS
   ============================================================ */
.kpi-grid {
  display:               grid;
  grid-template-columns: repeat(4, 1fr);
  gap:                   var(--space-4);
  margin-bottom:         var(--space-6);
}

.kpi-card {
  background:    var(--bg-panel);
  border:        1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding:       var(--space-4) var(--space-5);
  box-shadow:    var(--shadow-sm);
  border-left:   3px solid var(--brand-red);
  transition:    box-shadow var(--transition), transform var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform:  translateY(-1px);
}

.kpi-label {
  font-size:      11px;
  font-weight:    600;
  color:          var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom:  var(--space-2);
}

.kpi-value {
  font-size:      28px;
  font-weight:    700;
  color:          var(--text-primary);
  letter-spacing: -0.5px;
  line-height:    1;
}

.kpi-meta {
  margin-top: var(--space-2);
  font-size:  12px;
  color:      var(--text-subtle);
}

/* ============================================================
   7. BUTTONS
   ============================================================ */
.btn {
  display:       inline-flex;
  align-items:   center;
  gap:           6px;
  padding:       7px var(--space-4);
  border-radius: var(--radius-md);
  font-size:     13px;
  font-weight:   500;
  border:        1px solid transparent;
  cursor:        pointer;
  transition:    all var(--transition);
  white-space:   nowrap;
  text-decoration: none;
  line-height:   1.4;
  font-family:   var(--font-sans);
}

.btn:disabled { opacity: 0.50; cursor: not-allowed; }

.btn-primary {
  background:   var(--brand-red);
  color:        #fff;
  border-color: var(--brand-red);
  box-shadow:   0 1px 3px rgba(204,31,31,0.30);
}
.btn-primary:hover:not(:disabled) {
  background:   var(--brand-red-light);
  border-color: var(--brand-red-light);
}

.btn-navy {
  background:   #DC2626;
  color:        #fff;
  border-color: #DC2626;
}
.btn-navy:hover:not(:disabled) {
  background:   #B91C1C;
  border-color: #B91C1C;
}

.btn-ghost {
  background:   #fff;
  color:        var(--text-secondary);
  border-color: var(--border-standard);
}
.btn-ghost:hover:not(:disabled) {
  background:    var(--bg-hover);
  border-color:  var(--border-strong);
  color:         var(--text-primary);
}

.btn-danger {
  background:   var(--red-dim);
  color:        var(--red);
  border-color: rgba(220,38,38,0.25);
}
.btn-danger:hover:not(:disabled) { background: rgba(220,38,38,0.14); }

.btn-wa {
  background:   var(--green-dim);
  color:        var(--wa-green);
  border-color: rgba(22,163,74,0.25);
}
.btn-wa:hover:not(:disabled) { background: rgba(22,163,74,0.14); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px var(--space-5); font-size: 14px; }
.w-100  { width: 100%; justify-content: center; }

.icon-inline {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 14px;
}

.icon-inline svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

.title-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.title-inline .icon-inline {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
  color: var(--brand-navy);
}

/* ============================================================
   8. FORMS
   ============================================================ */
.form-group  { margin-bottom: var(--space-4); }

.form-label {
  display:       block;
  font-size:     12.5px;
  font-weight:   500;
  color:         var(--text-secondary);
  margin-bottom: var(--space-1);
}

.required { color: var(--brand-red); margin-left: 2px; }

.form-control {
  width:         100%;
  padding:       8px 12px;
  background:    #fff;
  border:        1px solid var(--border-standard);
  border-radius: var(--radius-md);
  color:         var(--text-primary);
  font-size:     13.5px;
  font-family:   var(--font-sans);
  transition:    border-color var(--transition), box-shadow var(--transition);
  outline:       none;
  line-height:   1.5;
}

.form-control::placeholder { color: var(--text-subtle); }
.form-control:focus {
  border-color: #94a3b8;
  box-shadow:   0 0 0 3px rgba(148,163,184,0.18);
}
.form-control:disabled { background: var(--bg-page); opacity: 0.7; cursor: not-allowed; }

select.form-control {
  appearance:         none;
  background-image:   url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1.5 3.5h9L6 8z'/%3E%3C/svg%3E");
  background-repeat:  no-repeat;
  background-position: right 10px center;
  padding-right:      32px;
}

.custom-select {
  position: relative;
  width: 100%;
  z-index: 1;
}

.custom-select.open {
  z-index: 220;
}

.filter-bar .custom-select.open,
[class*="-filter"] .custom-select.open {
  z-index: 4000;
  position: relative;
}

.custom-select select.form-control {
  display: none;
}

.custom-select-trigger {
  width: 100%;
  min-height: 46px;
  padding: 10px 38px 10px 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
  position: relative;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  transition: all 0.18s ease;
}

.custom-select-trigger::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1.5 3.5h9L6 8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus-visible {
  border-color: rgba(220, 38, 38, 0.55);
  box-shadow:
    0 0 0 4px rgba(220, 38, 38, 0.10),
    0 10px 26px rgba(15, 23, 42, 0.08);
  outline: none;
}

.custom-select.open .custom-select-trigger::after {
  transform: translateY(-50%) rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 240;
  display: none;
  max-height: 330px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(229, 231, 235, 0.85);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
}

.filter-bar .custom-select-menu,
[class*="-filter"] .custom-select-menu {
  z-index: 4100;
}

[class*="-filter-card"],
[class*="-filter-bar"] {
  position: relative;
  z-index: 3000;
  overflow: visible;
}

.filter-bar,
[class*="-filter"],
[class*="-toolbar"] {
  position: relative;
  z-index: 3000;
  overflow: visible;
}

.table-wrapper,
[class*="-table-card"],
[class*="-table-wrapper"],
[class*="-chart-card"] {
  position: relative;
  z-index: 1;
}

.modal .custom-select-menu {
  z-index: 520;
}

.custom-select.open .custom-select-menu {
  display: grid;
  gap: 4px;
}

.custom-select-option {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #111827;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: all 0.15s ease;
}

.custom-select-option:hover,
.custom-select-option:focus-visible {
  background: #F3F4F6;
  outline: none;
}

.custom-select-option.is-selected {
  background: #FEE2E2;
  color: #B91C1C;
  font-weight: 700;
}

.custom-select-option.is-selected::after {
  content: "✓";
  color: #DC2626;
  font-size: 13px;
  font-weight: 800;
  float: right;
}

.form-hint {
  font-size:  11.5px;
  color:      var(--text-subtle);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ============================================================
   9. TABLE
   ============================================================ */
.table-wrapper {
  background:    var(--bg-panel);
  border:        1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow:      hidden;
  overflow-x:    auto;
  box-shadow:    var(--shadow-sm);
}

.table {
  width:           100%;
  border-collapse: collapse;
  font-size:       12px;
  font-family:     'Plus Jakarta Sans', 'Inter', var(--font-sans);
}

.table th {
  background:     rgba(0,0,0,0.02);
  color:          #9CA3AF;
  font-size:      10px;
  font-weight:    700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding:        10px 18px;
  text-align:     left;
  border-bottom:  0.5px solid rgba(0,0,0,0.06);
  white-space:    nowrap;
}

.table td {
  padding:        13px 18px;
  border-bottom:  0.5px solid rgba(0,0,0,0.05);
  color:          #374151;
  font-size:      12px;
  font-weight:    500;
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.60); }

/* ============================================================
   10. BADGES
   ============================================================ */
.badge {
  display:       inline-flex;
  align-items:   center;
  padding:       3px 10px;
  border-radius: 20px;
  font-size:     10.5px;
  font-weight:   600;
  letter-spacing: 0.02em;
  white-space:   nowrap;
  line-height:   1.5;
  font-family:   'Plus Jakarta Sans', 'Inter', var(--font-sans);
}

.badge-green   { background: var(--green-dim);  color: var(--green);   border: 1px solid rgba(22,163,74,0.20); }
.badge-red     { background: var(--red-dim);    color: var(--red);     border: 1px solid rgba(220,38,38,0.20); }
.badge-yellow  { background: var(--yellow-dim); color: var(--yellow);  border: 1px solid rgba(217,119,6,0.20); }
.badge-blue    { background: var(--blue-dim);   color: var(--blue);    border: 1px solid rgba(37,99,235,0.20); }
.badge-orange  { background: var(--orange-dim); color: var(--orange);  border: 1px solid rgba(234,88,12,0.20); }
.badge-neutral { background: var(--bg-page);    color: var(--text-muted); border: 1px solid var(--border-standard); }
.badge-brand   { background: var(--brand-red-dim); color: var(--brand-red); border: 1px solid var(--brand-red-border); }
.badge-navy    { background: var(--brand-navy-dim); color: var(--brand-navy); border: 1px solid rgba(27,62,140,0.20); }

.badge-admin {
  background: #F9FAFB;
  color: #6B7280;
  border: 0.5px solid rgba(0,0,0,0.08);
}

.badge-kepala {
  background: #F9FAFB;
  color: #6B7280;
  border: 0.5px solid rgba(0,0,0,0.08);
}

.badge-status-active {
  background: #F9FAFB;
  color: #6B7280;
  border: 0.5px solid rgba(0,0,0,0.08);
}

.badge-status-inactive {
  background: #F9FAFB;
  color: #9CA3AF;
  border: 0.5px solid rgba(0,0,0,0.08);
}

.wa-status-sent { font-size: 11px; color: var(--wa-green); font-weight: 600; }

/* ============================================================
   11. FILTER BAR
   ============================================================ */
.filter-bar {
  display:       flex;
  gap:           var(--space-3);
  flex-wrap:     wrap;
  align-items:   flex-end;
  background:    var(--bg-panel);
  border:        1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding:       var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow:    var(--shadow-sm);
}

.filter-bar .form-group { margin-bottom: 0; min-width: 150px; }

.filter-bar .form-control,
[class*="-filter-card"] .form-control,
[class*="-filter"] .form-control {
  min-height:    34px;
  padding-top:   6px;
  padding-bottom:6px;
  border-radius: 8px;
}

.filter-bar .btn-sm,
[class*="-filter-actions"] .btn-sm,
[class*="-table-toolbar"] .btn-sm,
[class*="-toolbar"] .btn-sm,
.page-header-actions .btn-sm {
  min-height:      34px;
  padding:         0 12px;
  border-radius:   8px;
  align-items:     center;
  justify-content: center;
}

/* ============================================================
   12. ALERTS
   ============================================================ */
.alert {
  padding:       10px 14px;
  border-radius: var(--radius-md);
  font-size:     13px;
  margin-bottom: var(--space-4);
  line-height:   1.5;
  border:        1px solid transparent;
}

.alert-success { background: var(--green-dim);  color: #15803d; border-color: rgba(22,163,74,0.25); }
.alert-error   { background: var(--red-dim);    color: #b91c1c; border-color: rgba(220,38,38,0.25); }
.alert-info    { background: var(--blue-dim);   color: #1d4ed8; border-color: rgba(37,99,235,0.25); }
.alert-warning { background: var(--yellow-dim); color: #b45309; border-color: rgba(217,119,6,0.25); }

/* ============================================================
   13. TOAST
   ============================================================ */
#toast-container {
  position:   fixed;
  bottom:     24px;
  right:      24px;
  z-index:    9999;
  display:    flex;
  flex-direction: column-reverse;
  gap:        8px;
  max-width:  360px;
}

.toast {
  background:    #fff;
  border:        1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding:       12px 16px;
  font-size:     13px;
  color:         var(--text-secondary);
  box-shadow:    var(--shadow-lg);
  animation:     toast-in 200ms ease forwards;
  line-height:   1.5;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   14. MODAL
   ============================================================ */
.modal-backdrop {
  display:         none;
  position:        fixed;
  inset:           0;
  background:      rgba(15, 23, 42, 0.40);
  backdrop-filter: blur(7px);
  z-index:         10000;
  align-items:     center;
  justify-content: center;
  padding:         var(--space-4);
}
.modal-backdrop.open { display: flex; }

.modal-backdrop .modal {
  position: relative;
  z-index: 10001;
}

body.modal-open .filter-bar,
body.modal-open [class*="-filter"],
body.modal-open [class*="-filter-card"],
body.modal-open [class*="-toolbar"] {
  z-index: 1 !important;
}

body:has(.modal-backdrop.open) .sidebar {
  opacity: 0.72;
}

.card,
.table-wrapper,
.admin-chart-card,
.head-chart-card,
.sales-card {
  content-visibility: visible;
}

.admin-chart-card,
.head-chart-card,
.sales-card {
  content-visibility: auto;
  contain-intrinsic-size: 420px;
}

.modal {
  background:    #fff;
  border:        1px solid var(--border-subtle);
  border-radius: 14px;
  width:         100%;
  max-width:     480px;
  max-height:    calc(100vh - 32px);
  overflow:      hidden;
  box-shadow:    var(--shadow-lg);
  transform:     translateZ(0);
}

.modal-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         var(--space-4) var(--space-5);
  border-bottom:   1px solid var(--border-subtle);
}

.modal-title {
  font-size:   14px;
  font-weight: 600;
  color:       var(--text-primary);
}

.modal-close {
  background:    none;
  border:        1px solid var(--border-standard);
  color:         var(--text-muted);
  width:         28px;
  height:        28px;
  border-radius: 50%;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     14px;
  cursor:        pointer;
  transition:    background var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body   {
  padding:    var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding:         var(--space-4) var(--space-5);
  border-top:      1px solid var(--border-subtle);
  display:         flex;
  justify-content: flex-end;
  gap:             var(--space-2);
}

body.modal-open {
  overflow: hidden;
}

.confirm-modal {
  max-width: 420px;
  border-radius: 18px;
}

.confirm-modal-body {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: flex-start;
}

.confirm-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(27,62,140,0.08);
  color: var(--brand-navy);
  font-size: 18px;
  font-weight: 700;
}

.confirm-modal-icon.is-danger {
  background: rgba(220,38,38,0.10);
  color: var(--red);
}

.confirm-modal-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.confirm-modal-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.confirm-modal-footer {
  justify-content: space-between;
}

/* ============================================================
   15. PAGINATION
   ============================================================ */
.pagination {
  display:         flex;
  gap:             4px;
  justify-content: center;
  margin-top:      var(--space-4);
}

.page-btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  width:           32px;
  height:          32px;
  border-radius:   var(--radius-md);
  font-size:       13px;
  font-weight:     500;
  color:           var(--text-muted);
  border:          1px solid var(--border-standard);
  background:      #fff;
  transition:      all var(--transition);
  text-decoration: none;
}

.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active {
  background:   var(--brand-red);
  border-color: var(--brand-red);
  color:        #fff;
}

/* ============================================================
   16. TIMELINE
   ============================================================ */
.timeline { padding: 0; }

.timeline-item {
  position:    relative;
  padding:     0 0 var(--space-5) 28px;
  border-left: 2px solid var(--border-subtle);
}
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }

.timeline-dot {
  position:      absolute;
  left:          -6px;
  top:           4px;
  width:         10px;
  height:        10px;
  border-radius: 50%;
  background:    var(--brand-red);
  border:        2px solid #fff;
  box-shadow:    0 0 0 2px var(--brand-red-border);
}

.timeline-date {
  font-size:     11.5px;
  color:         var(--text-subtle);
  margin-bottom: 4px;
}

.timeline-title {
  font-size:   13px;
  color:       var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.timeline-note {
  font-size:    12.5px;
  color:        var(--text-muted);
  background:   var(--bg-page);
  border:       1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding:      var(--space-2) var(--space-3);
  margin-top:   var(--space-2);
  line-height:  1.5;
}

/* ============================================================
   17. EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding:    var(--space-10) var(--space-6);
}

.empty-state-icon {
  font-size:     32px;
  margin-bottom: var(--space-3);
  opacity:       0.3;
}

.empty-state-title {
  font-size:     15px;
  font-weight:   600;
  color:         var(--text-primary);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size:   13px;
  color:       var(--text-subtle);
  max-width:   300px;
  margin:      0 auto;
  line-height: 1.6;
}

/* ============================================================
   18. SPINNER
   ============================================================ */
.spinner {
  display:        inline-block;
  width:          13px;
  height:         13px;
  border:         2px solid rgba(0,0,0,0.15);
  border-top-color: currentColor;
  border-radius:  50%;
  animation:      spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   19. LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 4vw, 46px);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.72) 0%, rgba(15, 23, 42, 0.44) 50%, rgba(15, 23, 42, 0.64) 100%),
    linear-gradient(180deg, rgba(220, 38, 38, 0.14), rgba(23, 59, 122, 0.18)),
    url('../img/login-background.png') center / cover no-repeat;
}

/* ----- CENTERED LOGIN CARD ----- */
.login-card {
  width: min(420px, 100%);
  padding: clamp(28px, 5vw, 40px);
  border-radius: 24px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.96);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
}

.login-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  padding: 8px;
  border-radius: 18px;
  background: #fff;
  box-shadow:
    0 12px 28px rgba(15, 23, 42, 0.08),
    inset 0 0 0 1px rgba(17,24,39,0.05);
}

.login-form-head {
  text-align: center;
  margin-bottom: 20px;
}

.login-title {
  font-size: clamp(22px, 4vw, 26px);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.login-sub {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* Alert on login */
.login-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.18);
  color: #b91c1c;
  font-size: 13px;
  font-weight: 500;
}

.alert-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.login-field {
  margin-bottom: 14px;
}

.login-form .form-label {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
}

/* Input with icon */
.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #9ca3af;
  transition: color 200ms ease;
  z-index: 1;
  pointer-events: none;
}

.login-input-icon svg {
  width: 18px;
  height: 18px;
}

.login-form .form-control.login-input {
  min-height: 50px;
  border-radius: 14px;
  border-color: #d7deea;
  background: #fff;
  padding-left: 44px;
  padding-right: 14px;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
  font-size: 14px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.login-form .form-control.login-input:focus {
  border-color: rgba(27,62,140,0.34);
  box-shadow: 0 0 0 4px rgba(27,62,140,0.08);
}

.login-form .form-control.login-input:focus ~ .login-input-icon,
.login-input-wrap:focus-within .login-input-icon {
  color: var(--brand-navy);
}

.login-input-password {
  padding-right: 54px !important;
}

.login-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-capslock {
  color: var(--brand-red);
  font-size: 11px;
  font-weight: 600;
}

.login-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: none;
  background: rgba(15,23,42,0.05);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  transition: background 150ms ease, color 150ms ease;
  z-index: 2;
}

.login-password-toggle:hover {
  background: rgba(15,23,42,0.08);
  color: var(--text-secondary);
}

.login-password-icon {
  width: 18px;
  height: 18px;
}

/* Submit button */
.login-submit {
  min-height: 52px;
  margin-top: 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 14px 26px rgba(220, 38, 38, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: box-shadow 200ms ease, transform 100ms ease;
}

.login-submit:hover:not(:disabled) {
  box-shadow: 0 18px 32px rgba(220, 38, 38, 0.30);
  transform: translateY(-1px);
}

.login-submit:active:not(:disabled) {
  transform: translateY(0);
}

.login-submit:disabled {
  opacity: 0.78;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.login-submit-arrow {
  width: 18px;
  height: 18px;
  transition: transform 200ms ease;
}

.login-submit:hover:not(:disabled) .login-submit-arrow {
  transform: translateX(3px);
}

/* ----- COPYRIGHT FOOTER ----- */
.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.40);
  letter-spacing: 0.02em;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 480px) {
  .login-card {
    padding: 24px 20px;
    border-radius: 20px;
  }

  .login-logo {
    width: 64px;
    height: 64px;
  }

  .login-title {
    font-size: 20px;
  }

  .login-sub {
    font-size: 12px;
  }

  .login-form .form-control.login-input {
    min-height: 46px;
    font-size: 13px;
  }

  .login-submit {
    min-height: 48px;
    font-size: 13px;
  }

  .login-label-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .login-footer {
    font-size: 11px;
  }
}

/* ============================================================
   20. SKIP LINK
   ============================================================ */
.skip-link {
  position:   absolute;
  top:        -40px;
  left:       0;
  background: var(--brand-red);
  color:      #fff;
  padding:    8px 16px;
  z-index:    9999;
  font-size:  13px;
  border-radius: 0 0 var(--radius-md) 0;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ============================================================
   21. RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform:  translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display:    none;
    position:   fixed;
    inset:      0;
    background: rgba(0,0,0,0.40);
    z-index:    199;
  }
  .sidebar-overlay.open { display: block; }

  .main-content  { margin-left: 0; }
  .hamburger     { display: inline-flex; }
  .form-row      { grid-template-columns: 1fr; }
  .page-body     { padding: var(--space-4); }
}

@media (max-width: 480px) {
  .kpi-grid    { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .topbar      { padding: 0 var(--space-4); }
  .modal-backdrop { padding: 10px; align-items: flex-start; }
  .modal       { border-radius: 12px; max-height: calc(100vh - 20px); }
  .modal-header,
  .modal-body,
  .modal-footer { padding-left: var(--space-4); padding-right: var(--space-4); }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

/* ============================================================
   22. SCROLLBAR & UTILITY
   ============================================================ */
::-webkit-scrollbar             { width: 6px; height: 6px; }
::-webkit-scrollbar-track       { background: var(--bg-page); }
::-webkit-scrollbar-thumb       { background: var(--border-standard); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.mb-0  { margin-bottom: 0 !important; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top:    16px; }

@media print {
  .sidebar, .topbar, .btn, .pagination { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
}

/* ============================================================
   23. Premium Theme Overrides (Global)
   ============================================================ */

/* Global glass surface for common cards/sections across all menus */
.card,
.table-wrapper,
.filter-bar,
.sales-prospect-filter-card,
.sales-prospect-table-card,
.sales-form-card,
.sales-detail-card,
.sales-reminder-card,
.sales-reminder-table-card,
.account-filter-card,
.account-table-card,
.branch-filter-card,
.branch-table-card,
.head-monthly-toolbar,
.head-monthly-section,
.head-report-card,
.head-report-toolbar,
.profile-card {
  background: rgba(255,255,255,0.78) !important;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.85) !important;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08) !important;
}

/* Global top controls feel closer to reference */
.filter-bar {
  border-radius: 14px;
  padding: 14px 16px;
  overflow: visible;
  gap: 10px;
}

.account-filter-card,
.branch-filter-card,
.sales-prospect-filter-card,
.head-report-toolbar,
.head-monthly-toolbar {
  overflow: visible !important;
}

.filter-bar,
[class*="-filter-card"] {
  border-radius: 14px !important;
}

.filter-bar .form-group,
[class*="-filter"] .form-group {
  margin-bottom: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.filter-bar .form-label,
[class*="-filter"] .form-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9CA3AF;
  margin-bottom: 6px;
  line-height: 1;
}

.filter-bar .form-control,
[class*="-filter"] .form-control,
[class*="-toolbar"] .form-control {
  background: rgba(255,255,255,0.90);
  border-color: rgba(0,0,0,0.10);
  min-height: 34px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 500;
  padding-top: 6px;
  padding-bottom: 6px;
}

.custom-select-trigger {
  border-color: rgba(148, 163, 184, 0.35);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.82);
  min-height: 34px;
  font-size: 11.5px;
}

.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus-visible {
  border-color: rgba(220, 38, 38, 0.55);
  box-shadow:
    0 0 0 4px rgba(220, 38, 38, 0.10),
    0 10px 26px rgba(15, 23, 42, 0.08);
}

.custom-select-menu {
  border: 1px solid rgba(229, 231, 235, 0.85);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
}

.filter-bar .btn,
[class*="-filter-actions"] .btn,
[class*="-filter"] .btn-sm {
  min-height: 34px;
  border-radius: 9px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* Primary action (Terapkan etc.) follows brand red gradient */
.btn-navy {
  background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.28);
}

.btn-navy:hover:not(:disabled) {
  background: linear-gradient(135deg, #C81E1E 0%, #E63A3A 100%);
  border-color: transparent;
}

/* Sidebar nav typography refinement for all levels */
.nav-item {
  font-size: 12px;
  font-weight: 400;
}

.nav-item.active {
  font-weight: 500;
}


/* ============================================================
   Generic password toggle (eye icon) — reusable di semua form
   Mirip dengan .login-password-toggle (lihat login.php)
   Pasang dengan markup:
     <div class="form-group">
        <label class="form-label">Password</label>
        <div class="password-wrap">  <!-- HANYA input + button! -->
           <input type="password" id="my-pw">
           <button type="button" class="password-toggle" data-target="my-pw"
                   aria-label="Tampilkan password">
              <span class="sr-only">Tampilkan password</span>
           </button>
        </div>
     </div>
   JS akan inject SVG eye otomatis (sama seperti login).
   ============================================================ */
.password-wrap {
  position: relative;
  display: block;
}

.password-wrap .form-control {
  width: 100%;
  padding-right: 50px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-muted, #6b7280);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
  user-select: none;
}

.password-toggle:hover {
  background: rgba(15, 23, 42, 0.10);
  color: var(--text-secondary, #1f2937);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--brand-navy, #1e3a8a);
  outline-offset: 2px;
}

.password-toggle.is-visible {
  color: var(--brand-navy, #1e3a8a);
}

.password-toggle-svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* sr-only utility (kalau belum ada) untuk label aksesibilitas */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ============================================================
   Custom select - disabled state (cascade kabupaten>kecamatan)
   ============================================================ */
.custom-select.is-disabled .custom-select-trigger,
.custom-select-trigger:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.85;
}
.custom-select.is-disabled .custom-select-trigger::after,
.custom-select-trigger:disabled::after {
  opacity: 0.5;
}

/* ============================================================
   24. Responsive Safety Layer
   Menjaga halaman admin/kepala/sales tetap nyaman di tablet & HP.
   ============================================================ */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.main-content,
.page-body,
.card,
.table-wrapper,
[class*="-card"],
[class*="-section"],
[class*="-toolbar"],
[class*="-filter"],
[class*="-grid"],
[class*="-page"] {
  min-width: 0;
}

.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

.table {
  min-width: 720px;
}

.table th,
.table td {
  overflow-wrap: anywhere;
}

canvas {
  max-width: 100% !important;
}

.page-header-actions,
[class*="-actions"],
[class*="-toolbar"] {
  min-width: 0;
}

@media (max-width: 1180px) {
  .page-body {
    padding: 20px;
  }

  .admin-stat-grid,
  .head-stat-grid,
  .sales-kpi-grid,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .admin-chart-grid,
  .head-chart-grid,
  .sales-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 900px) {
  .app-shell {
    overflow: visible;
  }

  .sidebar {
    width: min(82vw, 280px);
    z-index: 220;
  }

  .sidebar-overlay {
    z-index: 210;
  }

  .topbar {
    min-width: 0;
    padding-inline: 16px;
  }

  .topbar-title {
    font-size: 14px;
  }

  .topbar-right,
  .topbar .admin-filter,
  .topbar .head-filter {
    display: none !important;
  }

  .admin-toolbar,
  .head-toolbar {
    display: grid !important;
  }

  .filter-bar,
  .admin-filter,
  .head-filter,
  .sales-filter,
  [class*="-filter-form"],
  [class*="-filter-card"] form {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: end;
    width: 100%;
  }

  .filter-bar .form-group,
  [class*="-filter"] .form-group,
  .sales-filter-field {
    min-width: 0 !important;
    width: 100%;
  }

  .filter-bar .btn,
  [class*="-filter"] .btn,
  .sales-filter .btn {
    width: 100%;
    justify-content: center;
  }

  .admin-chart-grid,
  .head-chart-grid,
  .sales-chart-grid,
  .admin-detail-grid,
  .head-detail-grid,
  .sales-detail-grid,
  [class*="-detail-grid"] {
    grid-template-columns: 1fr !important;
  }

  .card-header,
  .page-header,
  [class*="-toolbar"] {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13.5px;
  }

  .page-body {
    padding: 12px;
  }

  .card,
  .sales-card,
  .admin-chart-card,
  .head-chart-card,
  .head-table-card,
  .admin-table-card,
  [class*="-card"] {
    border-radius: 12px !important;
    padding: 12px !important;
  }

  .admin-stat-grid,
  .head-stat-grid,
  .sales-kpi-grid,
  .kpi-grid,
  .admin-chart-grid,
  .head-chart-grid,
  .sales-chart-grid,
  [class*="-summary-grid"],
  [class*="-sales-card"] {
    grid-template-columns: 1fr !important;
  }

  .filter-bar,
  .admin-filter,
  .head-filter,
  .sales-filter,
  [class*="-filter-form"],
  [class*="-filter-card"] form {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .form-row,
  .profile-modal-grid,
  .confirm-modal-body,
  .head-info-row,
  [class*="-info-row"],
  [class*="-modal-status"],
  [class*="-modal-footer"] {
    grid-template-columns: 1fr !important;
  }

  .page-header {
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-header-actions,
  [class*="-actions"],
  [class*="-toolbar-actions"] {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  .page-header-actions .btn,
  [class*="-actions"] .btn,
  [class*="-toolbar-actions"] .btn {
    flex: 1 1 140px;
    justify-content: center;
  }

  .btn {
    min-height: 36px;
    justify-content: center;
  }

  .btn-sm {
    min-height: 34px;
  }

  .table {
    min-width: 640px;
    font-size: 11.5px;
  }

  .table th,
  .table td {
    padding: 10px 12px;
  }

  .badge {
    white-space: normal;
    text-align: center;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 8px;
  }

  .modal {
    max-width: none;
    max-height: calc(100dvh - 16px);
    display: flex;
    flex-direction: column;
  }

  .modal-body {
    flex: 1 1 auto;
  }

  .modal-footer,
  [class*="-modal-footer"] {
    flex-direction: column-reverse !important;
  }

  .modal-footer .btn,
  [class*="-modal-footer"] .btn {
    width: 100%;
  }

  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (max-width: 380px) {
  .page-body {
    padding: 10px;
  }

  .topbar {
    padding-inline: 10px;
    gap: 8px;
  }

  .topbar-title {
    font-size: 13px;
  }

  .card,
  .sales-card,
  [class*="-card"] {
    padding: 10px !important;
  }

  .page-header-actions .btn,
  [class*="-actions"] .btn,
  [class*="-toolbar-actions"] .btn {
    flex-basis: 100%;
  }
}
