@import url("https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@500;700&family=Roboto:wght@400;500;700&display=swap");
@import url("tokens.css");

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--elo-text-dark);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(168, 207, 69, 0.28), transparent 55%),
    radial-gradient(800px 380px at 100% 0%, rgba(62, 64, 149, 0.2), transparent 50%),
    var(--elo-bg);
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--elo-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .app-shell { width: min(640px, 100%); padding-top: 1.5rem; }
}
@media (min-width: 1100px) {
  .app-shell { width: min(720px, 100%); }
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.brand img {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--elo-primary);
  font-size: 1.05rem;
  line-height: 1.15;
}
.brand-title span {
  display: block;
  color: var(--elo-secondary);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-panel {
  background: var(--elo-white);
  border: 1px solid var(--elo-border);
  border-radius: 20px;
  box-shadow: var(--elo-shadow);
  padding: 1.35rem 1.25rem 1.5rem;
  flex: 1;
  width: 100%;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--elo-primary);
  margin: 0 0 0.55rem;
}
h1 { font-size: clamp(1.35rem, 4vw, 1.7rem); }
.lead {
  color: var(--elo-text);
  margin: 0 0 1.15rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--elo-text-dark);
  margin-bottom: 0.45rem;
}
.field { margin-bottom: 1.1rem; width: 100%; }

.app-panel input:not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
.app-panel select,
.app-panel textarea,
.field input,
.field select,
.field textarea,
input.input,
.input {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid #d5dbe8;
  border-radius: 14px;
  padding: 0.95rem 1.05rem;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--elo-text-dark);
  background: #f7f8fc;
  min-height: 52px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.app-panel input:not([type="hidden"]):hover,
.field input:hover,
.input:hover {
  border-color: #b8c0d6;
  background: #fff;
}
.app-panel input:not([type="hidden"]):focus,
.app-panel select:focus,
.app-panel textarea:focus,
.field input:focus,
.input:focus {
  outline: none;
  border-color: var(--elo-primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(62, 64, 149, 0.16);
}
.app-panel input:disabled,
.field input:disabled {
  opacity: 0.75;
  background: #eef0f5;
  color: var(--elo-text);
  cursor: not-allowed;
}
.app-panel input::placeholder,
.field input::placeholder {
  color: #9aa3b5;
  font-weight: 400;
}
.app-panel input[type="file"],
.field input[type="file"] {
  padding: 0.75rem;
  background: #fff;
  border-style: dashed;
  cursor: pointer;
  font-size: 0.92rem;
}
.app-panel input[type="password"],
.field input[type="password"],
.input[type="password"] {
  letter-spacing: 0.35em;
  font-weight: 700;
}
.app-panel input#code,
#code.input {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.25rem;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none !important;
  min-height: 48px;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--elo-primary), var(--elo-primary-dark));
  color: #fff;
}
.btn-secondary {
  background: var(--elo-secondary);
  color: #1f2a10;
}
.btn-ghost {
  background: #f3f5fb;
  border: 1px solid var(--elo-border);
  color: var(--elo-primary);
}
.btn-danger { background: var(--elo-danger); color: #fff; }
.btn-block { width: 100%; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}
.actions .btn { flex: 1 1 140px; }

.home-actions {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.15rem;
}

.alert {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-error { background: #fdecea; color: var(--elo-danger); }
.alert-success { background: #e8f8ee; color: var(--elo-success); }
.alert-info { background: #eef0fb; color: var(--elo-primary); }
.alert-warning { background: #fff7e0; color: var(--elo-warning); }

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--elo-text);
  font-size: 0.82rem;
  margin: 1.15rem 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--elo-border);
}

/* Membership card */
.membership-card {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1.586;
  margin: 0 auto 1rem;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d8dce8;
  box-shadow: 0 12px 28px rgba(40, 48, 61, 0.16);
  position: relative;
}
.membership-card .stripe {
  height: 12px;
  background: linear-gradient(90deg, var(--elo-secondary), #c5e36a);
  border-bottom: 2px solid var(--elo-primary);
}
.membership-card .body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem 0.7rem;
  padding: 0.7rem 0.85rem 0.55rem;
  height: calc(100% - 12px);
}
.membership-card .logo-row img { height: 36px; width: auto; }
.membership-card .label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--elo-text);
  margin: 0;
}
.membership-card .value {
  margin: 0.05rem 0 0.35rem;
  font-weight: 700;
  color: var(--elo-primary);
  font-size: clamp(0.78rem, 2.8vw, 0.95rem);
  line-height: 1.2;
  word-break: break-word;
}
.membership-card .side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.membership-card .photo {
  width: 68px;
  height: 68px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--elo-secondary);
  background: #eef1f6;
}
.membership-card .qr-img {
  width: 72px;
  height: 72px;
  background: #fff;
  border-radius: 6px;
  padding: 2px;
  border: 1px solid var(--elo-border);
}
.membership-card .footer-line {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: end;
  border-top: 1px dashed var(--elo-border);
  padding-top: 0.35rem;
  margin-top: auto;
  gap: 0.5rem;
}
.membership-card .expires {
  font-size: 0.7rem;
  color: var(--elo-text-dark);
  line-height: 1.25;
}
.membership-card .expires strong { color: var(--elo-primary); }
.membership-card .code-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--elo-primary);
  background: #f3f6ea;
  border: 1px solid #d7e8a8;
  border-radius: 8px;
  padding: 0.2rem 0.45rem;
  display: inline-block;
}

