/* Malice admin panel — dark glassmorphism, palette extracted from the
   product logo (see build notes in README.md). Dark mode only, by design. */

:root {
  color-scheme: dark;

  /* Palette sampled directly from icon.png's gradient. */
  --bg-void: #0a0a0f;
  --accent-light: #3d8bfa;
  --accent-mid: #2a6fe9;
  --accent-dark: #18397a;

  --text-primary: #f3f5fa;
  --text-secondary: #9aa1b5;
  --text-tertiary: #6b7185;

  --glass-fill-top: rgba(255, 255, 255, 0.055);
  --glass-fill-bottom: rgba(255, 255, 255, 0.022);
  --glass-border: rgba(255, 255, 255, 0.09);

  --success: #4fae82;
  --success-bg: rgba(79, 174, 130, 0.14);
  --success-text: #86d6ac;

  --warning: #d1a256;
  --warning-bg: rgba(209, 162, 86, 0.14);
  --warning-text: #e2bd82;

  --danger: #d1656b;
  --danger-bg: rgba(209, 101, 107, 0.14);
  --danger-text: #eaa3a8;

  --neutral-text: #838a9e;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 220ms;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text-primary);
  background:
    radial-gradient(ellipse 900px 560px at 50% -8%, rgba(47, 116, 240, 0.18), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 100%, rgba(24, 57, 122, 0.12), transparent 55%),
    var(--bg-void);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, form, ul {
  margin: 0;
}

button, input {
  font-family: inherit;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.glass {
  background: linear-gradient(180deg, var(--glass-fill-top), var(--glass-fill-bottom));
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 24px 48px -24px rgba(0, 0, 0, 0.65);
}

.wordmark {
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-mid));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[hidden] {
  display: none !important;
}

/* ---- buttons ---------------------------------------------------------- */

.btn {
  appearance: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease), opacity var(--duration-fast) var(--ease);
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none !important;
}
.btn-block {
  width: 100%;
}
.btn-small {
  padding: 6px 12px;
  font-size: var(--fs-xs);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-light), var(--accent-mid) 60%, var(--accent-dark));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 4px 18px -6px rgba(47, 116, 240, 0.6);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 8px 26px -6px rgba(47, 116, 240, 0.8);
  transform: translateY(-1px);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
}
.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(209, 101, 107, 0.4);
  color: var(--danger-text);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(209, 101, 107, 0.22);
  box-shadow: 0 0 0 3px rgba(209, 101, 107, 0.15);
}

/* ---- form fields -------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.field input,
.search-input,
textarea {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: var(--fs-base);
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}
.field input:focus,
.search-input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-mid);
  background: rgba(255, 255, 255, 0.065);
  box-shadow: 0 0 0 3px rgba(47, 116, 240, 0.18);
}
textarea {
  resize: vertical;
  min-height: 88px;
}

/* ---- loading view --------------------------------------------------- */

.view-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-mark {
  width: 52px;
  height: 52px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}

/* ---- login view ------------------------------------------------------- */

.view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: var(--space-6) var(--space-5);
  border-radius: var(--radius-lg);
  text-align: center;
}
.login-logo {
  width: 60px;
  height: 60px;
  margin-bottom: var(--space-3);
}
.login-card .wordmark {
  font-size: var(--fs-2xl);
  display: block;
}
.login-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin-top: 6px;
  margin-bottom: var(--space-5);
}
#login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  text-align: left;
}
.form-error {
  color: var(--danger-text);
  background: var(--danger-bg);
  border: 1px solid rgba(209, 101, 107, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--fs-xs);
  text-align: center;
}

/* ---- dashboard shell -------------------------------------------------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  border-left: none;
  border-right: none;
  border-top: none;
  border-radius: 0;
}
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 26px;
  height: 26px;
}
.topnav-brand .wordmark {
  font-size: var(--fs-md);
}
.topnav-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.035);
  padding: 4px;
  border-radius: var(--radius-full);
  margin: 0 auto;
}
.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
.tab-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-mid), var(--accent-dark));
}
.tab-btn:not(.is-active):hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}
.topnav-account {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.admin-username {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ---- stats -------------------------------------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
}
.stat-card {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
}
.stat-value {
  font-size: var(--fs-xl);
  font-weight: 700;
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---- panels & tables ---------------------------------------------------- */

