:root {
  --bg: #08112f;
  --bg-soft: rgba(8, 17, 47, 0.72);
  --card: rgba(255,255,255,0.94);
  --card-strong: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: rgba(148, 163, 184, 0.24);
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f3f4f6;
  color: var(--text);
}

h1, h2, h3, p { margin-top: 0; }

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
}

.dashboard-body {
  min-height: 100vh;
  position: relative;
  background:
    linear-gradient(180deg, rgba(4, 9, 31, 0.86), rgba(4, 9, 31, 0.96)),
    url('/images/spark-background.jpeg') center/cover fixed no-repeat;
}

.dashboard-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at top right, rgba(37, 99, 235, 0.18), transparent 34%);
}

.auth-card, .card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
}

.glass-panel {
  background: rgba(7, 15, 40, 0.7);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 32px;
  color: white;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar h1 {
  font-size: 32px;
  margin-bottom: 6px;
}

.topbar p,
.welcome-text {
  color: rgba(255,255,255,0.84);
  margin: 0;
}

.topbar-create {
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.dashboard-container {
  position: relative;
  z-index: 1;
}

.card {
  padding: 24px;
}

.create-panel {
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.22s ease, transform 0.22s ease, padding 0.22s ease, margin-bottom 0.22s ease;
  max-height: 1000px;
  opacity: 1;
  transform: translateY(0);
  margin-bottom: 24px;
}

.create-panel.collapsed {
  max-height: 0;
  opacity: 0;
  transform: translateY(-10px);
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border-width: 0;
}

.create-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.create-panel-header p {
  color: var(--muted);
  margin-bottom: 0;
}

.create-form-grid {
  display: grid;
  grid-template-columns: 1.3fr 1.5fr 0.8fr;
  gap: 16px;
  align-items: end;
}

.create-submit-wrap {
  display: flex;
  align-items: end;
}

.users-card {
  background: rgba(255,255,255,0.96);
}

.users-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.users-card-header p {
  color: var(--muted);
  margin-bottom: 0;
}

.users-card-header input {
  max-width: 320px;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(240px, 1fr) minmax(360px, 1.3fr);
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.9);
}

.user-main-info h3 {
  margin-bottom: 8px;
}

.user-main-info p {
  margin: 5px 0;
  color: var(--muted);
}

.user-status-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-pill,
.time-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  width: fit-content;
}

.status-active {
  background: #dcfce7;
  color: var(--green);
}

.status-blocked {
  background: #fee2e2;
  color: var(--red);
}

.status-expired {
  background: #fef3c7;
  color: var(--amber);
}

.time-pill {
  background: #eff6ff;
  color: #1d4ed8;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.mini-action-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mini-action-form input {
  width: 100px;
}

label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 14px;
  background: rgba(255,255,255,0.96);
}

textarea {
  min-height: 148px;
  resize: vertical;
}

button {
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  background: var(--primary);
  color: white;
  transition: transform .15s ease, background .18s ease, opacity .18s ease;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

button.secondary,
.ghost-btn {
  background: #111827;
}

button.secondary:hover,
.ghost-btn:hover {
  background: #000000;
}

.success-btn {
  background: var(--green);
}

.success-btn:hover {
  background: #15803d;
}

.danger-btn {
  background: var(--red);
}

.danger-btn:hover {
  background: #b91c1c;
}

.alert {
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 18px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0,0,0,0.1);
}

.alert.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.alert.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inline-row {
  display: flex;
  gap: 10px;
}

.align-end {
  align-items: stretch;
}

.wrap-mobile {
  flex-wrap: wrap;
}

.shrink-button {
  white-space: nowrap;
  flex: 0 0 auto;
}

.share-card {
  margin-top: 20px;
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.98), rgba(220, 252, 231, 0.98));
  border: 1px solid rgba(34, 197, 94, 0.22);
  border-radius: 20px;
  padding: 20px;
}

.share-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.share-card-header h3 {
  color: #166534;
  margin-bottom: 6px;
}

.share-card-header p {
  color: #166534;
  margin-bottom: 0;
}

.share-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-text {
  font-family: Arial, Helvetica, sans-serif;
  background: rgba(255,255,255,0.92);
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(148, 163, 184, 0.4);
  border-radius: 18px;
}

