:root {
  --pink: #e84a9b;
  --pink-deep: #d63384;
  --purple: #3d2744;
  --purple-mid: #5a3d62;
  --lavender: #c9b3d4;
  --lavender-soft: #e8dff0;
  --bg: #f7f4f8;
  --ink: #2a1f30;
  --muted: #8a8290;
  --white: #ffffff;
  --line: rgba(61, 39, 68, 0.12);
  --ok: #1d6b3a;
  --ok-bg: #e4f6ea;
  --err: #9b1c2e;
  --err-bg: #fdecee;
  --warn-bg: #fff3cd;
  --font: "Montserrat", system-ui, sans-serif;
  --shadow: 0 12px 40px rgba(61, 39, 68, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(ellipse at 100% 0%, rgba(232, 74, 155, 0.08) 0%, transparent 45%),
    var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}

a { color: var(--pink-deep); }
a:hover { color: var(--purple); }

.portal-strip {
  background: var(--pink);
  color: var(--white);
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.4rem 1rem;
}

.portal-top {
  background: var(--purple);
  color: var(--white);
  padding: 0.95rem 0;
  box-shadow: 0 8px 24px rgba(61, 39, 68, 0.18);
}

.portal-top .bar {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--white);
  text-decoration: none;
}

.portal-brand img {
  height: 40px;
  width: auto;
  filter: brightness(0) invert(1);
}

.portal-brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.portal-brand-text strong {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--pink);
  letter-spacing: -0.01em;
}

.portal-brand-text span {
  font-size: 0.72rem;
  opacity: 0.8;
  font-weight: 500;
}

.portal-top nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.portal-top nav a {
  color: var(--white);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.portal-top nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--white);
}

.portal-top nav a.is-logout {
  border-color: rgba(255, 255, 255, 0.35);
}

.role-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(232, 74, 155, 0.2);
  color: #ffd0e8;
  border: 1px solid rgba(232, 74, 155, 0.35);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  margin-right: 0.35rem;
}

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3.5rem;
}

.page-head {
  margin-bottom: 1.5rem;
}

h1 {
  margin: 0 0 0.4rem;
  color: var(--purple);
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 0.85rem;
  color: var(--purple);
  font-size: 1.05rem;
  font-weight: 800;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.25rem;
  max-width: 42rem;
}

.flash {
  padding: 0.9rem 1.05rem;
  margin-bottom: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid transparent;
}

.flash.success {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #b7e0c5;
}

.flash.error {
  background: var(--err-bg);
  color: var(--err);
  border-color: #f3c2ca;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card.flush {
  padding: 0;
  overflow: hidden;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

.field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--purple);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  padding: 0.75rem 0.85rem;
  font: inherit;
  background: var(--white);
  border-radius: 10px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(232, 74, 155, 0.16);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0.8rem 1.15rem;
  text-decoration: none;
  background: var(--pink);
  color: var(--white);
  border-radius: 10px;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn:hover {
  background: var(--pink-deep);
  color: var(--white);
  transform: translateY(-1px);
}

.btn-secondary { background: var(--purple); }
.btn-secondary:hover { background: var(--purple-mid); color: var(--white); }
.btn-danger { background: var(--err); }
.btn-danger:hover { background: #7f1524; color: var(--white); }
.btn-ghost {
  background: transparent;
  color: var(--purple);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  background: var(--lavender-soft);
  color: var(--purple);
}
.btn-small {
  padding: 0.42rem 0.75rem;
  font-size: 0.82rem;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--white);
}

th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.85rem 0.9rem;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  background: #faf8fb;
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(232, 74, 155, 0.03); }

.badge {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
  background: #eee;
  letter-spacing: 0.02em;
}

.badge.pending_payment {
  background: var(--warn-bg);
  color: #7a5b00;
}

.badge.active {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.cancelled {
  background: var(--err-bg);
  color: var(--err);
}

.badge.expired {
  background: #e9e6ec;
  color: var(--muted);
}

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-page .portal-strip { flex: 0 0 auto; }

.auth-shell {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1rem 3rem;
  background:
    linear-gradient(160deg, var(--purple) 0%, #2a1a30 48%, var(--purple-mid) 100%);
  position: relative;
  overflow: hidden;
}

.auth-shell::before {
  content: "";
  position: absolute;
  width: 50%;
  height: 80%;
  right: -10%;
  top: -20%;
  background: radial-gradient(circle, rgba(232, 74, 155, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.auth-box {
  width: min(420px, 100%);
  background: var(--white);
  border-radius: 20px;
  padding: 1.75rem 1.6rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  position: relative;
  z-index: 1;
}

.auth-box .auth-brand {
  color: var(--pink);
  font-weight: 800;
  font-size: 1.15rem;
  margin: 0 0 0.15rem;
  letter-spacing: -0.02em;
}

.auth-box h1 {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
  align-items: end;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.filters .field { margin: 0; min-width: 180px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat .label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat .value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--purple);
}

.stat.pink .value { color: var(--pink); }

.back-link {
  display: inline-block;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}

.back-link:hover { color: var(--pink-deep); }

.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
}

.kv {
  display: grid;
  gap: 0.65rem;
}

.kv-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.5rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }

.kv-row dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 0.15rem;
}

.kv-row dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.portal-footer {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.portal-footer a {
  color: var(--muted);
  text-decoration: none;
}

.portal-footer a:hover { color: var(--pink-deep); }

@media (max-width: 820px) {
  .stat-row,
  .detail-grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .portal-brand-text span { display: none; }

  .kv-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

@media (max-width: 640px) {
  .portal-top .bar {
    flex-direction: column;
    align-items: flex-start;
  }

  table { display: block; overflow-x: auto; }
}
