:root {
  --brand-red: #fe0e0f;
  --brand-red-dark: #d70d0d;
  --text: #111111;
  --muted: #6f6f76;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --surface-alt: #f7f7f9;
  --surface-soft: #fbfbfd;
  --line: rgba(236, 236, 241, 0.92);
  --shadow: 0 24px 60px rgba(17, 17, 17, 0.08);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --success: #166534;
  --success-bg: rgba(22, 163, 74, 0.1);
  --warning: #9a6700;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #8f1112;
  --danger-bg: rgba(185, 28, 28, 0.1);
  --sidebar-grad: linear-gradient(160deg, rgba(255,255,255,0.97), rgba(251,251,253,0.95));
  color-scheme: light;
}

:root[data-theme='dark'] {
  --text: #f5f5f7;
  --muted: #9f9fa8;
  --surface: rgba(18, 18, 21, 0.94);
  --surface-strong: #17171b;
  --surface-alt: #202026;
  --surface-soft: #131317;
  --line: rgba(255, 255, 255, 0.08);
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
  --success: #67d892;
  --success-bg: rgba(34, 197, 94, 0.15);
  --warning: #ffcf66;
  --warning-bg: rgba(245, 158, 11, 0.18);
  --danger: #ff8686;
  --danger-bg: rgba(239, 68, 68, 0.18);
  --sidebar-grad: linear-gradient(160deg, rgba(15,15,18,0.97), rgba(22,22,27,0.95));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(254,14,15,0.12), transparent 28%),
    radial-gradient(circle at bottom left, rgba(254,14,15,0.08), transparent 24%),
    linear-gradient(180deg, var(--surface-soft) 0%, color-mix(in srgb, var(--surface-soft) 72%, #ffffff 28%) 46%, var(--surface-soft) 100%);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }

.admin-page {
  min-height: 100vh;
  padding: 22px;
  position: relative;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-view {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 20px;
  min-height: calc(100vh - 44px);
}

.auth-brand-card, .auth-form-card { padding: 30px; }
.auth-brand-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(140deg, rgba(17,17,17,0.97), rgba(33,33,36,0.95));
  color: #fff;
  position: relative;
  overflow: hidden;
}

.auth-brand-card::after {
  content: '';
  position: absolute;
  inset: auto -80px -80px auto;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(254,14,15,0.32), transparent 70%);
}

.auth-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  margin-bottom: 18px;
}

.auth-brand h1, .topbar h1 {
  margin: 14px 0 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.auth-brand p, .form-header p, .topbar p, .table-subtitle, .metric-card p, .detail-header p, .timeline-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-copy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.auth-copy-grid article {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}

.auth-copy-grid h2, .form-header h2, .section-card h2, .detail-header h2 {
  margin: 0 0 8px;
  font-size: 1.12rem;
}

.auth-form-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-red);
  background: color-mix(in srgb, var(--brand-red) 8%, transparent);
  border: 1px solid rgba(254,14,15,0.18);
}

.pill--soft { background: color-mix(in srgb, var(--brand-red) 6%, transparent); }
.pill--danger { color: var(--danger); background: var(--danger-bg); border-color: rgba(185, 28, 28, 0.22); }

.notice {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(254,14,15,0.18);
  background: rgba(254,14,15,0.06);
  color: var(--danger);
  font-weight: 600;
  line-height: 1.5;
}