.panel {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
}
.panel-title {
  font-size: var(--fs-md);
  font-weight: 600;
}
.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.search-input {
  min-width: 240px;
}

.batch-form {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}
.field-inline {
  width: 160px;
}
.batch-result {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.batch-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.batch-key-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.batch-key-list li {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}
.batch-key-list li:hover {
  background: rgba(255, 255, 255, 0.09);
}

.table-scroll {
  /* overflow-x: auto made the container clip the row-action dropdown
     on both axes — CSS forces overflow-y to auto whenever overflow-x
     is not visible. On any desktop viewport the table fits without a
     scroll, so the clip is pure downside. Set it to visible so the
     dropdown can render freely. Narrow viewports fall back to a
     horizontal scroll on the container via the media query below. */
  overflow: visible;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--fs-xs);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  vertical-align: middle;
  white-space: nowrap;
  color: var(--text-primary);
}
.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}
.col-actions {
  width: 44px;
}
.notes-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap !important;
  color: var(--text-secondary);
}
.mono {
  font-family: var(--font-mono);
}
.muted {
  color: var(--text-tertiary);
}
.empty-row td {
  color: var(--text-secondary);
  text-align: center;
  padding: var(--space-6);
  white-space: normal;
}

/* ---- status pills -------------------------------------------------------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}
.status-active { background: var(--success-bg); color: var(--success-text); }
.status-active::before { background: var(--success); box-shadow: 0 0 6px rgba(79, 174, 130, 0.7); }
.status-expiring { background: var(--warning-bg); color: var(--warning-text); }
.status-expiring::before { background: var(--warning); box-shadow: 0 0 6px rgba(209, 162, 86, 0.7); }
.status-expired, .status-revoked { background: var(--danger-bg); color: var(--danger-text); }
.status-expired::before, .status-revoked::before { background: var(--danger); box-shadow: 0 0 6px rgba(209, 101, 107, 0.7); }
.status-none { background: rgba(255, 255, 255, 0.06); color: var(--neutral-text); }
.status-none::before { background: var(--neutral-text); }

/* ---- row action menu ---------------------------------------------------- */

.row-menu-wrapper {
  position: relative;
  display: inline-block;
}
.row-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.row-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  z-index: 30;
  border-radius: var(--radius-md);
  padding: 6px;
  background: rgba(18, 19, 28, 0.97);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.65);
}
.row-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
}
.row-menu button:hover {
  background: rgba(255, 255, 255, 0.07);
}
.row-menu button.danger {
  color: var(--danger-text);
}
.row-menu button.danger:hover {
  background: rgba(209, 101, 107, 0.14);
}

/* ---- pagination --------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.pagination button {
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.pagination button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.pagination button.is-active {
  background: linear-gradient(135deg, var(--accent-mid), var(--accent-dark));
  color: #fff;
  border-color: transparent;
}
.pagination button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---- modal --------------------------------------------------------------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 9, 0.62);
  backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  animation: modal-in var(--duration-base) var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal-title {
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.modal-body {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.55;
  margin-bottom: var(--space-4);
}
.modal-body strong {
  color: var(--text-primary);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}
.reveal-value {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: var(--fs-base);
  color: var(--accent-light);
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.modal-field {
  margin-bottom: var(--space-4);
}

/* ---- toasts -------------------------------------------------------------- */

