:root {
  --white: #FFFFFF;
  --grey-50: #F9FAFB;
  --grey-100: #F3F4F6;
  --grey-200: #E5E7EB;
  --grey-300: #D1D5DB;
  --grey-400: #9CA3AF;
  --grey-500: #6B7280;
  --grey-600: #4B5563;
  --grey-700: #374151;
  --grey-800: #1F2937;
  --grey-900: #111827;
  --black: #000000;

  --bg-primary: #0A0A0A;
  --bg-secondary: #121212;
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-tertiary: rgba(255, 255, 255, 0.45);

  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --glass-active: rgba(255, 255, 255, 0.12);

  --accent-primary: rgba(255, 255, 255, 0.9);
  /* Blue replaces green everywhere */
  --accent-success: #3B82F6;
  --accent-success-light: #93C5FD;
  --accent-success-dim: rgba(59, 130, 246, 0.12);
  --accent-success-border: rgba(59, 130, 246, 0.5);
  --accent-error: #EF4444;
  --accent-warning: #F59E0B;
  --accent-danger: #DC2626;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --side-inset: var(--space-xl);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --font-xs: 11px;
  --font-sm: 12px;
  --font-base: 14px;
  --font-md: 15px;
  --font-lg: 16px;
  --font-xl: 18px;
  --font-2xl: 24px;
  --font-3xl: 32px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --brand-title-size: 34px;
  --brand-title-mobile: 30px;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

html, body { height: 100%; overflow-x: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  font-size: var(--font-base);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  position: relative;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle 800px at 20% 30%, rgba(59, 130, 246, 0.04), transparent 60%),
    radial-gradient(circle 600px at 80% 70%, rgba(59, 130, 246, 0.025), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.15;
  pointer-events: none;
  z-index: 1;
}

/* ── Loading ─────────────────────────────────── */
.loadingOverlay {
  position: fixed; inset: 0;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--space-xl); z-index: 9999;
  transition: opacity var(--transition-base);
}
.loadingOverlay.hidden { display: none; opacity: 0; pointer-events: none; }
.loadingSpinner {
  width: 48px; height: 48px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loadingText { font-size: var(--font-lg); font-weight: 500; color: var(--text-secondary); letter-spacing: -0.01em; }

/* ── Glass ───────────────────────────────────── */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-md);
}

/* ── Topbar ──────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  padding: var(--space-lg) var(--side-inset);
  background: rgba(10, 10, 10, 0.8);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-xl);
}

body[data-aspect="portrait-narrow"] .topbar,
body[data-aspect="portrait"] .topbar { flex-direction: column; align-items: stretch; gap: var(--space-md); }
body[data-aspect="portrait-narrow"] .brand,
body[data-aspect="portrait"] .brand { width: 100%; justify-content: center; }
body[data-aspect="portrait-narrow"] .brand .title,
body[data-aspect="portrait"] .brand .title { text-align: center; width: 100%; line-height: 1.1; }
body[data-aspect="portrait-narrow"] .right,
body[data-aspect="portrait"] .right { width: 100%; justify-content: space-between; gap: var(--space-md); }
body[data-aspect="portrait-narrow"] #whoami,
body[data-aspect="portrait"] #whoami { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.brand { display: flex; flex-direction: row; align-items: center; gap: 0; }
.brand .title { font-size: var(--brand-title-size); font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
.right { display: flex; align-items: center; gap: var(--space-lg); }
#whoami { font-size: var(--font-sm); font-weight: 500; color: var(--text-secondary); letter-spacing: 0.02em; }

/* ── Container ───────────────────────────────── */
.container { position: relative; z-index: 2; max-width: 1440px; margin: 0 auto; padding: var(--space-2xl) var(--space-xl); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-xl); align-items: start; }

body[data-layout="stack"] .grid { grid-template-columns: 1fr; width: 100%; margin-left: 0; margin-right: 0; align-items: start; }
body[data-layout="stack"] .viewUser .grid { width: 100%; margin-left: 0; margin-right: 0; }

@media (min-width: 769px) {
  body[data-layout="stack"] .viewAdmin .adminGrid {
    position: static; left: auto; right: auto; margin-left: 0; margin-right: 0;
    width: auto; padding-left: 0; padding-right: 0;
    grid-template-columns: 1fr; gap: var(--space-xl);
  }
}

