/* SignReveng / revenger.ios — тёмная тема как на основном сайте */
:root {
  --black: #000000;
  --surface: #0a0a0a;
  --elevated: #141414;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #a3a3a3;
  --muted2: #737373;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --radius-pill: 9999px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --accent: #6aa5f4;
  --accent-dim: rgba(106, 165, 244, 0.15);
  --ok: #34d399;
  --wait: #fbbf24;
  --no: #f87171;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--black);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.bg-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg-glow {
  position: absolute;
  width: min(900px, 120vw);
  height: min(480px, 65vh);
  top: -6%;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 70% 60% at 50% 40%, rgba(255, 255, 255, 0.065), transparent 72%);
  animation: glowShift 14s ease-in-out infinite;
}
.bg-glow--foot {
  top: auto;
  bottom: -18%;
  opacity: 0.6;
  animation-delay: -7s;
}
.dot-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 260px;
  height: 180px;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.11) 1px, transparent 1px);
  background-size: 14px 14px;
  mask-image: linear-gradient(135deg, black 18%, transparent 65%);
  opacity: 0.32;
}
.noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes glowShift {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.85; transform: translateX(-50%) scale(1.03); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#app {
  position: relative;
  z-index: 1;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 14px clamp(12px, 2.2vw, 20px) max(20px, env(safe-area-inset-bottom, 0px));
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  min-height: calc(100dvh - 28px);
}

.content-area {
  min-width: 0;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px clamp(14px, 2.3vw, 22px);
  background: var(--elevated);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand { display: flex; align-items: center; min-width: 0; }

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
}

.brand-title {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: -0.02em;
  color: var(--muted);
  line-height: 1.2;
}

.site-logo {
  height: 28px;
  width: auto;
  max-width: min(96px, 34vw);
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  touch-action: manipulation;
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), opacity 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}

.btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  width: 100%;
  background: #fff;
  color: #0a0a0a;
  box-shadow: 0 8px 28px rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 40px rgba(255, 255, 255, 0.14);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e5e5;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-ghost {
  background: transparent;
  color: var(--muted2);
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
}

.btn-ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.btn-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e5e5e5;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.12s;
}

.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
}

.btn-icon.copied {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.45);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeIn 0.35s ease;
}

.login-overlay.hidden { display: none; }

.login-card {
  width: 100%;
  max-width: 420px;
  padding: clamp(28px, 6vw, 40px) clamp(20px, 5vw, 32px);
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  animation: popIn 0.5s var(--ease-out) backwards;
}

.login-card h2 {
  margin: 0 0 16px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

input[type="password"],
input[type="text"],
input[type="search"] {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.err {
  color: var(--no);
  font-size: 0.86rem;
  min-height: 1.25em;
  margin-top: 12px;
  text-align: center;
}

.content-main {
  padding: 14px clamp(14px, 2.3vw, 22px) 24px;
}

#dashboard.view-users .page-head,
#dashboard.view-users .metrics-wrap,
#dashboard.view-users #section-purchases,
#dashboard.view-users #section-products {
  display: none;
}

#dashboard.view-purchases .page-head,
#dashboard.view-purchases .metrics-wrap,
#dashboard.view-purchases #section-users,
#dashboard.view-purchases #section-products {
  display: none;
}

#dashboard.view-products .page-head,
#dashboard.view-products .metrics-wrap,
#dashboard.view-products #section-users,
#dashboard.view-products #section-purchases {
  display: none;
}

#dashboard.view-usage .dashboard-stack {
  display: none;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.page-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.metrics-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 0 22px;
}

.section-title {
  margin: 2px 0 4px;
  color: var(--muted2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.metrics-row.metrics-row-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .metrics-row { grid-template-columns: 1fr; }
}

.metric {
  position: relative;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  animation: slideUp 0.55s var(--ease-out) backwards;
  transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.metric:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e5e5e5;
}

.metric-icon svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metric .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted2);
  line-height: 1.35;
}