.toast-root {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
}
.toast {
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  background: rgba(18, 19, 28, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 32px -8px rgba(0, 0, 0, 0.6);
  animation: toast-in var(--duration-base) var(--ease);
  color: var(--text-primary);
}
.toast-error {
  border-color: rgba(209, 101, 107, 0.4);
  color: var(--danger-text);
}
.toast-success {
  border-color: rgba(79, 174, 130, 0.4);
  color: var(--success-text);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 860px) {
  .topnav {
    flex-wrap: wrap;
    row-gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  /* Three tabs don't fit a phone width with default padding — let the
     tab strip scroll horizontally rather than clip or wrap into two
     rows. Scrollbar hidden; touch swipe is the affordance. */
  .topnav-tabs {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topnav-tabs::-webkit-scrollbar { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Narrow viewports need horizontal scroll for the wide table.
     Same trade-off as before: the dropdown can only render into the
     visible scroll region, so reserve room at the bottom. */
  .table-scroll {
    overflow-x: auto;
    padding-bottom: 260px;
    margin-bottom: -260px;
  }
  .pagination {
    margin-top: calc(var(--space-4) + 260px);
    transform: translateY(-260px);
  }
}

/* ---- Narrow phones (up to 640px) ---------------------------------- */

@media (max-width: 640px) {
  /* Topnav compression. The username label takes real width and adds
     nothing on a phone — the avatar in the header already identifies
     the session. Hide it, tighten the gaps, shrink the buttons. */
  .topnav { gap: var(--space-2); }
  .topnav-brand { gap: 8px; }
  .topnav-brand .wordmark { font-size: var(--fs-base); }
  .brand-logo { width: 22px; height: 22px; }

  .version-pill {
    margin-left: 6px;
    padding: 3px 8px;
    font-size: 11px;
  }

  .topnav-account {
    gap: 6px;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
  }
  .admin-username { display: none; }
  .topnav-account .btn {
    padding: 5px 9px;
    font-size: 11px;
  }

  .topnav-tabs .tab-btn {
    padding: 7px 12px;
    font-size: var(--fs-xs);
  }

  .main-content { padding: var(--space-4); }
  .panel { padding: var(--space-4); }
  .panel-title { font-size: var(--fs-base); }
  .stat-card { padding: var(--space-3) var(--space-4); }
  .stat-value { font-size: var(--fs-lg); }

  /* Modal — near full-bleed with a small margin, tighter padding,
     and any actions row wraps instead of forcing a horizontal
     scroll on a two-button confirmation. */
  .modal-root { padding: var(--space-3); }
  .modal-card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }
  .modal-card-wide { max-width: 100%; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }

  /* dvh excludes the mobile browser chrome; vh alone pushes the
     bottom of the modal behind the address bar. Fallback to vh for
     browsers that haven't shipped dvh. */
  .user-detail-body {
    max-height: 68vh;
    max-height: 68dvh;
  }

  .user-detail-name { font-size: var(--fs-md); }
  .user-detail-head { flex-wrap: wrap; }
  .user-detail-card { padding: 12px 14px; }
  .user-detail-card-title { margin-bottom: 8px; }

  /* The user-detail tables were keeping the desktop rule
     (white-space: nowrap; overflow: hidden; max-width: 220px) — the
     specificity of `.user-detail-table td` beat the mobile
     `.data-table td` override, so the tables stayed desktop-style
     inside a phone-width modal. Switch to wrapping cells at a
     smaller font so the values are readable without ellipsis or a
     horizontal scroll. */
  .user-detail-table {
    font-size: 11px;
    table-layout: auto;
  }
  .user-detail-table th,
  .user-detail-table td {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    padding: 6px 8px;
  }

  /* Batch form on the users tab — tighter vertical rhythm between
     the two inputs and the button. */
  .batch-form { gap: var(--space-3); }
  .batch-key-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr; }
  .batch-form { flex-direction: column; align-items: stretch; }
  .field-inline { width: 100%; }
  .panel-toolbar { flex-direction: column; align-items: stretch; }
  .search-input { min-width: 0; }

  /* ---- Stacked table for phones -----------------------------------
     The table has 10 columns; no phone screen fits them without a
     horizontal scroll. On narrow viewports, take the table out of
     table-mode and let each <tr> render as a stacked block: label
     above value. The panel then scrolls vertically like any normal
     page. The row-action dropdown still works — it anchors under the
     ⋯ button at the bottom of each stacked row. */

  .table-scroll {
    overflow: visible;
    padding-bottom: 0;
    margin-bottom: 0;
  }
  .pagination {
    margin-top: var(--space-4);
    transform: none;
  }

  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
    width: 100%;
  }

  /* Hide the header row entirely — labels come from the data-label
     attribute injected on each cell (see below). */
  .data-table thead {
    display: none;
  }

  .data-table tr {
    background: rgba(255, 255, 255, 0.028);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    padding: var(--space-2) 0;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    white-space: normal;
    text-align: right;
  }
  .data-table td:last-child {
    border-bottom: none;
  }

  /* Label side of each row: comes from data-label on the <td>. */
  .data-table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-align: left;
    padding-right: var(--space-3);
  }

  /* Empty state and the actions column render without a label. */
  .data-table td.col-actions::before,
  .data-table .empty-row td::before {
    content: none;
  }
  .data-table td.col-actions {
    width: 100%;
    justify-content: flex-end;
    padding: 4px 14px 8px;
  }

  /* The notes cell was truncating to one line — on mobile let it
     wrap so the full note is readable. */
  .notes-cell {
    max-width: none;
    overflow: visible;
    white-space: normal !important;
  }

  /* Row-menu anchors to the ⋯ button which is now full-width-aligned
     right. Keep the dropdown inside the viewport by anchoring to the
     right of its wrapper. */
  .row-menu {
    right: 0;
    left: auto;
    max-width: calc(100vw - 60px);
  }
}