.auth-form { display: grid; gap: 14px; }
.auth-decoy-fields {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.auth-decoy-fields input {
  width: 1px;
  height: 1px;
  border: 0;
  padding: 0;
}
.field { display: grid; gap: 8px; }
.field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.field input:not([type="checkbox"]), .toolbar input, .toolbar select, .toolbar textarea, .detail-suspension select, .detail-suspension textarea {
  width: 100%;
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  padding: 0 16px;
  outline: none;
}

textarea.detail-notes, .detail-suspension textarea {
  min-height: 112px;
  padding: 14px 16px;
  resize: vertical;
}

.field input:not([type="checkbox"]):focus,
.toolbar input:focus,
.toolbar select:focus,
.toolbar textarea:focus,
.detail-suspension select:focus,
.detail-suspension textarea:focus {
  border-color: rgba(254,14,15,0.34);
  box-shadow: 0 0 0 4px rgba(254,14,15,0.08);
}

.button {
  min-height: 50px;
  border-radius: 18px;
  border: 0;
  padding: 0 18px;
  font-weight: 800;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.button:active { transform: translateY(1px); }
.button:disabled { opacity: 0.6; cursor: wait; }
.button--primary { background: var(--brand-red); color: #fff; }
.button--primary:hover { background: var(--brand-red-dark); }
.button--secondary {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line);
}
.button--secondary:hover { border-color: rgba(254,14,15,0.18); }
.button--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.button--small { min-height: 38px; border-radius: 14px; padding: 0 12px; font-size: 13px; }
.button--danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(185,28,28,0.18); }

.app-view {
  width: min(1500px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 44px);
  align-items: start;
}

.sidebar {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 22px;
  background: var(--sidebar-grad);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sidebar-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--brand-red) 8%, transparent);
  border: 1px solid rgba(254,14,15,0.16);
}
.sidebar-brand strong { display: block; font-size: 18px; }
.sidebar-brand span, .sidebar-footer small, .meta-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.sidebar-nav { display: grid; gap: 8px; }
.nav-item {
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 14px;
  font-weight: 700;
}
.nav-item:hover { background: rgba(254,14,15,0.06); border-color: rgba(254,14,15,0.1); }
.nav-item.active {
  background: linear-gradient(180deg, rgba(254,14,15,0.14), rgba(254,14,15,0.09));
  border-color: rgba(254,14,15,0.18);
  color: var(--brand-red);
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.main-shell {
  display: grid;
  gap: 18px;
  align-content: start;
}
.topbar {
  padding: 24px 26px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}
.topbar h1 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.notification-button {
  position: relative;
  min-width: 44px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  justify-content: center;
}
.notification-icon {
  width: 17px;
  height: 17px;
}
.notification-dot {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand-red);
  border: 2px solid var(--surface);
  display: block;
}
.member-picker {
  display: grid;
  gap: 10px;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-alt);
}
.member-picker__item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
}
.member-picker__item:hover {
  border-color: rgba(254,14,15,0.14);
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
}
.member-picker__item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 2px 0 0;
  accent-color: var(--brand-red);
}
.member-picker__item span {
  display: grid;
  gap: 3px;
}
.member-picker__item strong {
  font-size: 14px;
  line-height: 1.2;
}
.member-picker__item small {
  color: var(--muted);
  line-height: 1.35;
}
.content-root { display: grid; gap: 18px; align-content: start; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric-card, .section-card, .timeline-card, .stack-card { padding: 20px; }
.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.9rem, 2.8vw, 2.5rem);
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}
.dashboard-stack { display: grid; gap: 18px; }
.dashboard-feed { display: grid; gap: 12px; }
.feed-item, .timeline-item, .address-card {
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
}
.list-table {
  border-radius: 20px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface-strong);
}
.list-head {
  background: color-mix(in srgb, var(--surface-alt) 82%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.list-row {
  display: grid;
  align-items: start;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child {
  border-bottom: 0;
}
.list-row--users {
  grid-template-columns: minmax(210px, 1.25fr) minmax(220px, 1.15fr) minmax(170px, 0.95fr) minmax(170px, 0.95fr) minmax(100px, 0.65fr);
}
.list-row--team {
  grid-template-columns: minmax(220px, 1.2fr) minmax(200px, 1fr) minmax(150px, 0.8fr) minmax(220px, 1fr) minmax(120px, 0.7fr);
}
.list-row--purchases {
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 0.95fr) minmax(135px, 0.75fr) minmax(105px, 0.7fr) minmax(180px, 0.95fr) minmax(145px, 0.8fr);
}
.list-cell {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: center;
}
.list-cell strong,
.list-cell .link-button {
  font-size: 15px;
}
.list-cell small {
  color: var(--muted);
  line-height: 1.45;
}
.list-cell--actions {
  justify-items: start;
}
.stacked-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.record-money {
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
}
.presence-stack {
  display: grid;
  gap: 4px;
}
.presence-stack small {
  color: var(--muted);
}
.feed-item-header, .row-header, .detail-metric-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.feed-item strong, .detail-summary strong { font-size: 15px; }
.feed-item small, .timeline-copy small, .soft-copy { color: var(--muted); }
.timeline-copy p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}
.meta-separator {
  display: inline-block;
  margin: 0 6px;
  color: var(--muted);
}
.link-button {
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  font-weight: 800;
}
.link-button:hover { color: var(--brand-red); }
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar > * { flex: 1 1 180px; }
.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: var(--surface-strong);
}
.table th, .table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}
.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: color-mix(in srgb, var(--surface-alt) 80%, transparent);
}
.table tr:last-child td { border-bottom: 0; }
.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-actions .button--small {
  min-height: 34px;
  border-radius: 12px;
  padding: 0 10px;
}
.inline-actions.inline-actions--stack { flex-direction: column; align-items: stretch; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}
.badge--live, .badge--approved, .badge--completed, .badge--active { color: var(--success); background: var(--success-bg); border-color: rgba(22,163,74,0.18); }
.badge--pending, .badge--shipping_progress, .badge--in_progress, .badge--temporary { color: var(--warning); background: var(--warning-bg); border-color: rgba(245,158,11,0.18); }
.badge--rejected, .badge--cancelled, .badge--refunded, .badge--disabled, .badge--permanent { color: var(--danger); background: var(--danger-bg); border-color: rgba(185,28,28,0.18); }
.badge--role { color: var(--brand-red); background: color-mix(in srgb, var(--brand-red) 7%, transparent); border-color: rgba(254,14,15,0.18); }
.loading-state { padding: 40px 24px; text-align: center; color: var(--muted); }
.loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: 999px;
  border: 3px solid rgba(254,14,15,0.12);
  border-top-color: var(--brand-red);
  animation: spin 0.9s linear infinite;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}