[data-layout="user-split-50-50"] .viewUser .grid,
body[data-layout="user-centered-2-3"] .viewUser .grid { align-items: start; }
body[data-layout="user-split-50-50"] #viewUser .grid > .card,
body[data-layout="user-centered-2-3"] #viewUser .grid > .card { max-height: calc(100vh - 140px); overflow: auto; }

@media (max-width: 768px) {
  .container { padding: var(--space-xl) var(--space-lg); }
  .grid { grid-template-columns: 1fr; gap: var(--space-lg); }
  .topbar { padding: var(--space-md) var(--space-lg); }
  .brand .title { font-size: var(--brand-title-mobile); }
  input, select, textarea { font-size: 16px; }
  .brand { gap: var(--space-md); }
}

/* ── Card ────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}
.card:hover { background: var(--glass-hover); box-shadow: var(--shadow-lg); transform: translateY(-2px); }

h2 { margin: 0 0 var(--space-lg) 0; font-size: var(--font-xl); font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
h3 { margin: 0; font-size: var(--font-md); font-weight: 800; letter-spacing: -0.01em; color: var(--text-primary); }
.muted { color: var(--text-secondary); }
.small { font-size: var(--font-sm); }
.hint { margin-top: var(--space-md); padding: var(--space-md); background: rgba(255,255,255,0.03); border-radius: var(--radius-md); border-left: 2px solid var(--glass-border); }

/* ── User actions ────────────────────────────── */
.userActions { margin-top: var(--space-lg); display: flex; gap: var(--space-md); flex-wrap: wrap; width: 100%; }
.userActions .btn { flex: 1 1 0; min-width: 120px; }
.panel { margin-top: var(--space-lg); padding: var(--space-lg); background: rgba(0,0,0,0.22); border-radius: var(--radius-lg); border: 1px solid var(--glass-border); }
.panel .actionRow { width: 100%; }
.panel .actionRow .btn { flex: 1 1 0; min-width: 120px; }
.actionRow { display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: center; }
.hidden { display: none !important; }

/* ── Forms ───────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: var(--space-lg); margin-top: var(--space-lg); }

label { display: flex; flex-direction: column; gap: var(--space-sm); font-size: var(--font-sm); font-weight: 500; color: var(--text-secondary); letter-spacing: -0.01em; }

input, select, textarea {
  width: 100%; padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md); border: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.3); color: var(--text-primary);
  font-size: 16px; -webkit-text-size-adjust: 100%;
  font-family: inherit; outline: none;
  transition: all var(--transition-base);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-primary);
  background: rgba(0,0,0,0.4);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.1);
}
input::placeholder { color: var(--text-tertiary); }
.input.smallInput { padding: var(--space-sm) var(--space-md); font-size: var(--font-sm); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md); border: 1px solid var(--glass-border);
  background: var(--glass-bg); color: var(--text-primary);
  font-size: var(--font-base); font-weight: 600; font-family: inherit;
  letter-spacing: -0.01em; cursor: pointer;
  transition: all var(--transition-base);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--glass-hover); border-color: var(--accent-primary); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline { background: transparent; border-color: var(--glass-border); }
.btn-outline:hover:not(:disabled) { background: var(--glass-bg); }
.btn-danger { background: rgba(220,38,38,0.15); border-color: var(--accent-danger); color: #FCA5A5; }
.btn-danger:hover:not(:disabled) { background: rgba(220,38,38,0.25); border-color: #DC2626; color: #FECACA; }

/* BLUE btn-success */
.btn-success {
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.55);
  color: #DBEAFE;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(59,130,246,0.15);
}
.btn-success:hover:not(:disabled) {
  background: rgba(59,130,246,0.28); border-color: #3B82F6; color: #EFF6FF;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(59,130,246,0.2), 0 0 12px rgba(59,130,246,0.18);
}
.btn-success:active:not(:disabled) { transform: translateY(0); background: rgba(59,130,246,0.32); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(59,130,246,0.15); }
.btn-success:focus-visible { outline: 2px solid #3B82F6; outline-offset: 2px; box-shadow: var(--shadow-sm), 0 0 0 4px rgba(59,130,246,0.25); }
.btn-success:disabled { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.25); color: rgba(219,234,254,0.45); box-shadow: none; }

