
/* Critical Utility: Force Hidden Elements to Hide */
[hidden] {
  display: none !important;
}

#message:empty {
  display: none !important;
}

/* ==========================================================================
   SGO VPN PLATFORM — MODERN DARK CYBER-SAAS DESIGN SYSTEM
   Inspired by Linear, Supabase, and Vercel Dark Aesthetics
   ========================================================================== */

:root {
  color-scheme: dark;
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Inter', Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Deep Space Color Palette */
  --bg: #07090e;
  --bg-surface: #0e131f;
  --panel: rgba(16, 22, 36, 0.75);
  --panel-solid: #101624;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  
  /* Text & Contrast Hierarchy */
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  /* Brand & Accents */
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --blue-glow: rgba(59, 130, 246, 0.35);
  
  /* Semantic Statuses */
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.3);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.3);
  --rose: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.3);
  
  /* Radius & Motion */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  min-height: 100vh;
}

/* Ambient Top Mesh Glow */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.14) 0%, rgba(16, 185, 129, 0.04) 45%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

/* Base Interactive Inputs */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  touch-action: manipulation;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
  color: #fff;
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Primary Linear Button */
.primary, button.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: 0 4px 14px var(--blue-glow);
}

.primary:hover:not(:disabled), button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 20px var(--blue-glow);
}

.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--blue);
}

.quiet:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.1);
  border-color: transparent;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Header */
header {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1200px) / 2));
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(7, 9, 14, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.brand span {
  background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

#identity {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
}

#identity::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

/* Main Container */
main {
  max-width: 1200px;
  padding: 36px 24px 72px;
  margin: auto;
  min-height: calc(100vh - 160px);
}

/* Typography Hierarchy */
h1 {
  font-size: clamp(28px, 3.5vw, 40px);
  letter-spacing: -1.2px;
  line-height: 1.2;
  font-weight: 800;
  color: #fff;
  margin: 6px 0 16px;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #fff;
  margin: 0 0 20px;
}

p {
  line-height: 1.65;
  color: var(--text-muted);
}

.subtitle {
  color: var(--blue);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin: 0;
}

.lead {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 0 28px;
  max-width: 75ch;
}

.hint {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Glassmorphic Panel */
.panel {
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
}

/* Auth Section */
#auth {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 56px;
  max-width: 980px;
  margin: 48px auto;
  align-items: center;
}

.intro {
  padding: 16px 24px 0 0;
}

.intro h1 {
  font-size: clamp(36px, 4.5vw, 54px);
  letter-spacing: -1.8px;
  line-height: 1.15;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro p:not(.subtitle) {
  font-size: 16px;
  color: var(--text-muted);
}

/* Forms & Fields */
form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  margin: 16px 0;
}

input, select, textarea {
  display: block;
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 8px;
  background: rgba(11, 15, 25, 0.85);
  color: #fff;
  transition: all var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
  outline: none;
}

form .primary, form .quiet {
  width: 100%;
  margin-top: 14px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}

.page-heading h1 {
  margin-bottom: 6px;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.field-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

/* Device Cards Grid */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.device {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.device::after {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--blue) 50%, transparent 100%);
  opacity: 0.6;
}

.device:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.device h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.badge.ready, .badge.published, .badge.active {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.28);
}

.badge.ready::before, .badge.active::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.badge.revoking {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.badge.revoked, .badge.inconsistent {
  color: #fca5a5;
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
}

.device button {
  display: flex;
  width: 100%;
  margin-top: 12px;
}

/* Navigation Tabs */
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 20px;
  background: rgba(15, 20, 32, 0.6);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  width: fit-content;
}

nav button {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

nav button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transform: none;
}

nav .selected {
  color: #fff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  font-weight: 700;
  box-shadow: 0 2px 8px var(--blue-glow);
}

/* Modern Data Table */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(11, 15, 25, 0.6);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: rgba(15, 23, 42, 0.85);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  color: #e2e8f0;
  font-variant-numeric: tabular-nums lining-nums;
  overflow-wrap: anywhere;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

td small {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 4px;
}

td button {
  font-size: 12px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 6px;
  margin: 2px 4px 2px 0;
}

.empty {
  padding: 32px 0;
  text-align: center;
  color: var(--text-dim);
}

/* Feedback & Messages */
#message {
  padding: 14px 18px;
  margin-bottom: 24px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#message::before {
  content: 'ℹ';
  font-weight: 800;
  display: inline-block;
}

/* Footer */
footer {
  border-top: 1px solid var(--line);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--text-dim);
  font-size: 12px;
}

