/* Project Flux Admin — matches desktop app theme tokens (src/theme/tokens.ts) */
:root {
  --pf-brand: #2563eb;
  --pf-brand-dark: #1d4ed8;
  --pf-brand-mid: #3b82f6;
  --pf-brand-light: #60a5fa;
  --pf-brand-soft: #dbeafe;
  --pf-brand-pale: #eff6ff;
  --pf-surface-page: #f1f5f9;
  --pf-surface-card: #ffffff;
  --pf-surface-muted: #f8fafc;
  --pf-surface-toolbar: #eff6ff;
  --pf-text: #0f172a;
  --pf-text-secondary: #334155;
  --pf-text-muted: #64748b;
  --pf-text-inverse: #ffffff;
  --pf-border: #cbd5e1;
  --pf-border-strong: #94a3b8;
  --pf-danger: #be123c;
  --pf-danger-bg: #fff1f2;
  --pf-danger-border: #fb7185;
  --pf-ok: #15803d;
  --pf-ok-bg: #ecfdf5;
  --font: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --display: "Syne", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: var(--font);
  color: var(--pf-text);
  background: var(--pf-surface-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pf-brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

#app {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-shell {
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid rgba(37, 99, 235, 0.15);
  background: var(--pf-surface-toolbar);
  flex: 0 0 auto;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--display);
  font-weight: 700;
  color: var(--pf-brand);
  grid-column: 1;
  grid-row: 1;
}
.brand img { width: 32px; height: 32px; }
.nav-toggle {
  display: none;
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  padding: 0.3rem 0.6rem !important;
  font-size: 0.78rem !important;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}
.nav button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--pf-text-secondary);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  z-index: 2;
  font-weight: 600;
}
.nav button.active, .nav button:hover {
  color: var(--pf-brand);
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--pf-brand-pale);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--pf-text-muted);
  font-size: 0.85rem;
  grid-column: 3;
  grid-row: 1;
}
.top-actions .btn { position: relative; z-index: 2; cursor: pointer; }

.main {
  width: min(1200px, calc(100% - 2rem));
  margin: 0.4rem auto 0.5rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.main.main-user {
  overflow: hidden;
  margin-top: 0.25rem;
}
.main.main-dashboard {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  width: min(1360px, calc(100% - 1rem));
  margin: 0.25rem auto 0.3rem;
}
.main.main-users {
  overflow: hidden;
  width: min(1360px, calc(100% - 1rem));
  margin: 0.15rem auto 0.2rem;
}
.page-title {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--pf-text);
  line-height: 1.2;
}
.user-page {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  height: 100%;
  overflow: hidden;
  gap: 0.3rem;
}
.user-head {
  flex: 0 0 auto;
  z-index: 3;
  background: var(--pf-surface-page);
  padding: 0 0 0.2rem;
  border-bottom: 1px solid #e2e8f0;
  margin: 0;
}
.user-head-top {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem 0.4rem;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: thin;
}
.user-head-top > * {
  flex: 0 0 auto;
  min-width: max-content;
}
.user-head-id {
  min-width: 0;
  max-width: 12rem;
  flex: 0 1 auto !important;
}
.user-head-top .page-title {
  font-size: 0.82rem;
  margin: 0;
  line-height: 1.15;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.user-email {
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--pf-text-muted);
  white-space: nowrap;
  margin-left: 0.3rem;
}
.user-meta-chips {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
  flex: 0 0 auto !important;
  min-width: max-content !important;
}
.umeta {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  padding: 0.1rem 0.32rem;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--pf-text-muted);
  white-space: nowrap;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}
.umeta strong {
  color: var(--pf-text);
  font-weight: 800;
}
.umeta-id {
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.58rem;
}
.user-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: hidden;
}
.user-actions {
  flex: 0 0 auto;
  z-index: 3;
  background: var(--pf-surface-page);
  padding: 0.3rem 0 0.1rem;
  border-top: 1px solid #e2e8f0;
}
.user-actions .btn {
  flex: 1 1 auto;
  min-width: 5.5rem;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(800px 400px at 15% 0%, rgba(37, 99, 235, 0.12), transparent 55%),
    var(--pf-surface-page);
}
.login-card {
  width: min(420px, 100%);
  padding: 1.5rem;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 16px;
  background: var(--pf-surface-card);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}