.btn-small { padding: var(--space-xs) var(--space-md); font-size: var(--font-sm); }
.linkBtn { background: transparent; border: none; color: var(--text-primary); cursor: pointer; padding: var(--space-sm) var(--space-md); font-weight: 600; font-size: var(--font-sm); transition: all var(--transition-fast); text-decoration: none; }
.linkBtn:hover { color: var(--accent-primary); text-decoration: underline; }

/* ── Footer row ──────────────────────────────── */
.footerRow { margin-top: var(--space-xl); padding-top: var(--space-lg); border-top: 1px solid var(--glass-border); display: flex; align-items: center; gap: var(--space-md); justify-content: center; }

/* ── Row / rowRight ──────────────────────────── */
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); margin-bottom: var(--space-lg); }
.rowRight { display: flex; align-items: center; gap: var(--space-md); flex: 1; max-width: 600px; }
@media (min-width: 769px) and (max-width: 1100px) {
  body[data-view="admin"] .rowRight { max-width: none; }
  body[data-view="admin"] .rowRight input { flex: 1 1 auto; min-width: 420px; }
}
@media (max-width: 768px) { .row { flex-direction: column; align-items: stretch; } .rowRight { width: 100%; max-width: none; } }

/* ── KV rows ─────────────────────────────────── */
.kv { display: flex; flex-direction: column; gap: var(--space-md); }
.kv > div { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-md) var(--space-lg); background: rgba(0,0,0,0.3); border-radius: var(--radius-md); border: 1px solid var(--glass-border); }

/* ── Pills ───────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full); border: 1px solid var(--glass-border);
  background: var(--glass-bg); font-weight: 700; font-size: var(--font-xs);
  letter-spacing: 0.05em; text-transform: uppercase;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease, box-shadow 220ms ease;
}
/* BLUE for active/paired/granted */
.pill.status-active  { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.12); color: #BFDBFE; }
.pill.status-offline { border-color: rgba(220,38,38,0.5);  background: rgba(220,38,38,0.12);  color: #FCA5A5; }
.pill.status-pending { border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.12); color: #FDE68A; }
.pill.card-paired    { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.12); color: #DBEAFE; }
.pill.card-unpaired  { border-color: rgba(156,163,175,0.35); background: rgba(0,0,0,0.15);   color: var(--text-secondary); }
.pill.pin-set        { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.12); color: #BFDBFE; }
.pill.pin-unset      { border-color: rgba(156,163,175,0.35); background: rgba(0,0,0,0.15);   color: var(--text-secondary); }
.pill.access-granted { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.12); color: #BFDBFE; }
.pill.access-denied  { border-color: rgba(220,38,38,0.5);  background: rgba(220,38,38,0.12);  color: #FCA5A5; }

/* ── Tables ──────────────────────────────────── */
.tableWrap { overflow-x: auto; border: 1px solid var(--glass-border); border-radius: var(--radius-lg); margin-top: var(--space-lg); background: rgba(0,0,0,0.2); }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: var(--space-md) var(--space-lg); text-align: left; border-bottom: 1px solid var(--glass-border); font-size: var(--font-sm); }
th { background: rgba(0,0,0,0.4); color: var(--text-secondary); font-weight: 700; font-size: var(--font-xs); text-transform: uppercase; letter-spacing: 0.05em; }
td { color: var(--text-primary); }
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:last-child td { border-bottom: none; }
.actionBtns { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.pairIdInline { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0.06em; font-family: 'SF Mono', 'Monaco', 'Courier New', monospace; }

/* ── Messages ────────────────────────────────── */
.msg { margin-top: var(--space-lg); padding: var(--space-md) var(--space-lg); border-radius: var(--radius-md); font-size: var(--font-sm); font-weight: 500; border: 1px solid transparent; }
.msg:empty { display: none; margin-top: 0; padding: 0; border: none; }
.msg.ok  { color: var(--accent-success-light); background: var(--accent-success-dim); border-color: rgba(59,130,246,0.2); }
.msg.err { color: var(--accent-error); background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.2); }

@keyframes fadeIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }
.card, .btn, input, select { animation: fadeIn var(--transition-slow) ease-out; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--glass-hover); }