/* Modals & Dialogs */
dialog {
  background: rgba(14, 20, 32, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 28px;
  width: calc(100% - 32px);
  max-width: 460px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

dialog img {
  display: block;
  width: 220px;
  height: 220px;
  max-width: 100%;
  margin: 16px auto;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

dialog h2 {
  padding-right: 32px;
}

dialog .close {
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 20px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  padding: 0;
}

dialog .close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

dialog .primary {
  width: 100%;
  margin-top: 16px;
}

/* KPI Pulse Bar */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.status-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.text-emerald { color: #34d399 !important; }
.text-blue { color: #60a5fa !important; }
.text-amber { color: #fbbf24 !important; }

/* ==========================================================================
   MOBILE & RESPONSIVE ERGONOMICS SYSTEM (SGO DARK CYBER-SAAS)
   Designed for thumb reach, fast scanning, zero-clutter & high density
   ========================================================================== */

/* Universal Visibility Helpers */
.lbl-mob { display: none !important; }
.lbl-full { display: inline !important; }

/* Desktop Navigation Switcher & User Tag */
.header-main {
  display: flex;
  align-items: center;
  gap: 18px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-nav-switcher:not([hidden]) {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  white-space: nowrap;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding: 3px 4px;
  border-radius: 10px;
  flex-shrink: 0;
}

.nav-switch-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-switch-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-switch-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(6, 182, 212, 0.2));
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.15);
}

.admin-banner {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.admin-banner-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-banner strong {
  color: #60a5fa;
  font-size: 15px;
}

.admin-banner .hint {
  margin: 4px 0 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.user-tag {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

/* Tablet & Mobile Screens (<= 768px) */
@media (max-width: 768px) {
  .lbl-mob { display: inline !important; }
  .lbl-full { display: none !important; }

  /* 1. Compact Sticky Header */
  header {
    height: 56px !important;
    padding: 0 12px !important;
    gap: 8px !important;
    background: rgba(7, 9, 14, 0.94) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  }

  .header-main {
    gap: 8px !important;
    flex: 1;
    min-width: 0;
  }

  .brand {
    font-size: 16px !important;
    letter-spacing: -0.5px !important;
    flex-shrink: 0;
  }

  .header-main {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 6px !important;
    min-width: 0 !important;
  }

  .admin-nav-switcher:not([hidden]) {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    padding: 2px !important;
    gap: 2px !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }

  .nav-switch-btn {
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    padding: 4px 7px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    gap: 2px !important;
    border-radius: 6px !important;
    height: 28px !important;
  }

  .header-user {
    gap: 6px !important;
    flex-shrink: 0;
  }

  .user-tag {
    font-size: 11px !important;
    padding: 3px 6px !important;
    max-width: 70px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 5px !important;
  }

  .btn-logout, #logout {
    font-size: 11.5px !important;
    padding: 5px 8px !important;
    height: 30px !important;
    border-radius: 6px !important;
  }

  /* 2. Main Container Spacing */
  main {
    padding: 14px 12px 64px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  /* 3. Page Heading */
  .page-heading {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }

  .page-heading h1 {
    font-size: 20px !important;
    letter-spacing: -0.4px !important;
    margin: 0 !important;
  }

  .page-heading .subtitle {
    font-size: 11.5px !important;
    margin: 0 0 2px 0 !important;
  }

  .lead {
    font-size: 13px !important;
    margin-bottom: 14px !important;
  }

  .heading-actions {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .heading-actions button {
    flex: 1 !important;
    height: 40px !important;
    font-size: 13px !important;
    justify-content: center !important;
  }

  /* 4. Horizontal Scrollable Native Admin Tabs Strip */
  #admin-tabs {
    display: flex !important;
    width: calc(100% + 24px) !important;
    min-width: 0 !important;
    max-width: calc(100% + 24px) !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    gap: 6px !important;
    padding: 4px 2px 10px 2px !important;
    margin: 0 -12px 14px -12px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #admin-tabs::-webkit-scrollbar {
    display: none !important;
  }

  #admin-tabs button {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 12px !important;
    padding: 7px 12px !important;
    border-radius: 9999px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
  }

  #admin-tabs button.selected {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(6, 182, 212, 0.15)) !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    color: #34d399 !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2) !important;
  }

  /* 5. Compact 2x2 KPI Status Bar */
  .kpi-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .kpi-card {
    padding: 8px 10px !important;
    border-radius: 10px !important;
  }

  .kpi-label {
    font-size: 10.5px !important;
  }

  .kpi-value {
    font-size: 14.5px !important;
    margin: 2px 0 !important;
  }

  .kpi-sub {
    font-size: 10px !important;
    line-height: 1.25 !important;
    opacity: 0.75 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* 6. Admin Switch Banner */
  .admin-banner {
    padding: 12px 14px !important;
    border-radius: 12px !important;
    margin-bottom: 14px !important;
  }

  .admin-banner strong {
    font-size: 13.5px !important;
  }

  .admin-banner .hint {
    font-size: 12px !important;
  }

  .admin-banner button {
    width: 100% !important;
    margin-top: 8px !important;
    height: 40px !important;
    font-size: 13px !important;
  }

  /* 7. App Card Transformation for Admin Tables */
  .table-scroll {
    overflow: visible !important;
    border: none !important;
    background: transparent !important;
  }

  .table-scroll table,
  .table-scroll tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    border: none !important;
  }

  .table-scroll thead {
    display: none !important;
  }

  .table-scroll tr {
    display: flex !important;
    flex-direction: column !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 14px !important;
    padding: 14px !important;
    gap: 8px !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
  }

  .table-scroll td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 !important;
    border: none !important;
    font-size: 13px !important;
  }

  .table-scroll td:before {
    content: attr(data-label) !important;
    font-size: 11.5px !important;
    color: var(--text-dim) !important;
    font-weight: 600 !important;
    margin-right: 8px !important;
    flex-shrink: 0 !important;
  }

  /* Card Title: Tên khách hàng / Tên thiết bị */
  .table-scroll td[data-label="Tên"],
  .table-scroll td[data-label="Thiết bị"],
  .table-scroll td[data-label="Tài khoản"]:first-child {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #fff !important;
    padding-bottom: 6px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    margin-bottom: 4px !important;
  }

  .table-scroll td[data-label="Tên"]:before,
  .table-scroll td[data-label="Thiết bị"]:before {
    display: none !important;
  }

  /* Card Action Buttons */
  .table-scroll td[data-label="Điều khiển"],
  .table-scroll td[data-label="Duyệt"] {
    display: block !important;
    width: 100% !important;
    margin-top: 8px !important;
    padding-top: 10px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  }

  .table-scroll td[data-label="Điều khiển"]:before,
  .table-scroll td[data-label="Duyệt"]:before {
    display: none !important;
  }

  .table-scroll td[data-label="Điều khiển"] > div,
  .table-scroll td[data-label="Duyệt"] > div {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .table-scroll td[data-label="Điều khiển"] button,
  .table-scroll td[data-label="Duyệt"] button {
    height: 40px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 0 8px !important;
    justify-content: center !important;
    width: 100% !important;
    border-radius: 8px !important;
  }

  /* 8. Customer Personal Devices Section */
  .device-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .device {
    padding: 16px !important;
    border-radius: 14px !important;
  }

  .device h2 {
    font-size: 17px !important;
  }

  .device button {
    height: 44px !important;
    font-size: 13.5px !important;
    width: 100% !important;
    margin-top: 8px !important;
    border-radius: 10px !important;
  }

  /* 9. Forms & Inputs (Zero iOS Zoom) */
  input, select, textarea {
    font-size: 16px !important; /* Critical to prevent iOS viewport auto-zoom */
    height: 44px !important;
    padding: 0 12px !important;
    border-radius: 10px !important;
  }

  .two-columns {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .field-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .panel {
    padding: 16px 14px !important;
    border-radius: 16px !important;
  }

  #auth {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    margin: 8px auto !important;
  }

  #auth .intro h1 {
    font-size: 24px !important;
  }

  /* 10. Modals & Dialogs */
  dialog {
    width: calc(100% - 24px) !important;
    max-width: 460px !important;
    max-height: 85vh !important;
    margin: auto !important;
    border-radius: 20px !important;
    padding: 20px 16px !important;
    box-sizing: border-box !important;
  }

  dialog h2 {
    font-size: 18px !important;
  }

  dialog .close {
    width: 36px !important;
    height: 36px !important;
    font-size: 20px !important;
    top: 12px !important;
    right: 12px !important;
  }

  dialog img#qr-image {
    max-width: 200px !important;
    height: auto !important;
    margin: 12px auto !important;
    border-radius: 10px !important;
  }

  dialog .primary {
    height: 46px !important;
    font-size: 14.5px !important;
    width: 100% !important;
  }

  .dialog-actions {
    display: flex !important;
    gap: 8px !important;
  }

  .dialog-actions button {
    flex: 1 !important;
    height: 44px !important;
    font-size: 13.5px !important;
  }
}

.actions-bar {
  margin-bottom: 16px;
}

.kpi-icon {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
}

.table-scroll td {
  white-space: nowrap;
}
.table-scroll td:first-child,
.table-scroll td:last-child {
  white-space: normal;
}

/* ==========================================================================
   INFALLIBLE HIDDEN RULE - WINS OVER ALL CSS RULES
   ========================================================================== */
[hidden], [hidden="true"], [hidden="until-found"], *[hidden] {
  display: none !important;
}

.payment-order-cell {min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;}
.payment-order-cell button {display:block;max-width:100%;white-space:normal;margin-top:8px;}
.payment-evidence {min-width:0;overflow-wrap:anywhere;}
.payment-evidence input[type=file] {min-width:0;max-width:100%;}
.payment-evidence button {max-width:100%;white-space:normal;}
.payment-evidence a {overflow-wrap:anywhere;}

/* Compact operations view. Keep the established customer and dialog contracts. */
:root {
  --font-sans: "Segoe UI", Arial, sans-serif;
  --font-mono: Consolas, "Courier New", monospace;
  --bg: #10131a;
  --bg-surface: #11151d;
  --panel: #191d27;
  --panel-solid: #191d27;
  --line: #2c3240;
  --line-strong: #40495b;
  --text: #edf0f7;
  --text-muted: #a6afc0;
  --text-dim: #98a1b3;
  --blue: #5089f2;
  --blue-hover: #427bdf;
  --blue-glow: transparent;
  --emerald: #78c9a1;
  --emerald-glow: transparent;
  --amber: #e5be76;
  --amber-glow: transparent;
  --rose: #ef939b;
  --rose-glow: transparent;
  --radius-sm: 5px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --transition-fast: none;
  --transition-smooth: none;
}

html, body { max-width: 100%; }
body { background: #10131a; font: 14px/1.5 "Segoe UI", Arial, sans-serif; }
*, *::before, *::after { animation: none !important; transition: none !important; }
body::before, .device::after, #identity::before { display: none !important; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { min-width: 0; font-family: inherit; }
button {
  min-height: 36px; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 5px; background: #191d27; font-weight: 500;
  box-shadow: none !important; transform: none !important; white-space: normal;
}
button:hover:not(:disabled) { background: #252c3b; border-color: #485267; transform: none; }
button.primary, .primary { background: #376dcc; border-color: #376dcc; color: #fff; }
button.primary:hover:not(:disabled), .primary:hover:not(:disabled) { background: #427bdf; border-color: #427bdf; }
button.quiet, button.ghost { background: transparent; border-color: transparent; color: #aac9ff; }
button.danger, .danger { color: #ef939b; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible { outline: 2px solid #5089f2; outline-offset: 3px; }
input, select, textarea {
  min-height: 38px; max-width: 100%; margin-top: 6px; padding: 8px 10px;
  border: 1px solid #3b4456; border-radius: 5px; background: #11151d; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: #5089f2; box-shadow: none; }
textarea { height: auto; min-height: 112px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 17px; min-height: 17px; margin: 0; accent-color: #5089f2; flex-shrink: 0; }
input[readonly] { color: #c4cddd; }
input::placeholder, textarea::placeholder { color: #8791a5; opacity: 1; }
a { color: #aac9ff; text-underline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important; }

header {
  height: 62px; padding: 0 max(24px, calc((100vw - 1250px) / 2));
  background: #10131a; backdrop-filter: none; -webkit-backdrop-filter: none;
  border-bottom: 1px solid #2c3240; gap: 16px; justify-content: space-between;
}
.header-main, .header-user { min-width: 0; gap: 12px; }
.brand { font-size: 18px; font-weight: 600; letter-spacing: 0; }
.brand span { background: none; -webkit-text-fill-color: #aac9ff; color: #aac9ff; font-weight: 600; }
#identity, .user-tag { border-radius: 5px; padding: 4px 8px; background: none; border: 0; }
.admin-nav-switcher:not([hidden]) { background: none; border: 0; border-radius: 5px; padding: 0; margin: 0; }
.nav-switch-btn, .nav-switch-btn.active { border: 1px solid #2c3240; border-radius: 5px; box-shadow: none; }
.nav-switch-btn.active { background: #24334e; color: #c9ddff; border-color: #40577e; }
main { max-width: 1250px; padding: 28px 24px 48px; }
h1 { font-size: 25px; font-weight: 600; letter-spacing: -.4px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 19px; font-weight: 600; letter-spacing: 0; margin: 0 0 16px; }
h3 { font-size: 15px; font-weight: 600; margin: 20px 0 10px; }
p { color: var(--text-muted); line-height: 1.5; }
.subtitle { color: var(--text-muted); text-transform: none; letter-spacing: 0; font-weight: 400; }
.lead { font-size: 14px; margin-bottom: 20px; }
.hint { font-size: 12px; color: #a6afc0; }
.panel, .device, .kpi-card, .admin-banner {
  background: #191d27; border: 1px solid #2c3240; border-radius: 6px;
  box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.panel { padding: 20px; margin-bottom: 20px; }
.device { padding: 20px; }
.device:hover { transform: none; }
.device h2 { font-weight: 600; }
#admin .kpi-grid { display: none !important; }
.kpi-value { font-size: 18px; font-weight: 600; }
.status-pulse-dot { box-shadow: none; }
.intro h1 { font-size: 36px; font-weight: 600; background: none; -webkit-text-fill-color: var(--text); letter-spacing: -.5px; }
.admin-banner strong { color: #b4cfff; font-weight: 600; }
.two-columns { gap: 20px; }
form label { font-weight: 500; color: #c7cedb; }
.field-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; }
.field-row > *, .two-columns > *, .device-grid > * { min-width: 0; }

#admin .simple-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
#admin .simple-top h1 { margin: 0 0 4px; }
#admin .simple-top p { margin: 0; font-size: 13px; }
.user-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; }
.user-toolbar .search { flex: 1 1 260px; width: auto; max-width: none; margin: 0; }
.user-toolbar select { flex: 0 1 170px; width: auto; margin: 0; }
.user-toolbar button { flex: 0 0 auto; }
#user-filter-panel, #user-filter-panel .user-filter-fields { display: contents; }
#user-filter-panel > summary { display: none; }
#user-filter-panel::details-content { display: contents; content-visibility: visible; }
.user-toolbar .search input { margin-top: 0; }
.summary-line { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 16px; color: #98a1b3; font-size: 12px; }
.summary-line strong { color: #edf0f7; font-size: 14px; font-weight: 600; }
#admin-tabs { width: 100%; padding: 0 0 12px; margin: 0 0 18px; border: 0; border-bottom: 1px solid #2c3240; border-radius: 0; background: none; align-items: flex-start; gap: 8px; }
#admin-tabs button, #admin-tabs summary { min-height: 36px; border: 1px solid #2c3240; border-radius: 5px; padding: 7px 12px; color: #b4bdcd; font-size: 13px; background: #191d27; box-shadow: none; }
#admin-tabs .selected { color: #edf0f7; border-color: #485267; background: #252c3b; font-weight: 600; }
#admin-tabs .system-menu { margin: 0 0 0 auto; min-width: 0; position: relative; }
#admin-tabs .system-menu > summary { cursor: pointer; list-style: none; }
#admin-tabs .system-menu > summary::-webkit-details-marker { display: none; }
#admin-tabs .system-menu > summary::after { content: " ▾"; font-size: 11px; }
#admin-tabs .system-menu[open] > summary::after { content: " ▴"; }
#admin-tabs .system-menu > div, #admin-tabs .system-menu > nav, #admin-tabs .system-links {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 45; display: grid;
  gap: 6px; width: 220px; max-width: calc(100vw - 32px); margin: 0; padding: 8px;
  background: #191d27; border: 1px solid #3b4456; border-radius: 5px;
}
#admin-tabs .system-menu button { width: 100%; text-align: left; justify-content: flex-start; }
#admin-content { padding: 0; border: 0; background: none; box-shadow: none; min-width: 0; }
.table-scroll { border: 1px solid #2c3240; border-radius: 6px; background: #10131a; }
table { width: 100%; font-size: 14px; border-collapse: collapse; }
th { padding: 12px 16px; background: #191d27; color: #a6afc0; font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; }
td { padding: 15px 16px; color: #edf0f7; border-bottom: 1px solid #252b37; vertical-align: middle; }
.table-scroll td { white-space: normal; overflow-wrap: anywhere; }
tr:hover td { background: #181d29; }
td button { min-height: 34px; font-size: 13px; padding: 6px 10px; margin: 0; }
:is(#user-list, .user-list) .user-name { min-height: 24px; padding: 0; border: 0; background: none; justify-content: flex-start; text-align: left; font-weight: 600; font-size: 14px; color: #edf0f7; }
:is(#user-list, .user-list) .user-name:hover { color: #b4cfff; background: none; }
:is(#user-list, .user-list) .user-meta { color: #98a1b3; font-size: 12px; line-height: 1.5; margin-top: 3px; overflow-wrap: anywhere; }
:is(#user-list, .user-list) .user-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
:is(#user-list, .user-list) .user-actions button { flex: 0 1 auto; max-width: 100%; }
.badge { border: 0; padding: 3px 7px; border-radius: 4px; background: #242a36; color: #b5bece; font-weight: 500; }
.badge.ready, .badge.active, .badge.published { color: #a1d8bc; background: #1d342b; border-color: transparent; }
.badge.pending, .badge.revoking, .badge.expiring, .badge.awaiting_payment { color: #e6c78e; background: #342d21; }
.badge.revoked, .badge.expired, .badge.inconsistent, .badge.suspended { color: #efadb2; background: #35252c; }
.badge::before { box-shadow: none !important; }
.empty { padding: 36px 16px; color: #98a1b3; }
#message { padding: 11px 14px; margin-bottom: 18px; border: 1px solid #3c5275; background: #1b293e; color: #c5d8f7; border-radius: 5px; display: block; }
#message::before { display: none; }
footer { padding: 18px 24px; font-size: 12px; color: #98a1b3; }

dialog {
  width: calc(100% - 32px); max-width: 520px; max-height: calc(100dvh - 40px);
  padding: 24px; overflow: auto; overscroll-behavior: contain; border: 1px solid #3b4456;
  border-radius: 7px; background: #191d27; box-shadow: none; backdrop-filter: none;
  -webkit-backdrop-filter: none; scrollbar-color: #485267 #191d27; overflow-wrap: anywhere;
}
dialog::backdrop { background: #070a10a6; backdrop-filter: none; -webkit-backdrop-filter: none; }
dialog .close { border: 1px solid #2c3240; border-radius: 5px; width: 36px; height: 36px; min-height: 36px; background: #191d27; color: #c7cedb; }
dialog h2 { margin-bottom: 16px; }
dialog .field-row > label { min-width: 0; }
dialog img { width: 220px; height: auto; max-width: 100%; border-radius: 5px; padding: 10px; background: #fff; }
dialog input, dialog select, dialog textarea { max-width: 100%; }
dialog .dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
dialog .dialog-actions button { flex: 1 1 130px; }
#simple-dialog, #user-dialog {
  position: fixed; inset: 0 0 0 auto; margin: 0 !important; width: min(600px, 100vw) !important;
  max-width: 600px !important; height: 100dvh; max-height: 100dvh !important;
  padding: 24px 26px !important; border-radius: 0 !important; border-width: 0 0 0 1px;
}
.simple-form { min-width: 0; }
.simple-form .field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.simple-form .field-row > label { margin: 10px 0; }
.simple-form .simple-options { display: block; margin: 16px 0; padding: 12px 0; border-block: 1px solid #2c3240; }
.simple-options > summary { min-height: 36px; cursor: pointer; color: #b4bdcd; }
.simple-options label { display: block; margin: 12px 0; font-size: 14px; }
.simple-options input { width: 100%; }
.simple-options label:has(input[type="checkbox"]), .simple-options label:has(input[type="radio"]) { display: flex; align-items: center; gap: 8px; }
.simple-options input[type="checkbox"], .simple-options input[type="radio"] { width: 17px; min-height: 17px; margin: 0; }
.simple-progress { padding: 12px 14px; margin: 16px 0; background: #1c293d; border-left: 3px solid #5089f2; color: #cfddf3; border-radius: 3px; overflow-wrap: anywhere; }
.simple-success { padding: 0; margin: 16px 0; background: transparent; border: 0; border-radius: 0; color: #edf0f7; overflow-wrap: anywhere; }
.simple-success h3 { margin-top: 0; }
.simple-success label { display: block; margin: 12px 0; color: #c7cedb; }
.user-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 0 0 20px; padding-right: 34px; min-width: 0; }
.user-detail-head h2 { margin: 0 0 4px; padding: 0; }
.user-detail-head p { margin: 0; }
.user-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.user-detail-actions button { flex: 0 1 auto; }
.payment-order-cell, .payment-evidence { min-width: 0; max-width: 100%; }
.payment-evidence input[type="file"] { width: 100%; max-width: 100%; height: auto !important; min-height: 44px; padding: 8px !important; }
.payment-evidence button, .payment-order-cell button { max-width: 100%; height: auto; min-height: 36px; white-space: normal; }
.payment-evidence p, .payment-evidence a, #created-state { overflow-wrap: anywhere; }
.payment-evidence img { aspect-ratio: 1; object-fit: contain; }
body #routing-dialog { border-radius: 6px !important; }
body #routing-error { background: #35252c; color: #efadb2; border: 1px solid #62404a; }

@media (max-width: 760px) {
  body { font-size: 14px; }
  header { height: auto !important; min-height: 60px; padding: 8px 16px !important; gap: 8px !important; background: #10131a !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  .header-main { min-width: 0; gap: 8px !important; flex: 1; }
  .header-user { gap: 6px !important; }
  .brand { font-size: 16px !important; }
  #identity { max-width: 100px; padding: 3px 0 !important; font-size: 12px !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-nav-switcher:not([hidden]) { margin: 0 !important; padding: 0 !important; background: none !important; border: 0 !important; }
  .nav-switch-btn, .nav-switch-btn.active { background: #191d27 !important; box-shadow: none !important; padding: 6px 8px !important; }
  .nav-switch-btn.active { background: #24334e !important; border-color: #40577e !important; }
  main { padding: 22px 16px 32px !important; }
  h1 { font-size: 24px !important; letter-spacing: -.3px !important; }
  h2 { font-size: 18px !important; }
  button { min-height: 44px; height: auto !important; }
  input, select, textarea { font-size: 16px !important; min-height: 44px; height: auto !important; padding: 10px 11px !important; border-radius: 5px !important; }
  input[type="checkbox"], input[type="radio"] { min-height: 17px !important; height: 17px !important; padding: 0 !important; }
  textarea { min-height: 112px; }
  .panel, .device, .admin-banner { padding: 16px !important; border-radius: 6px !important; box-shadow: none !important; }
  .two-columns, .field-row, .simple-form .field-row { grid-template-columns: minmax(0, 1fr) !important; gap: 10px !important; }
  #admin .simple-top { align-items: flex-start; gap: 12px; }
  #admin .simple-top button { flex-shrink: 0; padding: 9px 12px; }
  .user-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px; }
  .user-toolbar .search { grid-column: 1; grid-row: 1; width: 100%; min-width: 0; }
  .user-toolbar select, .user-toolbar button { width: 100%; max-width: 100%; min-width: 0; }
  #user-filter-panel > summary { display: flex; align-items: center; justify-content: center; grid-column: 2; grid-row: 1; min-height: 44px; padding: 9px 12px; border: 1px solid #3b4456; border-radius: 5px; background: #191d27; color: #c7cedb; cursor: pointer; list-style: none; }
  #user-filter-panel > summary::-webkit-details-marker { display: none; }
  #user-filter-panel > summary::after { content: " ▾"; margin-left: 6px; font-size: 11px; }
  #user-filter-panel[open] > summary::after { content: " ▴"; }
  #user-filter-panel .user-filter-fields { display: grid; grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  #user-filter-panel:not([open]) .user-filter-fields { display: none; }
  .summary-line { gap: 6px 14px; margin-bottom: 14px; }
  #admin-tabs { width: 100% !important; max-width: 100% !important; margin: 0 0 18px !important; flex-wrap: wrap !important; overflow: visible !important; padding: 0 0 12px !important; gap: 8px !important; border-radius: 0 !important; background: none !important; }
  #admin-tabs button, #admin-tabs summary { min-height: 44px; padding: 9px 11px !important; border-radius: 5px !important; }
  #admin-tabs .system-menu { margin-left: auto; }
  #admin-content { padding: 0 !important; border: 0 !important; background: none !important; }
  .table-scroll { overflow: visible !important; border: 0 !important; border-radius: 0; background: none !important; }
  .table-scroll table, .table-scroll tbody { display: block !important; width: 100% !important; gap: 0 !important; }
  .table-scroll thead { display: none !important; }
  .table-scroll tr { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px !important; padding: 16px !important; margin-bottom: 12px; border: 1px solid #2c3240 !important; border-radius: 6px !important; background: #191d27 !important; box-shadow: none !important; }
  .table-scroll td { display: block !important; width: auto; min-width: 0; padding: 0 !important; border: 0 !important; margin: 0 !important; font-size: 14px !important; white-space: normal !important; overflow-wrap: anywhere; }
  .table-scroll td:first-child, .table-scroll td:last-child { grid-column: 1 / -1; }
  .table-scroll td::before { display: block !important; content: attr(data-label) !important; margin: 0 0 4px !important; color: #98a1b3 !important; font-size: 12px !important; font-weight: 400 !important; }
  .table-scroll td:first-child::before, .table-scroll td:last-child::before { display: none !important; }
  .table-scroll td[data-label="Tên"], .table-scroll td[data-label="Thiết bị"], .table-scroll td[data-label="Tài khoản"]:first-child { border: 0 !important; padding: 0 !important; margin: 0 !important; font-size: 16px !important; }
  .table-scroll td[data-label="Điều khiển"], .table-scroll td[data-label="Duyệt"] { display: block !important; margin-top: 2px !important; padding-top: 10px !important; border-top: 1px solid #2c3240 !important; }
  .table-scroll td[data-label="Điều khiển"] > div, .table-scroll td[data-label="Duyệt"] > div { display: flex !important; flex-wrap: wrap !important; width: 100% !important; gap: 8px !important; }
  .table-scroll td button, .table-scroll td[data-label="Điều khiển"] button, .table-scroll td[data-label="Duyệt"] button { width: auto !important; max-width: 100%; min-height: 44px; height: auto !important; padding: 9px 11px !important; border-radius: 5px !important; font-size: 13px !important; }
  :is(#user-list, .user-list) .user-name { min-height: 36px; font-size: 16px; }
  :is(#user-list, .user-list) .user-meta { font-size: 12px; }
  :is(#user-list, .user-list) .user-actions { display: flex !important; flex-wrap: wrap; gap: 8px !important; }
  :is(#user-list, .user-list) .user-actions button { flex: 1 1 auto; min-width: 80px; width: auto !important; }
  :is(#user-list, .user-list) .table-scroll tr { gap: 8px !important; padding: 12px !important; }
  :is(#user-list, .user-list) .table-scroll td:nth-child(3)::before { display: block !important; content: attr(data-label) !important; }
  :is(#user-list, .user-list) .table-scroll td:nth-child(3) { font-size: 14px !important; font-weight: 400 !important; }
  :is(#user-list, .user-list) .table-scroll td:nth-child(4) { display: flex !important; grid-column: 1 / -1; align-items: center; justify-content: space-between; gap: 8px; }
  :is(#user-list, .user-list) .table-scroll td:nth-child(4)::before { margin: 0 !important; }
  :is(#user-list, .user-list) .table-scroll td .user-name { min-height: 28px; padding: 0 !important; }
  :is(#user-list, .user-list) .user-meta { margin-top: 2px; }
  dialog { width: calc(100% - 20px) !important; max-width: 520px !important; max-height: calc(100dvh - 20px) !important; margin: auto !important; padding: 20px 16px !important; border-radius: 6px !important; }
  dialog .close { width: 38px !important; height: 38px !important; min-height: 38px; border-radius: 5px; }
  dialog .primary { min-height: 44px; height: auto !important; font-size: 14px !important; white-space: normal; }
  dialog img, dialog img#qr-image { max-width: 220px !important; width: min(220px, 100%) !important; height: auto !important; border-radius: 5px !important; }
  #simple-dialog, #user-dialog { width: 100% !important; max-width: 100vw !important; height: 100dvh; max-height: 100dvh !important; margin: 0 !important; padding: 22px 18px calc(28px + env(safe-area-inset-bottom)) !important; border-radius: 0 !important; border-width: 0; }
  .user-detail-actions button { flex: 1 1 120px; }
  .payment-evidence button, .payment-order-cell button { min-height: 44px; height: auto !important; }
  .payment-evidence input[type="file"] { padding: 8px !important; }
  .empty { padding: 24px 12px; }
  footer { flex-direction: column; gap: 6px; padding: 16px; }
}

[hidden], [hidden="true"], [hidden="until-found"], *[hidden] { display: none !important; }


/* ==========================================================================
   SGO BRAND MARK & BANK QR / TRANSFER VERIFICATION STYLES
   ========================================================================== */
.brand .mark {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background: #376dcc;
  color: #fff;
  -webkit-text-fill-color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-right: 4px;
}

.bank-config-card {
  max-width: 720px;
  background: #191d27;
  border: 1px solid #2c3240;
  border-radius: 6px;
  padding: 20px;
}

.bank-config-card h2 {
  margin: 0 0 6px;
}

.bank-config-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.qr-upload-section {
  background: #11151d;
  border: 1px dashed #3b4456;
  border-radius: 6px;
  padding: 16px;
  margin-top: 8px;
}

.qr-preview-container {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.bank-qr-preview-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 6px;
  border: 6px solid #fff;
  background: #fff;
  object-fit: contain;
}

.payment-intake-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  margin-top: 8px;
  background: #11151d;
  border: 1px solid #2c3240;
  border-radius: 6px;
}

.payment-flex-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  background: #191d27;
  padding: 14px;
  border-radius: 6px;
  border: 1px solid #2c3240;
}

.payment-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 170px;
}

.payment-bank-qr-image {
  width: 170px !important;
  height: 170px !important;
  object-fit: contain;
  border-radius: 6px !important;
  border: 6px solid #fff;
  background: #fff;
  margin: 0 !important;
  padding: 4px !important;
}

.payment-qr-caption {
  font-size: 12px;
  color: #98a1b3;
  text-align: center;
}

.payment-details-box {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.payment-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #252b37;
  font-size: 13px;
}

.payment-detail-row span {
  color: #98a1b3;
}

.payment-memo-highlight {
  background: #1b293e;
  border: 1px solid #3c5275;
  border-radius: 5px;
  padding: 10px 12px;
  margin-top: 4px;
}

.payment-memo-label {
  font-size: 11px;
  font-weight: 600;
  color: #aac9ff;
  margin-bottom: 4px;
}

.payment-memo-value-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.payment-memo-code {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: #78c9a1;
  background: #10131a;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #2c3240;
}

.payment-memo-sub {
  margin-top: 6px !important;
  font-size: 12px;
  color: #98a1b3;
}

.payment-upload-zone {
  background: #191d27;
  border: 1px dashed #3b4456;
  border-radius: 6px;
  padding: 12px;
}

.payment-upload-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: #edf0f7;
}

.payment-upload-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.payment-upload-controls input[type="file"] {
  flex: 1;
  min-width: 180px;
  margin-top: 0;
}

.receipt-gallery-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.receipt-item-card {
  background: #191d27;
  border: 1px solid #2c3240;
  border-radius: 5px;
  padding: 10px;
}

.receipt-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 12px;
}

.receipt-item-actions {
  display: flex;
  gap: 8px;
}

.receipt-link-btn {
  font-size: 12px;
  padding: 3px 8px;
  background: #252c3b;
  border: 1px solid #3b4456;
  border-radius: 4px;
  color: #edf0f7;
  text-decoration: none;
}

.receipt-preview-wrap {
  display: flex;
  justify-content: center;
  background: #10131a;
  border-radius: 4px;
  padding: 6px;
}

.receipt-thumbnail {
  max-width: 100% !important;
  max-height: 240px !important;
  width: auto !important;
  height: auto !important;
  border-radius: 4px !important;
  object-fit: contain;
  cursor: zoom-in;
  background: transparent !important;
  padding: 0 !important;
}

/* Comfortable dialog controls on small screens and touch devices. */
@media (max-width: 820px), (pointer: coarse) {
  dialog button { min-height: 44px !important; }
  dialog .close { width: 44px !important; min-width: 44px !important; height: 44px !important; }
}