.login-card h1 {
  font-family: var(--display);
  margin: 0.5rem 0 0.35rem;
  font-size: 1.6rem;
  color: var(--pf-text);
}
.login-card p { color: var(--pf-text-muted); margin: 0 0 1.1rem; font-size: 0.92rem; }

label { display: block; font-size: 0.85rem; color: var(--pf-text-muted); margin-bottom: 0.35rem; font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--pf-border);
  border-radius: 10px;
  background: var(--pf-surface-card);
  color: var(--pf-text);
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.85rem;
  color-scheme: light;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: var(--pf-brand);
}

/* Fix OS dropdown: dark options on white were unreadable */
select {
  background-color: var(--pf-surface-card);
  color: var(--pf-text);
}
select option,
select optgroup {
  background-color: #ffffff;
  color: #0f172a;
}
select option:checked,
select option:hover {
  background-color: var(--pf-brand-pale);
  color: var(--pf-brand-dark);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary {
  color: var(--pf-text-inverse);
  background: var(--pf-brand);
}
.btn-primary:hover { background: var(--pf-brand-dark); }
.btn-ghost {
  color: var(--pf-brand);
  background: var(--pf-surface-card);
  border: 1px solid rgba(37, 99, 235, 0.3);
}
.btn-ghost:hover {
  background: var(--pf-brand-pale);
  border-color: var(--pf-brand);
}
.btn-danger {
  color: #fff;
  background: var(--pf-danger);
}
.btn-danger:hover { background: #9f1239; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Dashboard — page scrolls so limit cards never get squeezed/overlap */
.dash {
  flex: 0 0 auto;
  min-height: min-content;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: auto;
  overflow: visible;
}
.dash-hero {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 12px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(96, 165, 250, 0.18), transparent 55%),
    linear-gradient(135deg, #eff6ff 0%, #ffffff 48%, #f8fafc 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.dash-kicker {
  margin: 0 0 0.05rem;
  font-family: var(--font);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pf-brand);
}
.dash-title {
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--pf-text);
}
.dash-sub {
  margin: 0.15rem 0 0;
  max-width: 34rem;
  font-family: var(--font);
  font-size: 0.75rem;
  color: var(--pf-text-muted);
  font-weight: 500;
  line-height: 1.35;
}
.dash-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 0 0 auto;
}
.dash-hero-actions .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.45rem;
}
.dash-stats {
  flex: 0 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}