/* ---- banned pill + row menu divider --------------------------------- */

.status-banned {
  background: var(--danger-bg);
  color: var(--danger-text);
}
.status-banned::before {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(209, 101, 107, 0.7);
}

.cell-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.row-menu-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

/* ---- Client version pill (topnav, next to Malice wordmark) --------- */

.version-pill {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: 10px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent, #4a90e2);
  background: rgba(74, 144, 226, 0.10);
  border: 1px solid rgba(74, 144, 226, 0.32);
  border-radius: 999px;
  cursor: default;
  user-select: none;
}

/* Display-only. No hover, no cursor change — the pill is a badge,
   not a button. */
.version-pill {
  cursor: default;
  user-select: none;
}

.version-pill-label {
  opacity: 0.65;
  margin-right: 1px;
}

.version-pill-value {
  font-variant-numeric: tabular-nums;
}

/* Modal body used by the version editor — matches the existing
   .modal-field pattern used elsewhere. */

.version-editor-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.version-editor-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim, #8c94a4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.version-editor-row input {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text, #e6e8eb);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
}

.version-editor-row input:focus {
  outline: none;
  border-color: rgba(74, 144, 226, 0.55);
  background: rgba(255, 255, 255, 0.06);
}

.version-editor-hint {
  font-size: 12px;
  color: var(--text-dim, #8c94a4);
  line-height: 1.45;
  margin: 0 0 14px;
}

/* ---- Kill switch button (topnav) ---------------------------------- */

#kill-switch-btn.is-armed {
  background: rgba(209, 101, 107, 0.20);
  border-color: rgba(209, 101, 107, 0.55);
  color: var(--danger-text);
  box-shadow: 0 0 0 3px rgba(209, 101, 107, 0.12);
}

#kill-switch-btn.is-armed:hover:not(:disabled) {
  background: rgba(209, 101, 107, 0.30);
}

#kill-switch-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- Wider modal variant ---------------------------------------- */

.modal-card-wide {
  max-width: 900px;
}

/* ---- User detail view -------------------------------------------- */

.user-detail-body {
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
}

.user-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.user-detail-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin: 0;
}

.user-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.user-detail-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.user-detail-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.user-detail-card:last-child { margin-bottom: 0; }

.user-detail-card-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.user-detail-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
  font-size: var(--fs-sm);
}

.user-detail-k {
  color: var(--text-secondary);
  flex: none;
}

.user-detail-v {
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
}

.user-detail-notes {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  margin: 0;
  word-break: break-word;
}

.user-detail-table {
  font-size: var(--fs-xs);
  width: 100%;
}

.user-detail-table th {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  white-space: nowrap;
}

.user-detail-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.user-detail-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---- Clickable username cell ------------------------------------- */