/* ── Activity list ───────────────────────────── */
.activityList { display: flex; flex-direction: column; gap: var(--space-sm); max-height: 340px; overflow-y: auto; overscroll-behavior: contain; }
.activityEmpty { text-align: center; padding: var(--space-xl) 0; opacity: 0.6; }
.activityRow { display: flex; align-items: center; justify-content: space-between; padding: var(--space-sm) var(--space-md); background: rgba(0,0,0,0.2); border-radius: var(--radius-md); border: 1px solid var(--glass-border); gap: var(--space-md); }
.activityTime { white-space: nowrap; flex-shrink: 0; }

/* ── OTP Display ─────────────────────────────── */
.otpDisplay { margin-top: var(--space-lg); padding: var(--space-lg); background: rgba(0,0,0,0.25); border-radius: var(--radius-lg); border: 1px solid var(--glass-border); display: flex; flex-direction: column; align-items: center; gap: var(--space-md); }
.otpCode { font-size: var(--font-2xl); font-weight: 700; letter-spacing: 0.18em; font-variant-numeric: tabular-nums; font-family: 'SF Mono','Monaco','Courier New',monospace; color: var(--text-primary); padding: var(--space-md) var(--space-lg); background: rgba(0,0,0,0.3); border-radius: var(--radius-lg); border: 1px solid rgba(255,255,255,0.08); width: 100%; text-align: center; white-space: nowrap; overflow: hidden; transition: color var(--transition-base), opacity var(--transition-base); }
.otpCode--active  { border-color: rgba(59,130,246,0.4); box-shadow: 0 0 12px rgba(59,130,246,0.07); }
.otpCode--expired { color: var(--text-tertiary); border-color: rgba(239,68,68,0.3); box-shadow: none; opacity: 0.55; }
.otpMeta { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; justify-content: center; }
.otpStatusPill { font-size: var(--font-xs); }
.otpStatusPill:empty { display: none; }
@media (max-width: 480px) { .otpCode { font-size: var(--font-2xl); letter-spacing: 0.14em; min-width: 0; width: 100%; } }

/* ── Pair section ────────────────────────────── */
.pairSection { display: flex; flex-direction: column; align-items: center; padding-bottom: var(--space-xl); }
.pairSectionSep { width: 100%; height: 1px; background: var(--glass-border); margin: var(--space-xl) 0; }
.pairIdDisplay { display: flex; flex-direction: column; align-items: center; margin-top: var(--space-lg); width: 100%; }
.pairIdCode { font-size: var(--font-3xl); font-weight: 700; letter-spacing: 0.18em; font-variant-numeric: tabular-nums; font-family: 'SF Mono','Monaco','Courier New',monospace; color: var(--text-secondary); padding: var(--space-lg) var(--space-xl); background: rgba(0,0,0,0.3); border-radius: var(--radius-lg); border: 1px solid var(--glass-border); min-width: 200px; text-align: center; transition: color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base); }
.pairIdCode--active { color: var(--text-primary); border-color: rgba(59,130,246,0.4); box-shadow: 0 0 16px rgba(59,130,246,0.1); }

/* ── Password toggle ─────────────────────────── */
.password-wrapper { position: relative; display: flex; align-items: center; }
.password-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); transition: color var(--transition-fast); outline: none; }
.password-toggle:hover { color: var(--text-secondary); }
.password-toggle:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; border-radius: 4px; }
.password-toggle svg { width: 20px; height: 20px; display: block; }
.password-wrapper input[type="password"], .password-wrapper input[type="text"] { padding-right: 44px; }

