:root {
  --bg: #eef3ff;
  --bg-2: #ffffff;
  --panel: rgba(255,255,255,0.82);
  --text: #1a2540;
  --muted: #70809c;
  --border: rgba(113,130,160,0.18);
  --shadow: 0 20px 60px rgba(27, 52, 108, 0.12);
  --primary: #365be6;
  --primary-2: #1f9bd8;
  --success: #19a56f;
  --danger: #d44d68;
  --sidebar: #071e66;
  --sidebar-text: #dbe4ff;
}
html[data-theme="dark"] {
  --bg: #0c1324;
  --bg-2: #111a30;
  --panel: rgba(17,26,48,0.88);
  --text: #eef3ff;
  --muted: #9fb0d4;
  --border: rgba(179,198,242,0.12);
  --shadow: 0 20px 60px rgba(0,0,0,0.28);
  --primary: #5176ff;
  --primary-2: #20b4ef;
  --success: #27bf83;
  --danger: #ff6486;
  --sidebar: #081332;
  --sidebar-text: #dbe4ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
.bg-gradient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 20%, rgba(95,132,255,.24), transparent 26%),
    radial-gradient(circle at 85% 10%, rgba(255,130,198,.18), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(110,255,220,.12), transparent 26%),
    linear-gradient(135deg, rgba(255,255,255,.7), rgba(235,240,255,.2));
  pointer-events: none;
}
.auth-shell, .app-shell {
  position: relative;
  z-index: 1;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.auth-card {
  width: min(100%, 520px);
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-wide { width: min(100%, 760px); }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.brand-logo { width: 54px; height: 54px; object-fit: contain; border-radius: 14px; background: white; padding: 6px; }
.auth-brand h1, .topbar h1 { margin: 0; font-size: 30px; }
.auth-brand p, .topbar p { margin: 4px 0 0; color: var(--muted); }
.hero-panel {
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
}
.stack { display: grid; gap: 14px; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field-wide { grid-column: 1 / -1; }
label span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.7);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: rgba(255,255,255,0.03); }
button {
  font: inherit;
  cursor: pointer;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.btn:hover, .theme-switch:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 10px 26px rgba(53, 91, 230, 0.28);
}
.btn-secondary {
  background: rgba(54,91,230,0.1);
  color: var(--primary);
  border-color: rgba(54,91,230,0.14);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.theme-switch {
  border: 1px solid var(--border);
  min-height: 42px;
  min-width: 42px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  margin-left: auto;
}
.alert {
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 14px;
}
.alert-error { background: rgba(212,77,104,0.12); color: var(--danger); }
.alert-success { background: rgba(25,165,111,0.12); color: var(--success); }
.text-link { color: var(--primary); font-weight: 600; }
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  padding: 18px;
  gap: 18px;
}
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #03154b);
  color: var(--sidebar-text);
  border-radius: 28px;
  padding: 24px 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  box-shadow: var(--shadow);
}
.light-admin {
  background: rgba(255,255,255,0.88);
  color: var(--text);
  border: 1px solid var(--border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sidebar-brand small { display: block; opacity: .75; }
.sidebar-nav {
  display: grid;
  gap: 8px;
}
.sidebar-nav a {
  border-radius: 14px;
  padding: 13px 14px;
  color: inherit;
  opacity: .85;
}
.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.1);
  opacity: 1;
}
.light-admin .sidebar-nav a.active,
.light-admin .sidebar-nav a:hover { background: rgba(54,91,230,0.08); color: var(--primary); }
.sidebar-bottom { display: grid; gap: 10px; }
.main-panel {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.profile-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 16px;
  color: var(--muted);
}
.grid-cards {
  display: grid;
  gap: 18px;
}
.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.card, .hero-card {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 22px;
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .hero-card { background: rgba(255,255,255,0.03); }
.hero-card {
  position: relative;
  overflow: hidden;
}
.hero-cover {
  position: absolute;
  inset: 0 0 auto 0;
  height: 210px;
  background:
    radial-gradient(circle at 10% 20%, rgba(255,255,255,.18), transparent 26%),
    linear-gradient(135deg, var(--primary), var(--primary-2));
}
.hero-content {
  position: relative;
  z-index: 1;
  min-height: 210px;
  color: white;
}
.hero-content h2 { margin-top: 20px; font-size: 30px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.18);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .04em;
}
.status-active, .status-partner_unlimited { background: rgba(25,165,111,0.22); }
.status-trial { background: rgba(255,255,255,0.22); }
.status-expired, .status-blocked { background: rgba(212,77,104,0.22); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.stat-box {
  background: rgba(255,255,255,0.16);
  padding: 16px;
  border-radius: 18px;
}
.stat-box span, .muted { color: var(--muted); }
.hero-content .muted, .hero-content span { color: rgba(255,255,255,0.86); }
.qr-wrap {
  display: grid;
  place-items: center;
  min-height: 260px;
}
.qr-wrap img { max-width: 220px; width: 100%; height: auto; }
.copy-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.clean-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}
.button-row, .inline-actions, .inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.kv-list {
  display: grid;
  gap: 12px;
}
.kv-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; }
.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(54,91,230,0.08);
  color: var(--primary);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}