.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.34);
  backdrop-filter: blur(6px);
}
.detail-panel {
  position: relative;
  margin: 14px;
  width: min(640px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.detail-header {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}
.detail-content {
  overflow: auto;
  padding: 20px 22px 24px;
  display: grid;
  gap: 18px;
}
.detail-summary {
  display: grid;
  gap: 14px;
}
.detail-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}
.detail-avatar {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--brand-red) 8%, transparent);
  border: 1px solid rgba(254,14,15,0.16);
  display: grid;
  place-items: center;
  color: var(--brand-red);
  font-weight: 800;
  overflow: hidden;
}
.detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.detail-metric {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 80%, transparent);
}
.detail-metric strong {
  display: block;
  font-size: 1.2rem;
  margin-top: 6px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.detail-section {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
  display: grid;
  gap: 14px;
}
.detail-section-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.detail-list {
  display: grid;
  gap: 12px;
}
.timeline-item {
  display: grid;
  gap: 8px;
}
.timeline-item--critical {
  border-color: rgba(185,28,28,0.35);
  background: color-mix(in srgb, var(--danger-bg) 86%, transparent);
}
.timeline-copy {
  display: grid;
  gap: 4px;
}
.tracking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.receipt-thumb-button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-alt) 82%, transparent);
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.receipt-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-preview-wrap {
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-alt) 70%, transparent);
}
.image-preview-full {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: block;
}
.detail-suspension {
  display: grid;
  gap: 12px;
}
.detail-suspension-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.helper-text { color: var(--muted); font-size: 12px; }
.audit-danger {
  color: var(--danger);
  font-weight: 700;
}
.empty-state {
  padding: 20px;
  border-radius: 20px;
  border: 1px dashed var(--line);
  color: var(--muted);
}

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

@media (max-width: 1280px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1120px) {
  .auth-view, .app-view { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

@media (max-width: 760px) {
  .admin-page { padding: 14px; }
  .auth-brand-card, .auth-form-card, .sidebar, .topbar, .metric-card, .section-card, .detail-panel { padding: 18px; }
  .auth-copy-grid, .metrics-grid, .detail-metrics, .detail-suspension-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .toolbar { flex-direction: column; }
  .detail-panel { margin: 0; width: 100vw; max-height: 100vh; border-radius: 0; }
  .table { min-width: 640px; }
  .list-table {
    overflow: auto;
  }
  .list-row--users {
    min-width: 1080px;
  }
  .list-row--team {
    min-width: 1100px;
  }
  .list-row--purchases {
    min-width: 1120px;
  }
}