/* ── Admin grid ──────────────────────────────── */
@media (min-width: 769px) {
  .viewAdmin .adminGrid {
    position: relative; left: 50%; right: 50%; margin-left: -50vw; margin-right: -50vw;
    width: 100vw; padding-left: var(--side-inset); padding-right: var(--side-inset);
    box-sizing: border-box; display: grid; grid-template-columns: 2fr 1fr;
    gap: var(--space-2xl); align-items: start;
  }
  .viewAdmin .adminGrid .card { height: auto; display: flex; flex-direction: column; }
  .viewAdmin .adminEmpty { min-height: 320px; background: var(--glass-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow-md); border-radius: var(--radius-xl); padding: var(--space-2xl); display: flex; flex-direction: column; }
  .viewAdmin .adminUsers { box-sizing: border-box; }
  .viewAdmin .adminEmpty { box-sizing: border-box; }
  .viewAdmin .adminGrid .adminEmpty .admin-chips { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 768px) {
  .viewAdmin .adminGrid { width: 100%; margin-left: 0; margin-right: 0; grid-template-columns: 1fr; gap: var(--space-lg); }
  .viewAdmin .row { display: flex; flex-direction: column; gap: var(--space-md); }
  .viewAdmin .row h2 { margin-bottom: 0; }
  .viewAdmin .rowRight { display: flex; flex-direction: column; width: 100%; gap: var(--space-md); }
  .viewAdmin #userSearch, .viewAdmin #btnRefreshUsers { width: 100%; }
  .viewAdmin .tableWrap { border: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .viewAdmin table { min-width: 960px; border: 0; }
  .viewAdmin thead { display: table-header-group; }
  .viewAdmin tbody tr { display: table-row; margin-bottom: 0; background: transparent; border: 0; border-radius: 0; padding: 0; }
  .viewAdmin td { display: table-cell; padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--glass-border); font-size: var(--font-sm); }
  .viewAdmin td::before { content: none; display: none; }
  .viewAdmin .actionBtns { flex-direction: row; }
  .viewAdmin .adminEmpty { min-height: auto; padding: var(--space-xl); }
  .admin-chips__donut { width: 160px; height: 160px; }
  .pairSection { padding-bottom: var(--space-lg); }
}

/* ── Admin chips ─────────────────────────────── */
.admin-chips { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; width: 100%; }
.admin-chips__donut { display: flex; align-items: center; justify-content: center; width: 192px; height: 192px; }
.admin-chips__svg { display: block; }
.admin-chips__bg { stroke: var(--grey-700); opacity: 0.55; }
.admin-chips__active { stroke: var(--accent-success); opacity: 0.95; }
.admin-chips__label { margin-top: 2px; }
@keyframes admin-chips-pulse { 0% { opacity: 0.85; } 50% { opacity: 1; } 100% { opacity: 0.85; } }
.admin-chips__active.active-segment { animation: admin-chips-pulse 1.8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .admin-chips__active.active-segment { animation: none; } }
body[data-layout="stack"] .viewAdmin .adminEmpty { min-height: auto; }
body[data-layout="stack"] .viewAdmin .adminEmpty .admin-chips { justify-content: center; padding: 18px 0; }

/* ── Whoami portrait ─────────────────────────── */
body[data-aspect="portrait"] #whoami, body[data-aspect="portrait-narrow"] #whoami { max-width: 100%; white-space: normal; overflow: visible; text-overflow: clip; display: flex; flex-direction: column; gap: 2px; }
body[data-aspect="portrait"] #whoami .whoami-role, body[data-aspect="portrait-narrow"] #whoami .whoami-role { display: block; }
body[data-aspect="portrait"] #whoami .whoami-email, body[data-aspect="portrait-narrow"] #whoami .whoami-email { display: block; opacity: 0.85; }

/* ── Admin portrait ──────────────────────────── */
body[data-aspect="portrait"] .viewAdmin .adminGrid, body[data-aspect="portrait-narrow"] .viewAdmin .adminGrid { width: 100%; max-width: 100%; }
body[data-aspect="portrait"] .viewAdmin .adminGrid > *, body[data-aspect="portrait-narrow"] .viewAdmin .adminGrid > * { min-width: 0; max-width: 100%; }
body[data-aspect="portrait"] .viewAdmin .card, body[data-aspect="portrait-narrow"] .viewAdmin .card { max-width: 100%; }
body[data-aspect="portrait"] .viewAdmin .tableWrap, body[data-aspect="portrait-narrow"] .viewAdmin .tableWrap { overflow-x: auto; overflow-y: hidden; max-width: 100%; -webkit-overflow-scrolling: touch; border: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); }
body[data-aspect="portrait"] .viewAdmin table, body[data-aspect="portrait-narrow"] .viewAdmin table { width: max-content; min-width: 700px; border-collapse: collapse; }
body[data-aspect="portrait"] .viewAdmin thead, body[data-aspect="portrait-narrow"] .viewAdmin thead { display: table-header-group; }
body[data-aspect="portrait"] .viewAdmin tbody tr, body[data-aspect="portrait-narrow"] .viewAdmin tbody tr { display: table-row; background: transparent; border: none; border-radius: 0; padding: 0; margin: 0; }
body[data-aspect="portrait"] .viewAdmin td, body[data-aspect="portrait"] .viewAdmin th, body[data-aspect="portrait-narrow"] .viewAdmin td, body[data-aspect="portrait-narrow"] .viewAdmin th { display: table-cell; padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--glass-border); }
body[data-aspect="portrait"] .viewAdmin td::before, body[data-aspect="portrait-narrow"] .viewAdmin td::before { content: none; }

