:root {
  --bg: #0b0f17;
  --bg-card: #131b2e;
  --bg-card-hover: #19233c;
  --bg-input: #0e1525;
  --border: #23304d;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-hover: #059669;
  --accent: #3b82f6;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

/* Custom Modern Dark Scrollbars (Menghilangkan Scrollbar Windows Kaku Secara Global) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) rgba(11, 15, 23, 0.5);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(11, 15, 23, 0.5);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

html,
body {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.hidden {
  display: none !important;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
}

/* Auth / Login Screen Enterprise Edition */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, #0f2744 0%, #08111e 45%, var(--bg) 80%);
  position: relative;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
  top: 15%;
  left: 20%;
  pointer-events: none;
  filter: blur(40px);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(19, 27, 46, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.65), 0 0 25px rgba(16, 185, 129, 0.08);
  position: relative;
  z-index: 2;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #34d399;
  margin-bottom: 14px;
  text-transform: uppercase;
}

.auth-brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.auth-card h1 {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
  margin-bottom: 24px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}

.input-with-icon input {
  padding-left: 38px !important;
}

/* Password Input Wrapper with Eye Toggle Button */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrapper .input-icon {
  position: absolute;
  left: 12px;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}

.password-input-wrapper input {
  padding-left: 38px !important;
  padding-right: 42px !important;
  width: 100%;
}

.btn-password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  z-index: 3;
}

.btn-password-toggle:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
}

.auth-footer-badge {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main App Layout (Fixed Viewport Desktop Shell: Sidebar Tetap di Kiri, Konten Mandiri) */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  background: #0e1422;
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #047857);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 1.05rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-btn.active {
  background: rgba(16, 185, 129, 0.14);
  color: var(--primary);
  font-weight: 600;
}

.main-area {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.topbar {
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(14, 20, 34, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-title {
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clock-pill {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Fluid Full-Width Desktop Content (Menghapus Sisa Ruang Hitam Kosong di Layar Kanan) */
.content {
  padding: 24px 32px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Tabel Riwayat Log & Bubble Chat Proporsional */
#logs-table {
  width: 100%;
  min-width: 960px;
  table-layout: fixed;
}

.log-chat-bubble {
  max-height: 95px;
  overflow-y: auto;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  white-space: pre-wrap;
}

/* Layout Khusus Tab Jadwal (Form Kiri 46% vs Daftar Kanan 54%) */
.schedule-grid {
  display: grid;
  grid-template-columns: 46% 1fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 1150px) {
  .schedule-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* Modul Langkah 4: Kartu Grup Teks Balasan Fleksibel */
.text-group-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease;
}

.text-group-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

.text-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.group-line-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.group-line-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.group-line-chip:hover {
  border-color: var(--primary);
  color: var(--text);
}

.group-line-chip.active {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.6);
  color: #34d399;
  font-weight: 600;
}

.group-line-chip input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
}

.template-preset-select {
  padding: 4px 8px;
  font-size: 0.74rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  max-width: 260px;
}

/* Layout Pusat Bantuan & Open Ticket */
.ticket-grid {
  display: grid;
  grid-template-columns: 44% 1fr;
  gap: 22px;
  align-items: start;
  width: 100%;
}

.ticket-grid.admin-view {
  grid-template-columns: 1fr !important;
}

@media (max-width: 1150px) {
  .ticket-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* Stat Cards Khusus Helpdesk Admin */
.ticket-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .ticket-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .ticket-stats-grid {
    grid-template-columns: 1fr;
  }
}

.ticket-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.ticket-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.ticket-stat-card.stat-total::before {
  background: #3b82f6;
}

.ticket-stat-card.stat-open::before {
  background: #f59e0b;
}

.ticket-stat-card.stat-progress::before {
  background: #60a5fa;
}

.ticket-stat-card.stat-resolved::before {
  background: #10b981;
}

.ticket-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.ticket-stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.ticket-filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

/* Animasi Highlight Form Saat Tombol Edit Ditekan */
@keyframes formEditGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    border-color: rgba(16, 185, 129, 0.9);
  }
  40% {
    box-shadow: 0 0 22px 4px rgba(16, 185, 129, 0.45);
    border-color: #10b981;
  }
  100% {
    box-shadow: none;
    border-color: var(--border);
  }
}

.edit-form-highlight {
  animation: formEditGlow 1.8s ease-in-out;
}

/* Badge Tiket Kendala High Contrast Dark Theme */
.badge-ticket-open {
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.5);
  font-weight: 600;
}