.error-text {
  color: var(--error-text);
  font-weight: 700;
}

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

  .user-actions {
    justify-content: flex-start;
  }

  .create-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-left,
  .topbar-right,
  .share-card-header,
  .users-card-header,
  .create-panel-header {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .share-summary-grid {
    grid-template-columns: 1fr;
  }

  .users-card-header input {
    max-width: none;
  }

  .mini-action-form {
    flex-wrap: wrap;
  }
}

/* --- Dashboard users redesign --- */
.modern-users-card {
  padding: 28px;
}

.users-overview-header {
  margin-bottom: 18px;
}

.users-overview-header h2 {
  margin-bottom: 8px;
  font-size: 2.05rem;
}

.users-overview-header p {
  color: var(--muted);
  margin-bottom: 0;
}

.users-tab-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.users-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 92px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245, 247, 255, 0.96));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.users-tab:hover {
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(239, 246, 255, 0.98));
}

.users-tab.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.98), rgba(59, 130, 246, 0.92));
  color: white;
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.26);
}

.users-tab.active .users-tab-label {
  color: rgba(255,255,255,0.9);
}

.users-tab strong {
  font-size: 1.55rem;
  line-height: 1;
}

.users-tab-label {
  font-size: 0.97rem;
  color: var(--muted);
  text-align: left;
}

.users-toolbar-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  margin-bottom: 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255,255,255,0.98));
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.search-input-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 14px;
  border-radius: 16px;
  background: white;
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.search-input-wrap input {
  border: 0;
  background: transparent;
  padding-left: 0;
  padding-right: 0;
}

.search-input-wrap input:focus {
  outline: none;
}

.search-icon {
  font-size: 1rem;
}

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

.modern-user-row {
  position: relative;
  grid-template-columns: 34px minmax(250px, 1.3fr) minmax(230px, 0.9fr) minmax(420px, 1.3fr);
  gap: 20px;
  padding: 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248, 250, 252, 0.96));
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.bulk-select-box {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.bulk-select-box.visible {
  opacity: 1;
  pointer-events: auto;
}

.bulk-select-box input {
  display: none;
}

.bulk-select-box span {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid rgba(37, 99, 235, 0.42);
  background: white;
  display: inline-block;
  position: relative;
}

.bulk-select-box input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
}

.bulk-select-box input:checked + span::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.user-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.user-title-row h3 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.user-meta-grid {
  display: grid;
  gap: 8px;
}

.user-meta-grid p {
  margin: 0;
  color: var(--muted);
  word-break: break-word;
}

.compact-status-area {
  align-self: stretch;
  justify-content: center;
}

.compact-status-area .time-pill {
  min-height: 54px;
  justify-content: flex-start;
  text-align: left;
  padding-inline: 16px;
}

.modern-actions {
  justify-content: flex-start;
}

.recharge-form {
  background: rgba(239, 246, 255, 0.7);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 16px;
  padding: 8px;
}

.recharge-form input {
  width: 88px;
  background: white;
}

.recharge-form input::placeholder {
  color: #94a3b8;
}

@media (max-width: 1260px) {
  .users-tab-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modern-user-row {
    grid-template-columns: 34px 1fr;
  }

  .compact-status-area,
  .modern-actions {
    grid-column: 2;
  }
}

@media (max-width: 760px) {
  .modern-users-card {
    padding: 20px;
  }

  .users-tab-grid {
    grid-template-columns: 1fr;
  }

  .users-toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-actions {
    width: 100%;
  }

  .bulk-actions button {
    flex: 1 1 auto;
  }

  .modern-user-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px;
  }

  .bulk-select-box {
    order: -1;
    justify-content: flex-start;
    padding-top: 0;
  }

  .compact-status-area,
  .modern-actions {
    grid-column: auto;
  }

  .recharge-form {
    width: 100%;
    flex-wrap: wrap;
  }

  .recharge-form input,
  .recharge-form button {
    flex: 1 1 100%;
    width: 100%;
  }
}


/* --- Multi app selector --- */
.app-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
  margin-top: 26px;
}

.app-selector-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 28px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-selector-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.app-selector-card h2 {
  margin: 14px 0 10px;
}

.app-selector-card p {
  margin-bottom: 18px;
  line-height: 1.5;
}

.app-selector-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.app-switch-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