.big-number { font-size: 42px; }

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.small-text { font-size: 13px; }
.compact .kv-list div, .kv-list.compact div { padding-bottom: 8px; }
.table-wrap { overflow-x: auto; }
.compact-table th, .compact-table td { padding: 10px 8px; }
.admin-shell .main-panel { overflow: hidden; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.checkout-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(54,91,230,0.04);
}
.payment-method-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}
.payment-method-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.status-badge.small {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(54,91,230,0.08);
}
@media (max-width: 1280px) {
  .three-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .auth-card, .main-panel { padding: 18px; }
  .grid-form { grid-template-columns: 1fr; }
  .copy-box { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.section-head h3 {
  margin: 0 0 4px;
}
.subscription-hero-card {
  position: relative;
  overflow: hidden;
}
.subscription-hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(54,91,230,0.06), rgba(31,155,216,0.08));
  pointer-events: none;
}
.subscription-hero-card > * {
  position: relative;
  z-index: 1;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.info-tile {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,0.58);
}
html[data-theme="dark"] .info-tile {
  background: rgba(255,255,255,0.03);
}
.info-tile span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 14px;
}
.info-tile strong {
  font-size: 18px;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-badge.small {
  padding: 8px 10px;
  font-size: 12px;
}
.status-active,
.status-succeeded,
.status-partner_unlimited {
  background: rgba(25,165,111,0.12);
  color: var(--success);
  border-color: rgba(25,165,111,0.18);
}
.status-trial,
.status-pending,
.status-waiting_for_capture,
.status-grace {
  background: rgba(54,91,230,0.1);
  color: var(--primary);
  border-color: rgba(54,91,230,0.16);
}
.status-expired,
.status-blocked,
.status-failed,
.status-canceled,
.status-refunded,
.status-partially_refunded {
  background: rgba(212,77,104,0.12);
  color: var(--danger);
  border-color: rgba(212,77,104,0.18);
}
.subscription-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.payment-method-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  background: rgba(255,255,255,0.52);
}
html[data-theme="dark"] .payment-method-card {
  background: rgba(255,255,255,0.03);
}
.payment-method-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.kv-list.compact div {
  padding-bottom: 10px;
}
.checkout-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(54,91,230,0.06);
}
.checkout-summary span {
  color: var(--muted);
}
.checkout-summary strong {
  font-size: 20px;
}
.table-wrap {
  width: 100%;
  overflow-x: auto;
}
.small-text {
  font-size: 14px;
}
@media (max-width: 640px) {
  .info-grid {
    grid-template-columns: 1fr;
  }
  .section-head {
    flex-direction: column;
  }
  .checkout-summary {
    flex-direction: column;
    align-items: flex-start;
  }
}