@media (min-width: 769px) { .viewAdmin .adminGrid { align-items: stretch; } }

body[data-device="tablet"][data-aspect="portrait"] .topbar,
body[data-device="tablet"][data-aspect="portrait-narrow"] .topbar,
body[data-device="monitor"][data-aspect="portrait"] .topbar,
body[data-device="monitor"][data-aspect="portrait-narrow"] .topbar { flex-direction: row; align-items: center; gap: var(--space-xl); }
body[data-device="tablet"][data-aspect="portrait"] .brand,
body[data-device="tablet"][data-aspect="portrait-narrow"] .brand,
body[data-device="monitor"][data-aspect="portrait"] .brand,
body[data-device="monitor"][data-aspect="portrait-narrow"] .brand { width: auto; justify-content: flex-start; }
body[data-device="tablet"][data-aspect="portrait"] .brand .title,
body[data-device="tablet"][data-aspect="portrait-narrow"] .brand .title,
body[data-device="monitor"][data-aspect="portrait"] .brand .title,
body[data-device="monitor"][data-aspect="portrait-narrow"] .brand .title { text-align: left; width: auto; }
body[data-device="tablet"][data-aspect="portrait"] .right,
body[data-device="tablet"][data-aspect="portrait-narrow"] .right,
body[data-device="monitor"][data-aspect="portrait"] .right,
body[data-device="monitor"][data-aspect="portrait-narrow"] .right { width: auto; justify-content: flex-end; gap: var(--space-lg); }
body[data-device="tablet"][data-aspect="portrait"] #whoami,
body[data-device="tablet"][data-aspect="portrait-narrow"] #whoami,
body[data-device="monitor"][data-aspect="portrait"] #whoami,
body[data-device="monitor"][data-aspect="portrait-narrow"] #whoami { white-space: nowrap; }
body[data-device="tablet"][data-aspect="portrait"] .viewAdmin table,
body[data-device="tablet"][data-aspect="portrait-narrow"] .viewAdmin table,
body[data-device="monitor"][data-aspect="portrait"] .viewAdmin table,
body[data-device="monitor"][data-aspect="portrait-narrow"] .viewAdmin table { width: 100%; min-width: 700px; table-layout: auto; }
body[data-device="tablet"][data-aspect="portrait"] .viewAdmin .tableWrap,
body[data-device="tablet"][data-aspect="portrait-narrow"] .viewAdmin .tableWrap,
body[data-device="monitor"][data-aspect="portrait"] .viewAdmin .tableWrap,
body[data-device="monitor"][data-aspect="portrait-narrow"] .viewAdmin .tableWrap { overflow-x: hidden; }

/* ── Auth layouts ────────────────────────────── */
[data-layout="auth-mobile"] #viewLogin.card,
[data-layout="auth-mobile"] #viewForgot.card,
[data-layout="auth-mobile"] #viewReset.card { width: 100%; max-width: none; margin-left: 0; margin-right: 0; }
[data-layout="auth-tablet-port"] #viewLogin.card,
[data-layout="auth-tablet-port"] #viewForgot.card,
[data-layout="auth-tablet-port"] #viewReset.card { width: 50%; max-width: none; margin-left: auto; margin-right: auto; }
[data-layout="auth-tablet-land"] #viewLogin.card,
[data-layout="auth-tablet-land"] #viewForgot.card,
[data-layout="auth-tablet-land"] #viewReset.card { width: 50%; max-width: none; margin-left: auto; margin-right: auto; }
[data-layout="auth-monitor-land"] #viewLogin.card,
[data-layout="auth-monitor-land"] #viewForgot.card,
[data-layout="auth-monitor-land"] #viewReset.card { width: calc(100vw / 3); max-width: none; margin-left: auto; margin-right: auto; }
[data-layout="auth-monitor-port"] #viewLogin.card,
[data-layout="auth-monitor-port"] #viewForgot.card,
[data-layout="auth-monitor-port"] #viewReset.card { width: 66.666%; max-width: none; margin-left: auto; margin-right: auto; }

*:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* ── User 3-col grid ─────────────────────────── */
#viewUser .userGrid { grid-template-columns: repeat(3, 1fr) !important; align-items: start; width: 100%; }
#viewUser .userActionsCard .userActions { margin-top: 0; flex-direction: column; gap: var(--space-md); }
#viewUser .userActionsCard .userActions .btn { width: 100%; flex: none; }
#viewUser .userActionsCard .panel { margin-top: var(--space-lg); }
#viewUser .activityCard { align-self: stretch; display: flex; flex-direction: column; }
#viewUser .activityCard .activityList { flex: 1 1 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }

body[data-layout="stack"] #viewUser .userGrid { grid-template-columns: 1fr !important; }
body[data-layout="user-3col"] #viewUser .userGrid { grid-template-columns: repeat(3, 1fr) !important; align-items: stretch; width: 100%; }
body[data-layout="user-3col"] #viewUser .activityCard { display: flex; flex-direction: column; }
body[data-layout="user-3col"] #viewUser .activityCard .activityList { flex: 1 1 0; max-height: none; overflow-y: auto; }
body[data-layout="user-monitor-port-centered"] #viewUser .userGrid { grid-template-columns: 1fr !important; align-items: start; width: 66.666%; margin-left: auto; margin-right: auto; gap: var(--space-xl); }
body[data-layout="user-monitor-port-centered"] #viewUser .userGrid > .card { max-height: none; overflow: visible; }
body[data-layout="user-monitor-port-centered"] #viewUser .activityCard { display: flex; flex-direction: column; }
body[data-layout="user-monitor-port-centered"] #viewUser .activityCard .activityList { flex: 1 1 auto; max-height: 500px; overflow-y: auto; }
body[data-layout="user-tablet-port-centered"] #viewUser .userGrid { grid-template-columns: 1fr !important; align-items: start; width: 50%; margin-left: auto; margin-right: auto; gap: var(--space-xl); }
body[data-layout="user-tablet-port-centered"] #viewUser .userGrid > .card { max-height: none; overflow: visible; }
body[data-layout="user-tablet-port-centered"] #viewUser .activityCard { display: flex; flex-direction: column; }
body[data-layout="user-tablet-port-centered"] #viewUser .activityCard .activityList { flex: 1 1 auto; max-height: 500px; overflow-y: auto; }
body[data-layout="user-2col"] #viewUser .userGrid { grid-template-columns: 1fr 1fr !important; align-items: stretch; }
body[data-layout="user-2col"] #viewUser .activityCard { grid-column: 1 / -1; }
body[data-layout="user-2col"] #viewUser .userGrid > .card,
body[data-layout="user-3col"] #viewUser .userGrid > .card { max-height: none; overflow: visible; }
body[data-layout="user-2col"] #viewUser .activityCard .activityList,
body[data-layout="user-3col"] #viewUser .activityCard .activityList { max-height: 340px; overflow-y: auto; }
body[data-device="mobile"][data-orientation="landscape"][data-layout="user-2col"] #viewUser .userGrid { grid-template-columns: 1fr 1fr !important; align-items: start; gap: var(--space-md); }
body[data-device="mobile"][data-orientation="landscape"][data-layout="user-2col"] #viewUser .userGrid > .card { max-height: calc(100vh - 86px - var(--space-2xl)); overflow-y: auto; overscroll-behavior: contain; }
body[data-device="mobile"][data-orientation="landscape"][data-layout="user-2col"] #viewUser .activityCard { grid-column: 1 / -1; max-height: 180px; }
body[data-device="mobile"][data-orientation="landscape"][data-layout="user-2col"] #viewUser .activityCard .activityList { max-height: 100px; overflow-y: auto; }