.photo-preview {
  width: 112px;
  height: 112px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid var(--elo-secondary);
  background: #eef1f6;
  display: block;
  margin-bottom: 0.5rem;
}

.upload-box {
  border: 1.5px dashed #c9d0e2;
  border-radius: 14px;
  padding: 0.85rem;
  background: #fafbff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
}
.status-valid { background: #e8f8ee; color: var(--elo-success); }
.status-invalid { background: #fdecea; color: var(--elo-danger); }
.status-expired { background: #fff7e0; color: var(--elo-warning); }

.site-footer {
  text-align: center;
  color: var(--elo-text);
  font-size: 0.8rem;
  padding: 1rem 0 0.35rem;
  line-height: 1.5;
}
.admin-whisper {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: #a0a6b5;
  text-decoration: none !important;
}
.admin-whisper:hover { color: var(--elo-primary); }

#reader {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  margin-bottom: 0.75rem;
}
.hidden { display: none !important; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.muted { color: var(--elo-text); font-size: 0.88rem; }

/* Admin keeps working */
.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.admin-nav {
  background: linear-gradient(180deg, var(--elo-primary), var(--elo-primary-dark));
  color: #fff;
  padding: 1.25rem 1rem;
}
.admin-nav a {
  display: block;
  color: #fff;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  margin-bottom: 0.25rem;
  text-decoration: none;
}
.admin-nav a:hover,
.admin-nav a.active {
  background: rgba(255,255,255,0.14);
  text-decoration: none;
}
.admin-main { padding: 1.5rem; }
.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: #fff;
  border: 1px solid var(--elo-border);
  border-radius: 12px;
  padding: 1rem;
}
.stat strong {
  display: block;
  font-size: 1.6rem;
  color: var(--elo-primary);
}
.table-wrap {
  background: #fff;
  border: 1px solid var(--elo-border);
  border-radius: 12px;
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--elo-border);
  text-align: left;
  vertical-align: middle;
}
th { background: #f7f8fc; color: var(--elo-text); font-weight: 600; }
.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tab {
  border: 1px solid var(--elo-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  color: inherit;
}
.tab.active {
  background: var(--elo-primary);
  color: #fff;
  border-color: var(--elo-primary);
}
.help-box {
  background: #f7faf0;
  border: 1px solid #d7e8a8;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.card-panel {
  background: var(--elo-white);
  border: 1px solid var(--elo-border);
  border-radius: var(--elo-radius);
  box-shadow: var(--elo-shadow);
  padding: 1.75rem;
  margin: 1.25rem auto 2rem;
  max-width: 520px;
}
.container {
  width: min(960px, calc(100% - 2rem));
  margin: 0 auto;
}

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { display: flex; gap: 0.35rem; overflow-x: auto; }
  .admin-nav a { white-space: nowrap; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .membership-card .photo { width: 56px; height: 56px; }
  .membership-card .qr-img { width: 60px; height: 60px; }
  .membership-card .logo-row img { height: 30px; }
}
