

:root {
  --bg: #08080a;
  --bg2: #0e0e12;
  --surface: #131318;
  --surface-2: #1b1b22;
  --surface-elevated: #16161d;
  --border: #272730;
  --border-hover: rgba(225, 29, 72, 0.5);
  --border-glow: rgba(225, 29, 72, 0.45);
  --text: #fafafa;
  --muted: #9ca3af;
  --primary: #e11d48;
  --primary-2: #f43f5e;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --accent: #fb7185;
  --radius: 12px;
  --grad: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  --grad-accent: linear-gradient(135deg, #f43f5e 0%, #9f1239 100%);
  --grad-ok: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --shadow: 0 20px 50px rgba(0, 0, 0, .75);
  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: #fb7185; text-decoration: none; transition: color 0.15s; }
a:hover { color: #fda4af; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

/* Tactical Crimson Ambient Background */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -15%, rgba(225, 29, 72, 0.14) 0, transparent 55%),
    radial-gradient(circle at 85% 90%, rgba(159, 18, 57, 0.1) 0, transparent 50%),
    var(--bg);
  pointer-events: none;
}
.bg-orbs i {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .22;
  animation: floatOrb 18s ease-in-out infinite;
}
.bg-orbs i:nth-child(1) { width: 520px; height: 520px; background: #e11d48; top: -180px; left: -140px; }
.bg-orbs i:nth-child(2) { width: 460px; height: 460px; background: #881337; bottom: -180px; right: -120px; animation-delay: -6s; }
.bg-orbs i:nth-child(3) { width: 340px; height: 340px; background: #be123c; top: 42%; left: 55%; opacity: .14; animation-delay: -12s; }
@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(40px, 30px); }
}

/* ============================================================
   Tactical Crimson Dashboard Shell (Sidebar + Topbar + Content)
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1.2rem;
  background: #0e0e12;
  border-right: 1px solid var(--border);
  z-index: 40;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.side-top {
  padding: 0.3rem 0.4rem 1.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.2rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: .8rem;
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--grad);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(225, 29, 72, .4);
  color: #ffffff;
  font-size: 18px;
}
.logo-text-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.logo-text-sub {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #f43f5e;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: .35rem;
  flex: 1 0 auto;
  align-content: start;
  margin-bottom: 1rem;
}
.side-link {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .72rem 1rem;
  border-radius: 10px;
  color: #a1a1aa;
  font-weight: 500;
  font-size: .9rem;
  transition: all .16s ease;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.side-link:hover {
  background: var(--surface-2);
  color: #fff;
  transform: translateX(2px);
}
.side-link.active {
  background: rgba(225, 29, 72, 0.16);
  color: #ffffff;
  font-weight: 700;
  border-color: rgba(225, 29, 72, 0.45);
  box-shadow: inset 3px 0 0 #e11d48;
}
.side-link .nav-ic {
  font-size: 17px;
  display: flex;
  align-items: center;
}

/* User Box at Bottom of Sidebar */
.side-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-top: auto;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--grad);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex: none;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.su-info {
  min-width: 0;
  flex: 1;
}
.su-info strong {
  display: block;
  font-size: .88rem;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.su-info small {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: .5rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: all .15s;
}
.icon-btn:hover {
  color: #f87171;
  background: rgba(248, 113, 113, .15);
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 2.2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(14, 14, 18, .92);
}
.topbar h1 {
  font-size: 1.25rem;
  font-weight: 700;
  flex: 1;
  color: #ffffff;
  letter-spacing: -0.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: .8rem;
}
.menu-btn {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: #ffffff;
  padding: .5rem .8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
}

.content {
  padding: 2rem 2.2rem;
  max-width: 1350px;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
}
.content > * {
  min-width: 0;
  max-width: 100%;
}

/* ============================================================
   Buttons & Controls (Tactical Crimson)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.35rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: 600 .92rem/1 inherit;
  color: #fff !important;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .18s;
  white-space: nowrap;
  background: #e11d48;
}
.btn:hover { transform: translateY(-1px); color: #fff !important; background: #be123c; }
.btn-primary {
  background: var(--grad) !important;
  color: #fff !important;
  box-shadow: 0 8px 24px rgba(225, 29, 72, .32);
}
.btn-primary:hover {
  box-shadow: 0 12px 32px rgba(225, 29, 72, .48);
}
.btn-success {
  background: #10b981 !important;
  color: #fff !important;
  border: none;
}
.btn-success:hover {
  background: #059669 !important;
}
.btn-whatsapp {
  background: #25d366 !important;
  color: #fff !important;
  border: none;
}
.btn-whatsapp:hover {
  background: #128c7e !important;
}
.btn-warning {
  background: #f59e0b !important;
  color: #fff !important;
  border: none;
}
.btn-warning:hover {
  background: #d97706 !important;
}
.btn-danger {
  background: #ef4444 !important;
  color: #fff !important;
  border: none;
}
.btn-danger:hover {
  background: #dc2626 !important;
}
.btn-secondary {
  background: #334155 !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-secondary:hover {
  background: #475569 !important;
}
.btn-ghost {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  color: #e0e7ff !important;
}
.btn-ghost:hover {
  background: var(--surface-2) !important;
}
.btn-sm {
  padding: .5rem .9rem;
  font-size: .84rem;
  border-radius: 10px;
}
.btn-block { width: 100%; }

.notif-controls {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 12px;
}
.notif-btn {
  background: transparent;
  border: none;
  font-size: 15px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all .2s;
}
.notif-btn:hover {
  background: var(--surface-2);
  color: #fff;
}

/* ============================================================
   Cards, Grid & Stats (Exact QrisGateway)
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: .25rem;
  color: #ffffff;
}
.card .sub {
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: 1.2rem;
}

.grid { display: grid; gap: 1.2rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stat {
  padding: 1.25rem 1.45rem;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad);
  opacity: 0.8;
}
.stat small {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}
.stat strong {
  display: block;
  font-size: 2.1rem;
  font-weight: 800;
  margin-top: .3rem;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.stat span {
  color: var(--muted);
  font-size: .82rem;
  margin-top: .4rem;
  display: block;
}

/* Badges & Alerts (Exact QrisGateway) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: .25rem .65rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.badge-ok { color: #6ee7b7; background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .3); }
.badge-warn { color: #fcd34d; background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .3); }
.badge-danger { color: #fca5a5; background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .3); }
.badge-accent { color: #fda4af; background: rgba(225, 29, 72, .16); border-color: rgba(225, 29, 72, .42); }
.badge-ghost { color: #a1a1aa; background: rgba(255, 255, 255, .04); border-color: var(--border); }
.badge-muted { color: var(--muted); }

.alert {
  padding: .9rem 1.2rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  font-size: .92rem;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-ok { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .3); color: #a7f3d0; }
.alert-warn { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); color: #fde68a; }
.alert-danger { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .3); color: #fecaca; }
.alert-info { background: rgba(225, 29, 72, .12); border-color: rgba(225, 29, 72, .38); color: #fecdd3; }


/* Dark Theme Enforcement for User Detail Modal */
#userDetailContent div[style*="background: white"],
#userDetailContent div[style*="background:white"],
.user-detail-grid div[style*="background: white"],
.user-detail-grid div[style*="background:white"] {
    background: rgba(0, 0, 0, 0.45) !important;
    border: 1px solid var(--border) !important;
    color: #cbd5e1 !important;
}

#userDetailContent div[style*="background: #dbeafe"],
.user-detail-grid div[style*="background: #dbeafe"] {
    background: rgba(225, 29, 72, 0.15) !important;
    border: 1px solid rgba(225, 29, 72, 0.35) !important;
    color: #fecdd3 !important;
}

/* Toast alert popup (Compact top right) */
.alert-toast {
  position: fixed !important;
  top: 84px !important;
  right: 18px !important;
  bottom: auto !important;
  left: auto !important;
  width: auto !important;
  max-width: 330px !important;
  min-height: auto !important;
  height: auto !important;
  padding: 8px 14px !important;
  border-radius: 10px !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  z-index: 9999999 !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  line-height: 1.35 !important;
  word-break: break-word !important;
  animation: slideToast 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
@keyframes slideToast {
  from { transform: translateY(-15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Tables (Exact QrisGateway) */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
th, td {
  padding: .85rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: rgba(255, 255, 255, .03);
  font-weight: 600;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }
td.wrap-cell { white-space: normal; max-width: 320px; }

/* Forms & Inputs (Exact QrisGateway) */
.form-group {
  margin-bottom: 1.1rem;
  display: grid;
  gap: .45rem;
}
.form-group label {
  font-size: .88rem;
  font-weight: 500;
  color: #c9d0f2;
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-group small {
  color: var(--muted);
  font-size: .8rem;
}
input, select, textarea {
  width: 100%;
  padding: .8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, .32);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #e11d48;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, .22);
}
select option { background: #0e0e12; color: #fff; }
textarea { min-height: 100px; resize: vertical; }

/* Modals (Clean, zero leakage) */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8, 8, 10, 0.88);
  backdrop-filter: blur(16px);
  z-index: 100000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: #131318;
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.88);
  animation: modalScale 0.25s ease-out;
}
@keyframes modalScale {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-header {
  padding: 1.25rem 1.6rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}
.close-modal {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.close-modal:hover { color: #fff; }

/* Tab content panes */
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ============================================================
   Tactical Crimson Auth Screen
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  margin: 0 auto;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 2.4rem;
  background: #111116;
  border: 1px solid rgba(225, 29, 72, 0.35);
  border-radius: 18px;
  backdrop-filter: blur(28px);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(225, 29, 72, 0.12);
  display: grid;
  gap: 1.25rem;
  position: relative;
  overflow: hidden;
}
.auth-logo {
  text-align: center;
  margin-bottom: .2rem;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(0, 0, 0, 0.45);
  padding: 5px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.auth-tab-btn {
  padding: .7rem .6rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: .86rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.auth-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}
.auth-tab-btn.active.license-tab {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.35);
}
.auth-tab-btn.active.admin-tab {
  background: linear-gradient(135deg, #be123c, #881337);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.35);
}

/* Mirror Feature Dropdown Accordion */
#mirrorMenuHeader:hover {
  background: rgba(225, 29, 72, 0.12) !important;
  color: #fda4af !important;
}
#mirrorMenuHeader:hover #mirrorMenuIcon {
  background: rgba(225, 29, 72, 0.3) !important;
  transform: scale(1.08);
}

/* Snusbase Feature Dropdown Accordion */
#snusbaseMenuHeader:hover {
  background: rgba(244, 63, 94, 0.12) !important;
  color: #fecdd3 !important;
}
#snusbaseMenuHeader:hover #snusbaseMenuIcon {
  background: rgba(244, 63, 94, 0.3) !important;
  transform: scale(1.08);
}

/* ============================================================
   ULTRA-RESPONSIVE MOBILE ENGINE (PHONES & TABLETS)
   ============================================================ */

/* Backdrop overlay for mobile drawer */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 10, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-backdrop.active,
.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 900px) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr) !important;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
  }

  .main {
    min-width: 0 !important;
    max-width: 100vw !important;
    width: 100% !important;
  }
  
  /* Off-canvas mobile navigation drawer (scrollable top to bottom) */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 280px !important;
    max-width: 84vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    transform: translateX(-105%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s !important;
    box-shadow: none !important;
    z-index: 9999 !important;
    border-right: 1px solid rgba(225, 29, 72, 0.3) !important;
    padding: 1.15rem 1rem 2rem !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.92), 0 0 25px rgba(225, 29, 72, 0.2) !important;
  }
  
  .sidebar-close-btn {
    cursor: pointer !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
    flex-shrink: 0;
  }
  .sidebar-close-btn:active {
    background: rgba(225, 29, 72, 0.25);
    color: #fda4af;
  }

  .menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 20px;
    border-radius: 10px;
    flex-shrink: 0;
  }
  
  /* Topbar Mobile Polish */
  .topbar {
    padding: 0.7rem 0.9rem !important;
    gap: 0.6rem !important;
    max-width: 100vw;
  }
  .topbar h1 {
    font-size: 0.98rem !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }
  .topbar-right {
    gap: 0.4rem !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
  }
  .notif-controls {
    padding: 2px !important;
    gap: 2px !important;
    border-radius: 10px !important;
  }
  .notif-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 14px !important;
    border-radius: 6px !important;
  }
  #refreshAllBtn {
    padding: 0.45rem 0.65rem !important;
    font-size: 0.8rem !important;
    border-radius: 9px !important;
  }
  #refreshAllBtn span {
    display: none !important;
  }
  #userRoleBadge {
    padding: 0.3rem 0.55rem !important;
    font-size: 10.5px !important;
    max-width: 115px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  /* Main Content Spacing */
  .content {
    padding: 0.95rem 0.8rem 2.2rem !important;
    gap: 1rem !important;
    max-width: 100vw !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Stat cards responsive grid */
  .g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .g3, .g2 {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }
  .stat {
    padding: 0.95rem 1rem !important;
    border-radius: 12px !important;
    min-width: 0 !important;
  }
  .stat strong {
    font-size: 1.45rem !important;
    margin: 4px 0 2px !important;
    word-break: break-word !important;
  }
  .stat small {
    font-size: 0.72rem !important;
    letter-spacing: 0.02em !important;
    display: block !important;
    white-space: normal !important;
    line-height: 1.3 !important;
  }
  .stat span {
    font-size: 0.72rem !important;
    white-space: normal !important;
    line-height: 1.3 !important;
  }

  /* Card */
  .card {
    padding: 1.05rem 0.95rem !important;
    border-radius: 14px !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .card h2 {
    font-size: 1.05rem !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
  }

  /* Table container touch scroll (smooth horizontal swipe) */
  .table-wrap,
  #historyTableContainer,
  div[style*="overflow-x: auto"],
  div[style*="overflow-x:auto"] {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain;
    border-radius: 10px;
  }
  table {
    font-size: 0.8rem !important;
  }
  th, td {
    padding: 0.6rem 0.7rem !important;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.6rem 0.75rem !important;
  }
  .topbar h1 {
    font-size: 0.92rem !important;
    max-width: none !important;
  }
  #userRoleBadge {
    display: none !important;
  }

  /* Stat Cards */
  .g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .g3, .g2 {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
  }
  .stat {
    padding: 0.8rem 0.85rem !important;
  }
  .stat strong {
    font-size: 1.3rem !important;
  }
  .stat small {
    font-size: 0.68rem !important;
  }
  .stat span {
    font-size: 0.68rem !important;
    margin-top: 3px !important;
  }

  /* Tab Header Buttons & Flex */
  .tab-content h2 {
    font-size: 1.12rem !important;
    margin-bottom: 0.85rem !important;
  }
  
  /* Buat Mirror: photo upload slots */
  #photoSlotsGrid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  
  /* Forms */
  input, select, textarea {
    padding: 0.68rem 0.85rem !important;
    font-size: 14px !important;
    border-radius: 10px !important;
    max-width: 100%;
  }
  .btn {
    padding: 0.62rem 0.95rem !important;
    font-size: 0.84rem !important;
    border-radius: 10px !important;
    white-space: normal !important;
    text-align: center !important;
    line-height: 1.25 !important;
  }

  /* Modal mobile fullscreen feel */
  .modal {
    padding: 8px !important;
  }
  .modal-content {
    border-radius: 14px !important;
    max-height: 92dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .modal-header {
    padding: 0.9rem 1rem !important;
  }
  .modal-header h2 {
    font-size: 1rem !important;
  }
  #userDetailContent {
    padding: 12px 10px !important;
  }
  
  /* Auth Screen Card */
  .auth-wrap {
    padding: 1rem 0.6rem !important;
  }
  .auth-card {
    padding: 1.5rem 1.15rem !important;
    border-radius: 16px !important;
  }
  .auth-logo h1 {
    font-size: 1.2rem !important;
  }
  .auth-tab-btn {
    padding: 0.6rem 0.4rem !important;
    font-size: 0.8rem !important;
  }

  /* Toasts */
  .alert-toast {
    top: 14px !important;
    right: 12px !important;
    left: 12px !important;
    bottom: auto !important;
    max-width: calc(100vw - 24px) !important;
    padding: 8px 12px !important;
    font-size: 11.5px !important;
  }

  /* Terminal Modal Mobile Fit */
  .terminal-window {
    height: 90dvh !important;
    max-height: 90dvh !important;
    border-radius: 12px !important;
  }
  .terminal-titlebar {
    flex-wrap: wrap !important;
    padding: 8px 10px !important;
    gap: 6px !important;
  }
  .terminal-title {
    order: 3 !important;
    flex: 1 1 100% !important;
    text-align: left !important;
    font-size: 10.5px !important;
    padding-top: 2px !important;
  }
  .terminal-actions {
    margin-left: auto !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .term-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
  .terminal-screen {
    padding: 12px !important;
    font-size: 11.5px !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .terminal-statusbar {
    flex-wrap: wrap !important;
    gap: 4px !important;
    padding: 6px 10px !important;
    font-size: 10px !important;
  }
}

@media (max-width: 360px) {
  .g4, .g3 {
    grid-template-columns: 1fr !important;
  }
}

.shell { display: grid; }