@media (max-height: 520px) and (min-width: 820px) {
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-split-50-50"] #viewUser .grid,
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-2col"] #viewUser .userGrid { align-items: stretch; }
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-split-50-50"] #viewUser .grid > .card:not(.activityCard),
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-2col"] #viewUser .userGrid > .card:not(.activityCard) { max-height: none !important; overflow: visible !important; }
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-split-50-50"] #viewUser .activityCard,
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-2col"] #viewUser .activityCard { position: sticky; top: 86px; align-self: start; max-height: calc(100vh - 86px - 18px); overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-split-50-50"] #viewUser .activityCard::-webkit-scrollbar,
  body[data-device="mobile"][data-orientation="landscape"][data-view="user"][data-layout="user-2col"] #viewUser .activityCard::-webkit-scrollbar { width: 0px; height: 0px; }
}

@media (max-width: 480px) {
  .topbar { position: relative; flex-direction: column; align-items: flex-start; gap: var(--space-md); }
  .brand { display: flex; justify-content: center; align-items: center; width: 100%; }
  .brand .title { font-size: var(--brand-title-mobile); margin-left: 0; position: static; transform: none; top: auto; right: auto; left: auto; text-align: center; white-space: normal; }
  .right { width: 100%; justify-content: space-between; }
  .card { padding: var(--space-xl); }
  table { min-width: 600px; }
  .kv > div { flex-direction: column; align-items: flex-start; gap: var(--space-xs); }
  .kv > .kv-status { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; gap: var(--space-md); }
  .actionBtns { flex-direction: column; }
  .btn-small { width: 100%; }
  .userActions { flex-direction: column; }
  .actionRow { flex-direction: column; align-items: stretch; }
  .actionRow .btn { width: 100%; }
  .pairIdCode { font-size: var(--font-2xl); letter-spacing: 0.12em; min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }
@media (min-width: 1200px) { .viewUser .grid.userGrid { width: 100%; margin-left: auto; margin-right: auto; } }

/* ═══════════════════════════════════════════════
   LOCKID ADDITIONS — per-card loading, whoami,
   button height, spacing fixes, card loader
═══════════════════════════════════════════════ */

/* Whoami: rola oddelená od emailu */
#whoami {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
}
.whoami-role {
  color: var(--text-primary);
  font-weight: 600;
}
.whoami-sep {
  color: var(--text-tertiary);
  font-size: var(--font-xs);
}
.whoami-email {
  color: var(--text-secondary);
}

/* Portrait: whoami stacks */
body[data-aspect="portrait"] #whoami,
body[data-aspect="portrait-narrow"] #whoami {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
body[data-aspect="portrait"] #whoami .whoami-sep,
body[data-aspect="portrait-narrow"] #whoami .whoami-sep {
  display: none;
}

/* btn-full: full-width button with proper height */
.btn-full {
  width: 100%;
  min-height: 44px;
  padding: var(--space-md) var(--space-xl);
}

/* Fix btn-small height — was too flat */
.btn-small {
  min-height: 36px;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-sm);
}

/* Per-card loading skeleton */
.card--loading {
  position: relative;
  overflow: hidden;
  pointer-events: none;
}
.card--loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: cardShimmer 1.4s ease-in-out infinite;
  border-radius: inherit;
  z-index: 10;
}
@keyframes cardShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* Consistent heading spacing inside cards */
.card h2 { margin-bottom: var(--space-lg); }
.card h3 { margin-bottom: var(--space-lg); }

/* kv-status row: always space-between */
.kv-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

/* Consistent paragraph spacing after h2/h3 subtitle */
.card > .muted.small:first-of-type,
.card > p.muted { margin-top: 0; margin-bottom: var(--space-lg); }

/* OTP code active — blue glow */
.otpCode--active {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.08);
}

/* Topbar: ensure right side never wraps awkwardly */
.topbar .right {
  flex-shrink: 0;
  gap: var(--space-md);
}

/* Admin grid right column gap consistency */
.viewAdmin .adminGrid > div:last-child {
  gap: var(--space-xl);
}

/* Form spacing — equal top/bottom inside panels */
.panel .form { margin-top: 0; }
.panel label { margin-top: 0; }

/* Activity row: fix alignment on small screens */
.activityRow {
  flex-wrap: nowrap;
  min-width: 0;
}
.activityRow > .small {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive: on mobile, whoami email hidden if very narrow */
@media (max-width: 420px) {
  .whoami-email { display: none; }
  .whoami-sep   { display: none; }
}