.metric .value {
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 3.2vw, 1.4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.metric .hint {
  margin-top: 5px;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.dashboard-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stack {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0;
  overflow: hidden;
  animation: slideUp 0.55s var(--ease-out) backwards;
  animation-delay: 0.06s;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: clamp(16px, 3vw, 20px);
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.panel-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted2);
  margin-top: 4px;
}

.panel-body {
  padding: 0 20px 20px;
}

.search-wrap {
  width: 100%;
  max-width: 260px;
}

.table-wrap {
  margin-top: 4px;
  max-height: min(480px, 58dvh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
}

#section-users .table-wrap {
  max-height: min(560px, 62dvh);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
  background: rgba(20, 20, 20, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
  color: #e5e5e5;
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.06);
}

.mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

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

.username-cell {
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #f5f5f5;
}

.username-copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.username-copy-row .username-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.buyer-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.pcard .meta .buyer-line .btn-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.tabs-wrap {
  padding: 16px 20px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tab {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.tab:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.tab.active {
  color: #0a0a0a;
  background: #fff;
  border-color: #fff;
}

.tab .badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.2);
  vertical-align: middle;
}

.tab.active .badge {
  background: rgba(0, 0, 0, 0.08);
}

.purchase-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(560px, 62dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px clamp(14px, 3vw, 20px) 20px;
}

.pcard {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: cardIn 0.4s ease backwards;
  transition: border-color 0.2s;
}

.pcard:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.pcard .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.pcard .title {
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  line-height: 1.35;
  color: var(--text);
}

.pcard .amt {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: #d4d4d4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pcard .meta {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr));
  gap: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.pcard .meta span strong {
  font-family: inherit;
  color: #d4d4d4;
  font-weight: 600;
  margin-right: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-pill.ok {
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
}

.status-pill.wait {
  background: rgba(251, 191, 36, 0.12);
  color: var(--wait);
}

.status-pill.no {
  background: rgba(248, 113, 113, 0.12);
  color: var(--no);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  opacity: 0.85;
}

.empty-state p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.load-screen {
  text-align: center;
  padding: 72px 20px;
  color: var(--muted);
}

.load-screen.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%) translateY(80px);
  z-index: 200;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  background: rgba(28, 28, 30, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: transform 0.35s var(--ease-out), opacity 0.25s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#section-users .copy-id {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border-radius: 9px;
}

@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden;
  }

  #app,
  .app-shell,
  .content-area,
  .content-main,
  .dashboard-stack {
    max-width: 100%;
    overflow-x: hidden;
  }

  #app {
    padding: 6px 8px max(12px, env(safe-area-inset-bottom, 0px));
  }

  .app-shell {
    gap: 10px;
    min-height: calc(100dvh - 20px);
  }

  .content-area {
    border-radius: 16px;
  }

  .topbar {
    padding: 8px 10px;
    gap: 8px;
  }

  .brand-cluster {
    padding: 4px 8px 4px 6px;
    gap: 8px;
    border-radius: 10px;
  }

  .brand-title {
    font-size: 0.78rem;
  }

  .site-logo {
    height: 24px;
    max-width: min(80px, 40vw);
    border-radius: 6px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions .btn {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    font-size: 10px;
  }

  .content-main {
    padding: 8px 8px 14px;
  }

  .metrics-wrap {
    gap: 10px;
    margin: 0 0 16px;
  }

  .section-title {
    font-size: 10px;
    margin: 0 0 2px;
  }

  .metrics-row,
  .metrics-row.metrics-row-3 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric {
    padding: 12px 14px;
    border-radius: 14px;
  }

  .metric-top {
    margin-bottom: 8px;
    gap: 8px;
  }

  .metric-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .metric-icon svg {
    width: 15px;
    height: 15px;
  }

  .metric .label {
    font-size: 9px;
  }

  .metric .value {
    font-size: clamp(1rem, 5.5vw, 1.28rem);
  }

  .metric .hint {
    margin-top: 4px;
    font-size: 0.68rem;
  }

  .dashboard-stack {
    gap: 12px;
  }

  .panel {
    border-radius: 16px;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px 10px;
    gap: 10px;
  }

  .panel-head h2 {
    font-size: 0.92rem;
  }

  .panel-meta {
    font-size: 0.72rem;
    margin-top: 3px;
  }

  .panel-head .search-wrap {
    max-width: none;
  }

  .panel-body {
    padding: 0 14px 14px;
  }

  .table-wrap {
    margin-top: 2px;
    border-radius: 12px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }

  .table-wrap,
  #section-users .table-wrap {
    max-height: min(360px, 46dvh);
  }

  .panel .table-wrap table {
    table-layout: fixed;
    width: 100%;
  }

  .panel .table-wrap th,
  .panel .table-wrap td {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
  }

  .panel .table-wrap td.mono {
    word-break: break-all;
  }

  #section-users .table-wrap th:nth-child(1),
  #section-users .table-wrap td:nth-child(1) {
    width: 22%;
  }

  #section-users .table-wrap th:nth-child(2),
  #section-users .table-wrap td:nth-child(2) {
    width: 28%;
  }

  #section-users .table-wrap th:nth-child(3),
  #section-users .table-wrap td:nth-child(3) {
    width: 28%;
  }

  #section-users .table-wrap th:nth-child(4),
  #section-users .table-wrap td:nth-child(4) {
    width: 22%;
  }

  #section-products .table-wrap th:nth-child(1),
  #section-products .table-wrap td:nth-child(1) {
    width: 36%;
  }

  #section-products .table-wrap th:nth-child(2),
  #section-products .table-wrap td:nth-child(2) {
    width: 18%;
  }

  #section-products .table-wrap th:nth-child(3),
  #section-products .table-wrap td:nth-child(3) {
    width: 22%;
  }

  #section-products .table-wrap th:nth-child(4),
  #section-products .table-wrap td:nth-child(4) {
    width: 24%;
  }

  .cell-id {
    flex-wrap: wrap;
    min-width: 0;
  }

  .purchase-list {
    max-height: min(360px, 46dvh);
    padding: 12px 12px 14px;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  #section-purchases .pcard {
    min-width: 0;
    max-width: 100%;
  }

  #section-purchases .pcard .title {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #section-purchases .pcard .meta {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.78rem;
  }

  thead th {
    padding: 8px 10px;
    font-size: 9px;
  }

  td {
    padding: 9px 10px;
    font-size: 0.76rem;
  }

  .tabs-wrap {
    padding: 12px 14px 0;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    padding: 6px;
    gap: 6px;
    border-radius: 12px;
    max-width: 100%;
  }

  .tabs .tab {
    flex: 0 0 auto;
    min-width: max(46%, 120px);
    min-height: 40px;
    padding: 8px 10px;
    font-size: 10px;
    border-radius: 10px;
  }

  .tab .badge {
    margin-left: 4px;
    padding: 2px 6px;
    font-size: 0.6rem;
  }

  .pcard {
    padding: 12px 14px;
    border-radius: 12px;
  }

  .pcard .top {
    gap: 10px;
  }

  .pcard .title {
    font-size: 0.86rem;
  }

  .pcard .amt {
    font-size: 0.88rem;
  }

  .pcard .meta {
    margin-top: 10px;
    gap: 6px 8px;
    font-size: 0.72rem;
  }

  .status-pill {
    margin-top: 6px;
    padding: 3px 8px;
    font-size: 9px;
  }

  .empty-state {
    padding: 32px 16px;
  }

  .empty-state .empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    border-radius: 12px;
    font-size: 1.35rem;
  }

  .empty-state p {
    font-size: 0.84rem;
  }

  .load-screen {
    padding: 48px 16px;
  }

  .spinner {
    width: 34px;
    height: 34px;
    margin-bottom: 14px;
  }

  #toast {
    padding: 10px 16px;
    font-size: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  #section-users .copy-id {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 8px;
  }

  .btn-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 10px;
    font-size: 0.88rem;
  }

  .login-overlay {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .login-card {
    padding: 22px 18px;
    border-radius: 18px;
  }

  .field {
    gap: 6px;
    margin-bottom: 14px;
  }

  .field label {
    font-size: 10px;
  }

  input[type="password"],
  input[type="text"],
  input[type="search"] {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 16px;
  }

  .err {
    font-size: 0.8rem;
    margin-top: 10px;
  }
}

@media (max-width: 480px) {
  .content-main {
    padding: 6px 6px 12px;
  }

  .metric .value {
    font-size: clamp(0.95rem, 6vw, 1.15rem);
  }

  .panel-head {
    padding: 10px 12px 8px;
  }

  .panel-body {
    padding: 0 12px 12px;
  }

  .table-wrap,
  #section-users .table-wrap {
    max-height: min(300px, 42dvh);
  }

  .purchase-list {
    max-height: min(300px, 42dvh);
    padding: 10px 10px 12px;
  }

  th.col-name,
  td.col-name {
    min-width: 0;
  }
}

.charts-panel {
  margin-bottom: 20px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 20px 20px;
}

.chart-card {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 260px;
}

.chart-card canvas {
  width: 100% !important;
  height: 220px !important;
}

.chart-title {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}