.badge-ticket-progress {
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, 0.5);
  font-weight: 600;
}

.badge-ticket-resolved {
  background: rgba(16, 185, 129, 0.22);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.5);
  font-weight: 600;
}

.badge-ticket-closed {
  background: rgba(107, 114, 128, 0.25);
  color: #e5e7eb;
  border: 1px solid rgba(107, 114, 128, 0.45);
  font-weight: 600;
}

.priority-badge {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
}

.priority-urgent {
  background: rgba(239, 68, 68, 0.28);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

.priority-high {
  background: rgba(249, 115, 22, 0.28);
  color: #ffedd5;
  border: 1px solid rgba(249, 115, 22, 0.55);
}

.priority-medium {
  background: rgba(59, 130, 246, 0.25);
  color: #dbeafe;
  border: 1px solid rgba(59, 130, 246, 0.5);
}

.priority-low {
  background: rgba(107, 114, 128, 0.25);
  color: #f3f4f6;
  border: 1px solid rgba(107, 114, 128, 0.45);
}

/* Tombol Reorder Urutan Mode */
.btn-reorder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.72rem;
}

.btn-reorder:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}

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

/* Responsive Cards & Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text);
}

.badge-success {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.badge-warn {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.badge-info,
.badge-blue {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

.badge-gold {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.badge-purple {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.45);
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* Forms & Buttons */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='time'],
input[type='datetime-local'],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #042f2e;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-warning {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.btn-warning:hover {
  background: var(--warning);
  color: #1c1917;
}

.btn-success,
.btn-wa-admin {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
  border: 1px solid rgba(52, 211, 153, 0.45) !important;
  color: #ffffff !important;
  text-decoration: none !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.28);
}

.btn-success:hover,
.btn-wa-admin:hover {
  background: linear-gradient(135deg, #047857 0%, #059669 100%) !important;
  border-color: rgba(52, 211, 153, 0.7) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.73rem;
  border-radius: 6px;
}

/* Impersonation Banner (BKL-05) */
.impersonation-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.22), rgba(234, 88, 12, 0.22));
  border-bottom: 1px solid rgba(245, 158, 11, 0.45);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: #fde68a;
  animation: fadeIn 0.2s ease;
}

.impersonation-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.impersonation-icon {
  font-size: 1.15rem;
}

/* Master Switch Toggle for Line Cards (BKL-08) */
.master-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.master-toggle-btn.active {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}

.master-toggle-btn.active:hover {
  background: rgba(16, 185, 129, 0.28);
}

.master-toggle-btn.inactive {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.master-toggle-btn.inactive:hover {
  background: rgba(239, 68, 68, 0.28);
}

/* Quota Progress Bar (BKL-06) */
.quota-bar-wrapper {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
  width: 100%;
  max-width: 140px;
}

.quota-bar-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* Mobile Hamburger & Drawer Elements (BKL-04) */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
}

.hamburger-bar {
  width: 100%;
  height: 2px;
  background-color: var(--text);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.sidebar-close-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 199;
}

/* QR Container */
.qr-box {
  margin: 14px 0;
  padding: 16px;
  background: #ffffff;
  border-radius: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #0f172a;
}

.qr-box img {
  width: 230px;
  height: 230px;
  display: block;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

#users-table {
  min-width: 820px;
}

@media (min-width: 1200px) {
  #users-table {
    min-width: 100%;
  }
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Day Chips */
.day-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #10b981;
  color: #042f2e;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 200;
  transition: all 0.2s ease;
}

.toast.toast-error {
  background: #ef4444;
  color: #ffffff;
}

