/* TVITPAY — dark theme (mobile + desktop) */

:root {
  color-scheme: dark;
  --bg-0: #050506;
  --bg-1: #0c0c0e;
  --bg-2: #141416;
  --bg-3: #1a1a1d;
  --border: #27272a;
  --border-soft: #3f3f46;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #e4e4e7;
  --accent-strong: #ffffff;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --warn: #eab308;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  --sidebar-w: 260px;
  --bottom-nav-h: 64px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255, 255, 255, 0.03), transparent),
    var(--bg-0);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* ── Auth layout ── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #27272a, #09090b);
  border: 1px solid var(--border-soft);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.field input,
.field select {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-0);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--border-soft);
}

.form-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.trader-row {
  cursor: pointer;
}

.trader-row.selected td {
  background: rgba(99, 102, 241, 0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-3);
  color: var(--text);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.alert-info {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
}

/* ── App shell ── */
.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  display: none;
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-1);
  padding: 24px 16px;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 32px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border);
}

.nav-icon {
  width: 20px;
  text-align: center;
  opacity: 0.7;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 16px calc(var(--bottom-nav-h) + 24px);
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
  }

  .main {
    padding: 32px 40px 40px;
  }

  .bottom-nav {
    display: none !important;
  }

  .mobile-header {
    display: none !important;
  }
}

.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0 0 20px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-nav-h);
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  z-index: 100;
}

.bottom-nav .nav-item {
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  font-size: 0.7rem;
  width: auto;
  flex: 1;
  max-width: 88px;
}

.bottom-nav .nav-icon {
  font-size: 1.1rem;
}

/* ── Cards & stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 8px;
}

.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-weight: 600;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: lowercase;
  border: 1px solid var(--border);
  background: var(--bg-3);
}

.badge-new { color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
.badge-paid { color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.badge-expired,
.badge-canceled { color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.badge-dispute { color: #fcd34d; border-color: rgba(234, 179, 8, 0.3); }
.badge-transfer_waiting { color: #c4b5fd; }
.badge-transfer_confirmed { color: #67e8f9; }
.badge-pending_acceptance { color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); }
.badge-completed { color: #86efac; }

.merchant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.merchant-delete {
  color: #fca5a5;
}

.merchant-delete:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
}

.row-muted td {
  opacity: 0.72;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  margin-top: auto;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-0);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.user-email {
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.user-role {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
}

.session-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 16px 18px;
}

.session-status {
  flex: 1;
  min-width: 200px;
}

.loader {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.mono {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8rem;
}