.dash-stats .stat {
  min-height: 0;
  height: 100%;
}
.stat {
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: var(--pf-surface-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 0;
}
.dash-stats .stat {
  padding: 0.5rem 0.65rem 0.5rem 0.75rem;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--pf-brand-mid);
  opacity: 0.85;
}
.stat.tone-total::before { background: var(--pf-brand); }
.stat.tone-active::before { background: #0ea5e9; }
.stat.tone-paid::before { background: #15803d; }
.stat.tone-warn::before { background: #d97706; }
.stat.tone-danger::before { background: var(--pf-danger); }
.stat.tone-muted::before { background: #64748b; }
.stat.clickable {
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.stat.clickable:hover {
  border-color: rgba(37, 99, 235, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
}
.stat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.stat .label {
  font-family: var(--font);
  color: var(--pf-text-secondary);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0;
}
.stat-hint {
  font-family: var(--font);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--pf-brand);
  opacity: 0.45;
  white-space: nowrap;
}
.stat.clickable:hover .stat-hint { opacity: 1; }
.stat .value {
  font-family: var(--font);
  font-size: 1.35rem;
  margin-top: 0.2rem;
  color: var(--pf-text);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.dash-stats .stat .value {
  font-size: 1.4rem;
  margin-top: 0.25rem;
  padding-top: 0;
  color: var(--pf-text);
}

@media (max-width: 1000px) {
  .dash-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .dash-hero {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 480px) {
  .dash-stats {
    grid-template-columns: 1fr;
  }
}

/* API limits panel — simple block cards (no flex/height tricks that collapse rows) */
.lim-section {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0.55rem 0.7rem 0.85rem;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.lim-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.lim-title {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--pf-text);
}
.lim-sub {
  margin: 0.1rem 0 0;
  font-size: 0.7rem;
  color: var(--pf-text-muted);
  font-weight: 500;
}
.lim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}
.lim-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.65rem 0.7rem 0.7rem;
  background: var(--pf-surface-muted);
  box-sizing: border-box;
}
.lim-card.lim-ok { border-color: rgba(21, 128, 61, 0.25); }
.lim-card.lim-warm { border-color: rgba(217, 119, 6, 0.35); background: #fffbeb; }
.lim-card.lim-hot { border-color: rgba(190, 18, 60, 0.35); background: #fff1f2; }
.lim-card.lim-err { border-color: rgba(100, 116, 139, 0.35); }
.lim-head { margin-bottom: 0.45rem; }
.lim-name {
  font-size: 0.74rem !important;
  font-weight: 700;
  color: var(--pf-text);
  line-height: 1.3;
  margin: 0 0 0.15rem;
}
.lim-prov {
  font-size: 0.62rem !important;
  font-weight: 600;
  color: var(--pf-text-muted);
  margin: 0;
}
.lim-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.4rem;
}
.lim-metrics > div {
  min-width: 0;
  overflow: hidden;
}
.lim-metrics .lim-k {
  display: block;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--pf-text-muted);
  line-height: 1.2;
  margin-bottom: 0.12rem;
}
.lim-metrics strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--pf-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.lim-unit {
  font-size: 0.62rem;
  color: var(--pf-text-muted);
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.lim-usage { margin: 0 0 0.35rem; }
.lim-bar {
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-bottom: 0.2rem;
}
.lim-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pf-brand-mid), var(--pf-brand));
}
.lim-hot .lim-bar span { background: linear-gradient(90deg, #fb7185, #be123c); }
.lim-warm .lim-bar span { background: linear-gradient(90deg, #fbbf24, #d97706); }
.lim-pct {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--pf-text-secondary);
}
.lim-reset {
  font-size: 0.64rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.lim-reset > span:first-child {
  font-weight: 800;
  margin-right: 0.2rem;
}
.lim-clock {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.lim-clock-red,
.lim-clock-red > span:first-child,
.lim-clock-red .lim-clock { color: #dc2626; }
.lim-clock-blue,
.lim-clock-blue > span:first-child,
.lim-clock-blue .lim-clock { color: #2563eb; }
.lim-clock-pink,
.lim-clock-pink > span:first-child,
.lim-clock-pink .lim-clock { color: #db2777; }
.lim-clock-green,
.lim-clock-green > span:first-child,
.lim-clock-green .lim-clock { color: #16a34a; }
.lim-note {
  font-size: 0.6rem;
  color: var(--pf-text-muted);
  line-height: 1.35;
  margin: 0;
}
.lim-note-err { color: var(--pf-danger); font-weight: 600; }
.lim-fetched {
  margin: 0.35rem 0 0;
  font-size: 0.62rem;
  color: var(--pf-text-muted);
  flex: 0 0 auto;
}

@keyframes pf-spin {
  to { transform: rotate(360deg); }
}
@keyframes pf-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.refresh-ico {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.12em;
  margin-right: 0.35rem;
  box-sizing: border-box;
}
.btn-refresh-limits {
  display: inline-flex;
  align-items: center;
  min-width: 8.5rem;
  justify-content: center;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}
.btn-refresh-limits:not(.is-loading):active {
  transform: scale(0.97);
}
.btn-refresh-limits .refresh-ico {
  display: none;
}
.btn-refresh-limits.is-loading .refresh-ico,
.lim-loading-msg .refresh-ico {
  display: inline-block;
  animation: pf-spin 0.7s linear infinite;
}
.btn-refresh-limits.is-loading {
  cursor: wait;
  opacity: 0.9;
}
.lim-grid.is-loading {
  animation: pf-pulse 1s ease-in-out infinite;
  pointer-events: none;
}
.lim-grid.is-loading .lim-card {
  transition: opacity 200ms ease;
}
.lim-loading-msg {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
@media (max-width: 1100px) {
  .lim-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Mobile: compact header + document scroll (nested overflow is unreliable on phones) */
@media (max-width: 900px) {
  html, body {
    height: auto !important;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #app,
  .app-shell {
    height: auto !important;
    min-height: 100dvh;
    overflow: visible !important;
  }

  .topbar {
    grid-template-columns: 1fr auto auto;
    padding: 0.3rem 0.55rem;
    position: sticky;
    top: 0;
  }
  .brand {
    gap: 0.35rem;
    font-size: 0.92rem;
  }
  .brand img {
    width: 24px;
    height: 24px;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .topbar.nav-open .nav-toggle {
    background: var(--pf-brand-pale);
    border-color: rgba(37, 99, 235, 0.3);
    color: var(--pf-brand);
  }
  .nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    flex-wrap: nowrap;
    gap: 0.25rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.15rem 0 0.2rem;
  }
  .topbar.nav-open .nav {
    display: flex;
  }
  .nav button {
    flex: 0 0 auto;
    padding: 0.28rem 0.55rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }
  .top-actions {
    gap: 0.3rem;
    font-size: 0.7rem;
  }
  .top-actions #idle-label {
    display: none !important;
  }
  .top-actions .btn {
    padding: 0.28rem 0.55rem;
    font-size: 0.75rem;
  }

  .lim-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lim-metrics {
    gap: 0.35rem;
  }
  .lim-metrics strong {
    font-size: 0.68rem;
  }
  .lim-card {
    padding: 0.55rem 0.5rem 0.6rem;
    min-width: 0;
    overflow: hidden;
  }

  .main,
  .main.main-dashboard,
  .main.main-users,
  .main.main-user {
    overflow: visible !important;
    height: auto !important;
    flex: none !important;
    width: calc(100% - 0.7rem);
    margin: 0.2rem auto 0.8rem;
  }
  .dash,
  .users-page,
  .user-page {
    overflow: visible !important;
    height: auto !important;
    flex: none !important;
    min-height: 0 !important;
  }
  .lim-section,
  .lim-grid {
    overflow: visible !important;
    flex: none !important;
    max-height: none !important;
  }
  /* Users table: no nested vertical scroll — page/body scrolls */
  .users-page {
    display: block !important;
  }
  .users-table-wrap,
  .table-wrap.users-table-wrap {
    flex: none !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    overscroll-behavior: auto;
  }
  .users-hero {
    padding: 0.22rem 0.45rem;
  }
  .users-toolbar {
    padding: 0.25rem 0.4rem;
  }
  .users-pager {
    padding-bottom: 1rem;
  }
  .dash-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 0.45rem 0.65rem;
  }
  .dash-hero-actions {
    width: 100%;
  }
  .dash-hero-actions .btn {
    flex: 1 1 auto;
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin: 1rem 0;
}
.toolbar .field { flex: 1; min-width: 180px; margin: 0; }
.toolbar label { margin-bottom: 0.25rem; }
.toolbar input, .toolbar select { margin-bottom: 0; }

/* Users page — compact chrome so the table gets most of the viewport */
.users-page {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.users-hero {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 9px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(96, 165, 250, 0.12), transparent 55%),
    linear-gradient(135deg, #eff6ff 0%, #ffffff 55%, #f8fafc 100%);
}
.users-hero-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  min-width: 0;
}
.users-hero .dash-kicker {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
}
.users-hero .dash-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
}
.users-hero .dash-sub {
  margin: 0;
  font-size: 0.7rem;
  color: var(--pf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.users-hero-meta { flex: 0 0 auto; }
.users-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--pf-brand-dark);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(37, 99, 235, 0.22);
}
.users-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.3rem 0.45rem;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fff;
}
.users-toolbar .field { margin: 0; min-width: 110px; }
.users-toolbar .field.grow { flex: 1 1 auto; min-width: 160px; }
.users-toolbar label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.users-toolbar .field { position: relative; }
.users-toolbar input,
.users-toolbar select {
  margin: 0;
  padding: 0.32rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 7px;
  height: 2rem;
}
.users-toolbar .btn {
  height: 2rem;
  padding: 0 0.7rem;
}
.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 7px;
}
.btn-warn {
  color: #b45309 !important;
  border-color: rgba(217, 119, 6, 0.35) !important;
}
.btn-warn:hover {
  background: #fffbeb !important;
  border-color: #d97706 !important;
}
.btn-danger-outline {
  color: var(--pf-danger) !important;
  border-color: rgba(190, 18, 60, 0.3) !important;
}
.btn-danger-outline:hover {
  background: var(--pf-danger-bg) !important;
  border-color: var(--pf-danger) !important;
}

.table-wrap {
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 12px;
  overflow: auto;
  background: var(--pf-surface-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.users-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  /* Hard viewport cap — chrome is compact, give table more room */
  max-height: calc(100vh - 175px);
  overflow-x: auto;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #64748b #e2e8f0;
}
.users-table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
.users-table-wrap::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 8px;
}
.users-table-wrap::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
}
.users-table-wrap::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
@media (max-width: 860px) {
  .users-hero .dash-sub { display: none; }
  .users-toolbar { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .users-table-wrap,
  .table-wrap.users-table-wrap {
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    height: auto !important;
    flex: none !important;
  }
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.users-table { font-size: 0.82rem; }
.users-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #1d4ed8 0%, #2563eb 100%);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  padding: 0.55rem 0.7rem;
}
.users-table td {
  padding: 0.55rem 0.7rem;
  vertical-align: middle;
  border-bottom: 1px solid #dbe3ef;
}
.users-table tbody tr.user-row {
  transition: background 140ms ease;
}
.users-table tbody tr.user-row:hover td {
  background: #f8fbff;
}
.users-table tbody tr.user-row:last-child td {
  border-bottom: 1px solid #dbe3ef;
}
.td-empty {
  text-align: center;
  color: var(--pf-text-muted);
  padding: 2rem 1rem !important;
  font-weight: 600;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.user-avatar {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--pf-brand-dark);
  background: linear-gradient(145deg, #dbeafe, #eff6ff);
  border: 1px solid rgba(37, 99, 235, 0.2);
}
.user-cell-text { min-width: 0; }
.user-cell-name {
  font-weight: 700;
  color: var(--pf-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.user-cell-email {
  font-size: 0.72rem;
  color: var(--pf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.time-pill {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 7px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--pf-text-secondary);
}
.time-pill.time-wipe {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fdba74;
  white-space: nowrap;
}
.time-pill.time-wipe .wipe-label {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #c2410c;
  margin-right: 0.15rem;
}
.time-pill.time-empty {
  color: var(--pf-text-muted);
  font-weight: 600;
}
.td-money { white-space: nowrap; }
.money-pill {
  display: inline-block;
  padding: 0.2rem 0.48rem;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.money-balance {
  color: #0f766e;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
}
.money-spend {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #93c5fd;
}
.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}
.profile-chips .badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.action-row {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.action-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.td-actions {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}
.users-pager {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0.05rem 0.1rem;
  font-size: 0.78rem;
}
.badge.badge-paid {
  color: #15803d;
  background: #ecfdf5;
  border-color: #86efac;
}
.badge.badge-unpaid {
  color: #64748b;
  background: #f8fafc;
  border-color: #e2e8f0;
}
.badge.badge-online {
  color: #047857;
  background: #d1fae5;
  border-color: #34d399;
}
.online-dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.2rem;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  vertical-align: middle;
}
.badge.status-expired {
  color: #b45309;
  background: #fffbeb;
  border-color: #fcd34d;
}
.badge.status-never_paid {
  color: #475569;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

th, td {
  padding: 0.7rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}
th {
  background: var(--pf-brand);
  color: var(--pf-text-inverse);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tr:hover td { background: var(--pf-brand-pale); }
tr.clickable { cursor: pointer; }

.badge {
  display: inline-block;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid var(--pf-border);
  background: var(--pf-surface-muted);
  color: var(--pf-text-secondary);
  white-space: nowrap;
}
.badge.active {
  color: var(--pf-ok);
  background: var(--pf-ok-bg);
  border-color: #86efac;
}
.badge.blocked {
  color: var(--pf-danger);
  background: var(--pf-danger-bg);
  border-color: var(--pf-danger-border);
}
.badge.badge-profiles {
  color: #0c4a6e;
  background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
  border-color: #38bdf8;
  box-shadow: 0 1px 0 rgba(14, 165, 233, 0.15);
}
.profile-chips .badge:not(.badge-profiles):not(.badge-deleted) {
  color: #334155;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  border-color: #cbd5e1;
}
.badge.badge-deleted {
  color: #4c1d95;
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
  border-color: #c4b5fd;
}
.badge.badge-real {
  color: #14532d;
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
  border-color: #4ade80;
}
.umeta.umeta-real {
  color: #14532d;
  background: #dcfce7;
  border-color: #86efac;
  font-weight: 700;
}
.td-real {
  white-space: nowrap;
  vertical-align: middle;
}
.rb-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.rb-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.rb-track {
  width: 2.2rem;
  height: 1.2rem;
  border-radius: 999px;
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
.rb-track::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 2px;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  transition: transform 0.15s ease;
}
.rb-toggle.is-on .rb-track,
.rb-toggle:has(input:checked) .rb-track {
  background: #22c55e;
  border-color: #16a34a;
}
.rb-toggle.is-on .rb-track::after,
.rb-toggle:has(input:checked) .rb-track::after {
  transform: translateX(0.95rem);
}
.rb-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #64748b;
  min-width: 1.6rem;
}
.rb-toggle.is-on .rb-label,
.rb-toggle:has(input:checked) .rb-label {
  color: #15803d;
}
.user-profile-badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.18rem;
  margin: 0 0 0 0.15rem;
  flex: 0 0 auto !important;
  min-width: max-content !important;
  position: relative;
  z-index: 1;
}
.user-profile-badges .badge {
  padding: 0.1rem 0.32rem;
  font-size: 0.6rem;
  flex: 0 0 auto;
  position: relative;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  color: var(--pf-text-muted);
  font-size: 0.88rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(170px, 220px) 1fr;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100vh - 150px);
  max-height: calc(100vh - 150px);
  overflow: hidden;
}
.pane {
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 9px;
  background: var(--pf-surface-card);
  padding: 0.35rem 0.4rem;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pane-title {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--pf-brand);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex: 0 0 auto;
  margin-bottom: 0.35rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #eef2f7;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 0 0 auto;
}
.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.28rem 0.55rem;
}
.fact {
  min-width: 0;
}
.fact span {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--pf-text-muted);
  margin-bottom: 0.05rem;
}
.fact strong {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--pf-text);
  line-height: 1.25;
  word-break: break-word;
}
.fact-wide { grid-column: 1 / -1; }
.fact-wide strong.mono {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--pf-text-secondary);
}
.detail-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem !important;
}
.profile-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.3rem;
  flex: 0 0 auto;
}
.ptab {
  flex: 1 1 auto;
  border: 1px solid rgba(37, 99, 235, 0.2);
  background: #fff;
  color: var(--pf-text-secondary);
  border-radius: 7px;
  padding: 0.28rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.ptab:hover { border-color: rgba(37, 99, 235, 0.4); }
.ptab.active {
  background: var(--pf-brand-pale);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--pf-brand-dark);
}
.profile-tools {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.3rem;
  flex: 0 0 auto;
}
.profile-tools input,
.profile-tools select {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 7px;
  padding: 0.28rem 0.4rem;
  font-size: 0.74rem;
  background: #fff;
  color: var(--pf-text);
  height: 1.9rem;
}
.profile-tools select { flex: 0 0 38%; }
.profile-select-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  margin-bottom: 0.3rem;
  flex: 0 0 auto;
  font-size: 0.72rem;
}
.profile-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--pf-text-secondary);
  cursor: pointer;
  margin: 0;
}
.profile-select-all input,
.profile-check input {
  width: auto;
  margin: 0;
  accent-color: var(--pf-brand);
  cursor: pointer;
}
.profile-check {
  display: flex;
  align-items: flex-start;
  padding-top: 0.15rem;
  margin: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
.profile-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}
.profile-item-body {
  min-width: 0;
  flex: 1 1 auto;
}
.pane-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: scroll; /* always reserve/show scrollbar track */
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #64748b #e2e8f0;
}
#profiles-scroll {
  max-height: none;
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll !important;
}
.mobile-profile-bar {
  display: none;
}
@media (max-width: 900px) {
  .main.main-user {
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    width: calc(100% - 0.7rem);
  }
  .user-page {
    height: auto !important;
    overflow: visible !important;
    flex: none !important;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
  }
  .user-head-top {
    gap: 0.3rem;
    padding-bottom: 0.15rem;
  }
  .user-head-id {
    flex: 0 1 auto !important;
    max-width: 6.5rem;
    min-width: 0 !important;
  }
  .user-meta-chips,
  .user-profile-badges {
    flex: 0 0 auto !important;
    min-width: max-content !important;
  }
  .user-email { display: none; }
  .umeta-id { max-width: 4.2rem; }
  #back-users {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    flex: 0 0 auto !important;
    min-width: max-content !important;
  }
  .mobile-profile-bar {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 0 0 auto;
    padding: 0.45rem 0.5rem;
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 10px;
    background: var(--pf-surface-card);
  }
  .mobile-profile-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--pf-text-muted);
    margin: 0;
  }
  .mobile-profile-bar #profile-pick {
    width: 100%;
    min-height: 2.4rem;
    border: 1px solid #dbe3f0;
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--pf-brand);
    background: #fff;
  }
  .mobile-detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .mobile-detail-actions .btn {
    width: 100%;
    min-width: 0;
  }
  .mobile-detail-actions .btn-hard-delete {
    grid-column: 1 / -1;
  }
  .detail-grid {
    grid-template-columns: 1fr;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    gap: 0.45rem;
  }
  .pane {
    height: auto;
    max-height: none;
  }
  .pane-list {
    display: none !important;
  }
  .pane-detail {
    min-height: 10rem;
  }
  .pane-detail .detail-top {
    display: none;
  }
  .pane-detail .pane-scroll {
    max-height: none;
    overflow: visible;
  }
  /* History: hard-height scroll box (flex nesting fails with document scroll on mobile) */
  .pane-detail-history {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    display: block !important;
  }
  .pane-detail-history .pane-scroll,
  .pane-detail-history .pane-scroll-history {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .pane-detail-history .history-box-fill {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: hidden !important;
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 10px;
    background: #fff;
  }
  .pane-detail-history .hist-list {
    display: block !important;
    flex: none !important;
    height: min(52vh, 380px) !important;
    max-height: min(52vh, 380px) !important;
    overflow-x: hidden !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: #64748b #e2e8f0;
    scrollbar-gutter: stable;
  }
  .pane-detail-history .hist-list::-webkit-scrollbar { width: 8px; }
  .pane-detail-history .hist-list::-webkit-scrollbar-thumb {
    background: #64748b;
    border-radius: 8px;
  }
  .pane-detail-history .hist-list::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 8px;
  }
  .pane-detail-history .hist-head {
    font-size: 0.7rem;
    padding: 0.4rem 0.55rem;
  }
  .pane-detail-history .hist-day {
    font-size: 0.66rem;
    padding: 0.4rem 0.55rem 0.15rem;
  }
  .pane-detail-history .hist-item {
    grid-template-columns: 14px 3rem 14px minmax(0, 1fr) 20px;
    gap: 0.2rem 0.3rem;
    padding: 0.22rem 0.4rem;
    min-height: 0;
    margin: 0 0.15rem;
  }
  .pane-detail-history .hist-check input {
    width: 12px;
    height: 12px;
  }
  .pane-detail-history .hist-clock {
    font-size: 0.58rem;
  }
  .pane-detail-history .hist-favicon,
  .pane-detail-history .hist-favicon-fallback {
    width: 14px;
    height: 14px;
  }
  .pane-detail-history .hist-main {
    flex-wrap: nowrap;
    flex-direction: column;
    gap: 0;
    min-width: 0;
  }
  .pane-detail-history .hist-title {
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
  }
  .pane-detail-history .hist-host {
    font-size: 0.58rem;
    max-width: 100%;
  }
  .pane-detail-history .hist-more {
    width: 20px;
    height: 20px;
    font-size: 0.85rem;
    opacity: 0.55;
  }
  .fact-grid {
    grid-template-columns: 1fr 1fr;
  }
  .user-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .user-actions .btn {
    width: 100%;
    min-width: 0;
  }
}
.pane-scroll::-webkit-scrollbar { width: 10px; }
.pane-scroll::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
}
.pane-scroll::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 8px; }
.pane h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: var(--pf-brand);
}
.profile-item {
  padding: 0.35rem 0.4rem !important;
  margin-bottom: 0.2rem !important;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.profile-item strong { font-size: 0.8rem; }
.profile-item .meta { font-size: 0.68rem !important; }
.profile-item:hover, .profile-item.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--pf-brand-pale);
}
.profile-item .meta,
.meta { color: var(--pf-text-muted); font-size: 0.85rem; }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--pf-text-secondary);
}
.countdown {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--pf-brand-dark);
  font-weight: 600;
}
.actions-bar {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid #e2e8f0;
}