/* Custom Modern Modal (menggantikan alert/confirm bawaan browser) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 300;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.15s ease-out;
}

.modal-dialog {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  animation: scaleUp 0.16s ease-out;
  margin: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.modal-icon.info {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

.modal-icon.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Session Schedule Row Responsive Grid (Tab 2) */
.sch-session-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  margin-bottom: 8px;
}

.sch-session-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 105px 105px auto;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.sch-col-name,
.sch-col-line,
.sch-col-time,
.sch-col-btn {
  min-width: 0;
}

/* Header & Card Responsive Layouts */
.header-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.header-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.line-status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.line-status-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.line-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.mode-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.mode-card-info {
  flex: 1;
  min-width: 0;
}

.mode-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* WhatsApp Sync Toolbar Responsive Layout (Tab 3) */
.wa-sync-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.wa-sync-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.wa-sync-filter-group,
.wa-sync-action-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.wa-toolbar-input {
  padding: 6px 10px;
  font-size: 0.81rem;
  flex: 1 1 180px;
  min-width: 140px;
}

/* Help (?) Button & Documentation Modal */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.help-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #ffffff;
}

.help-icon-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.help-step {
  border-left: 3px solid var(--primary);
  background: rgba(255, 255, 255, 0.025);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 10px;
}

.help-step strong {
  color: var(--text);
  display: block;
  margin-bottom: 3px;
  font-size: 0.88rem;
}

.help-step p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* RESPONSIVE BREAKPOINTS */

@media (max-width: 1024px) {
  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.6);
  }

  .main-area {
    height: auto;
    overflow-y: visible;
  }

  .content {
    padding: 16px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .sidebar-close-btn {
    display: block;
  }
}

@media (max-width: 960px) {
  .grid-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .sch-session-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .sch-col-name {
    grid-column: 1 / -1;
  }

  .sch-col-line {
    grid-column: 1 / -1;
  }

  .sch-col-time {
    grid-column: auto;
  }

  .sch-col-btn {
    grid-column: 1 / -1;
  }

  .sch-col-btn .btn {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 14px;
    min-height: 56px;
  }

  #server-clock {
    display: none;
  }

  .content {
    padding: 14px;
    gap: 16px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card {
    padding: 14px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  table {
    min-width: 580px;
  }

  #tab-logs table {
    min-width: 780px;
  }

  #tab-contacts table {
    min-width: 620px;
  }

  th,
  td {
    padding: 9px 8px;
    font-size: 0.81rem;
  }

  .wa-sync-filter-group,
  .wa-sync-action-group {
    flex-direction: column;
    align-items: stretch;
  }

  .wa-toolbar-input {
    width: 100% !important;
    flex: none;
  }

  .wa-sync-action-group .btn {
    width: 100%;
  }

  .impersonation-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 10px;
  }

  .impersonation-banner .btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 12px;
    min-height: 52px;
  }

  .topbar-title {
    font-size: 0.88rem;
    max-width: 135px;
  }

  .help-btn {
    padding: 0 7px;
    height: 28px;
  }

  .help-btn-text {
    display: none;
  }

  .refresh-btn-text {
    display: none;
  }

  #refresh-btn {
    padding: 5px 9px;
  }

  .header-card-row {
    flex-direction: column;
    align-items: stretch;
  }

  .header-card-actions {
    width: 100%;
    flex-direction: column;
  }

  .header-card-actions .btn {
    width: 100%;
  }

  .line-status-box {
    flex-direction: column;
    align-items: stretch;
  }

  .line-status-actions {
    width: 100%;
    flex-direction: column;
  }

  .line-status-actions .btn {
    width: 100%;
  }

  .line-card-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px !important;
  }

  .line-card-actions .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .line-card-actions .btn[data-action="delete-line"] {
    grid-column: 1 / -1;
    margin-left: 0 !important;
  }

  .mode-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-card-actions {
    width: 100%;
    margin-top: 10px;
  }

  .mode-card-actions .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: 16px;
    width: auto;
    text-align: center;
    justify-content: center;
  }

  .modal-dialog {
    max-width: 100% !important;
    max-height: calc(100vh - 24px) !important;
    padding: 18px 14px;
    border-radius: 14px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .auth-card {
    padding: 22px 16px;
  }
}