.user-name-link {
  cursor: pointer;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  transition: color 0.12s ease, border-color 0.12s ease;
}

.user-name-link:hover {
  color: var(--accent-light, #3d8bfa);
  border-bottom-color: var(--accent-light, #3d8bfa);
}

@media (max-width: 720px) {
  .user-detail-grid { grid-template-columns: 1fr; }
}


/* ===================================================================
   Responsive fixes v2 — appended so source order overrides the
   earlier breakpoint blocks at the same specificity.
   =================================================================== */

/* ---- Tablet: horizontal scroll for the wide users table ----------
   Between 861 and 1120 px the panel stops fitting the 10-column
   users table and the rightmost header ("Last check-in") gets
   clipped. Reuse the same overflow pattern the ≤860px block already
   uses. Scoped to ≥521px so it doesn't fight the stacked-table
   rules on phones. */
@media (max-width: 1120px) and (min-width: 521px) {
  .table-scroll {
    overflow-x: auto;
    padding-bottom: 260px;
    margin-bottom: -260px;
    -webkit-overflow-scrolling: touch;
  }
  .pagination {
    margin-top: calc(var(--space-4) + 260px);
    transform: translateY(-260px);
  }
}

/* ---- Phone: topnav becomes three rows ---------------------------
   Previously the brand and four account buttons shared a single row
   with only 6 px between them — the pills visually touched. Force
   the account cluster onto its own full-width row and let the four
   buttons stretch to fill it as one even toolbar. The tab strip
   stays on its own row below via the existing order:3 rule. */
@media (max-width: 640px) {
  .topnav {
    row-gap: 10px;
  }
  .topnav-brand {
    width: 100%;
  }
  .topnav-account {
    order: 2;
    width: 100%;
    margin-left: 0;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .topnav-account .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 6px;
    text-align: center;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


/* Center the tab strip on narrow viewports. The ≤860px rule set
   justify-content: flex-start so the tabs hugged the left edge. On
   phones that reads as unbalanced against the row above it. Center
   them when they fit; the strip is still a horizontal scroller if
   they don't. */
@media (max-width: 860px) {
  .topnav-tabs {
    justify-content: center;
  }
}


/* ===================================================================
   Updates tab — current build display, drop zone, upload progress.
   =================================================================== */

.updates-current-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: var(--space-3);
}

.updates-current-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  font-size: var(--fs-sm);
}

.updates-current-label {
  color: var(--text-secondary);
  flex: none;
  min-width: 90px;
}

.updates-current-value {
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
}

.dropzone {
  margin-top: var(--space-4);
  padding: 36px 24px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.015);
  text-align: center;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease);
  outline: none;
}
.dropzone:hover,
.dropzone:focus-visible {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.25);
}
.dropzone-active {
  background: rgba(61, 139, 250, 0.09);
  border-color: var(--accent-light);
  border-style: solid;
}
.dropzone-icon {
  font-size: 32px;
  line-height: 1;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  transition: color var(--duration-fast) var(--ease);
}
.dropzone:hover .dropzone-icon,
.dropzone-active .dropzone-icon {
  color: var(--accent-light);
}
.dropzone-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.dropzone-sub {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.updates-staged {
  margin-top: var(--space-4);
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.updates-staged-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--fs-sm);
}

.updates-staged-label {
  color: var(--text-secondary);
  flex: none;
  min-width: 60px;
}

.updates-publish-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.updates-version-field {
  width: 140px;
  flex: none;
}

.updates-progress {
  margin-top: var(--space-4);
}
.updates-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.updates-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-mid));
  border-radius: var(--radius-full);
  transition: width 120ms linear;
}
.updates-progress-label {
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.updates-danger-text {
  margin: var(--space-3) 0 var(--space-4);
  font-size: var(--fs-sm);
  max-width: 620px;
}

@media (max-width: 520px) {
  .updates-publish-row { flex-direction: column; align-items: stretch; }
  .updates-version-field { width: 100%; }
  .dropzone { padding: 24px 16px; }
  .updates-current-row { flex-wrap: wrap; }
  .updates-current-value { text-align: left; width: 100%; }
}