.panel-card {
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 12px;
  padding: 1.1rem;
  background: var(--pf-surface-card);
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.panel-card h2 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 1.25rem;
  color: var(--pf-text);
}

/* Billing — compact price + wallet */
.billing-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.15rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.billing-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(37, 99, 235, 0.12), transparent 55%),
    linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}
.billing-kicker {
  margin: 0;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--pf-brand-dark);
}
.billing-title {
  margin: 0.15rem 0 0;
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--pf-text);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.billing-sub {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--pf-text-secondary);
  font-weight: 500;
  line-height: 1.35;
  max-width: 22rem;
}
.billing-stats {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.billing-stat {
  min-width: 6.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e2e8f0;
}
.billing-stat span {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--pf-text-secondary);
}
.billing-stat strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 1rem;
  font-weight: 750;
  color: var(--pf-text);
  line-height: 1.25;
}
.billing-stat strong em {
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--pf-text-secondary);
}
.billing-stat strong.mono {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--pf-brand-dark);
}
.billing-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 0.65rem;
}
.billing-card {
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  background: var(--pf-surface-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}
.billing-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}
.billing-card-head h3 {
  margin: 0;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--pf-text);
  letter-spacing: -0.01em;
}
.billing-chip {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--pf-brand-dark);
  background: var(--pf-brand-pale);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  padding: 0.14rem 0.5rem;
}
.billing-label {
  font-size: 0.78rem !important;
  font-weight: 600;
  color: var(--pf-text-secondary);
  margin: 0 !important;
}
.billing-price-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.billing-price-row input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 !important;
}
.billing-price-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.billing-addr {
  margin: 0 !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem !important;
  letter-spacing: 0;
  color: var(--pf-text);
}
.billing-price-row input {
  font-size: 0.92rem !important;
  font-weight: 600;
}
@media (max-width: 720px) {
  .billing-grid { grid-template-columns: 1fr; }
  .billing-hero { align-items: stretch; }
  .billing-stats { width: 100%; }
  .billing-stat { flex: 1 1 auto; }
  .billing-title { font-size: 1.08rem; }
  .billing-sub { font-size: 0.78rem; max-width: none; }
  .billing-price-row {
    flex-wrap: wrap;
  }
  .billing-price-row .btn {
    width: 100%;
  }
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}
.modal {
  width: min(520px, 100%);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 14px;
  background: var(--pf-surface-card);
  padding: 1.2rem;
  max-height: min(90vh, 720px);
  overflow: auto;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  color: var(--pf-text);
}
.modal h3 { margin: 0 0 0.5rem; color: var(--pf-text); }
.modal p { color: var(--pf-text-muted); font-size: 0.9rem; }
.modal label input[type="checkbox"] {
  width: auto;
  margin: 0.15rem 0 0;
  accent-color: var(--pf-brand);
}

.toast {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--pf-text);
  color: var(--pf-text-inverse);
  border: 1px solid var(--pf-brand-dark);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  max-width: min(520px, calc(100% - 2rem));
  font-size: 0.9rem;
  pointer-events: none;
}
.toast.show {
  display: block;
  pointer-events: auto;
}

.history-box {
  max-height: min(480px, 55vh);
  overflow: auto;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 12px;
  padding: 0;
  background: #fff;
  margin-top: 0.65rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.pane-scroll-history {
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  padding: 0;
}
.history-box-fill {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.history-box-fill .hist-head {
  flex: 0 0 auto;
}
.history-box-fill .hist-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #64748b #e2e8f0;
}
.history-box-fill pre {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  margin: 0;
}
.hist-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--pf-brand-dark);
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  border-bottom: 1px solid #eef2f7;
}
.hist-list {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0 0.55rem;
}
.hist-day {
  padding: 0.9rem 1rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
}
.hist-item {
  display: grid;
  grid-template-columns: 20px 4.1rem 20px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 0.4rem 0.55rem;
  padding: 0.42rem 0.85rem 0.42rem 1rem;
  min-height: 40px;
  border-radius: 8px;
  margin: 0 0.4rem;
}
.hist-item:hover {
  background: #f1f5f9;
}
.hist-check {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: default;
}
.hist-check input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--pf-brand);
}
.hist-clock {
  text-align: right;
  font-size: 0.78rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 500;
}
.hist-favicon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: contain;
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}
.hist-favicon-fallback {
  display: inline-block;
  background: #e2e8f0;
  border-radius: 4px;
}
.hist-main {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1rem 0.5rem;
}
.hist-title {
  font-weight: 650;
  font-size: 0.9rem;
  color: #0f172a;
  line-height: 1.3;
  text-decoration: none;
  word-break: break-word;
}
.hist-title:hover {
  color: var(--pf-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hist-host {
  font-size: 0.78rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.hist-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease;
}
.hist-item:hover .hist-more { opacity: 1; }
.hist-more:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.login-wrap { overflow: auto; height: 100%; }
